| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/layer_sorter.h" | 7 #include "cc/layer_sorter.h" |
| 8 | 8 |
| 9 #include "cc/layer_impl.h" | 9 #include "cc/layer_impl.h" |
| 10 #include "cc/math_util.h" | 10 #include "cc/math_util.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 { | 60 { |
| 61 LayerSorter::ABCompareResult overlapResult; | 61 LayerSorter::ABCompareResult overlapResult; |
| 62 const float zThreshold = 0.1f; | 62 const float zThreshold = 0.1f; |
| 63 float weight = 0; | 63 float weight = 0; |
| 64 | 64 |
| 65 WebTransformationMatrix perspectiveMatrix; | 65 WebTransformationMatrix perspectiveMatrix; |
| 66 perspectiveMatrix.applyPerspective(1000); | 66 perspectiveMatrix.applyPerspective(1000); |
| 67 | 67 |
| 68 // Two layers forming a right angle with a perspective viewing transform. | 68 // Two layers forming a right angle with a perspective viewing transform. |
| 69 WebTransformationMatrix leftFaceMatrix; | 69 WebTransformationMatrix leftFaceMatrix; |
| 70 leftFaceMatrix.translate3d(-1, 0, -5); |
| 70 leftFaceMatrix.rotate3d(0, 1, 0, -90); | 71 leftFaceMatrix.rotate3d(0, 1, 0, -90); |
| 71 leftFaceMatrix.translateRight3d(-1, 0, -5); | |
| 72 leftFaceMatrix.translate(-1, -1); | 72 leftFaceMatrix.translate(-1, -1); |
| 73 LayerShape leftFace(2, 2, perspectiveMatrix * leftFaceMatrix); | 73 LayerShape leftFace(2, 2, perspectiveMatrix * leftFaceMatrix); |
| 74 WebTransformationMatrix frontFaceMatrix; | 74 WebTransformationMatrix frontFaceMatrix; |
| 75 frontFaceMatrix.translate3d(0, 0, -4); | 75 frontFaceMatrix.translate3d(0, 0, -4); |
| 76 frontFaceMatrix.translate(-1, -1); | 76 frontFaceMatrix.translate(-1, -1); |
| 77 LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix); | 77 LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix); |
| 78 | 78 |
| 79 overlapResult = LayerSorter::checkOverlap(&frontFace, &leftFace, zThreshold,
weight); | 79 overlapResult = LayerSorter::checkOverlap(&frontFace, &leftFace, zThreshold,
weight); |
| 80 EXPECT_EQ(LayerSorter::BBeforeA, overlapResult); | 80 EXPECT_EQ(LayerSorter::BBeforeA, overlapResult); |
| 81 } | 81 } |
| 82 | 82 |
| 83 TEST(LayerSorterTest, IntersectingLayerOverlap) | 83 TEST(LayerSorterTest, IntersectingLayerOverlap) |
| 84 { | 84 { |
| 85 LayerSorter::ABCompareResult overlapResult; | 85 LayerSorter::ABCompareResult overlapResult; |
| 86 const float zThreshold = 0.1f; | 86 const float zThreshold = 0.1f; |
| 87 float weight = 0; | 87 float weight = 0; |
| 88 | 88 |
| 89 WebTransformationMatrix perspectiveMatrix; | 89 WebTransformationMatrix perspectiveMatrix; |
| 90 perspectiveMatrix.applyPerspective(1000); | 90 perspectiveMatrix.applyPerspective(1000); |
| 91 | 91 |
| 92 // Intersecting layers. An explicit order will be returned based on relative
z | 92 // Intersecting layers. An explicit order will be returned based on relative
z |
| 93 // values at the overlapping features but the weight returned should be zero
. | 93 // values at the overlapping features but the weight returned should be zero
. |
| 94 WebTransformationMatrix frontFaceMatrix; | 94 WebTransformationMatrix frontFaceMatrix; |
| 95 frontFaceMatrix.translate3d(0, 0, -4); | 95 frontFaceMatrix.translate3d(0, 0, -4); |
| 96 frontFaceMatrix.translate(-1, -1); | 96 frontFaceMatrix.translate(-1, -1); |
| 97 LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix); | 97 LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix); |
| 98 | 98 |
| 99 WebTransformationMatrix throughMatrix; | 99 WebTransformationMatrix throughMatrix; |
| 100 throughMatrix.translate3d(0, 0, -4); |
| 100 throughMatrix.rotate3d(0, 1, 0, 45); | 101 throughMatrix.rotate3d(0, 1, 0, 45); |
| 101 throughMatrix.translateRight3d(0, 0, -4); | |
| 102 throughMatrix.translate(-1, -1); | 102 throughMatrix.translate(-1, -1); |
| 103 LayerShape rotatedFace(2, 2, perspectiveMatrix * throughMatrix); | 103 LayerShape rotatedFace(2, 2, perspectiveMatrix * throughMatrix); |
| 104 overlapResult = LayerSorter::checkOverlap(&frontFace, &rotatedFace, zThresho
ld, weight); | 104 overlapResult = LayerSorter::checkOverlap(&frontFace, &rotatedFace, zThresho
ld, weight); |
| 105 EXPECT_NE(LayerSorter::None, overlapResult); | 105 EXPECT_NE(LayerSorter::None, overlapResult); |
| 106 EXPECT_EQ(0, weight); | 106 EXPECT_EQ(0, weight); |
| 107 } | 107 } |
| 108 | 108 |
| 109 TEST(LayerSorterTest, LayersAtAngleOverlap) | 109 TEST(LayerSorterTest, LayersAtAngleOverlap) |
| 110 { | 110 { |
| 111 LayerSorter::ABCompareResult overlapResult; | 111 LayerSorter::ABCompareResult overlapResult; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); | 259 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); |
| 260 EXPECT_EQ(3, layerList[0]->id()); | 260 EXPECT_EQ(3, layerList[0]->id()); |
| 261 EXPECT_EQ(4, layerList[1]->id()); | 261 EXPECT_EQ(4, layerList[1]->id()); |
| 262 EXPECT_EQ(1, layerList[2]->id()); | 262 EXPECT_EQ(1, layerList[2]->id()); |
| 263 EXPECT_EQ(2, layerList[3]->id()); | 263 EXPECT_EQ(2, layerList[3]->id()); |
| 264 EXPECT_EQ(5, layerList[4]->id()); | 264 EXPECT_EQ(5, layerList[4]->id()); |
| 265 } | 265 } |
| 266 | 266 |
| 267 } // namespace | 267 } // namespace |
| OLD | NEW |