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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 layerSorter.sort(layerList.begin(), layerList.end()); | 257 layerSorter.sort(layerList.begin(), layerList.end()); |
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 TEST(LayerSorterTest, verifyConcidentLayerPrecisionLossResultsInDocumentOrder) | |
268 { | |
269 DebugScopedSetImplThread thisScopeIsOnImplThread; | |
270 | |
271 scoped_ptr<LayerImpl> layer1 = LayerImpl::create(1); | |
272 scoped_ptr<LayerImpl> layer2 = LayerImpl::create(2); | |
273 | |
274 // Layer 1 should occur of layer 2 in paint. However, due to numeric | |
shawnsingh
2012/11/01 23:03:57
"of" --> is this a typo? do we mean "before" or
| |
275 // issues in the sorter, it will puts the layers in the wrong order | |
shawnsingh
2012/11/01 23:03:57
puts --> put
| |
276 // in some situations. Here we test a patch that results in in | |
shawnsingh
2012/11/01 23:03:57
"in in" --> "in"
| |
277 // document order rather than calculated order when numeric percision | |
278 // is suspect in calculated order. | |
279 | |
280 WebTransformationMatrix BehindMatrix; | |
281 BehindMatrix.translate3d(0, 0, 0.999999f); | |
282 BehindMatrix.rotate3d(38.5f, 77.0f, 0); | |
283 WebTransformationMatrix FrontMatrix; | |
284 FrontMatrix.translate3d(0, 0, 1.0f); | |
285 FrontMatrix.rotate3d(38.5f, 77.0f, 0); | |
286 | |
287 layer1->setBounds(IntSize(10, 10)); | |
288 layer1->setContentBounds(IntSize(10, 10)); | |
289 layer1->setDrawTransform(BehindMatrix); | |
290 layer1->setDrawsContent(true); | |
291 | |
292 layer2->setBounds(IntSize(10, 10)); | |
293 layer2->setContentBounds(IntSize(10, 10)); | |
294 layer2->setDrawTransform(FrontMatrix); | |
295 layer2->setDrawsContent(true); | |
296 | |
297 std::vector<LayerImpl*> layerList; | |
298 layerList.push_back(layer1.get()); | |
299 layerList.push_back(layer2.get()); | |
300 | |
301 ASSERT_EQ(static_cast<size_t>(2), layerList.size()); | |
302 EXPECT_EQ(1, layerList[0]->id()); | |
303 EXPECT_EQ(2, layerList[1]->id()); | |
304 | |
305 LayerSorter layerSorter; | |
306 layerSorter.sort(layerList.begin(), layerList.end()); | |
307 | |
308 ASSERT_EQ(static_cast<size_t>(2), layerList.size()); | |
309 EXPECT_EQ(1, layerList[0]->id()); | |
310 EXPECT_EQ(2, layerList[1]->id()); | |
311 EXPECT_FALSE(1.0f == 0.999999f); | |
312 } | |
313 | |
267 } // namespace | 314 } // namespace |
OLD | NEW |