Index: cc/layer_sorter_unittest.cc |
diff --git a/cc/layer_sorter_unittest.cc b/cc/layer_sorter_unittest.cc |
index 941bd725158d8daa57b8a1c9ab99f4e327b1e356..76b10f2e10ce1e7ed8f05a8db33877bd08b46118 100644 |
--- a/cc/layer_sorter_unittest.cc |
+++ b/cc/layer_sorter_unittest.cc |
@@ -264,4 +264,51 @@ TEST(LayerSorterTest, verifyExistingOrderingPreservedWhenNoZDiff) |
EXPECT_EQ(5, layerList[4]->id()); |
} |
+TEST(LayerSorterTest, verifyConcidentLayerPrecisionLossResultsInDocumentOrder) |
+{ |
+ DebugScopedSetImplThread thisScopeIsOnImplThread; |
+ |
+ scoped_ptr<LayerImpl> layer1 = LayerImpl::create(1); |
+ scoped_ptr<LayerImpl> layer2 = LayerImpl::create(2); |
+ |
+ // Layer 1 should occur of layer 2 in paint. However, due to numeric |
+ // issues in the sorter, it will puts the layers in the wrong order |
+ // in some situations. Here we test a patch that results in in |
+ // document order rather than calculated order when numeric percision |
+ // is suspect in calculated order. |
+ |
+ WebTransformationMatrix BehindMatrix; |
+ BehindMatrix.translate3d(0, 0, 0.999999f); |
+ BehindMatrix.rotate3d(38.5f, 77.0f, 0); |
+ WebTransformationMatrix FrontMatrix; |
+ FrontMatrix.translate3d(0, 0, 1.0f); |
+ FrontMatrix.rotate3d(38.5f, 77.0f, 0); |
+ |
+ layer1->setBounds(IntSize(10, 10)); |
+ layer1->setContentBounds(IntSize(10, 10)); |
+ layer1->setDrawTransform(BehindMatrix); |
+ layer1->setDrawsContent(true); |
+ |
+ layer2->setBounds(IntSize(10, 10)); |
+ layer2->setContentBounds(IntSize(10, 10)); |
+ layer2->setDrawTransform(FrontMatrix); |
+ layer2->setDrawsContent(true); |
+ |
+ std::vector<LayerImpl*> layerList; |
+ layerList.push_back(layer1.get()); |
+ layerList.push_back(layer2.get()); |
+ |
+ ASSERT_EQ(static_cast<size_t>(2), layerList.size()); |
+ EXPECT_EQ(1, layerList[0]->id()); |
+ EXPECT_EQ(2, layerList[1]->id()); |
+ |
+ LayerSorter layerSorter; |
+ layerSorter.sort(layerList.begin(), layerList.end()); |
+ |
+ ASSERT_EQ(static_cast<size_t>(2), layerList.size()); |
+ EXPECT_EQ(1, layerList[0]->id()); |
+ EXPECT_EQ(2, layerList[1]->id()); |
+ EXPECT_FALSE(1.0f == 0.999999f); |
enne (OOO)
2012/11/01 22:55:23
As I think about it, I'm not sure this is worth as
|
+} |
+ |
} // namespace |