Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: gpu/tools/compositor_model_bench/render_tree.h

Issue 7792016: Revert 98706 - Initial checkin of the compositor_model_bench tool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 RenderNode() {}
47 virtual ~RenderNode() {}
48 virtual void Accept(RenderNodeVisitor* v);
49
50 int layerID() {
51 return layerID_;
52 }
53
54 void set_layerID(int id) {
55 layerID_ = id;
56 }
57
58 int width() {
59 return width_;
60 }
61
62 void set_width(int width) {
63 width_ = width;
64 }
65
66 int height() {
67 return height_;
68 }
69
70 void set_height(int height) {
71 height_ = height;
72 }
73
74 bool drawsContent() {
75 return drawsContent_;
76 }
77
78 void set_drawsContent(bool draws) {
79 drawsContent_ = draws;
80 }
81
82 void set_targetSurface(int surface) {
83 targetSurface_ = surface;
84 }
85
86 float* transform() {
87 return transform_;
88 }
89
90 void set_transform(float* mat) {
91 memcpy(reinterpret_cast<void*>(transform_),
92 reinterpret_cast<void*>(mat),
93 16 * sizeof(transform_[0]));
94 }
95
96 void add_tile(Tile t) {
97 tiles_.push_back(t);
98 }
99
100 size_t num_tiles() {
101 return tiles_.size();
102 }
103
104 Tile* tile(size_t index) {
105 return &tiles_[index];
106 }
107
108 int tile_width() {
109 return tile_width_;
110 }
111
112 void set_tile_width(int width) {
113 tile_width_ = width;
114 }
115
116 int tile_height() {
117 return tile_height_;
118 }
119
120 void set_tile_height(int height) {
121 tile_height_ = height;
122 }
123
124 private:
125 int layerID_;
126 int width_;
127 int height_;
128 bool drawsContent_;
129 int targetSurface_;
130 float transform_[16];
131 std::vector<Tile> tiles_;
132 int tile_width_;
133 int tile_height_;
134 };
135
136 class ContentLayerNode : public RenderNode {
137 public:
138 ContentLayerNode() {}
139 virtual void Accept(RenderNodeVisitor* v) OVERRIDE;
140
141 void set_skipsDraw(bool skips) {
142 skipsDraw_ = skips;
143 }
144
145 void add_child(RenderNode* child) {
146 children_.push_back(child);
147 }
148
149 private:
150 ScopedVector<RenderNode> children_;
151 bool skipsDraw_;
152 };
153
154 class CCNode : public RenderNode {
155 public:
156 CCNode() {}
157
158 virtual void Accept(RenderNodeVisitor* v) OVERRIDE;
159
160 ShaderID vertex_shader() {
161 return vertex_shader_;
162 }
163
164 void set_vertex_shader(ShaderID shader) {
165 vertex_shader_ = shader;
166 }
167
168 ShaderID fragment_shader() {
169 return fragment_shader_;
170 }
171
172 void set_fragment_shader(ShaderID shader) {
173 fragment_shader_ = shader;
174 }
175
176 void add_texture(Texture t) {
177 textures_.push_back(t);
178 }
179
180 size_t num_textures() {
181 return textures_.size();
182 }
183
184 Texture* texture(size_t index) {
185 return &textures_[index];
186 }
187
188 private:
189 ShaderID vertex_shader_;
190 ShaderID fragment_shader_;
191 std::vector<Texture> textures_;
192 };
193
194 class RenderNodeVisitor {
195 public:
196 virtual ~RenderNodeVisitor() {}
197
198 virtual void BeginVisitRenderNode(RenderNode* v) = 0;
199 virtual void BeginVisitContentLayerNode(ContentLayerNode* v) {
200 this->BeginVisitRenderNode(v);
201 }
202 virtual void BeginVisitCCNode(CCNode* v) {
203 this->BeginVisitRenderNode(v);
204 }
205
206 virtual void EndVisitRenderNode(RenderNode* v) {}
207 virtual void EndVisitContentLayerNode(ContentLayerNode* v) {
208 this->EndVisitRenderNode(v);
209 }
210 virtual void EndVisitCCNode(CCNode* v) {
211 this->EndVisitRenderNode(v);
212 }
213 };
214
215 RenderNode* BuildRenderTreeFromFile(const FilePath& path);
216
217 #endif // GPU_TOOLS_COMPOSITOR_MODEL_BENCH_RENDER_TREE_H_
218
OLDNEW
« no previous file with comments | « gpu/tools/compositor_model_bench/render_models.cc ('k') | gpu/tools/compositor_model_bench/render_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698