OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "cc/solid_color_layer_impl.h" | |
6 | |
7 #include "cc/quad_sink.h" | |
8 #include "cc/quads/solid_color_draw_quad.h" | |
9 | |
10 namespace cc { | |
11 | |
12 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id) | |
13 : LayerImpl(tree_impl, id), | |
14 tile_size_(256) {} | |
15 | |
16 SolidColorLayerImpl::~SolidColorLayerImpl() {} | |
17 | |
18 scoped_ptr<LayerImpl> SolidColorLayerImpl::CreateLayerImpl( | |
19 LayerTreeImpl* tree_impl) { | |
20 return SolidColorLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); | |
21 } | |
22 | |
23 void SolidColorLayerImpl::AppendQuads(QuadSink* quad_sink, | |
24 AppendQuadsData* append_quads_data) { | |
25 SharedQuadState* shared_quad_state = | |
26 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | |
27 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | |
28 | |
29 // We create a series of smaller quads instead of just one large one so that | |
30 // the culler can reduce the total pixels drawn. | |
31 int width = content_bounds().width(); | |
32 int height = content_bounds().height(); | |
33 for (int x = 0; x < width; x += tile_size_) { | |
34 for (int y = 0; y < height; y += tile_size_) { | |
35 gfx::Rect solidTileRect(x, | |
36 y, | |
37 std::min(width - x, tile_size_), | |
38 std::min(height - y, tile_size_)); | |
39 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | |
40 quad->SetNew(shared_quad_state, solidTileRect, background_color()); | |
41 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | |
42 } | |
43 } | |
44 } | |
45 | |
46 const char* SolidColorLayerImpl::LayerTypeAsString() const { | |
47 return "SolidColorLayer"; | |
48 } | |
49 | |
50 } // namespace cc | |
OLD | NEW |