Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp

Issue 2161253003: Revert of PaintChunk::id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@CommitOnTheWay
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
index 0c8e2caaa3736c74b396b35c1c1f1317725cf4bf..4d0379811621c8f9435ff680181d6dc29142bf87 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
@@ -31,26 +31,6 @@
RuntimeEnabledFeatures::Backup m_featuresBackup;
};
-class TestDisplayItem : public DisplayItem, public DisplayItemClient {
-public:
- TestDisplayItem(DisplayItem::Type type) : DisplayItem(*this, type, sizeof(*this)) { }
-
- void replay(GraphicsContext&) const final { NOTREACHED(); }
- void appendToWebDisplayItemList(const IntRect&, WebDisplayItemList*) const final { NOTREACHED(); }
- String debugName() const final { return "Test"; }
- LayoutRect visualRect() const final { return LayoutRect(); }
-};
-
-class NormalTestDisplayItem : public TestDisplayItem {
-public:
- NormalTestDisplayItem() : TestDisplayItem(DisplayItem::DrawingFirst) { }
-};
-
-class TestDisplayItemRequiringSeparateChunk : public TestDisplayItem {
-public:
- TestDisplayItemRequiringSeparateChunk() : TestDisplayItem(DisplayItem::ForeignLayerPlugin) { }
-};
-
TEST_F(PaintChunkerTest, Empty)
{
Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks();
@@ -60,108 +40,108 @@
TEST_F(PaintChunkerTest, SingleNonEmptyRange)
{
PaintChunker chunker;
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- Vector<PaintChunk> chunks = chunker.releasePaintChunks();
-
- EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 2, nullptr, rootPaintChunkProperties())));
+ chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties());
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 2, rootPaintChunkProperties())));
}
TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk)
{
PaintChunker chunker;
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- Vector<PaintChunk> chunks = chunker.releasePaintChunks();
-
- EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 3, nullptr, rootPaintChunkProperties())));
+ chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties());
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties());
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 3, rootPaintChunkProperties())));
}
TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex)
{
PaintChunker chunker;
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.decrementDisplayItemIndex();
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- Vector<PaintChunk> chunks = chunker.releasePaintChunks();
-
- EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 2, nullptr, rootPaintChunkProperties())));
+ chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties());
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.decrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 2, rootPaintChunkProperties())));
}
TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging)
{
PaintChunker chunker;
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
+ chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties());
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
PaintChunkProperties simpleTransform;
simpleTransform.transform = TransformPaintPropertyNode::create(TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
- chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
+ chunker.updateCurrentPaintChunkProperties(simpleTransform);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
PaintChunkProperties anotherTransform;
anotherTransform.transform = TransformPaintPropertyNode::create(TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
- chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
-
- Vector<PaintChunk> chunks = chunker.releasePaintChunks();
-
- EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
- PaintChunk(2, 3, nullptr, simpleTransform),
- PaintChunk(3, 4, nullptr, anotherTransform)));
+ chunker.updateCurrentPaintChunkProperties(anotherTransform);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 2, rootPaintChunkProperties()),
+ PaintChunk(2, 3, simpleTransform),
+ PaintChunk(3, 4, anotherTransform)));
}
TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges)
{
PaintChunker chunker;
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
+ chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties());
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
PaintChunkProperties simpleTransform;
simpleTransform.transform = TransformPaintPropertyNode::create(TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7));
- chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
+ chunker.updateCurrentPaintChunkProperties(simpleTransform);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
PaintChunkProperties simpleTransformAndEffect;
simpleTransformAndEffect.transform = simpleTransform.transform;
simpleTransformAndEffect.effect = EffectPaintPropertyNode::create(0.5f);
- chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
+ chunker.updateCurrentPaintChunkProperties(simpleTransformAndEffect);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform;
simpleTransformAndEffectWithUpdatedTransform.transform = TransformPaintPropertyNode::create(TransformationMatrix(1, 1, 0, 0, 0, 0), FloatPoint3D(9, 8, 7));
simpleTransformAndEffectWithUpdatedTransform.effect = EffectPaintPropertyNode::create(simpleTransformAndEffect.effect->opacity());
- chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffectWithUpdatedTransform);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
+ chunker.updateCurrentPaintChunkProperties(simpleTransformAndEffectWithUpdatedTransform);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
// Test that going back to a previous chunk property still creates a new chunk.
- chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
-
- Vector<PaintChunk> chunks = chunker.releasePaintChunks();
-
- EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
- PaintChunk(1, 3, nullptr, simpleTransform),
- PaintChunk(3, 5, nullptr, simpleTransformAndEffect),
- PaintChunk(5, 7, nullptr, simpleTransformAndEffectWithUpdatedTransform),
- PaintChunk(7, 9, nullptr, simpleTransformAndEffect)));
+ chunker.updateCurrentPaintChunkProperties(simpleTransformAndEffect);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 1, rootPaintChunkProperties()),
+ PaintChunk(1, 3, simpleTransform),
+ PaintChunk(3, 5, simpleTransformAndEffect),
+ PaintChunk(5, 7, simpleTransformAndEffectWithUpdatedTransform),
+ PaintChunk(7, 9, simpleTransformAndEffect)));
}
TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms)
@@ -170,47 +150,47 @@
// sequence of transforms and display items:
// <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, </root xform>
PaintChunker chunker;
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
+ chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties());
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
PaintChunkProperties simpleTransform;
simpleTransform.transform = TransformPaintPropertyNode::create(TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
- chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
-
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
-
- Vector<PaintChunk> chunks = chunker.releasePaintChunks();
-
- EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
- PaintChunk(1, 3, nullptr, simpleTransform),
- PaintChunk(3, 4, nullptr, rootPaintChunkProperties())));
+ chunker.updateCurrentPaintChunkProperties(simpleTransform);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+
+ chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties());
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 1, rootPaintChunkProperties()),
+ PaintChunk(1, 3, simpleTransform),
+ PaintChunk(3, 4, rootPaintChunkProperties())));
}
TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems)
{
// Test that properties can change without display items being generated.
PaintChunker chunker;
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
+ chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties());
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
PaintChunkProperties firstTransform;
firstTransform.transform = TransformPaintPropertyNode::create(TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
- chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform);
+ chunker.updateCurrentPaintChunkProperties(firstTransform);
PaintChunkProperties secondTransform;
secondTransform.transform = TransformPaintPropertyNode::create(TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1));
- chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform);
-
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- Vector<PaintChunk> chunks = chunker.releasePaintChunks();
-
- EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
- PaintChunk(1, 2, nullptr, secondTransform)));
+ chunker.updateCurrentPaintChunkProperties(secondTransform);
+
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 1, rootPaintChunkProperties()),
+ PaintChunk(1, 2, secondTransform)));
}
TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested)
@@ -218,99 +198,29 @@
// Tests that the chunker creates a separate chunks for display items which
// require it.
PaintChunker chunker;
- TestDisplayItemRequiringSeparateChunk i1, i2, i3, i4, i5, i6;
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(i1);
- chunker.incrementDisplayItemIndex(i2);
- chunker.incrementDisplayItemIndex(i3);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(i4);
- chunker.incrementDisplayItemIndex(i5);
- chunker.decrementDisplayItemIndex();
- chunker.decrementDisplayItemIndex();
- chunker.decrementDisplayItemIndex();
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(i6);
-
- DisplayItem::Id id1 = i1.getId();
- DisplayItem::Id id2 = i2.getId();
- DisplayItem::Id id3 = i3.getId();
- DisplayItem::Id id6 = i6.getId();
- Vector<PaintChunk> chunks = chunker.releasePaintChunks();
- EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
- PaintChunk(1, 2, &id1, rootPaintChunkProperties()),
- PaintChunk(2, 3, &id2, rootPaintChunkProperties()),
- PaintChunk(3, 4, &id3, rootPaintChunkProperties()),
- PaintChunk(4, 6, nullptr, rootPaintChunkProperties()),
- PaintChunk(6, 7, &id6, rootPaintChunkProperties())));
-}
-
-TEST_F(PaintChunkerTest, ChunkIds)
-{
- PaintChunker chunker;
- TestDisplayItem i1(DisplayItem::DrawingFirst);
- DisplayItem::Id id1 = i1.getId();
- TestDisplayItemRequiringSeparateChunk i2;
- DisplayItem::Id id2 = i2.getId();
-
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
-
- PaintChunkProperties simpleTransform;
- simpleTransform.transform = TransformPaintPropertyNode::create(TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
- chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
-
- chunker.incrementDisplayItemIndex(i1);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(i2);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
-
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
-
- Vector<PaintChunk> chunks = chunker.releasePaintChunks();
- EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
- PaintChunk(2, 4, &id1, simpleTransform),
- PaintChunk(4, 5, &id2, simpleTransform),
- PaintChunk(5, 6, nullptr, simpleTransform),
- PaintChunk(6, 7, nullptr, rootPaintChunkProperties())));
-}
-
-TEST_F(PaintChunkerTest, ChunkIdsSkippingCache)
-{
- PaintChunker chunker;
- TestDisplayItem i1(DisplayItem::DrawingFirst);
- i1.setSkippedCache();
- DisplayItem::Id id1 = i1.getId();
- TestDisplayItemRequiringSeparateChunk i2;
- i2.setSkippedCache();
-
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
-
- PaintChunkProperties simpleTransform;
- simpleTransform.transform = TransformPaintPropertyNode::create(TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
- chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
-
- chunker.incrementDisplayItemIndex(i1);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
- chunker.incrementDisplayItemIndex(i2);
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
-
- chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties());
- chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
-
- Vector<PaintChunk> chunks = chunker.releasePaintChunks();
- EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
- PaintChunk(2, 4, nullptr, simpleTransform),
- PaintChunk(4, 5, nullptr, simpleTransform),
- PaintChunk(5, 6, nullptr, simpleTransform),
- PaintChunk(6, 7, nullptr, rootPaintChunkProperties())));
+ chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties());
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk);
+ chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk);
+ chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk);
+ chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk);
+ chunker.decrementDisplayItemIndex();
+ chunker.decrementDisplayItemIndex();
+ chunker.decrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior);
+ chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk);
+
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 1, rootPaintChunkProperties()),
+ PaintChunk(1, 2, rootPaintChunkProperties()),
+ PaintChunk(2, 3, rootPaintChunkProperties()),
+ PaintChunk(3, 4, rootPaintChunkProperties()),
+ PaintChunk(4, 6, rootPaintChunkProperties()),
+ PaintChunk(6, 7, rootPaintChunkProperties())));
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698