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