Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Data structures for representing parts of Chromium's composited layer tree | |
| 6 // and a function to load it from the JSON configuration file | |
| 7 | |
| 8 #ifndef GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_TREE_H_ | |
| 9 #define GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_TREE_H_ | |
| 10 | |
| 11 #include <string> | |
| 12 #include <vector> | |
| 13 | |
| 14 #include "base/compiler_specific.h" | |
| 15 #include "base/memory/scoped_vector.h" | |
| 16 #include "gpu/tools/compositor_model_bench/shaders.h" | |
| 17 #include "ui/gfx/gl/gl_bindings.h" | |
| 18 #include "ui/gfx/gl/gl_implementation.h" | |
| 19 | |
| 20 // These are fairly arbitrary values based on how big my actual browser | |
| 21 // window was. | |
| 22 const int WINDOW_WIDTH = 1609; | |
| 23 const int WINDOW_HEIGHT = 993; | |
| 24 | |
| 25 struct Tile { | |
| 26 int x; | |
| 27 int y; | |
| 28 int texID; | |
| 29 }; | |
| 30 | |
| 31 struct Texture { | |
| 32 int texID; | |
| 33 int height; | |
| 34 int width; | |
| 35 GLenum format; | |
| 36 }; | |
| 37 | |
| 38 GLenum TextureFormatFromString(std::string format); | |
| 39 const char* TextureFormatName(GLenum format); | |
| 40 int FormatBytesPerPixel(GLenum format); | |
| 41 | |
| 42 struct RenderNodeVisitor; | |
| 43 | |
| 44 class RenderNode { | |
| 45 public: | |
| 46 virtual ~RenderNode() {} | |
| 47 int layerID; | |
|
piman
2011/08/26 02:24:16
according to our style, classes are not supposed t
| |
| 48 int width; | |
| 49 int height; | |
| 50 bool drawsContent; | |
| 51 int targetSurface; | |
| 52 float transform[16]; | |
| 53 std::vector<Tile> tiles; | |
| 54 int tile_width; | |
| 55 int tile_height; | |
| 56 | |
| 57 virtual void Accept(RenderNodeVisitor* v); | |
| 58 }; | |
| 59 | |
| 60 class ContentLayerNode : public RenderNode { | |
| 61 public: | |
| 62 ScopedVector<RenderNode> children; | |
| 63 bool skipsDraw; | |
| 64 | |
| 65 virtual void Accept(RenderNodeVisitor* v) OVERRIDE; | |
| 66 }; | |
| 67 | |
| 68 class CCNode : public RenderNode { | |
| 69 public: | |
| 70 ShaderID vertex_shader; | |
| 71 ShaderID fragment_shader; | |
| 72 std::vector<Texture> textures; | |
| 73 | |
| 74 virtual void Accept(RenderNodeVisitor* v) OVERRIDE; | |
| 75 }; | |
| 76 | |
| 77 class RenderNodeVisitor { | |
| 78 public: | |
| 79 virtual ~RenderNodeVisitor() {} | |
| 80 | |
| 81 virtual void BeginVisitRenderNode(RenderNode* v) = 0; | |
| 82 virtual void BeginVisitContentLayerNode(ContentLayerNode* v) { | |
| 83 this->BeginVisitRenderNode(v); | |
| 84 } | |
| 85 virtual void BeginVisitCCNode(CCNode* v) { | |
| 86 this->BeginVisitRenderNode(v); | |
| 87 } | |
| 88 | |
| 89 virtual void EndVisitRenderNode(RenderNode* v) {} | |
| 90 virtual void EndVisitContentLayerNode(ContentLayerNode* v) { | |
| 91 this->EndVisitRenderNode(v); | |
| 92 } | |
| 93 virtual void EndVisitCCNode(CCNode* v) { | |
| 94 this->EndVisitRenderNode(v); | |
| 95 } | |
| 96 }; | |
| 97 | |
| 98 RenderNode* BuildRenderTreeFromFile(const FilePath& path); | |
| 99 | |
| 100 #endif // GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_TREE_H_ | |
| 101 | |
| OLD | NEW |