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