| 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 d36cfceb8ec5d5f92d52d426651112476856aed4..2ce49c0e1c857e8f5bc952efee6829ad178aeaca 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
|
| @@ -5,10 +5,13 @@
|
| #include "platform/graphics/paint/PaintChunker.h"
|
|
|
| #include "platform/RuntimeEnabledFeatures.h"
|
| +#include "platform/testing/PaintPropertyTestHelpers.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| -using testing::ElementsAre;
|
| +using ::blink::testing::createOpacityOnlyEffect;
|
| +using ::blink::testing::defaultPaintChunkProperties;
|
| +using ::testing::ElementsAre;
|
|
|
| namespace blink {
|
| namespace {
|
| @@ -17,16 +20,7 @@ namespace {
|
| // bots.
|
| #if defined(NDEBUG) || !OS(WIN)
|
|
|
| -PaintChunkProperties rootPaintChunkProperties() {
|
| - PaintChunkProperties rootProperties;
|
| - rootProperties.transform = TransformPaintPropertyNode::root();
|
| - rootProperties.clip = ClipPaintPropertyNode::root();
|
| - rootProperties.effect = EffectPaintPropertyNode::root();
|
| - rootProperties.scroll = ScrollPaintPropertyNode::root();
|
| - return rootProperties;
|
| -}
|
| -
|
| -class PaintChunkerTest : public testing::Test {
|
| +class PaintChunkerTest : public ::testing::Test {
|
| protected:
|
| void SetUp() override {
|
| RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
|
| @@ -71,34 +65,34 @@ TEST_F(PaintChunkerTest, Empty) {
|
| TEST_F(PaintChunkerTest, SingleNonEmptyRange) {
|
| PaintChunker chunker;
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| Vector<PaintChunk> chunks = chunker.releasePaintChunks();
|
|
|
| EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
|
| - rootPaintChunkProperties())));
|
| + defaultPaintChunkProperties())));
|
| }
|
|
|
| TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) {
|
| PaintChunker chunker;
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| Vector<PaintChunk> chunks = chunker.releasePaintChunks();
|
|
|
| EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 3, nullptr,
|
| - rootPaintChunkProperties())));
|
| + defaultPaintChunkProperties())));
|
| }
|
|
|
| TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) {
|
| PaintChunker chunker;
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.decrementDisplayItemIndex();
|
| @@ -106,24 +100,24 @@ TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) {
|
| Vector<PaintChunk> chunks = chunker.releasePaintChunks();
|
|
|
| EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
|
| - rootPaintChunkProperties())));
|
| + defaultPaintChunkProperties())));
|
| }
|
|
|
| TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) {
|
| PaintChunker chunker;
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| - PaintChunkProperties simpleTransform = rootPaintChunkProperties();
|
| + PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
|
| simpleTransform.transform = TransformPaintPropertyNode::create(
|
| nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
|
|
|
| chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| - PaintChunkProperties anotherTransform = rootPaintChunkProperties();
|
| + PaintChunkProperties anotherTransform = defaultPaintChunkProperties();
|
| anotherTransform.transform = TransformPaintPropertyNode::create(
|
| nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
|
| chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform);
|
| @@ -131,45 +125,42 @@ TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) {
|
|
|
| Vector<PaintChunk> chunks = chunker.releasePaintChunks();
|
|
|
| - EXPECT_THAT(chunks,
|
| - ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
|
| - PaintChunk(2, 3, nullptr, simpleTransform),
|
| - PaintChunk(3, 4, nullptr, anotherTransform)));
|
| + EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
|
| + defaultPaintChunkProperties()),
|
| + PaintChunk(2, 3, nullptr, simpleTransform),
|
| + PaintChunk(3, 4, nullptr, anotherTransform)));
|
| }
|
|
|
| TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) {
|
| PaintChunker chunker;
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| - PaintChunkProperties simpleTransform = rootPaintChunkProperties();
|
| + PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
|
| simpleTransform.transform = TransformPaintPropertyNode::create(
|
| nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7));
|
| chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| - PaintChunkProperties simpleTransformAndEffect = rootPaintChunkProperties();
|
| + PaintChunkProperties simpleTransformAndEffect = defaultPaintChunkProperties();
|
| simpleTransformAndEffect.transform = simpleTransform.transform;
|
| - simpleTransformAndEffect.effect = EffectPaintPropertyNode::create(
|
| - EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
|
| - ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5f);
|
| + simpleTransformAndEffect.effect =
|
| + createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5f);
|
| chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform =
|
| - rootPaintChunkProperties();
|
| + defaultPaintChunkProperties();
|
| simpleTransformAndEffectWithUpdatedTransform.transform =
|
| TransformPaintPropertyNode::create(nullptr,
|
| TransformationMatrix(1, 1, 0, 0, 0, 0),
|
| FloatPoint3D(9, 8, 7));
|
| simpleTransformAndEffectWithUpdatedTransform.effect =
|
| - EffectPaintPropertyNode::create(
|
| - EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
|
| - ClipPaintPropertyNode::root(), CompositorFilterOperations(),
|
| - simpleTransformAndEffect.effect->opacity());
|
| + createOpacityOnlyEffect(EffectPaintPropertyNode::root(),
|
| + simpleTransformAndEffect.effect->opacity());
|
| chunker.updateCurrentPaintChunkProperties(
|
| nullptr, simpleTransformAndEffectWithUpdatedTransform);
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| @@ -185,7 +176,7 @@ TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) {
|
|
|
| EXPECT_THAT(
|
| chunks,
|
| - ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
|
| + ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()),
|
| PaintChunk(1, 3, nullptr, simpleTransform),
|
| PaintChunk(3, 5, nullptr, simpleTransformAndEffect),
|
| PaintChunk(5, 7, nullptr,
|
| @@ -200,10 +191,10 @@ TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) {
|
| // </root xform>
|
| PaintChunker chunker;
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| - PaintChunkProperties simpleTransform = rootPaintChunkProperties();
|
| + PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
|
| simpleTransform.transform = TransformPaintPropertyNode::create(
|
| nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
|
| chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
|
| @@ -211,31 +202,31 @@ TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) {
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| Vector<PaintChunk> chunks = chunker.releasePaintChunks();
|
|
|
| EXPECT_THAT(
|
| chunks,
|
| - ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
|
| + ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()),
|
| PaintChunk(1, 3, nullptr, simpleTransform),
|
| - PaintChunk(3, 4, nullptr, rootPaintChunkProperties())));
|
| + PaintChunk(3, 4, nullptr, defaultPaintChunkProperties())));
|
| }
|
|
|
| TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) {
|
| // Test that properties can change without display items being generated.
|
| PaintChunker chunker;
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| - PaintChunkProperties firstTransform = rootPaintChunkProperties();
|
| + PaintChunkProperties firstTransform = defaultPaintChunkProperties();
|
| firstTransform.transform = TransformPaintPropertyNode::create(
|
| nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
|
| chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform);
|
|
|
| - PaintChunkProperties secondTransform = rootPaintChunkProperties();
|
| + PaintChunkProperties secondTransform = defaultPaintChunkProperties();
|
| secondTransform.transform = TransformPaintPropertyNode::create(
|
| nullptr, TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1));
|
| chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform);
|
| @@ -243,9 +234,9 @@ TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) {
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| Vector<PaintChunk> chunks = chunker.releasePaintChunks();
|
|
|
| - EXPECT_THAT(chunks,
|
| - ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
|
| - PaintChunk(1, 2, nullptr, secondTransform)));
|
| + EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 1, nullptr,
|
| + defaultPaintChunkProperties()),
|
| + PaintChunk(1, 2, nullptr, secondTransform)));
|
| }
|
|
|
| TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) {
|
| @@ -254,7 +245,7 @@ TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) {
|
| PaintChunker chunker;
|
| TestDisplayItemRequiringSeparateChunk i1, i2, i3, i4, i5, i6;
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.incrementDisplayItemIndex(i1);
|
| chunker.incrementDisplayItemIndex(i2);
|
| @@ -274,13 +265,14 @@ TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) {
|
| 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())));
|
| + EXPECT_THAT(
|
| + chunks,
|
| + ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()),
|
| + PaintChunk(1, 2, &id1, defaultPaintChunkProperties()),
|
| + PaintChunk(2, 3, &id2, defaultPaintChunkProperties()),
|
| + PaintChunk(3, 4, &id3, defaultPaintChunkProperties()),
|
| + PaintChunk(4, 6, nullptr, defaultPaintChunkProperties()),
|
| + PaintChunk(6, 7, &id6, defaultPaintChunkProperties())));
|
| }
|
|
|
| TEST_F(PaintChunkerTest, ChunkIds) {
|
| @@ -291,11 +283,11 @@ TEST_F(PaintChunkerTest, ChunkIds) {
|
| DisplayItem::Id id2 = i2.getId();
|
|
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| - PaintChunkProperties simpleTransform = rootPaintChunkProperties();
|
| + PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
|
| simpleTransform.transform = TransformPaintPropertyNode::create(
|
| nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
|
| chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
|
| @@ -306,17 +298,17 @@ TEST_F(PaintChunkerTest, ChunkIds) {
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| Vector<PaintChunk> chunks = chunker.releasePaintChunks();
|
| EXPECT_THAT(
|
| chunks,
|
| - ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
|
| + ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()),
|
| PaintChunk(2, 4, &id1, simpleTransform),
|
| PaintChunk(4, 5, &id2, simpleTransform),
|
| PaintChunk(5, 6, nullptr, simpleTransform),
|
| - PaintChunk(6, 7, nullptr, rootPaintChunkProperties())));
|
| + PaintChunk(6, 7, nullptr, defaultPaintChunkProperties())));
|
| }
|
|
|
| TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) {
|
| @@ -328,11 +320,11 @@ TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) {
|
| i2.setSkippedCache();
|
|
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| - PaintChunkProperties simpleTransform = rootPaintChunkProperties();
|
| + PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
|
| simpleTransform.transform = TransformPaintPropertyNode::create(
|
| nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
|
| chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
|
| @@ -343,17 +335,17 @@ TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) {
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| chunker.updateCurrentPaintChunkProperties(nullptr,
|
| - rootPaintChunkProperties());
|
| + defaultPaintChunkProperties());
|
| chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
|
|
|
| Vector<PaintChunk> chunks = chunker.releasePaintChunks();
|
| EXPECT_THAT(
|
| chunks,
|
| - ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
|
| + ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()),
|
| PaintChunk(2, 4, nullptr, simpleTransform),
|
| PaintChunk(4, 5, nullptr, simpleTransform),
|
| PaintChunk(5, 6, nullptr, simpleTransform),
|
| - PaintChunk(6, 7, nullptr, rootPaintChunkProperties())));
|
| + PaintChunk(6, 7, nullptr, defaultPaintChunkProperties())));
|
| }
|
|
|
| #endif
|
|
|