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 #include "gpu/tools/compositor_model_bench/forward_render_model.h" | |
| 6 | |
| 7 #include <cstdlib> | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "gpu/tools/compositor_model_bench/render_model_utils.h" | |
| 11 | |
| 12 using std::vector; | |
| 13 | |
| 14 class ForwardRenderNodeVisitor : public RenderNodeVisitor { | |
| 15 public: | |
| 16 ForwardRenderNodeVisitor() {} | |
| 17 | |
| 18 virtual void BeginVisitRenderNode(RenderNode* v) OVERRIDE { | |
| 19 NOTREACHED(); | |
| 20 } | |
| 21 | |
| 22 virtual void BeginVisitCCNode(CCNode* v) OVERRIDE { | |
| 23 if (!v->drawsContent) | |
| 24 return; | |
| 25 ConfigAndActivateShaderForNode(v); | |
| 26 DrawQuad(v->width, v->height); | |
| 27 } | |
| 28 | |
| 29 virtual void BeginVisitContentLayerNode(ContentLayerNode* l) OVERRIDE { | |
| 30 if (!l->drawsContent) | |
| 31 return; | |
| 32 ConfigAndActivateShaderForTiling(l); | |
| 33 // Now that we capture root layer tiles, a layer without tiles | |
| 34 // should not get drawn. | |
| 35 if (l->tiles.size()) { | |
| 36 typedef vector<Tile>::iterator tile_itr; | |
| 37 for (tile_itr i = l->tiles.begin(); i != l->tiles.end(); ++i) { | |
| 38 DrawTileQuad(i->texID, i->x, i->y); | |
| 39 } | |
| 40 } else { | |
| 41 NOTREACHED(); | |
| 42 } | |
| 43 } | |
| 44 }; | |
| 45 | |
| 46 ForwardRenderSimulator::ForwardRenderSimulator(RenderNode* root, | |
| 47 int window_width, | |
| 48 int window_height) | |
| 49 : RenderModelSimulator(root), | |
| 50 visitor_(NULL) { | |
| 51 textures_.reset(new TextureGenerator(root)); | |
| 52 visitor_ = new ForwardRenderNodeVisitor(); | |
| 53 glViewport(0, 0, window_width, window_height); | |
| 54 glDisable(GL_DEPTH_TEST); | |
| 55 glDisable(GL_CULL_FACE); | |
| 56 glEnable(GL_BLEND); | |
| 57 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |
| 58 } | |
| 59 | |
| 60 ForwardRenderSimulator::~ForwardRenderSimulator() OVERRIDE { | |
| 61 delete visitor_; | |
|
piman
2011/08/26 02:24:16
use scoped_ptr instead?
joshtrask
2011/08/26 04:12:35
I had been doing so at one point, but it occurred
| |
| 62 } | |
| 63 | |
| 64 void ForwardRenderSimulator::Update() OVERRIDE { | |
| 65 glClearColor(0, 0, 1, 1); | |
| 66 glColorMask(true, true, true, true); | |
| 67 glClear(GL_COLOR_BUFFER_BIT); | |
| 68 glColorMask(true, true, true, false); | |
| 69 BeginFrame(10, 11); | |
|
piman
2011/08/26 02:24:16
I was initially confused about the magic "10" and
| |
| 70 if (visitor_) | |
|
piman
2011/08/26 02:24:16
visitor_ can't be NULL, right? You should be able
joshtrask
2011/08/26 04:29:04
Is that true? What about std::bad_alloc?
On 2011/
joshtrask
2011/08/26 04:30:07
Well, I suppose if that was going to give me a pro
| |
| 71 root_->Accept(visitor_); | |
| 72 } | |
| 73 | |
| 74 void ForwardRenderSimulator::Resize(int width, int height) OVERRIDE { | |
| 75 glViewport(0, 0, width, height); | |
| 76 } | |
| OLD | NEW |