The DisplayVirtualKeyboard function on Windows 8 and beyond should not be displaying...
[chromium-blink-merge.git] / cc / layers / solid_color_layer_impl.cc
blobc8ddc7d7df85e2b820a714b47084fe7cd24d428a
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::Size& content_bounds,
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 width = content_bounds.width();
40 int height = content_bounds.height();
41 for (int x = 0; x < width; x += kSolidQuadTileSize) {
42 for (int y = 0; y < height; y += kSolidQuadTileSize) {
43 gfx::Rect quad_rect(x,
45 std::min(width - x, kSolidQuadTileSize),
46 std::min(height - y, kSolidQuadTileSize));
47 gfx::Rect visible_quad_rect =
48 occlusion_in_content_space.GetUnoccludedContentRect(quad_rect);
49 if (visible_quad_rect.IsEmpty())
50 continue;
52 append_quads_data->visible_content_area +=
53 visible_quad_rect.width() * visible_quad_rect.height();
55 SolidColorDrawQuad* quad =
56 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
57 quad->SetNew(
58 shared_quad_state, quad_rect, visible_quad_rect, color, false);
63 void SolidColorLayerImpl::AppendQuads(
64 RenderPass* render_pass,
65 const Occlusion& occlusion_in_content_space,
66 AppendQuadsData* append_quads_data) {
67 SharedQuadState* shared_quad_state =
68 render_pass->CreateAndAppendSharedQuadState();
69 PopulateSharedQuadState(shared_quad_state);
71 AppendDebugBorderQuad(
72 render_pass, content_bounds(), shared_quad_state, append_quads_data);
74 AppendSolidQuads(render_pass,
75 occlusion_in_content_space,
76 shared_quad_state,
77 content_bounds(),
78 background_color(),
79 append_quads_data);
82 const char* SolidColorLayerImpl::LayerTypeAsString() const {
83 return "cc::SolidColorLayerImpl";
86 } // namespace cc