Update V8 to version 4.6.61.
[chromium-blink-merge.git] / gpu / tools / compositor_model_bench / forward_render_model.cc
blob03e8b1e768f17d37b15769723979c2c954913150
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 void BeginVisitRenderNode(RenderNode* v) override { NOTREACHED(); }
20 void BeginVisitCCNode(CCNode* v) override {
21 if (!v->drawsContent())
22 return;
23 ConfigAndActivateShaderForNode(v);
24 DrawQuad(v->width(), v->height());
27 void BeginVisitContentLayerNode(ContentLayerNode* l) override {
28 if (!l->drawsContent())
29 return;
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,
41 int window_width,
42 int window_height)
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);
49 glEnable(GL_BLEND);
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);
61 BeginFrame();
62 root_->Accept(visitor_.get());
65 void ForwardRenderSimulator::Resize(int width, int height) {
66 glViewport(0, 0, width, height);