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/occlusion_tracker.h" | 5 #include "cc/trees/occlusion_tracker.h" |
6 | 6 |
7 #include "cc/animation/layer_animation_controller.h" | 7 #include "cc/animation/layer_animation_controller.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 }; | 53 }; |
54 | 54 |
55 class TestOcclusionTrackerWithClip : public TestOcclusionTracker { | 55 class TestOcclusionTrackerWithClip : public TestOcclusionTracker { |
56 public: | 56 public: |
57 explicit TestOcclusionTrackerWithClip(const gfx::Rect& viewport_rect) | 57 explicit TestOcclusionTrackerWithClip(const gfx::Rect& viewport_rect) |
58 : TestOcclusionTracker(viewport_rect) {} | 58 : TestOcclusionTracker(viewport_rect) {} |
59 | 59 |
60 bool OccludedLayer(const LayerImpl* layer, | 60 bool OccludedLayer(const LayerImpl* layer, |
61 const gfx::Rect& content_rect) const { | 61 const gfx::Rect& content_rect) const { |
62 DCHECK(layer->visible_layer_rect().Contains(content_rect)); | 62 DCHECK(layer->visible_layer_rect().Contains(content_rect)); |
63 return this->GetCurrentOcclusionForLayer(layer->draw_transform()) | 63 return this->GetCurrentOcclusionForLayer(layer->DrawTransform()) |
64 .IsOccluded(content_rect); | 64 .IsOccluded(content_rect); |
65 } | 65 } |
66 | 66 |
67 // Gives an unoccluded sub-rect of |content_rect| in the content space of the | 67 // Gives an unoccluded sub-rect of |content_rect| in the content space of the |
68 // layer. Simple wrapper around GetUnoccludedContentRect. | 68 // layer. Simple wrapper around GetUnoccludedContentRect. |
69 gfx::Rect UnoccludedLayerContentRect(const LayerImpl* layer, | 69 gfx::Rect UnoccludedLayerContentRect(const LayerImpl* layer, |
70 const gfx::Rect& content_rect) const { | 70 const gfx::Rect& content_rect) const { |
71 DCHECK(layer->visible_layer_rect().Contains(content_rect)); | 71 DCHECK(layer->visible_layer_rect().Contains(content_rect)); |
72 return this->GetCurrentOcclusionForLayer(layer->draw_transform()) | 72 return this->GetCurrentOcclusionForLayer(layer->DrawTransform()) |
73 .GetUnoccludedContentRect(content_rect); | 73 .GetUnoccludedContentRect(content_rect); |
74 } | 74 } |
75 | 75 |
76 gfx::Rect UnoccludedSurfaceContentRect(const LayerImpl* layer, | 76 gfx::Rect UnoccludedSurfaceContentRect(const LayerImpl* layer, |
77 const gfx::Rect& content_rect) const { | 77 const gfx::Rect& content_rect) const { |
78 RenderSurfaceImpl* surface = layer->render_surface(); | 78 RenderSurfaceImpl* surface = layer->render_surface(); |
79 return this->GetCurrentOcclusionForContributingSurface( | 79 return this->GetCurrentOcclusionForContributingSurface( |
80 surface->draw_transform()) | 80 surface->draw_transform()) |
81 .GetUnoccludedContentRect(content_rect); | 81 .GetUnoccludedContentRect(content_rect); |
82 } | 82 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 void CalcDrawEtc(TestContentLayerImpl* root) { | 220 void CalcDrawEtc(TestContentLayerImpl* root) { |
221 DCHECK(root == root_.get()); | 221 DCHECK(root == root_.get()); |
222 | 222 |
223 // These occlusion tests attach and detach layers in multiple | 223 // These occlusion tests attach and detach layers in multiple |
224 // iterations, so rebuild property trees every time. | 224 // iterations, so rebuild property trees every time. |
225 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 225 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
226 | 226 |
227 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); | 227 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); |
228 | 228 |
| 229 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
229 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 230 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
230 root, root->bounds(), &render_surface_layer_list_impl_); | 231 root, root->bounds(), &render_surface_layer_list_impl_, |
| 232 root->layer_tree_impl()->current_render_surface_list_id()); |
231 inputs.can_adjust_raster_scales = true; | 233 inputs.can_adjust_raster_scales = true; |
232 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 234 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
233 | 235 |
234 layer_iterator_ = layer_iterator_begin_ = | 236 layer_iterator_ = layer_iterator_begin_ = |
235 LayerIterator::Begin(&render_surface_layer_list_impl_); | 237 LayerIterator::Begin(&render_surface_layer_list_impl_); |
236 } | 238 } |
237 | 239 |
238 void EnterLayer(LayerImpl* layer, OcclusionTracker* occlusion) { | 240 void EnterLayer(LayerImpl* layer, OcclusionTracker* occlusion) { |
239 ASSERT_EQ(*layer_iterator_, layer); | 241 ASSERT_EQ(*layer_iterator_, layer); |
240 ASSERT_TRUE(layer_iterator_.represents_itself()); | 242 ASSERT_TRUE(layer_iterator_.represents_itself()); |
(...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2510 EXPECT_EQ(gfx::Rect(), | 2512 EXPECT_EQ(gfx::Rect(), |
2511 occlusion.UnoccludedSurfaceContentRect( | 2513 occlusion.UnoccludedSurfaceContentRect( |
2512 surface, gfx::Rect(80, 70, 50, 50))); | 2514 surface, gfx::Rect(80, 70, 50, 50))); |
2513 } | 2515 } |
2514 }; | 2516 }; |
2515 | 2517 |
2516 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) | 2518 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) |
2517 | 2519 |
2518 } // namespace | 2520 } // namespace |
2519 } // namespace cc | 2521 } // namespace cc |
OLD | NEW |