Home | History | Annotate | Download | only in output
      1 // Copyright 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CC_OUTPUT_GL_RENDERER_DRAW_CACHE_H_
      6 #define CC_OUTPUT_GL_RENDERER_DRAW_CACHE_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/basictypes.h"
     11 #include "third_party/skia/include/core/SkColor.h"
     12 
     13 namespace cc {
     14 
     15 // Collects 4 floats at a time for easy upload to GL.
     16 struct Float4 {
     17   float data[4];
     18 };
     19 
     20 // Collects 16 floats at a time for easy upload to GL.
     21 struct Float16 {
     22   float data[16];
     23 };
     24 
     25 // A cache for storing textured quads to be drawn.  Stores the minimum required
     26 // data to tell if two back to back draws only differ in their transform. Quads
     27 // that only differ by transform may be coalesced into a single draw call.
     28 struct TexturedQuadDrawCache {
     29   TexturedQuadDrawCache();
     30   ~TexturedQuadDrawCache();
     31 
     32   // Values tracked to determine if textured quads may be coalesced.
     33   int program_id;
     34   int resource_id;
     35   bool needs_blending;
     36   SkColor background_color;
     37 
     38   // Information about the program binding that is required to draw.
     39   int uv_xform_location;
     40   int background_color_location;
     41   int vertex_opacity_location;
     42   int matrix_location;
     43   int sampler_location;
     44 
     45   // A cache for the coalesced quad data.
     46   std::vector<Float4> uv_xform_data;
     47   std::vector<float> vertex_opacity_data;
     48   std::vector<Float16> matrix_data;
     49 
     50  private:
     51   DISALLOW_COPY_AND_ASSIGN(TexturedQuadDrawCache);
     52 };
     53 
     54 }  // namespace cc
     55 
     56 #endif  // CC_OUTPUT_GL_RENDERER_DRAW_CACHE_H_
     57