| 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/trees/quad_culler.h" | 5 #include "cc/trees/quad_culler.h" |
| 6 | 6 |
| 7 #include "cc/debug/debug_colors.h" | 7 #include "cc/debug/debug_colors.h" |
| 8 #include "cc/debug/overdraw_metrics.h" | 8 #include "cc/debug/overdraw_metrics.h" |
| 9 #include "cc/layers/append_quads_data.h" | 9 #include "cc/layers/append_quads_data.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| 11 #include "cc/quads/debug_border_draw_quad.h" | 11 #include "cc/quads/debug_border_draw_quad.h" |
| 12 #include "cc/quads/render_pass.h" | 12 #include "cc/quads/render_pass.h" |
| 13 #include "cc/trees/occlusion_tracker.h" | 13 #include "cc/trees/occlusion_tracker.h" |
| 14 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
| 15 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 | 18 |
| 19 QuadCuller::QuadCuller(QuadList* quad_list, | 19 QuadCuller::QuadCuller(QuadList* quad_list, |
| 20 SharedQuadStateList* shared_quad_state_list, | 20 SharedQuadStateList* shared_quad_state_list, |
| 21 const LayerImpl* layer, | 21 const LayerImpl* layer, |
| 22 const OcclusionTrackerImpl& occlusion_tracker, | 22 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 23 bool show_culling_with_debug_border_quads, | 23 bool show_culling_with_debug_border_quads, |
| 24 bool for_surface) | 24 bool for_surface) |
| 25 : quad_list_(quad_list), | 25 : quad_list_(quad_list), |
| 26 shared_quad_state_list_(shared_quad_state_list), | 26 shared_quad_state_list_(shared_quad_state_list), |
| 27 layer_(layer), | 27 layer_(layer), |
| 28 occlusion_tracker_(occlusion_tracker), | 28 occlusion_tracker_(occlusion_tracker), |
| 29 current_shared_quad_state_(NULL), | 29 current_shared_quad_state_(NULL), |
| 30 show_culling_with_debug_border_quads_( | 30 show_culling_with_debug_border_quads_( |
| 31 show_culling_with_debug_border_quads), | 31 show_culling_with_debug_border_quads), |
| 32 for_surface_(for_surface) {} | 32 for_surface_(for_surface) {} |
| 33 | 33 |
| 34 SharedQuadState* QuadCuller::UseSharedQuadState( | 34 SharedQuadState* QuadCuller::UseSharedQuadState( |
| 35 scoped_ptr<SharedQuadState> shared_quad_state) { | 35 scoped_ptr<SharedQuadState> shared_quad_state) { |
| 36 // TODO(danakj): If all quads are culled for the shared_quad_state, we can | 36 // TODO(danakj): If all quads are culled for the shared_quad_state, we can |
| 37 // drop it from the list. | 37 // drop it from the list. |
| 38 current_shared_quad_state_ = shared_quad_state.get(); | 38 current_shared_quad_state_ = shared_quad_state.get(); |
| 39 shared_quad_state_list_->push_back(shared_quad_state.Pass()); | 39 shared_quad_state_list_->push_back(shared_quad_state.Pass()); |
| 40 return current_shared_quad_state_; | 40 return current_shared_quad_state_; |
| 41 } | 41 } |
| 42 | 42 |
| 43 static inline bool AppendQuadInternal( | 43 static inline bool AppendQuadInternal( |
| 44 scoped_ptr<DrawQuad> draw_quad, | 44 scoped_ptr<DrawQuad> draw_quad, |
| 45 const gfx::Rect& culled_rect, | 45 const gfx::Rect& culled_rect, |
| 46 QuadList* quad_list, | 46 QuadList* quad_list, |
| 47 const OcclusionTrackerImpl& occlusion_tracker, | 47 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 48 const LayerImpl* layer, | 48 const LayerImpl* layer, |
| 49 bool create_debug_border_quads) { | 49 bool create_debug_border_quads) { |
| 50 bool keep_quad = !culled_rect.IsEmpty(); | 50 bool keep_quad = !culled_rect.IsEmpty(); |
| 51 if (keep_quad) | 51 if (keep_quad) |
| 52 draw_quad->visible_rect = culled_rect; | 52 draw_quad->visible_rect = culled_rect; |
| 53 | 53 |
| 54 occlusion_tracker.overdraw_metrics()->DidCullForDrawing( | 54 occlusion_tracker.overdraw_metrics()->DidCullForDrawing( |
| 55 draw_quad->quadTransform(), draw_quad->rect, culled_rect); | 55 draw_quad->quadTransform(), draw_quad->rect, culled_rect); |
| 56 gfx::Rect opaque_draw_rect = | 56 gfx::Rect opaque_draw_rect = |
| 57 draw_quad->opacity() == 1.0f ? draw_quad->opaque_rect : gfx::Rect(); | 57 draw_quad->opacity() == 1.0f ? draw_quad->opaque_rect : gfx::Rect(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 return AppendQuadInternal(draw_quad.Pass(), | 100 return AppendQuadInternal(draw_quad.Pass(), |
| 101 culled_rect, | 101 culled_rect, |
| 102 quad_list_, | 102 quad_list_, |
| 103 occlusion_tracker_, | 103 occlusion_tracker_, |
| 104 layer_, | 104 layer_, |
| 105 show_culling_with_debug_border_quads_); | 105 show_culling_with_debug_border_quads_); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace cc | 108 } // namespace cc |
| OLD | NEW |