OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Whole-tree processing that's likely to be helpful in multiple render models. | 5 // Whole-tree processing that's likely to be helpful in multiple render models. |
6 | 6 |
7 #ifndef GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_MODEL_UTILS_H_ | 7 #ifndef GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_MODEL_UTILS_H_ |
8 #define GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_MODEL_UTILS_H_ | 8 #define GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_MODEL_UTILS_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "gpu/tools/compositor_model_bench/render_tree.h" | 16 #include "gpu/tools/compositor_model_bench/render_tree.h" |
17 | 17 |
18 // This is a visitor that runs over the tree structure that was built from the | 18 // This is a visitor that runs over the tree structure that was built from the |
19 // configuration file. It creates OpenGL textures (random checkerboards) that | 19 // configuration file. It creates OpenGL textures (random checkerboards) that |
20 // match the specifications of the original textures and overwrites the old | 20 // match the specifications of the original textures and overwrites the old |
21 // texture ID's in the tree, replacing them with the matching new textures. | 21 // texture ID's in the tree, replacing them with the matching new textures. |
22 class TextureGenerator : public RenderNodeVisitor { | 22 class TextureGenerator : public RenderNodeVisitor { |
23 public: | 23 public: |
24 typedef scoped_ptr<uint8[]> ImagePtr; | 24 typedef scoped_ptr<uint8[]> ImagePtr; |
25 typedef std::vector<Tile>::iterator tile_iter; | 25 typedef std::vector<Tile>::iterator tile_iter; |
26 | 26 |
27 explicit TextureGenerator(RenderNode* root); | 27 explicit TextureGenerator(RenderNode* root); |
28 virtual ~TextureGenerator() OVERRIDE; | 28 virtual ~TextureGenerator() override; |
29 | 29 |
30 // RenderNodeVisitor functions look for textures and pass them | 30 // RenderNodeVisitor functions look for textures and pass them |
31 // off to HandleTexture (which behaves appropriately depending | 31 // off to HandleTexture (which behaves appropriately depending |
32 // on which pass we are in.) | 32 // on which pass we are in.) |
33 virtual void BeginVisitRenderNode(RenderNode* node) OVERRIDE; | 33 virtual void BeginVisitRenderNode(RenderNode* node) override; |
34 virtual void BeginVisitCCNode(CCNode* node) OVERRIDE; | 34 virtual void BeginVisitCCNode(CCNode* node) override; |
35 | 35 |
36 private: | 36 private: |
37 enum TextureGenStage { | 37 enum TextureGenStage { |
38 DiscoveryStage, | 38 DiscoveryStage, |
39 RemappingStage, | 39 RemappingStage, |
40 ImageGenerationStage | 40 ImageGenerationStage |
41 }; | 41 }; |
42 | 42 |
43 void DiscoverInputIDs(RenderNode* root); | 43 void DiscoverInputIDs(RenderNode* root); |
44 void GenerateGLTexIDs(); | 44 void GenerateGLTexIDs(); |
45 void AssignIDMapping(); | 45 void AssignIDMapping(); |
46 void WriteOutNewIDs(RenderNode* root); | 46 void WriteOutNewIDs(RenderNode* root); |
47 void AllocateImageArray(); | 47 void AllocateImageArray(); |
48 void BuildTextureImages(RenderNode* root); | 48 void BuildTextureImages(RenderNode* root); |
49 void HandleTexture(int* texID, int width, int height, GLenum format); | 49 void HandleTexture(int* texID, int width, int height, GLenum format); |
50 void GenerateImageForTexture(int texID, int width, int height, GLenum format); | 50 void GenerateImageForTexture(int texID, int width, int height, GLenum format); |
51 | 51 |
52 TextureGenStage stage_; | 52 TextureGenStage stage_; |
53 std::set<int> discovered_ids_; | 53 std::set<int> discovered_ids_; |
54 scoped_ptr<GLuint[]> tex_ids_; | 54 scoped_ptr<GLuint[]> tex_ids_; |
55 std::map<int, int> remapped_ids_; | 55 std::map<int, int> remapped_ids_; |
56 scoped_ptr<ImagePtr[]> image_data_; | 56 scoped_ptr<ImagePtr[]> image_data_; |
57 int images_generated_; | 57 int images_generated_; |
58 std::set<int> ids_for_completed_textures_; | 58 std::set<int> ids_for_completed_textures_; |
59 }; | 59 }; |
60 | 60 |
61 #endif // GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_MODEL_UTILS_H_ | 61 #endif // GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_MODEL_UTILS_H_ |
62 | 62 |
OLD | NEW |