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 for (size_t n = 0; n < l->num_tiles(); ++n) { |
| 36 const Tile* i = l->tile(n); |
| 37 DrawTileQuad(i->texID, i->x, i->y); |
| 38 } |
| 39 } |
| 40 }; |
| 41 |
| 42 ForwardRenderSimulator::ForwardRenderSimulator(RenderNode* root, |
| 43 int window_width, |
| 44 int window_height) |
| 45 : RenderModelSimulator(root) { |
| 46 textures_.reset(new TextureGenerator(root)); |
| 47 visitor_.reset(new ForwardRenderNodeVisitor()); |
| 48 glViewport(0, 0, window_width, window_height); |
| 49 glDisable(GL_DEPTH_TEST); |
| 50 glDisable(GL_CULL_FACE); |
| 51 glEnable(GL_BLEND); |
| 52 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 53 } |
| 54 |
| 55 ForwardRenderSimulator::~ForwardRenderSimulator() OVERRIDE { |
| 56 delete visitor_; |
| 57 } |
| 58 |
| 59 void ForwardRenderSimulator::Update() OVERRIDE { |
| 60 glClearColor(0, 0, 1, 1); |
| 61 glColorMask(true, true, true, true); |
| 62 glClear(GL_COLOR_BUFFER_BIT); |
| 63 glColorMask(true, true, true, false); |
| 64 BeginFrame(); |
| 65 root_->Accept(visitor_); |
| 66 } |
| 67 |
| 68 void ForwardRenderSimulator::Resize(int width, int height) OVERRIDE { |
| 69 glViewport(0, 0, width, height); |
| 70 } |
| 71 |
OLD | NEW |