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