| 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 "cc/layer_sorter.h" | 5 #include "cc/layer_sorter.h" |
| 6 | 6 |
| 7 #include "cc/layer_impl.h" | 7 #include "cc/layer_impl.h" |
| 8 #include "cc/math_util.h" | 8 #include "cc/math_util.h" |
| 9 #include "cc/single_thread_proxy.h" | 9 #include "cc/single_thread_proxy.h" |
| 10 #include "cc/test/fake_impl_proxy.h" |
| 11 #include "cc/test/fake_layer_tree_host_impl.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/gfx/transform.h" | 13 #include "ui/gfx/transform.h" |
| 12 | 14 |
| 13 namespace cc { | 15 namespace cc { |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 // Note: In the following overlap tests, the "camera" is looking down the negati
ve Z axis, | 18 // Note: In the following overlap tests, the "camera" is looking down the negati
ve Z axis, |
| 17 // meaning that layers with smaller z values (more negative) are further from th
e camera | 19 // meaning that layers with smaller z values (more negative) are further from th
e camera |
| 18 // and therefore must be drawn before layers with higher z values. | 20 // and therefore must be drawn before layers with higher z values. |
| 19 | 21 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // https://bugs.webkit.org/show_bug.cgi?id=75046. Before this fix, ordering
was | 192 // https://bugs.webkit.org/show_bug.cgi?id=75046. Before this fix, ordering
was |
| 191 // accidentally reversed, causing bugs in z-index ordering on websites when | 193 // accidentally reversed, causing bugs in z-index ordering on websites when |
| 192 // preserves3D triggered the LayerSorter. | 194 // preserves3D triggered the LayerSorter. |
| 193 | 195 |
| 194 // Input list of layers: [1, 2, 3, 4, 5]. | 196 // Input list of layers: [1, 2, 3, 4, 5]. |
| 195 // Expected output: [3, 4, 1, 2, 5]. | 197 // Expected output: [3, 4, 1, 2, 5]. |
| 196 // - 1, 2, and 5 do not have a 3d z difference, and therefore their relat
ive ordering should be retained. | 198 // - 1, 2, and 5 do not have a 3d z difference, and therefore their relat
ive ordering should be retained. |
| 197 // - 3 and 4 do not have a 3d z difference, and therefore their relative
ordering should be retained. | 199 // - 3 and 4 do not have a 3d z difference, and therefore their relative
ordering should be retained. |
| 198 // - 3 and 4 should be re-sorted so they are in front of 1, 2, and 5. | 200 // - 3 and 4 should be re-sorted so they are in front of 1, 2, and 5. |
| 199 | 201 |
| 200 scoped_ptr<LayerImpl> layer1 = LayerImpl::create(1); | 202 FakeImplProxy proxy; |
| 201 scoped_ptr<LayerImpl> layer2 = LayerImpl::create(2); | 203 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 202 scoped_ptr<LayerImpl> layer3 = LayerImpl::create(3); | 204 |
| 203 scoped_ptr<LayerImpl> layer4 = LayerImpl::create(4); | 205 scoped_ptr<LayerImpl> layer1 = LayerImpl::create(&hostImpl, 1); |
| 204 scoped_ptr<LayerImpl> layer5 = LayerImpl::create(5); | 206 scoped_ptr<LayerImpl> layer2 = LayerImpl::create(&hostImpl, 2); |
| 207 scoped_ptr<LayerImpl> layer3 = LayerImpl::create(&hostImpl, 3); |
| 208 scoped_ptr<LayerImpl> layer4 = LayerImpl::create(&hostImpl, 4); |
| 209 scoped_ptr<LayerImpl> layer5 = LayerImpl::create(&hostImpl, 5); |
| 205 | 210 |
| 206 gfx::Transform BehindMatrix; | 211 gfx::Transform BehindMatrix; |
| 207 BehindMatrix.Translate3d(0, 0, 2); | 212 BehindMatrix.Translate3d(0, 0, 2); |
| 208 gfx::Transform FrontMatrix; | 213 gfx::Transform FrontMatrix; |
| 209 FrontMatrix.Translate3d(0, 0, 1); | 214 FrontMatrix.Translate3d(0, 0, 1); |
| 210 | 215 |
| 211 layer1->setBounds(gfx::Size(10, 10)); | 216 layer1->setBounds(gfx::Size(10, 10)); |
| 212 layer1->setContentBounds(gfx::Size(10, 10)); | 217 layer1->setContentBounds(gfx::Size(10, 10)); |
| 213 layer1->drawProperties().target_space_transform = BehindMatrix; | 218 layer1->drawProperties().target_space_transform = BehindMatrix; |
| 214 layer1->setDrawsContent(true); | 219 layer1->setDrawsContent(true); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); | 258 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); |
| 254 EXPECT_EQ(3, layerList[0]->id()); | 259 EXPECT_EQ(3, layerList[0]->id()); |
| 255 EXPECT_EQ(4, layerList[1]->id()); | 260 EXPECT_EQ(4, layerList[1]->id()); |
| 256 EXPECT_EQ(1, layerList[2]->id()); | 261 EXPECT_EQ(1, layerList[2]->id()); |
| 257 EXPECT_EQ(2, layerList[3]->id()); | 262 EXPECT_EQ(2, layerList[3]->id()); |
| 258 EXPECT_EQ(5, layerList[4]->id()); | 263 EXPECT_EQ(5, layerList[4]->id()); |
| 259 } | 264 } |
| 260 | 265 |
| 261 } // namespace | 266 } // namespace |
| 262 } // namespace cc | 267 } // namespace cc |
| OLD | NEW |