| 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" | 
| 11 #include "cc/layers/layer_impl.h" | 11 #include "cc/layers/layer_impl.h" | 
|  | 12 #include "cc/output/filter_operation.h" | 
|  | 13 #include "cc/output/filter_operations.h" | 
| 12 #include "cc/test/animation_test_common.h" | 14 #include "cc/test/animation_test_common.h" | 
| 13 #include "cc/test/fake_impl_proxy.h" | 15 #include "cc/test/fake_impl_proxy.h" | 
| 14 #include "cc/test/fake_layer_tree_host_impl.h" | 16 #include "cc/test/fake_layer_tree_host_impl.h" | 
| 15 #include "cc/test/geometry_test_utils.h" | 17 #include "cc/test/geometry_test_utils.h" | 
| 16 #include "cc/test/occlusion_tracker_test_common.h" | 18 #include "cc/test/occlusion_tracker_test_common.h" | 
| 17 #include "cc/trees/layer_tree_host_common.h" | 19 #include "cc/trees/layer_tree_host_common.h" | 
| 18 #include "cc/trees/single_thread_proxy.h" | 20 #include "cc/trees/single_thread_proxy.h" | 
| 19 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" | 
| 20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" | 
| 21 #include "third_party/WebKit/public/platform/WebFilterOperation.h" |  | 
| 22 #include "third_party/WebKit/public/platform/WebFilterOperations.h" |  | 
| 23 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" | 
| 24 | 24 | 
| 25 namespace cc { | 25 namespace cc { | 
| 26 namespace { | 26 namespace { | 
| 27 | 27 | 
| 28 class TestContentLayer : public Layer { | 28 class TestContentLayer : public Layer { | 
| 29  public: | 29  public: | 
| 30   TestContentLayer() : Layer(), override_opaque_contents_rect_(false) {} | 30   TestContentLayer() : Layer(), override_opaque_contents_rect_(false) {} | 
| 31 | 31 | 
| 32   virtual bool DrawsContent() const OVERRIDE { return true; } | 32   virtual bool DrawsContent() const OVERRIDE { return true; } | 
| (...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1614                                  gfx::PointF(30.f, 30.f), | 1614                                  gfx::PointF(30.f, 30.f), | 
| 1615                                  gfx::Size(500, 500), | 1615                                  gfx::Size(500, 500), | 
| 1616                                  true); | 1616                                  true); | 
| 1617     typename Types::ContentLayerType* opacity_layer = | 1617     typename Types::ContentLayerType* opacity_layer = | 
| 1618         this->CreateDrawingLayer(parent, | 1618         this->CreateDrawingLayer(parent, | 
| 1619                                  layer_transform, | 1619                                  layer_transform, | 
| 1620                                  gfx::PointF(30.f, 30.f), | 1620                                  gfx::PointF(30.f, 30.f), | 
| 1621                                  gfx::Size(500, 500), | 1621                                  gfx::Size(500, 500), | 
| 1622                                  true); | 1622                                  true); | 
| 1623 | 1623 | 
| 1624     WebKit::WebFilterOperations filters; | 1624     FilterOperations filters; | 
| 1625     filters.append(WebKit::WebFilterOperation::createBlurFilter(10.f)); | 1625     filters.Append(FilterOperation::CreateBlurFilter(10.f)); | 
| 1626     blur_layer->SetFilters(filters); | 1626     blur_layer->SetFilters(filters); | 
| 1627 | 1627 | 
| 1628     filters.clear(); | 1628     filters.Clear(); | 
| 1629     filters.append(WebKit::WebFilterOperation::createGrayscaleFilter(0.5f)); | 1629     filters.Append(FilterOperation::CreateGrayscaleFilter(0.5f)); | 
| 1630     opaque_layer->SetFilters(filters); | 1630     opaque_layer->SetFilters(filters); | 
| 1631 | 1631 | 
| 1632     filters.clear(); | 1632     filters.Clear(); | 
| 1633     filters.append(WebKit::WebFilterOperation::createOpacityFilter(0.5f)); | 1633     filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); | 
| 1634     opacity_layer->SetFilters(filters); | 1634     opacity_layer->SetFilters(filters); | 
| 1635 | 1635 | 
| 1636     this->CalcDrawEtc(parent); | 1636     this->CalcDrawEtc(parent); | 
| 1637 | 1637 | 
| 1638     TestOcclusionTrackerWithClip<typename Types::LayerType, | 1638     TestOcclusionTrackerWithClip<typename Types::LayerType, | 
| 1639                                  typename Types::RenderSurfaceType> occlusion( | 1639                                  typename Types::RenderSurfaceType> occlusion( | 
| 1640         gfx::Rect(0, 0, 1000, 1000)); | 1640         gfx::Rect(0, 0, 1000, 1000)); | 
| 1641 | 1641 | 
| 1642     // Opacity layer won't contribute to occlusion. | 1642     // Opacity layer won't contribute to occlusion. | 
| 1643     this->VisitLayer(opacity_layer, &occlusion); | 1643     this->VisitLayer(opacity_layer, &occlusion); | 
| (...skipping 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3564                                  gfx::Size(100, 50), | 3564                                  gfx::Size(100, 50), | 
| 3565                                  true); | 3565                                  true); | 
| 3566     typename Types::LayerType* occluding_layer5 = | 3566     typename Types::LayerType* occluding_layer5 = | 
| 3567         this->CreateDrawingLayer(parent, | 3567         this->CreateDrawingLayer(parent, | 
| 3568                                  this->identity_matrix, | 3568                                  this->identity_matrix, | 
| 3569                                  gfx::PointF(250.f, 50.f), | 3569                                  gfx::PointF(250.f, 50.f), | 
| 3570                                  gfx::Size(50, 50), | 3570                                  gfx::Size(50, 50), | 
| 3571                                  true); | 3571                                  true); | 
| 3572 | 3572 | 
| 3573     // Filters make the layer own a surface. | 3573     // Filters make the layer own a surface. | 
| 3574     WebKit::WebFilterOperations filters; | 3574     FilterOperations filters; | 
| 3575     filters.append(WebKit::WebFilterOperation::createBlurFilter(10.f)); | 3575     filters.Append(FilterOperation::CreateBlurFilter(10.f)); | 
| 3576     filtered_surface->SetBackgroundFilters(filters); | 3576     filtered_surface->SetBackgroundFilters(filters); | 
| 3577 | 3577 | 
| 3578     // Save the distance of influence for the blur effect. | 3578     // Save the distance of influence for the blur effect. | 
| 3579     int outset_top, outset_right, outset_bottom, outset_left; | 3579     int outset_top, outset_right, outset_bottom, outset_left; | 
| 3580     filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); | 3580     filters.GetOutsets( | 
|  | 3581         &outset_top, &outset_right, &outset_bottom, &outset_left); | 
| 3581 | 3582 | 
| 3582     this->CalcDrawEtc(parent); | 3583     this->CalcDrawEtc(parent); | 
| 3583 | 3584 | 
| 3584     TestOcclusionTrackerWithClip<typename Types::LayerType, | 3585     TestOcclusionTrackerWithClip<typename Types::LayerType, | 
| 3585                                  typename Types::RenderSurfaceType> occlusion( | 3586                                  typename Types::RenderSurfaceType> occlusion( | 
| 3586         gfx::Rect(0, 0, 1000, 1000)); | 3587         gfx::Rect(0, 0, 1000, 1000)); | 
| 3587 | 3588 | 
| 3588     // These layers occlude pixels directly beside the filtered_surface. Because | 3589     // These layers occlude pixels directly beside the filtered_surface. Because | 
| 3589     // filtered surface blends pixels in a radius, it will need to see some of | 3590     // filtered surface blends pixels in a radius, it will need to see some of | 
| 3590     // the pixels (up to radius far) underneath the occluding layers. | 3591     // the pixels (up to radius far) underneath the occluding layers. | 
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3747     typename Types::LayerType* filtered_surface2 = this->CreateDrawingLayer( | 3748     typename Types::LayerType* filtered_surface2 = this->CreateDrawingLayer( | 
| 3748         parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false); | 3749         parent, scale_by_half, gfx::PointF(), gfx::Size(300, 300), false); | 
| 3749     typename Types::LayerType* occluding_layer_above = | 3750     typename Types::LayerType* occluding_layer_above = | 
| 3750         this->CreateDrawingLayer(parent, | 3751         this->CreateDrawingLayer(parent, | 
| 3751                                  this->identity_matrix, | 3752                                  this->identity_matrix, | 
| 3752                                  gfx::PointF(100.f, 100.f), | 3753                                  gfx::PointF(100.f, 100.f), | 
| 3753                                  gfx::Size(50, 50), | 3754                                  gfx::Size(50, 50), | 
| 3754                                  true); | 3755                                  true); | 
| 3755 | 3756 | 
| 3756     // Filters make the layers own surfaces. | 3757     // Filters make the layers own surfaces. | 
| 3757     WebKit::WebFilterOperations filters; | 3758     FilterOperations filters; | 
| 3758     filters.append(WebKit::WebFilterOperation::createBlurFilter(1.f)); | 3759     filters.Append(FilterOperation::CreateBlurFilter(1.f)); | 
| 3759     filtered_surface1->SetBackgroundFilters(filters); | 3760     filtered_surface1->SetBackgroundFilters(filters); | 
| 3760     filtered_surface2->SetBackgroundFilters(filters); | 3761     filtered_surface2->SetBackgroundFilters(filters); | 
| 3761 | 3762 | 
| 3762     // Save the distance of influence for the blur effect. | 3763     // Save the distance of influence for the blur effect. | 
| 3763     int outset_top, outset_right, outset_bottom, outset_left; | 3764     int outset_top, outset_right, outset_bottom, outset_left; | 
| 3764     filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); | 3765     filters.GetOutsets( | 
|  | 3766         &outset_top, &outset_right, &outset_bottom, &outset_left); | 
| 3765 | 3767 | 
| 3766     this->CalcDrawEtc(root); | 3768     this->CalcDrawEtc(root); | 
| 3767 | 3769 | 
| 3768     TestOcclusionTrackerWithClip<typename Types::LayerType, | 3770     TestOcclusionTrackerWithClip<typename Types::LayerType, | 
| 3769                                  typename Types::RenderSurfaceType> occlusion( | 3771                                  typename Types::RenderSurfaceType> occlusion( | 
| 3770         gfx::Rect(0, 0, 1000, 1000)); | 3772         gfx::Rect(0, 0, 1000, 1000)); | 
| 3771 | 3773 | 
| 3772     this->VisitLayer(occluding_layer_above, &occlusion); | 3774     this->VisitLayer(occluding_layer_above, &occlusion); | 
| 3773     EXPECT_EQ(gfx::Rect().ToString(), | 3775     EXPECT_EQ(gfx::Rect().ToString(), | 
| 3774               occlusion.occlusion_from_outside_target().ToString()); | 3776               occlusion.occlusion_from_outside_target().ToString()); | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3854                                  true); | 3856                                  true); | 
| 3855     typename Types::LayerType* occluding_layer5 = | 3857     typename Types::LayerType* occluding_layer5 = | 
| 3856         this->CreateDrawingLayer(parent, | 3858         this->CreateDrawingLayer(parent, | 
| 3857                                  this->identity_matrix, | 3859                                  this->identity_matrix, | 
| 3858                                  gfx::PointF(250.f, 50.f), | 3860                                  gfx::PointF(250.f, 50.f), | 
| 3859                                  gfx::Size(50, 50), | 3861                                  gfx::Size(50, 50), | 
| 3860                                  true); | 3862                                  true); | 
| 3861 | 3863 | 
| 3862     // Filters make the layer own a surface. This filter is large enough that it | 3864     // Filters make the layer own a surface. This filter is large enough that it | 
| 3863     // goes outside the bottom of the clipping_surface. | 3865     // goes outside the bottom of the clipping_surface. | 
| 3864     WebKit::WebFilterOperations filters; | 3866     FilterOperations filters; | 
| 3865     filters.append(WebKit::WebFilterOperation::createBlurFilter(12.f)); | 3867     filters.Append(FilterOperation::CreateBlurFilter(12.f)); | 
| 3866     filtered_surface->SetBackgroundFilters(filters); | 3868     filtered_surface->SetBackgroundFilters(filters); | 
| 3867 | 3869 | 
| 3868     // Save the distance of influence for the blur effect. | 3870     // Save the distance of influence for the blur effect. | 
| 3869     int outset_top, outset_right, outset_bottom, outset_left; | 3871     int outset_top, outset_right, outset_bottom, outset_left; | 
| 3870     filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); | 3872     filters.GetOutsets( | 
|  | 3873         &outset_top, &outset_right, &outset_bottom, &outset_left); | 
| 3871 | 3874 | 
| 3872     this->CalcDrawEtc(parent); | 3875     this->CalcDrawEtc(parent); | 
| 3873 | 3876 | 
| 3874     TestOcclusionTrackerWithClip<typename Types::LayerType, | 3877     TestOcclusionTrackerWithClip<typename Types::LayerType, | 
| 3875                                  typename Types::RenderSurfaceType> occlusion( | 3878                                  typename Types::RenderSurfaceType> occlusion( | 
| 3876         gfx::Rect(0, 0, 1000, 1000)); | 3879         gfx::Rect(0, 0, 1000, 1000)); | 
| 3877 | 3880 | 
| 3878     // These layers occlude pixels directly beside the filtered_surface. Because | 3881     // These layers occlude pixels directly beside the filtered_surface. Because | 
| 3879     // filtered surface blends pixels in a radius, it will need to see some of | 3882     // filtered surface blends pixels in a radius, it will need to see some of | 
| 3880     // the pixels (up to radius far) underneath the occluding layers. | 3883     // the pixels (up to radius far) underneath the occluding layers. | 
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4064                                  scale_by_half, | 4067                                  scale_by_half, | 
| 4065                                  gfx::PointF(50.f, 50.f), | 4068                                  gfx::PointF(50.f, 50.f), | 
| 4066                                  gfx::Size(100, 100), | 4069                                  gfx::Size(100, 100), | 
| 4067                                  false); | 4070                                  false); | 
| 4068     this->CreateReplicaLayer(filtered_surface, | 4071     this->CreateReplicaLayer(filtered_surface, | 
| 4069                              this->identity_matrix, | 4072                              this->identity_matrix, | 
| 4070                              gfx::PointF(300.f, 0.f), | 4073                              gfx::PointF(300.f, 0.f), | 
| 4071                              gfx::Size()); | 4074                              gfx::Size()); | 
| 4072 | 4075 | 
| 4073     // Filters make the layer own a surface. | 4076     // Filters make the layer own a surface. | 
| 4074     WebKit::WebFilterOperations filters; | 4077     FilterOperations filters; | 
| 4075     filters.append(WebKit::WebFilterOperation::createBlurFilter(3.f)); | 4078     filters.Append(FilterOperation::CreateBlurFilter(3.f)); | 
| 4076     filtered_surface->SetBackgroundFilters(filters); | 4079     filtered_surface->SetBackgroundFilters(filters); | 
| 4077 | 4080 | 
| 4078     this->CalcDrawEtc(parent); | 4081     this->CalcDrawEtc(parent); | 
| 4079 | 4082 | 
| 4080     TestOcclusionTrackerWithClip<typename Types::LayerType, | 4083     TestOcclusionTrackerWithClip<typename Types::LayerType, | 
| 4081                                  typename Types::RenderSurfaceType> occlusion( | 4084                                  typename Types::RenderSurfaceType> occlusion( | 
| 4082         gfx::Rect(0, 0, 1000, 1000)); | 4085         gfx::Rect(0, 0, 1000, 1000)); | 
| 4083 | 4086 | 
| 4084     // The surface has a background blur, so it blurs non-opaque pixels below | 4087     // The surface has a background blur, so it blurs non-opaque pixels below | 
| 4085     // it. | 4088     // it. | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4143                                  gfx::Size(50, 50), | 4146                                  gfx::Size(50, 50), | 
| 4144                                  true); | 4147                                  true); | 
| 4145     typename Types::LayerType* above_replica_layer = | 4148     typename Types::LayerType* above_replica_layer = | 
| 4146         this->CreateDrawingLayer(parent, | 4149         this->CreateDrawingLayer(parent, | 
| 4147                                  this->identity_matrix, | 4150                                  this->identity_matrix, | 
| 4148                                  gfx::PointF(200.f, 50.f), | 4151                                  gfx::PointF(200.f, 50.f), | 
| 4149                                  gfx::Size(50, 50), | 4152                                  gfx::Size(50, 50), | 
| 4150                                  true); | 4153                                  true); | 
| 4151 | 4154 | 
| 4152     // Filters make the layer own a surface. | 4155     // Filters make the layer own a surface. | 
| 4153     WebKit::WebFilterOperations filters; | 4156     FilterOperations filters; | 
| 4154     filters.append(WebKit::WebFilterOperation::createBlurFilter(3.f)); | 4157     filters.Append(FilterOperation::CreateBlurFilter(3.f)); | 
| 4155     filtered_surface->SetBackgroundFilters(filters); | 4158     filtered_surface->SetBackgroundFilters(filters); | 
| 4156 | 4159 | 
| 4157     this->CalcDrawEtc(parent); | 4160     this->CalcDrawEtc(parent); | 
| 4158 | 4161 | 
| 4159     TestOcclusionTrackerWithClip<typename Types::LayerType, | 4162     TestOcclusionTrackerWithClip<typename Types::LayerType, | 
| 4160                                  typename Types::RenderSurfaceType> occlusion( | 4163                                  typename Types::RenderSurfaceType> occlusion( | 
| 4161         gfx::Rect(0, 0, 1000, 1000)); | 4164         gfx::Rect(0, 0, 1000, 1000)); | 
| 4162 | 4165 | 
| 4163     this->VisitLayer(above_replica_layer, &occlusion); | 4166     this->VisitLayer(above_replica_layer, &occlusion); | 
| 4164     this->VisitLayer(above_surface_layer, &occlusion); | 4167     this->VisitLayer(above_surface_layer, &occlusion); | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4247                                  gfx::Size(10, 10), | 4250                                  gfx::Size(10, 10), | 
| 4248                                  true); | 4251                                  true); | 
| 4249     typename Types::LayerType* beside_replica_layer = | 4252     typename Types::LayerType* beside_replica_layer = | 
| 4250         this->CreateDrawingLayer(parent, | 4253         this->CreateDrawingLayer(parent, | 
| 4251                                  this->identity_matrix, | 4254                                  this->identity_matrix, | 
| 4252                                  gfx::PointF(200.f, 40.f), | 4255                                  gfx::PointF(200.f, 40.f), | 
| 4253                                  gfx::Size(10, 10), | 4256                                  gfx::Size(10, 10), | 
| 4254                                  true); | 4257                                  true); | 
| 4255 | 4258 | 
| 4256     // Filters make the layer own a surface. | 4259     // Filters make the layer own a surface. | 
| 4257     WebKit::WebFilterOperations filters; | 4260     FilterOperations filters; | 
| 4258     filters.append(WebKit::WebFilterOperation::createBlurFilter(3.f)); | 4261     filters.Append(FilterOperation::CreateBlurFilter(3.f)); | 
| 4259     filtered_surface->SetBackgroundFilters(filters); | 4262     filtered_surface->SetBackgroundFilters(filters); | 
| 4260 | 4263 | 
| 4261     // Save the distance of influence for the blur effect. | 4264     // Save the distance of influence for the blur effect. | 
| 4262     int outset_top, outset_right, outset_bottom, outset_left; | 4265     int outset_top, outset_right, outset_bottom, outset_left; | 
| 4263     filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); | 4266     filters.GetOutsets( | 
|  | 4267         &outset_top, &outset_right, &outset_bottom, &outset_left); | 
| 4264 | 4268 | 
| 4265     this->CalcDrawEtc(parent); | 4269     this->CalcDrawEtc(parent); | 
| 4266 | 4270 | 
| 4267     TestOcclusionTrackerWithClip<typename Types::LayerType, | 4271     TestOcclusionTrackerWithClip<typename Types::LayerType, | 
| 4268                                  typename Types::RenderSurfaceType> occlusion( | 4272                                  typename Types::RenderSurfaceType> occlusion( | 
| 4269         gfx::Rect(0, 0, 1000, 1000)); | 4273         gfx::Rect(0, 0, 1000, 1000)); | 
| 4270 | 4274 | 
| 4271     this->VisitLayer(beside_replica_layer, &occlusion); | 4275     this->VisitLayer(beside_replica_layer, &occlusion); | 
| 4272     this->VisitLayer(beside_surface_layer, &occlusion); | 4276     this->VisitLayer(beside_surface_layer, &occlusion); | 
| 4273     this->VisitLayer(above_replica_layer, &occlusion); | 4277     this->VisitLayer(above_replica_layer, &occlusion); | 
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4811               occlusion.occlusion_from_outside_target().ToString()); | 4815               occlusion.occlusion_from_outside_target().ToString()); | 
| 4812     EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), | 4816     EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), | 
| 4813               occlusion.occlusion_from_inside_target().ToString()); | 4817               occlusion.occlusion_from_inside_target().ToString()); | 
| 4814   } | 4818   } | 
| 4815 }; | 4819 }; | 
| 4816 | 4820 | 
| 4817 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerInSurfaceIsClipped) | 4821 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerInSurfaceIsClipped) | 
| 4818 | 4822 | 
| 4819 }  // namespace | 4823 }  // namespace | 
| 4820 }  // namespace cc | 4824 }  // namespace cc | 
| OLD | NEW | 
|---|