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.
5 #include "gpu/tools/compositor_model_bench/forward_render_model.h"
10 #include "gpu/tools/compositor_model_bench/render_model_utils.h"
14 class ForwardRenderNodeVisitor : public RenderNodeVisitor {
16 ForwardRenderNodeVisitor() {}
18 virtual void BeginVisitRenderNode(RenderNode* v) OVERRIDE {
22 virtual void BeginVisitCCNode(CCNode* v) OVERRIDE {
23 if (!v->drawsContent())
25 ConfigAndActivateShaderForNode(v);
26 DrawQuad(v->width(), v->height());
29 virtual void BeginVisitContentLayerNode(ContentLayerNode* l) OVERRIDE {
30 if (!l->drawsContent())
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);
42 ForwardRenderSimulator::ForwardRenderSimulator(RenderNode* root,
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);
52 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
55 ForwardRenderSimulator::~ForwardRenderSimulator() {
58 void ForwardRenderSimulator::Update() {
59 glClearColor(0, 0, 1, 1);
60 glColorMask(true, true, true, true);
61 glClear(GL_COLOR_BUFFER_BIT);
62 glColorMask(true, true, true, false);
64 root_->Accept(visitor_.get());
67 void ForwardRenderSimulator::Resize(int width, int height) {
68 glViewport(0, 0, width, height);