OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/solid_color_layer_impl.h" | 5 #include "cc/layers/solid_color_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "cc/layers/append_quads_data.h" | 9 #include "cc/layers/append_quads_data.h" |
10 #include "cc/quads/solid_color_draw_quad.h" | 10 #include "cc/quads/solid_color_draw_quad.h" |
11 #include "cc/trees/occlusion_tracker.h" | 11 #include "cc/trees/occlusion.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 namespace { | 15 namespace { |
16 const int kSolidQuadTileSize = 256; | 16 const int kSolidQuadTileSize = 256; |
17 } | 17 } |
18 | 18 |
19 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id) | 19 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id) |
20 : LayerImpl(tree_impl, id) { | 20 : LayerImpl(tree_impl, id) { |
21 } | 21 } |
22 | 22 |
23 SolidColorLayerImpl::~SolidColorLayerImpl() {} | 23 SolidColorLayerImpl::~SolidColorLayerImpl() {} |
24 | 24 |
25 scoped_ptr<LayerImpl> SolidColorLayerImpl::CreateLayerImpl( | 25 scoped_ptr<LayerImpl> SolidColorLayerImpl::CreateLayerImpl( |
26 LayerTreeImpl* tree_impl) { | 26 LayerTreeImpl* tree_impl) { |
27 return SolidColorLayerImpl::Create(tree_impl, id()); | 27 return SolidColorLayerImpl::Create(tree_impl, id()); |
28 } | 28 } |
29 | 29 |
30 void SolidColorLayerImpl::AppendSolidQuads( | 30 void SolidColorLayerImpl::AppendSolidQuads( |
31 RenderPass* render_pass, | 31 RenderPass* render_pass, |
32 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 32 const Occlusion& occlusion_in_content_space, |
33 SharedQuadState* shared_quad_state, | 33 SharedQuadState* shared_quad_state, |
34 const gfx::Size& content_bounds, | 34 const gfx::Size& content_bounds, |
35 const gfx::Transform& target_space_transform, | |
36 SkColor color, | 35 SkColor color, |
37 AppendQuadsData* append_quads_data) { | 36 AppendQuadsData* append_quads_data) { |
38 Occlusion occlusion = | |
39 occlusion_tracker.GetCurrentOcclusionForLayer(target_space_transform); | |
40 | |
41 // We create a series of smaller quads instead of just one large one so that | 37 // We create a series of smaller quads instead of just one large one so that |
42 // the culler can reduce the total pixels drawn. | 38 // the culler can reduce the total pixels drawn. |
43 int width = content_bounds.width(); | 39 int width = content_bounds.width(); |
44 int height = content_bounds.height(); | 40 int height = content_bounds.height(); |
45 for (int x = 0; x < width; x += kSolidQuadTileSize) { | 41 for (int x = 0; x < width; x += kSolidQuadTileSize) { |
46 for (int y = 0; y < height; y += kSolidQuadTileSize) { | 42 for (int y = 0; y < height; y += kSolidQuadTileSize) { |
47 gfx::Rect quad_rect(x, | 43 gfx::Rect quad_rect(x, |
48 y, | 44 y, |
49 std::min(width - x, kSolidQuadTileSize), | 45 std::min(width - x, kSolidQuadTileSize), |
50 std::min(height - y, kSolidQuadTileSize)); | 46 std::min(height - y, kSolidQuadTileSize)); |
51 gfx::Rect visible_quad_rect = | 47 gfx::Rect visible_quad_rect = |
52 occlusion.GetUnoccludedContentRect(quad_rect); | 48 occlusion_in_content_space.GetUnoccludedContentRect(quad_rect); |
53 if (visible_quad_rect.IsEmpty()) | 49 if (visible_quad_rect.IsEmpty()) |
54 continue; | 50 continue; |
55 | 51 |
56 append_quads_data->visible_content_area += | 52 append_quads_data->visible_content_area += |
57 visible_quad_rect.width() * visible_quad_rect.height(); | 53 visible_quad_rect.width() * visible_quad_rect.height(); |
58 | 54 |
59 SolidColorDrawQuad* quad = | 55 SolidColorDrawQuad* quad = |
60 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 56 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
61 quad->SetNew( | 57 quad->SetNew( |
62 shared_quad_state, quad_rect, visible_quad_rect, color, false); | 58 shared_quad_state, quad_rect, visible_quad_rect, color, false); |
63 } | 59 } |
64 } | 60 } |
65 } | 61 } |
66 | 62 |
67 void SolidColorLayerImpl::AppendQuads( | 63 void SolidColorLayerImpl::AppendQuads( |
68 RenderPass* render_pass, | 64 RenderPass* render_pass, |
69 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 65 const Occlusion& occlusion_in_content_space, |
70 AppendQuadsData* append_quads_data) { | 66 AppendQuadsData* append_quads_data) { |
71 SharedQuadState* shared_quad_state = | 67 SharedQuadState* shared_quad_state = |
72 render_pass->CreateAndAppendSharedQuadState(); | 68 render_pass->CreateAndAppendSharedQuadState(); |
73 PopulateSharedQuadState(shared_quad_state); | 69 PopulateSharedQuadState(shared_quad_state); |
74 | 70 |
75 AppendDebugBorderQuad( | 71 AppendDebugBorderQuad( |
76 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 72 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
77 | 73 |
78 AppendSolidQuads(render_pass, | 74 AppendSolidQuads(render_pass, |
79 occlusion_tracker, | 75 occlusion_in_content_space, |
80 shared_quad_state, | 76 shared_quad_state, |
81 content_bounds(), | 77 content_bounds(), |
82 draw_properties().target_space_transform, | |
83 background_color(), | 78 background_color(), |
84 append_quads_data); | 79 append_quads_data); |
85 } | 80 } |
86 | 81 |
87 const char* SolidColorLayerImpl::LayerTypeAsString() const { | 82 const char* SolidColorLayerImpl::LayerTypeAsString() const { |
88 return "cc::SolidColorLayerImpl"; | 83 return "cc::SolidColorLayerImpl"; |
89 } | 84 } |
90 | 85 |
91 } // namespace cc | 86 } // namespace cc |
OLD | NEW |