| 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/quad_sink.h" | |
| 10 #include "cc/quads/solid_color_draw_quad.h" | 9 #include "cc/quads/solid_color_draw_quad.h" |
| 10 #include "cc/trees/occlusion_tracker.h" |
| 11 | 11 |
| 12 namespace cc { | 12 namespace cc { |
| 13 | 13 |
| 14 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id) | 14 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 15 : LayerImpl(tree_impl, id), | 15 : LayerImpl(tree_impl, id), |
| 16 tile_size_(256) {} | 16 tile_size_(256) {} |
| 17 | 17 |
| 18 SolidColorLayerImpl::~SolidColorLayerImpl() {} | 18 SolidColorLayerImpl::~SolidColorLayerImpl() {} |
| 19 | 19 |
| 20 scoped_ptr<LayerImpl> SolidColorLayerImpl::CreateLayerImpl( | 20 scoped_ptr<LayerImpl> SolidColorLayerImpl::CreateLayerImpl( |
| 21 LayerTreeImpl* tree_impl) { | 21 LayerTreeImpl* tree_impl) { |
| 22 return SolidColorLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); | 22 return SolidColorLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void SolidColorLayerImpl::AppendQuads(QuadSink* quad_sink, | 25 void SolidColorLayerImpl::AppendQuads( |
| 26 AppendQuadsData* append_quads_data) { | 26 RenderPass* render_pass, |
| 27 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 27 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 28 AppendQuadsData* append_quads_data) { |
| 29 SharedQuadState* shared_quad_state = |
| 30 render_pass->CreateAndAppendSharedQuadState(); |
| 28 PopulateSharedQuadState(shared_quad_state); | 31 PopulateSharedQuadState(shared_quad_state); |
| 29 | 32 |
| 30 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 33 AppendDebugBorderQuad(render_pass, shared_quad_state, append_quads_data); |
| 31 | 34 |
| 32 // We create a series of smaller quads instead of just one large one so that | 35 // We create a series of smaller quads instead of just one large one so that |
| 33 // the culler can reduce the total pixels drawn. | 36 // the culler can reduce the total pixels drawn. |
| 34 int width = content_bounds().width(); | 37 int width = content_bounds().width(); |
| 35 int height = content_bounds().height(); | 38 int height = content_bounds().height(); |
| 36 for (int x = 0; x < width; x += tile_size_) { | 39 for (int x = 0; x < width; x += tile_size_) { |
| 37 for (int y = 0; y < height; y += tile_size_) { | 40 for (int y = 0; y < height; y += tile_size_) { |
| 38 gfx::Rect quad_rect(x, | 41 gfx::Rect quad_rect(x, |
| 39 y, | 42 y, |
| 40 std::min(width - x, tile_size_), | 43 std::min(width - x, tile_size_), |
| 41 std::min(height - y, tile_size_)); | 44 std::min(height - y, tile_size_)); |
| 42 gfx::Rect visible_quad_rect = quad_sink->UnoccludedContentRect( | 45 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( |
| 43 this, quad_rect, draw_properties().target_space_transform); | 46 this->render_target(), |
| 47 quad_rect, |
| 48 draw_properties().target_space_transform); |
| 44 if (visible_quad_rect.IsEmpty()) | 49 if (visible_quad_rect.IsEmpty()) |
| 45 continue; | 50 continue; |
| 46 | 51 |
| 47 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 52 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 48 quad->SetNew(shared_quad_state, | 53 quad->SetNew(shared_quad_state, |
| 49 quad_rect, | 54 quad_rect, |
| 50 visible_quad_rect, | 55 visible_quad_rect, |
| 51 background_color(), | 56 background_color(), |
| 52 false); | 57 false); |
| 53 quad_sink->Append(quad.PassAs<DrawQuad>()); | 58 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
| 54 } | 59 } |
| 55 } | 60 } |
| 56 } | 61 } |
| 57 | 62 |
| 58 const char* SolidColorLayerImpl::LayerTypeAsString() const { | 63 const char* SolidColorLayerImpl::LayerTypeAsString() const { |
| 59 return "cc::SolidColorLayerImpl"; | 64 return "cc::SolidColorLayerImpl"; |
| 60 } | 65 } |
| 61 | 66 |
| 62 } // namespace cc | 67 } // namespace cc |
| OLD | NEW |