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

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

Issue 1397583002: Implement the framework for a paint property hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 38be4a4e2c804612d0a7c9e67f5c6d0b1b98715b..bc8b908953d2aeaaaee4189bda500c16c74305a7 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
@@ -14,7 +14,7 @@ using testing::ElementsAre;
namespace blink {
namespace {
-static PaintProperties samplePaintProperties() { return PaintProperties(); }
+static PaintProperties rootPaintProperties() { return PaintProperties(); }
class PaintChunkerTest : public testing::Test {
protected:
@@ -41,33 +41,33 @@ TEST_F(PaintChunkerTest, Empty)
TEST_F(PaintChunkerTest, SingleNonEmptyRange)
{
PaintChunker chunker;
- chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
chunker.incrementDisplayItemIndex();
chunker.incrementDisplayItemIndex();
Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 2, samplePaintProperties())));
+ PaintChunk(0, 2, rootPaintProperties())));
}
TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk)
{
PaintChunker chunker;
- chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
chunker.incrementDisplayItemIndex();
chunker.incrementDisplayItemIndex();
- chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
chunker.incrementDisplayItemIndex();
Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 3, samplePaintProperties())));
+ PaintChunk(0, 3, rootPaintProperties())));
}
TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex)
{
PaintChunker chunker;
- chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
chunker.incrementDisplayItemIndex();
chunker.incrementDisplayItemIndex();
chunker.decrementDisplayItemIndex();
@@ -75,11 +75,85 @@ TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex)
Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 2, samplePaintProperties())));
+ PaintChunk(0, 2, rootPaintProperties())));
}
-// TODO(jbroman): Add more tests one it is possible for there to be two distinct
-// PaintProperties.
+TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging)
+{
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
+ chunker.incrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+
+ PaintProperties simpleTransform;
+ simpleTransform.transform = adoptRef(new TransformPaintPropertyNode(TransformationMatrix(), FloatPoint3D()));
+
+ chunker.updateCurrentPaintProperties(simpleTransform);
+ chunker.incrementDisplayItemIndex();
+
+ PaintProperties anotherTransform;
+ anotherTransform.transform = adoptRef(new TransformPaintPropertyNode(TransformationMatrix(), FloatPoint3D()));
+ chunker.updateCurrentPaintProperties(anotherTransform);
+ chunker.incrementDisplayItemIndex();
+
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 2, rootPaintProperties()),
chrishtr 2015/10/07 21:14:28 Make the different transforms have different param
pdr. 2015/10/07 22:15:59 Done
+ PaintChunk(2, 3, simpleTransform),
+ PaintChunk(3, 4, anotherTransform)));
+}
+
+TEST_F(PaintChunkerTest, BuildLinearChunksFromNestedTransforms)
+{
+ // Test that "nested" transforms linearize using the following
+ // sequence of transforms and display items:
+ // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, </root xform>
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
+ chunker.incrementDisplayItemIndex();
+
+ PaintProperties simpleTransform;
+ simpleTransform.transform = adoptRef(new TransformPaintPropertyNode(TransformationMatrix(), FloatPoint3D()));
+ chunker.updateCurrentPaintProperties(simpleTransform);
+ chunker.incrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
+ chunker.incrementDisplayItemIndex();
+
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 1, rootPaintProperties()),
+ PaintChunk(1, 3, simpleTransform),
+ PaintChunk(3, 4, rootPaintProperties())));
+}
+
+TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems)
+{
+ // Test that properties can change without display items being generated.
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
+ chunker.incrementDisplayItemIndex();
+
+ PaintProperties firstTransform;
+ firstTransform.transform = adoptRef(new TransformPaintPropertyNode(TransformationMatrix(), FloatPoint3D()));
+ chunker.updateCurrentPaintProperties(firstTransform);
+
+ PaintProperties secondTransform;
+ secondTransform.transform = adoptRef(new TransformPaintPropertyNode(TransformationMatrix(), FloatPoint3D()));
+ chunker.updateCurrentPaintProperties(secondTransform);
+
+ chunker.incrementDisplayItemIndex();
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 1, rootPaintProperties()),
+ PaintChunk(1, 2, secondTransform)));
+}
+
+// TODO(pdr): Add more tests once we have more paint properties.
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698