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 void BeginVisitRenderNode(RenderNode
* v
) override
{ NOTREACHED(); }
20 void BeginVisitCCNode(CCNode
* v
) override
{
21 if (!v
->drawsContent())
23 ConfigAndActivateShaderForNode(v
);
24 DrawQuad(v
->width(), v
->height());
27 void BeginVisitContentLayerNode(ContentLayerNode
* l
) override
{
28 if (!l
->drawsContent())
30 ConfigAndActivateShaderForTiling(l
);
31 // Now that we capture root layer tiles, a layer without tiles
32 // should not get drawn.
33 for (size_t n
= 0; n
< l
->num_tiles(); ++n
) {
34 const Tile
* i
= l
->tile(n
);
35 DrawTileQuad(i
->texID
, i
->x
, i
->y
);
40 ForwardRenderSimulator::ForwardRenderSimulator(RenderNode
* root
,
43 : RenderModelSimulator(root
) {
44 textures_
.reset(new TextureGenerator(root
));
45 visitor_
.reset(new ForwardRenderNodeVisitor());
46 glViewport(0, 0, window_width
, window_height
);
47 glDisable(GL_DEPTH_TEST
);
48 glDisable(GL_CULL_FACE
);
50 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
53 ForwardRenderSimulator::~ForwardRenderSimulator() {
56 void ForwardRenderSimulator::Update() {
57 glClearColor(0, 0, 1, 1);
58 glColorMask(true, true, true, true);
59 glClear(GL_COLOR_BUFFER_BIT
);
60 glColorMask(true, true, true, false);
62 root_
->Accept(visitor_
.get());
65 void ForwardRenderSimulator::Resize(int width
, int height
) {
66 glViewport(0, 0, width
, height
);