Adding a logging class to cast.
[chromium-blink-merge.git] / cc / layers / solid_color_layer_impl.cc
blobfaa967be2791a84e01bd53bd2b9271d5fc29ec4e
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/quad_sink.h"
10 #include "cc/quads/solid_color_draw_quad.h"
12 namespace cc {
14 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id)
15 : LayerImpl(tree_impl, id),
16 tile_size_(256) {}
18 SolidColorLayerImpl::~SolidColorLayerImpl() {}
20 scoped_ptr<LayerImpl> SolidColorLayerImpl::CreateLayerImpl(
21 LayerTreeImpl* tree_impl) {
22 return SolidColorLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
25 void SolidColorLayerImpl::AppendQuads(QuadSink* quad_sink,
26 AppendQuadsData* append_quads_data) {
27 SharedQuadState* shared_quad_state =
28 quad_sink->UseSharedQuadState(CreateSharedQuadState());
29 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data);
31 // We create a series of smaller quads instead of just one large one so that
32 // the culler can reduce the total pixels drawn.
33 int width = content_bounds().width();
34 int height = content_bounds().height();
35 for (int x = 0; x < width; x += tile_size_) {
36 for (int y = 0; y < height; y += tile_size_) {
37 gfx::Rect solid_tile_rect(x,
39 std::min(width - x, tile_size_),
40 std::min(height - y, tile_size_));
41 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
42 quad->SetNew(
43 shared_quad_state, solid_tile_rect, background_color(), false);
44 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data);
49 const char* SolidColorLayerImpl::LayerTypeAsString() const {
50 return "cc::SolidColorLayerImpl";
53 } // namespace cc