cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / gpu / tools / compositor_model_bench / forward_render_model.cc
blobc570bf3c5b47d82aa37b8a5bf0a3a8347ed97edd
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"
7 #include <cstdlib>
8 #include <vector>
10 #include "gpu/tools/compositor_model_bench/render_model_utils.h"
12 using std::vector;
14 class ForwardRenderNodeVisitor : public RenderNodeVisitor {
15 public:
16 ForwardRenderNodeVisitor() {}
18 virtual void BeginVisitRenderNode(RenderNode* v) OVERRIDE {
19 NOTREACHED();
22 virtual void BeginVisitCCNode(CCNode* v) OVERRIDE {
23 if (!v->drawsContent())
24 return;
25 ConfigAndActivateShaderForNode(v);
26 DrawQuad(v->width(), v->height());
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);
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);
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);
63 BeginFrame();
64 root_->Accept(visitor_.get());
67 void ForwardRenderSimulator::Resize(int width, int height) {
68 glViewport(0, 0, width, height);