| 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/debug/overdraw_metrics.h" | 9 #include "cc/debug/overdraw_metrics.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 bool* has_occlusion_from_outside_target_surface) const { | 99 bool* has_occlusion_from_outside_target_surface) const { |
| 100 return this->Occluded(layer->render_target(), | 100 return this->Occluded(layer->render_target(), |
| 101 content_rect, | 101 content_rect, |
| 102 layer->draw_transform(), | 102 layer->draw_transform(), |
| 103 LayerImplDrawTransformIsUnknown(layer), | 103 LayerImplDrawTransformIsUnknown(layer), |
| 104 layer->is_clipped(), | 104 layer->is_clipped(), |
| 105 layer->clip_rect(), | 105 layer->clip_rect(), |
| 106 has_occlusion_from_outside_target_surface); | 106 has_occlusion_from_outside_target_surface); |
| 107 } | 107 } |
| 108 // Gives an unoccluded sub-rect of |content_rect| in the content space of the | 108 // Gives an unoccluded sub-rect of |content_rect| in the content space of the |
| 109 // layer. Simple wrapper around unoccludedContentRect. | 109 // layer. Simple wrapper around UnoccludedContentRect. |
| 110 gfx::Rect UnoccludedLayerContentRect(const LayerType* layer, | 110 gfx::Rect UnoccludedLayerContentRect(const LayerType* layer, |
| 111 gfx::Rect content_rect) const { | 111 gfx::Rect content_rect) const { |
| 112 bool temp; | 112 bool temp; |
| 113 return UnoccludedLayerContentRect(layer, content_rect, &temp); | 113 return UnoccludedLayerContentRect(layer, content_rect, &temp); |
| 114 } | 114 } |
| 115 | 115 |
| 116 gfx::Rect UnoccludedLayerContentRect( | 116 gfx::Rect UnoccludedLayerContentRect( |
| 117 const LayerType* layer, | 117 const LayerType* layer, |
| 118 gfx::Rect content_rect, | 118 gfx::Rect content_rect, |
| 119 bool* has_occlusion_from_outside_target_surface) const { | 119 bool* has_occlusion_from_outside_target_surface) const { |
| (...skipping 3443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3563 filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); | 3563 filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); |
| 3564 | 3564 |
| 3565 this->CalcDrawEtc(parent); | 3565 this->CalcDrawEtc(parent); |
| 3566 | 3566 |
| 3567 TestOcclusionTrackerWithClip<typename Types::LayerType, | 3567 TestOcclusionTrackerWithClip<typename Types::LayerType, |
| 3568 typename Types::RenderSurfaceType> occlusion( | 3568 typename Types::RenderSurfaceType> occlusion( |
| 3569 gfx::Rect(0, 0, 1000, 1000)); | 3569 gfx::Rect(0, 0, 1000, 1000)); |
| 3570 | 3570 |
| 3571 // These layers occlude pixels directly beside the filtered_surface. Because | 3571 // These layers occlude pixels directly beside the filtered_surface. Because |
| 3572 // filtered surface blends pixels in a radius, it will need to see some of | 3572 // filtered surface blends pixels in a radius, it will need to see some of |
| 3573 // the pixels (up to radius far) underneath the occludingLayers. | 3573 // the pixels (up to radius far) underneath the occluding layers. |
| 3574 this->VisitLayer(occluding_layer5, occlusion); | 3574 this->VisitLayer(occluding_layer5, occlusion); |
| 3575 this->VisitLayer(occluding_layer4, occlusion); | 3575 this->VisitLayer(occluding_layer4, occlusion); |
| 3576 this->VisitLayer(occluding_layer3, occlusion); | 3576 this->VisitLayer(occluding_layer3, occlusion); |
| 3577 this->VisitLayer(occluding_layer2, occlusion); | 3577 this->VisitLayer(occluding_layer2, occlusion); |
| 3578 this->VisitLayer(occluding_layer1, occlusion); | 3578 this->VisitLayer(occluding_layer1, occlusion); |
| 3579 | 3579 |
| 3580 Region expected_occlusion; | 3580 Region expected_occlusion; |
| 3581 expected_occlusion.Union(gfx::Rect(0, 0, 300, 50)); | 3581 expected_occlusion.Union(gfx::Rect(0, 0, 300, 50)); |
| 3582 expected_occlusion.Union(gfx::Rect(0, 50, 50, 50)); | 3582 expected_occlusion.Union(gfx::Rect(0, 50, 50, 50)); |
| 3583 expected_occlusion.Union(gfx::Rect(100, 50, 100, 50)); | 3583 expected_occlusion.Union(gfx::Rect(100, 50, 100, 50)); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3852 filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); | 3852 filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); |
| 3853 | 3853 |
| 3854 this->CalcDrawEtc(parent); | 3854 this->CalcDrawEtc(parent); |
| 3855 | 3855 |
| 3856 TestOcclusionTrackerWithClip<typename Types::LayerType, | 3856 TestOcclusionTrackerWithClip<typename Types::LayerType, |
| 3857 typename Types::RenderSurfaceType> occlusion( | 3857 typename Types::RenderSurfaceType> occlusion( |
| 3858 gfx::Rect(0, 0, 1000, 1000)); | 3858 gfx::Rect(0, 0, 1000, 1000)); |
| 3859 | 3859 |
| 3860 // These layers occlude pixels directly beside the filtered_surface. Because | 3860 // These layers occlude pixels directly beside the filtered_surface. Because |
| 3861 // filtered surface blends pixels in a radius, it will need to see some of | 3861 // filtered surface blends pixels in a radius, it will need to see some of |
| 3862 // the pixels (up to radius far) underneath the occludingLayers. | 3862 // the pixels (up to radius far) underneath the occluding layers. |
| 3863 this->VisitLayer(occluding_layer5, occlusion); | 3863 this->VisitLayer(occluding_layer5, occlusion); |
| 3864 this->VisitLayer(occluding_layer4, occlusion); | 3864 this->VisitLayer(occluding_layer4, occlusion); |
| 3865 this->VisitLayer(occluding_layer3, occlusion); | 3865 this->VisitLayer(occluding_layer3, occlusion); |
| 3866 this->VisitLayer(occluding_layer2, occlusion); | 3866 this->VisitLayer(occluding_layer2, occlusion); |
| 3867 this->VisitLayer(occluding_layer1, occlusion); | 3867 this->VisitLayer(occluding_layer1, occlusion); |
| 3868 | 3868 |
| 3869 Region expected_occlusion; | 3869 Region expected_occlusion; |
| 3870 expected_occlusion.Union(gfx::Rect(0, 0, 300, 50)); | 3870 expected_occlusion.Union(gfx::Rect(0, 0, 300, 50)); |
| 3871 expected_occlusion.Union(gfx::Rect(0, 50, 50, 50)); | 3871 expected_occlusion.Union(gfx::Rect(0, 50, 50, 50)); |
| 3872 expected_occlusion.Union(gfx::Rect(100, 50, 100, 50)); | 3872 expected_occlusion.Union(gfx::Rect(100, 50, 100, 50)); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4255 this->VisitLayer(above_replica_layer, occlusion); | 4255 this->VisitLayer(above_replica_layer, occlusion); |
| 4256 this->VisitLayer(above_surface_layer, occlusion); | 4256 this->VisitLayer(above_surface_layer, occlusion); |
| 4257 | 4257 |
| 4258 // The surface has a background blur, so it blurs non-opaque pixels below | 4258 // The surface has a background blur, so it blurs non-opaque pixels below |
| 4259 // it. | 4259 // it. |
| 4260 this->VisitLayer(filtered_surface, occlusion); | 4260 this->VisitLayer(filtered_surface, occlusion); |
| 4261 this->VisitContributingSurface(filtered_surface, occlusion); | 4261 this->VisitContributingSurface(filtered_surface, occlusion); |
| 4262 | 4262 |
| 4263 // The filter in the surface and replica are partially unoccluded. Only the | 4263 // The filter in the surface and replica are partially unoccluded. Only the |
| 4264 // unoccluded parts should reduce occlusion. This means it will push back | 4264 // unoccluded parts should reduce occlusion. This means it will push back |
| 4265 // the occlusion that touches the unoccluded part (occlusionAbove___), but | 4265 // the occlusion that touches the unoccluded part (occlusion_above___), but |
| 4266 // it will not touch occlusion_beside____ since that is not beside the | 4266 // it will not touch occlusion_beside____ since that is not beside the |
| 4267 // unoccluded part of the surface, even though it is beside the occluded | 4267 // unoccluded part of the surface, even though it is beside the occluded |
| 4268 // part of the surface. | 4268 // part of the surface. |
| 4269 gfx::Rect occlusion_above_surface = | 4269 gfx::Rect occlusion_above_surface = |
| 4270 gfx::Rect(70 + outset_right, 50, 30 - outset_right, 50); | 4270 gfx::Rect(70 + outset_right, 50, 30 - outset_right, 50); |
| 4271 gfx::Rect occlusion_above_replica = | 4271 gfx::Rect occlusion_above_replica = |
| 4272 gfx::Rect(200, 50, 30 - outset_left, 50); | 4272 gfx::Rect(200, 50, 30 - outset_left, 50); |
| 4273 gfx::Rect occlusion_beside_surface = gfx::Rect(90, 40, 10, 10); | 4273 gfx::Rect occlusion_beside_surface = gfx::Rect(90, 40, 10, 10); |
| 4274 gfx::Rect occlusion_beside_replica = gfx::Rect(200, 40, 10, 10); | 4274 gfx::Rect occlusion_beside_replica = gfx::Rect(200, 40, 10, 10); |
| 4275 | 4275 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4522 gfx::Rect(0, 0, 100, 100), | 4522 gfx::Rect(0, 0, 100, 100), |
| 4523 &has_occlusion_from_outside_target_surface)); | 4523 &has_occlusion_from_outside_target_surface)); |
| 4524 EXPECT_FALSE(has_occlusion_from_outside_target_surface); | 4524 EXPECT_FALSE(has_occlusion_from_outside_target_surface); |
| 4525 } | 4525 } |
| 4526 }; | 4526 }; |
| 4527 | 4527 |
| 4528 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipIsExternalOcclusion) | 4528 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipIsExternalOcclusion) |
| 4529 | 4529 |
| 4530 } // namespace | 4530 } // namespace |
| 4531 } // namespace cc | 4531 } // namespace cc |
| OLD | NEW |