Don't add extra app list launcher page webviews.
[chromium-blink-merge.git] / cc / layers / solid_color_layer_impl.cc
blob276249744e83e306253a735004019f95fca0e4a7
1 // Copyright 2012 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 "cc/layers/solid_color_layer_impl.h"
7 #include <algorithm>
9 #include "cc/layers/append_quads_data.h"
10 #include "cc/quads/solid_color_draw_quad.h"
11 #include "cc/trees/occlusion.h"
13 namespace cc {
15 namespace {
16 const int kSolidQuadTileSize = 256;
19 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id)
20 : LayerImpl(tree_impl, id) {
23 SolidColorLayerImpl::~SolidColorLayerImpl() {}
25 scoped_ptr<LayerImpl> SolidColorLayerImpl::CreateLayerImpl(
26 LayerTreeImpl* tree_impl) {
27 return SolidColorLayerImpl::Create(tree_impl, id());
30 void SolidColorLayerImpl::AppendSolidQuads(
31 RenderPass* render_pass,
32 const Occlusion& occlusion_in_content_space,
33 SharedQuadState* shared_quad_state,
34 const gfx::Rect& visible_content_rect,
35 SkColor color,
36 AppendQuadsData* append_quads_data) {
37 // We create a series of smaller quads instead of just one large one so that
38 // the culler can reduce the total pixels drawn.
39 int right = visible_content_rect.right();
40 int bottom = visible_content_rect.bottom();
41 for (int x = visible_content_rect.x(); x < visible_content_rect.right();
42 x += kSolidQuadTileSize) {
43 for (int y = visible_content_rect.y(); y < visible_content_rect.bottom();
44 y += kSolidQuadTileSize) {
45 gfx::Rect quad_rect(x,
47 std::min(right - x, kSolidQuadTileSize),
48 std::min(bottom - y, kSolidQuadTileSize));
49 gfx::Rect visible_quad_rect =
50 occlusion_in_content_space.GetUnoccludedContentRect(quad_rect);
51 if (visible_quad_rect.IsEmpty())
52 continue;
54 append_quads_data->visible_content_area +=
55 visible_quad_rect.width() * visible_quad_rect.height();
57 SolidColorDrawQuad* quad =
58 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
59 quad->SetNew(
60 shared_quad_state, quad_rect, visible_quad_rect, color, false);
65 void SolidColorLayerImpl::AppendQuads(
66 RenderPass* render_pass,
67 AppendQuadsData* append_quads_data) {
68 SharedQuadState* shared_quad_state =
69 render_pass->CreateAndAppendSharedQuadState();
70 PopulateSharedQuadState(shared_quad_state);
72 AppendDebugBorderQuad(
73 render_pass, content_bounds(), shared_quad_state, append_quads_data);
75 // TODO(hendrikw): We need to pass the visible content rect rather than
76 // |content_bounds()| here.
77 AppendSolidQuads(render_pass, draw_properties().occlusion_in_content_space,
78 shared_quad_state, gfx::Rect(content_bounds()),
79 background_color(), append_quads_data);
82 const char* SolidColorLayerImpl::LayerTypeAsString() const {
83 return "cc::SolidColorLayerImpl";
86 } // namespace cc