| 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 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); | 1898 this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1899 typename Types::ContentLayerType* child1 = this->CreateDrawingLayer( | 1899 typename Types::ContentLayerType* child1 = this->CreateDrawingLayer( |
| 1900 parent, translation_to_back, gfx::PointF(), gfx::Size(100, 100), true); | 1900 parent, translation_to_back, gfx::PointF(), gfx::Size(100, 100), true); |
| 1901 typename Types::ContentLayerType* child2 = | 1901 typename Types::ContentLayerType* child2 = |
| 1902 this->CreateDrawingLayer(parent, | 1902 this->CreateDrawingLayer(parent, |
| 1903 translation_to_front, | 1903 translation_to_front, |
| 1904 gfx::PointF(50.f, 50.f), | 1904 gfx::PointF(50.f, 50.f), |
| 1905 gfx::Size(100, 100), | 1905 gfx::Size(100, 100), |
| 1906 true); | 1906 true); |
| 1907 parent->SetShouldFlattenTransform(false); | 1907 parent->SetShouldFlattenTransform(false); |
| 1908 parent->SetIs3dSorted(true); | 1908 parent->Set3dSortingContextId(1); |
| 1909 child1->SetIs3dSorted(true); | 1909 child1->Set3dSortingContextId(1); |
| 1910 child2->SetIs3dSorted(true); | 1910 child2->Set3dSortingContextId(1); |
| 1911 | 1911 |
| 1912 this->CalcDrawEtc(parent); | 1912 this->CalcDrawEtc(parent); |
| 1913 | 1913 |
| 1914 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1914 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1915 gfx::Rect(0, 0, 1000, 1000)); | 1915 gfx::Rect(0, 0, 1000, 1000)); |
| 1916 this->VisitLayer(child2, &occlusion); | 1916 this->VisitLayer(child2, &occlusion); |
| 1917 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1917 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1918 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); | 1918 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| 1919 | 1919 |
| 1920 this->VisitLayer(child1, &occlusion); | 1920 this->VisitLayer(child1, &occlusion); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1944 this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); | 1944 this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1945 typename Types::LayerType* container = this->CreateLayer( | 1945 typename Types::LayerType* container = this->CreateLayer( |
| 1946 parent, this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); | 1946 parent, this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); |
| 1947 typename Types::ContentLayerType* layer = | 1947 typename Types::ContentLayerType* layer = |
| 1948 this->CreateDrawingLayer(container, | 1948 this->CreateDrawingLayer(container, |
| 1949 transform, | 1949 transform, |
| 1950 gfx::PointF(100.f, 100.f), | 1950 gfx::PointF(100.f, 100.f), |
| 1951 gfx::Size(200, 200), | 1951 gfx::Size(200, 200), |
| 1952 true); | 1952 true); |
| 1953 container->SetShouldFlattenTransform(false); | 1953 container->SetShouldFlattenTransform(false); |
| 1954 container->SetIs3dSorted(true); | 1954 container->Set3dSortingContextId(1); |
| 1955 layer->SetIs3dSorted(true); | 1955 layer->Set3dSortingContextId(1); |
| 1956 layer->SetShouldFlattenTransform(false); | 1956 layer->SetShouldFlattenTransform(false); |
| 1957 | 1957 |
| 1958 this->CalcDrawEtc(parent); | 1958 this->CalcDrawEtc(parent); |
| 1959 | 1959 |
| 1960 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1960 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1961 gfx::Rect(0, 0, 1000, 1000)); | 1961 gfx::Rect(0, 0, 1000, 1000)); |
| 1962 this->EnterLayer(layer, &occlusion); | 1962 this->EnterLayer(layer, &occlusion); |
| 1963 | 1963 |
| 1964 EXPECT_RECT_EQ( | 1964 EXPECT_RECT_EQ( |
| 1965 gfx::Rect(0, 0, 200, 200), | 1965 gfx::Rect(0, 0, 200, 200), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1989 transform.RotateAboutXAxis(-167.0); | 1989 transform.RotateAboutXAxis(-167.0); |
| 1990 transform.Translate(-250.0, -50.0); | 1990 transform.Translate(-250.0, -50.0); |
| 1991 | 1991 |
| 1992 typename Types::ContentLayerType* parent = this->CreateRoot( | 1992 typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1993 this->identity_matrix, gfx::PointF(), gfx::Size(500, 100)); | 1993 this->identity_matrix, gfx::PointF(), gfx::Size(500, 100)); |
| 1994 typename Types::LayerType* container = this->CreateLayer( | 1994 typename Types::LayerType* container = this->CreateLayer( |
| 1995 parent, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500)); | 1995 parent, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500)); |
| 1996 typename Types::ContentLayerType* layer = this->CreateDrawingLayer( | 1996 typename Types::ContentLayerType* layer = this->CreateDrawingLayer( |
| 1997 container, transform, gfx::PointF(), gfx::Size(500, 500), true); | 1997 container, transform, gfx::PointF(), gfx::Size(500, 500), true); |
| 1998 container->SetShouldFlattenTransform(false); | 1998 container->SetShouldFlattenTransform(false); |
| 1999 container->SetIs3dSorted(true); | 1999 container->Set3dSortingContextId(1); |
| 2000 layer->SetShouldFlattenTransform(false); | 2000 layer->SetShouldFlattenTransform(false); |
| 2001 layer->SetIs3dSorted(true); | 2001 layer->Set3dSortingContextId(1); |
| 2002 this->CalcDrawEtc(parent); | 2002 this->CalcDrawEtc(parent); |
| 2003 | 2003 |
| 2004 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 2004 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 2005 gfx::Rect(0, 0, 1000, 1000)); | 2005 gfx::Rect(0, 0, 1000, 1000)); |
| 2006 this->EnterLayer(layer, &occlusion); | 2006 this->EnterLayer(layer, &occlusion); |
| 2007 | 2007 |
| 2008 // The bottom 11 pixel rows of this layer remain visible inside the | 2008 // The bottom 11 pixel rows of this layer remain visible inside the |
| 2009 // container, after translation to the target surface. When translated back, | 2009 // container, after translation to the target surface. When translated back, |
| 2010 // this will include many more pixels but must include at least the bottom | 2010 // this will include many more pixels but must include at least the bottom |
| 2011 // 11 rows. | 2011 // 11 rows. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2032 transform.Translate(50.0, 50.0); | 2032 transform.Translate(50.0, 50.0); |
| 2033 transform.ApplyPerspectiveDepth(100.0); | 2033 transform.ApplyPerspectiveDepth(100.0); |
| 2034 transform.Translate3d(0.0, 0.0, 110.0); | 2034 transform.Translate3d(0.0, 0.0, 110.0); |
| 2035 transform.Translate(-50.0, -50.0); | 2035 transform.Translate(-50.0, -50.0); |
| 2036 | 2036 |
| 2037 typename Types::ContentLayerType* parent = this->CreateRoot( | 2037 typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2038 this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); | 2038 this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 2039 typename Types::ContentLayerType* layer = this->CreateDrawingLayer( | 2039 typename Types::ContentLayerType* layer = this->CreateDrawingLayer( |
| 2040 parent, transform, gfx::PointF(), gfx::Size(100, 100), true); | 2040 parent, transform, gfx::PointF(), gfx::Size(100, 100), true); |
| 2041 parent->SetShouldFlattenTransform(false); | 2041 parent->SetShouldFlattenTransform(false); |
| 2042 parent->SetIs3dSorted(true); | 2042 parent->Set3dSortingContextId(1); |
| 2043 layer->SetShouldFlattenTransform(false); | 2043 layer->SetShouldFlattenTransform(false); |
| 2044 layer->SetIs3dSorted(true); | 2044 layer->Set3dSortingContextId(1); |
| 2045 this->CalcDrawEtc(parent); | 2045 this->CalcDrawEtc(parent); |
| 2046 | 2046 |
| 2047 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 2047 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 2048 gfx::Rect(0, 0, 1000, 1000)); | 2048 gfx::Rect(0, 0, 1000, 1000)); |
| 2049 | 2049 |
| 2050 // The |layer| is entirely behind the camera and should not occlude. | 2050 // The |layer| is entirely behind the camera and should not occlude. |
| 2051 this->VisitLayer(layer, &occlusion); | 2051 this->VisitLayer(layer, &occlusion); |
| 2052 this->EnterLayer(parent, &occlusion); | 2052 this->EnterLayer(parent, &occlusion); |
| 2053 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); | 2053 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| 2054 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 2054 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2073 transform.ApplyPerspectiveDepth(100.0); | 2073 transform.ApplyPerspectiveDepth(100.0); |
| 2074 transform.Translate3d(0.0, 0.0, 99.0); | 2074 transform.Translate3d(0.0, 0.0, 99.0); |
| 2075 transform.Translate(-50.0, -50.0); | 2075 transform.Translate(-50.0, -50.0); |
| 2076 | 2076 |
| 2077 typename Types::ContentLayerType* parent = this->CreateRoot( | 2077 typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2078 this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); | 2078 this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 2079 parent->SetMasksToBounds(true); | 2079 parent->SetMasksToBounds(true); |
| 2080 typename Types::ContentLayerType* layer = this->CreateDrawingLayer( | 2080 typename Types::ContentLayerType* layer = this->CreateDrawingLayer( |
| 2081 parent, transform, gfx::PointF(), gfx::Size(100, 100), true); | 2081 parent, transform, gfx::PointF(), gfx::Size(100, 100), true); |
| 2082 parent->SetShouldFlattenTransform(false); | 2082 parent->SetShouldFlattenTransform(false); |
| 2083 parent->SetIs3dSorted(true); | 2083 parent->Set3dSortingContextId(1); |
| 2084 layer->SetShouldFlattenTransform(false); | 2084 layer->SetShouldFlattenTransform(false); |
| 2085 layer->SetIs3dSorted(true); | 2085 layer->Set3dSortingContextId(1); |
| 2086 this->CalcDrawEtc(parent); | 2086 this->CalcDrawEtc(parent); |
| 2087 | 2087 |
| 2088 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 2088 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 2089 gfx::Rect(0, 0, 1000, 1000)); | 2089 gfx::Rect(0, 0, 1000, 1000)); |
| 2090 | 2090 |
| 2091 // This is very close to the camera, so pixels in its visible_content_rect() | 2091 // This is very close to the camera, so pixels in its visible_content_rect() |
| 2092 // will actually go outside of the layer's clip rect. Ensure that those | 2092 // will actually go outside of the layer's clip rect. Ensure that those |
| 2093 // pixels don't occlude things outside the clip rect. | 2093 // pixels don't occlude things outside the clip rect. |
| 2094 this->VisitLayer(layer, &occlusion); | 2094 this->VisitLayer(layer, &occlusion); |
| 2095 this->EnterLayer(parent, &occlusion); | 2095 this->EnterLayer(parent, &occlusion); |
| (...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3551 occlusion.occlusion_from_outside_target().ToString()); | 3551 occlusion.occlusion_from_outside_target().ToString()); |
| 3552 EXPECT_EQ(gfx::Rect().ToString(), | 3552 EXPECT_EQ(gfx::Rect().ToString(), |
| 3553 occlusion.occlusion_from_inside_target().ToString()); | 3553 occlusion.occlusion_from_inside_target().ToString()); |
| 3554 } | 3554 } |
| 3555 }; | 3555 }; |
| 3556 | 3556 |
| 3557 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) | 3557 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) |
| 3558 | 3558 |
| 3559 } // namespace | 3559 } // namespace |
| 3560 } // namespace cc | 3560 } // namespace cc |
| OLD | NEW |