Commit 54689895 authored by trchen's avatar trchen Committed by Commit bot

[SPv2] Add createOpacityOnlyEffect test helper

This CL adds a test helper header platform/testing/PaintPropertyTestHelpers.h
for common operations that are used in SPv2-related tests.

createOpacityOnlyEffect is added to create effect nodes with only opacity,
other optional effects are assigned a no-op value, and local transform space
and clip are inherited from parent.

As a side change, rootPaintChunkProperties is also moved to the helper header
and renamed to defaultPaintChunkProperties.
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2565903002
Cr-Commit-Position: refs/heads/master@{#437994}
parent d798a7a8
...@@ -1606,6 +1606,7 @@ static_library("test_support") { ...@@ -1606,6 +1606,7 @@ static_library("test_support") {
"testing/MessageLoopForMojo.h", "testing/MessageLoopForMojo.h",
"testing/PaintPrinters.cpp", "testing/PaintPrinters.cpp",
"testing/PaintPrinters.h", "testing/PaintPrinters.h",
"testing/PaintPropertyTestHelpers.h",
"testing/PictureMatchers.cpp", "testing/PictureMatchers.cpp",
"testing/PictureMatchers.h", "testing/PictureMatchers.h",
"testing/PlatformTestPrinters.cpp", "testing/PlatformTestPrinters.cpp",
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "platform/graphics/paint/EffectPaintPropertyNode.h" #include "platform/graphics/paint/EffectPaintPropertyNode.h"
#include "platform/graphics/paint/PaintArtifact.h" #include "platform/graphics/paint/PaintArtifact.h"
#include "platform/graphics/paint/ScrollPaintPropertyNode.h" #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
#include "platform/testing/PaintPropertyTestHelpers.h"
#include "platform/testing/PictureMatchers.h" #include "platform/testing/PictureMatchers.h"
#include "platform/testing/TestPaintArtifact.h" #include "platform/testing/TestPaintArtifact.h"
#include "platform/testing/WebLayerTreeViewImplForTesting.h" #include "platform/testing/WebLayerTreeViewImplForTesting.h"
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
namespace blink { namespace blink {
namespace { namespace {
using ::blink::testing::createOpacityOnlyEffect;
using ::testing::Pointee; using ::testing::Pointee;
PaintChunkProperties defaultPaintChunkProperties() { PaintChunkProperties defaultPaintChunkProperties() {
...@@ -569,15 +571,12 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, ...@@ -569,15 +571,12 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
} }
TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) {
RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create( RefPtr<EffectPaintPropertyNode> effect1 =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5); RefPtr<EffectPaintPropertyNode> effect2 =
RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create( createOpacityOnlyEffect(effect1, 0.3);
effect1, TransformPaintPropertyNode::root(), RefPtr<EffectPaintPropertyNode> effect3 =
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.3); createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.2);
RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create(
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.2);
TestPaintArtifact artifact; TestPaintArtifact artifact;
artifact artifact
...@@ -661,9 +660,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) { ...@@ -661,9 +660,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) {
} }
TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) {
RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( RefPtr<EffectPaintPropertyNode> effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5);
RefPtr<TransformPaintPropertyNode> scrollTranslationA = RefPtr<TransformPaintPropertyNode> scrollTranslationA =
TransformPaintPropertyNode::create( TransformPaintPropertyNode::create(
......
...@@ -10,22 +10,19 @@ ...@@ -10,22 +10,19 @@
#include "platform/graphics/paint/EffectPaintPropertyNode.h" #include "platform/graphics/paint/EffectPaintPropertyNode.h"
#include "platform/graphics/paint/ScrollPaintPropertyNode.h" #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
#include "platform/graphics/paint/TransformPaintPropertyNode.h" #include "platform/graphics/paint/TransformPaintPropertyNode.h"
#include "platform/testing/PaintPropertyTestHelpers.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace blink { namespace blink {
class GeometryMapperTest : public ::testing::Test { class GeometryMapperTest : public ::testing::Test {
public: public:
RefPtr<TransformPaintPropertyNode> rootTransformNode;
RefPtr<ClipPaintPropertyNode> rootClipNode;
RefPtr<EffectPaintPropertyNode> rootEffectNode;
RefPtr<ScrollPaintPropertyNode> rootScrollNode;
std::unique_ptr<GeometryMapper> geometryMapper; std::unique_ptr<GeometryMapper> geometryMapper;
PropertyTreeState rootPropertyTreeState() { PropertyTreeState rootPropertyTreeState() {
PropertyTreeState state(rootTransformNode.get(), rootClipNode.get(), PropertyTreeState state(
rootEffectNode.get(), rootScrollNode.get()); TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root());
return state; return state;
} }
...@@ -42,16 +39,6 @@ class GeometryMapperTest : public ::testing::Test { ...@@ -42,16 +39,6 @@ class GeometryMapperTest : public ::testing::Test {
private: private:
void SetUp() override { void SetUp() override {
rootTransformNode = TransformPaintPropertyNode::create(
nullptr, TransformationMatrix(), FloatPoint3D());
rootClipNode = ClipPaintPropertyNode::create(
nullptr, rootTransformNode,
FloatRoundedRect(LayoutRect::infiniteIntRect()));
rootEffectNode = EffectPaintPropertyNode::create(
nullptr, rootTransformNode, rootClipNode, CompositorFilterOperations(),
1.0);
rootScrollNode = ScrollPaintPropertyNode::create(
nullptr, rootTransformNode, IntSize(), IntSize(), false, false, 0);
geometryMapper = WTF::makeUnique<GeometryMapper>(); geometryMapper = WTF::makeUnique<GeometryMapper>();
} }
...@@ -116,9 +103,10 @@ const static float kTestEpsilon = 1e-6; ...@@ -116,9 +103,10 @@ const static float kTestEpsilon = 1e-6;
TEST_F(GeometryMapperTest, Root) { TEST_F(GeometryMapperTest, Root) {
FloatRect input(0, 0, 100, 100); FloatRect input(0, 0, 100, 100);
CHECK_MAPPINGS(input, input, input, rootTransformNode->matrix(), CHECK_MAPPINGS(input, input, input,
rootClipNode->clipRect().rect(), rootPropertyTreeState(), TransformPaintPropertyNode::root()->matrix(),
rootPropertyTreeState()); ClipPaintPropertyNode::root()->clipRect().rect(),
rootPropertyTreeState(), rootPropertyTreeState());
} }
TEST_F(GeometryMapperTest, IdentityTransform) { TEST_F(GeometryMapperTest, IdentityTransform) {
...@@ -132,7 +120,7 @@ TEST_F(GeometryMapperTest, IdentityTransform) { ...@@ -132,7 +120,7 @@ TEST_F(GeometryMapperTest, IdentityTransform) {
FloatRect input(0, 0, 100, 100); FloatRect input(0, 0, 100, 100);
CHECK_MAPPINGS(input, input, input, transform->matrix(), CHECK_MAPPINGS(input, input, input, transform->matrix(),
rootClipNode->clipRect().rect(), localState, ClipPaintPropertyNode::root()->clipRect().rect(), localState,
rootPropertyTreeState()); rootPropertyTreeState());
} }
...@@ -149,7 +137,7 @@ TEST_F(GeometryMapperTest, TranslationTransform) { ...@@ -149,7 +137,7 @@ TEST_F(GeometryMapperTest, TranslationTransform) {
FloatRect output = transformMatrix.mapRect(input); FloatRect output = transformMatrix.mapRect(input);
CHECK_MAPPINGS(input, output, output, transform->matrix(), CHECK_MAPPINGS(input, output, output, transform->matrix(),
rootClipNode->clipRect().rect(), localState, ClipPaintPropertyNode::root()->clipRect().rect(), localState,
rootPropertyTreeState()); rootPropertyTreeState());
bool success = false; bool success = false;
...@@ -174,7 +162,7 @@ TEST_F(GeometryMapperTest, RotationAndScaleTransform) { ...@@ -174,7 +162,7 @@ TEST_F(GeometryMapperTest, RotationAndScaleTransform) {
FloatRect output = transformMatrix.mapRect(input); FloatRect output = transformMatrix.mapRect(input);
CHECK_MAPPINGS(input, output, output, transformMatrix, CHECK_MAPPINGS(input, output, output, transformMatrix,
rootClipNode->clipRect().rect(), localState, ClipPaintPropertyNode::root()->clipRect().rect(), localState,
rootPropertyTreeState()); rootPropertyTreeState());
} }
...@@ -194,7 +182,7 @@ TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) { ...@@ -194,7 +182,7 @@ TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) {
FloatRect output = transformMatrix.mapRect(input); FloatRect output = transformMatrix.mapRect(input);
CHECK_MAPPINGS(input, output, output, transformMatrix, CHECK_MAPPINGS(input, output, output, transformMatrix,
rootClipNode->clipRect().rect(), localState, ClipPaintPropertyNode::root()->clipRect().rect(), localState,
rootPropertyTreeState()); rootPropertyTreeState());
} }
...@@ -218,8 +206,9 @@ TEST_F(GeometryMapperTest, NestedTransforms) { ...@@ -218,8 +206,9 @@ TEST_F(GeometryMapperTest, NestedTransforms) {
TransformationMatrix final = rotateTransform * scaleTransform; TransformationMatrix final = rotateTransform * scaleTransform;
FloatRect output = final.mapRect(input); FloatRect output = final.mapRect(input);
CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect(), CHECK_MAPPINGS(input, output, output, final,
localState, rootPropertyTreeState()); ClipPaintPropertyNode::root()->clipRect().rect(), localState,
rootPropertyTreeState());
// Check the cached matrix for the intermediate transform. // Check the cached matrix for the intermediate transform.
EXPECT_EQ(rotateTransform, EXPECT_EQ(rotateTransform,
...@@ -249,8 +238,9 @@ TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) { ...@@ -249,8 +238,9 @@ TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) {
TransformationMatrix final = scaleTransform * translateTransform; TransformationMatrix final = scaleTransform * translateTransform;
FloatRect output = final.mapRect(input); FloatRect output = final.mapRect(input);
CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect(), CHECK_MAPPINGS(input, output, output, final,
localState, rootPropertyTreeState()); ClipPaintPropertyNode::root()->clipRect().rect(), localState,
rootPropertyTreeState());
// Check the cached matrix for the intermediate transform. // Check the cached matrix for the intermediate transform.
EXPECT_EQ(scaleTransform, EXPECT_EQ(scaleTransform,
...@@ -281,13 +271,14 @@ TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) { ...@@ -281,13 +271,14 @@ TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) {
FloatRect output = scaleTransform.mapRect(input); FloatRect output = scaleTransform.mapRect(input);
CHECK_MAPPINGS(input, output, output, scaleTransform, CHECK_MAPPINGS(input, output, output, scaleTransform,
rootClipNode->clipRect().rect(), localState, ClipPaintPropertyNode::root()->clipRect().rect(), localState,
intermediateState); intermediateState);
} }
TEST_F(GeometryMapperTest, SimpleClip) { TEST_F(GeometryMapperTest, SimpleClip) {
RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
rootClipNode, rootTransformNode, FloatRoundedRect(10, 10, 50, 50)); ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
FloatRoundedRect(10, 10, 50, 50));
PropertyTreeState localState = rootPropertyTreeState(); PropertyTreeState localState = rootPropertyTreeState();
localState.setClip(clip.get()); localState.setClip(clip.get());
...@@ -295,13 +286,14 @@ TEST_F(GeometryMapperTest, SimpleClip) { ...@@ -295,13 +286,14 @@ TEST_F(GeometryMapperTest, SimpleClip) {
FloatRect input(0, 0, 100, 100); FloatRect input(0, 0, 100, 100);
FloatRect output(10, 10, 50, 50); FloatRect output(10, 10, 50, 50);
CHECK_MAPPINGS( CHECK_MAPPINGS(input, // Input
input, // Input output, // Visual rect
output, // Visual rect input, // Transformed rect (not clipped).
input, // Transformed rect (not clipped). TransformPaintPropertyNode::root()
rootTransformNode->matrix(), // Transform matrix to ancestor space ->matrix(), // Transform matrix to ancestor space
clip->clipRect().rect(), // Clip rect in ancestor space clip->clipRect().rect(), // Clip rect in ancestor space
localState, rootPropertyTreeState()); localState,
rootPropertyTreeState());
} }
TEST_F(GeometryMapperTest, ClipBeforeTransform) { TEST_F(GeometryMapperTest, ClipBeforeTransform) {
...@@ -312,7 +304,8 @@ TEST_F(GeometryMapperTest, ClipBeforeTransform) { ...@@ -312,7 +304,8 @@ TEST_F(GeometryMapperTest, ClipBeforeTransform) {
rotateTransform, FloatPoint3D()); rotateTransform, FloatPoint3D());
RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
rootClipNode, transform.get(), FloatRoundedRect(10, 10, 50, 50)); ClipPaintPropertyNode::root(), transform.get(),
FloatRoundedRect(10, 10, 50, 50));
PropertyTreeState localState = rootPropertyTreeState(); PropertyTreeState localState = rootPropertyTreeState();
localState.setClip(clip.get()); localState.setClip(clip.get());
...@@ -341,9 +334,9 @@ TEST_F(GeometryMapperTest, ClipAfterTransform) { ...@@ -341,9 +334,9 @@ TEST_F(GeometryMapperTest, ClipAfterTransform) {
TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
rotateTransform, FloatPoint3D()); rotateTransform, FloatPoint3D());
RefPtr<ClipPaintPropertyNode> clip = RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
ClipPaintPropertyNode::create(rootClipNode, rootTransformNode.get(), ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
FloatRoundedRect(10, 10, 200, 200)); FloatRoundedRect(10, 10, 200, 200));
PropertyTreeState localState = rootPropertyTreeState(); PropertyTreeState localState = rootPropertyTreeState();
localState.setClip(clip.get()); localState.setClip(clip.get());
...@@ -364,9 +357,9 @@ TEST_F(GeometryMapperTest, ClipAfterTransform) { ...@@ -364,9 +357,9 @@ TEST_F(GeometryMapperTest, ClipAfterTransform) {
} }
TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween) { TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween) {
RefPtr<ClipPaintPropertyNode> clip1 = RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
ClipPaintPropertyNode::create(rootClipNode, rootTransformNode.get(), ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
FloatRoundedRect(10, 10, 200, 200)); FloatRoundedRect(10, 10, 200, 200));
TransformationMatrix rotateTransform; TransformationMatrix rotateTransform;
rotateTransform.rotate(45); rotateTransform.rotate(45);
......
...@@ -5,24 +5,18 @@ ...@@ -5,24 +5,18 @@
#include "platform/graphics/paint/PaintChunker.h" #include "platform/graphics/paint/PaintChunker.h"
#include "platform/RuntimeEnabledFeatures.h" #include "platform/RuntimeEnabledFeatures.h"
#include "platform/testing/PaintPropertyTestHelpers.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.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 blink {
namespace { namespace {
PaintChunkProperties rootPaintChunkProperties() { class PaintChunkerTest : public ::testing::Test {
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 {
protected: protected:
void SetUp() override { void SetUp() override {
RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
...@@ -73,34 +67,34 @@ TEST_F(PaintChunkerTest, Empty) { ...@@ -73,34 +67,34 @@ TEST_F(PaintChunkerTest, Empty) {
TEST_F(PaintChunkerTest, SingleNonEmptyRange) { TEST_F(PaintChunkerTest, SingleNonEmptyRange) {
PaintChunker chunker; PaintChunker chunker;
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
Vector<PaintChunk> chunks = chunker.releasePaintChunks(); Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr, EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
rootPaintChunkProperties()))); defaultPaintChunkProperties())));
} }
TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) { TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) {
PaintChunker chunker; PaintChunker chunker;
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
Vector<PaintChunk> chunks = chunker.releasePaintChunks(); Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 3, nullptr, EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 3, nullptr,
rootPaintChunkProperties()))); defaultPaintChunkProperties())));
} }
TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) { TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) {
PaintChunker chunker; PaintChunker chunker;
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.decrementDisplayItemIndex(); chunker.decrementDisplayItemIndex();
...@@ -108,24 +102,24 @@ TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) { ...@@ -108,24 +102,24 @@ TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) {
Vector<PaintChunk> chunks = chunker.releasePaintChunks(); Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr, EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
rootPaintChunkProperties()))); defaultPaintChunkProperties())));
} }
TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) { TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) {
PaintChunker chunker; PaintChunker chunker;
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
PaintChunkProperties simpleTransform = rootPaintChunkProperties(); PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
simpleTransform.transform = TransformPaintPropertyNode::create( simpleTransform.transform = TransformPaintPropertyNode::create(
nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
PaintChunkProperties anotherTransform = rootPaintChunkProperties(); PaintChunkProperties anotherTransform = defaultPaintChunkProperties();
anotherTransform.transform = TransformPaintPropertyNode::create( anotherTransform.transform = TransformPaintPropertyNode::create(
nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform);
...@@ -133,45 +127,42 @@ TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) { ...@@ -133,45 +127,42 @@ TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) {
Vector<PaintChunk> chunks = chunker.releasePaintChunks(); Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), defaultPaintChunkProperties()),
PaintChunk(2, 3, nullptr, simpleTransform), PaintChunk(2, 3, nullptr, simpleTransform),
PaintChunk(3, 4, nullptr, anotherTransform))); PaintChunk(3, 4, nullptr, anotherTransform)));
} }
TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) { TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) {
PaintChunker chunker; PaintChunker chunker;
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
PaintChunkProperties simpleTransform = rootPaintChunkProperties(); PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
simpleTransform.transform = TransformPaintPropertyNode::create( simpleTransform.transform = TransformPaintPropertyNode::create(
nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7));
chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
PaintChunkProperties simpleTransformAndEffect = rootPaintChunkProperties(); PaintChunkProperties simpleTransformAndEffect = defaultPaintChunkProperties();
simpleTransformAndEffect.transform = simpleTransform.transform; simpleTransformAndEffect.transform = simpleTransform.transform;
simpleTransformAndEffect.effect = EffectPaintPropertyNode::create( simpleTransformAndEffect.effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5f);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5f);
chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform = PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform =
rootPaintChunkProperties(); defaultPaintChunkProperties();
simpleTransformAndEffectWithUpdatedTransform.transform = simpleTransformAndEffectWithUpdatedTransform.transform =
TransformPaintPropertyNode::create(nullptr, TransformPaintPropertyNode::create(nullptr,
TransformationMatrix(1, 1, 0, 0, 0, 0), TransformationMatrix(1, 1, 0, 0, 0, 0),
FloatPoint3D(9, 8, 7)); FloatPoint3D(9, 8, 7));
simpleTransformAndEffectWithUpdatedTransform.effect = simpleTransformAndEffectWithUpdatedTransform.effect =
EffectPaintPropertyNode::create( createOpacityOnlyEffect(EffectPaintPropertyNode::root(),
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), simpleTransformAndEffect.effect->opacity());
ClipPaintPropertyNode::root(), CompositorFilterOperations(),
simpleTransformAndEffect.effect->opacity());
chunker.updateCurrentPaintChunkProperties( chunker.updateCurrentPaintChunkProperties(
nullptr, simpleTransformAndEffectWithUpdatedTransform); nullptr, simpleTransformAndEffectWithUpdatedTransform);
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
...@@ -187,7 +178,7 @@ TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) { ...@@ -187,7 +178,7 @@ TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) {
EXPECT_THAT( EXPECT_THAT(
chunks, chunks,
ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()),
PaintChunk(1, 3, nullptr, simpleTransform), PaintChunk(1, 3, nullptr, simpleTransform),
PaintChunk(3, 5, nullptr, simpleTransformAndEffect), PaintChunk(3, 5, nullptr, simpleTransformAndEffect),
PaintChunk(5, 7, nullptr, PaintChunk(5, 7, nullptr,
...@@ -202,10 +193,10 @@ TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) { ...@@ -202,10 +193,10 @@ TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) {
// </root xform> // </root xform>
PaintChunker chunker; PaintChunker chunker;
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
PaintChunkProperties simpleTransform = rootPaintChunkProperties(); PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
simpleTransform.transform = TransformPaintPropertyNode::create( simpleTransform.transform = TransformPaintPropertyNode::create(
nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
...@@ -213,31 +204,31 @@ TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) { ...@@ -213,31 +204,31 @@ TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) {
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
Vector<PaintChunk> chunks = chunker.releasePaintChunks(); Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT( EXPECT_THAT(
chunks, chunks,
ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()),
PaintChunk(1, 3, nullptr, simpleTransform), PaintChunk(1, 3, nullptr, simpleTransform),
PaintChunk(3, 4, nullptr, rootPaintChunkProperties()))); PaintChunk(3, 4, nullptr, defaultPaintChunkProperties())));
} }
TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) { TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) {
// Test that properties can change without display items being generated. // Test that properties can change without display items being generated.
PaintChunker chunker; PaintChunker chunker;
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
PaintChunkProperties firstTransform = rootPaintChunkProperties(); PaintChunkProperties firstTransform = defaultPaintChunkProperties();
firstTransform.transform = TransformPaintPropertyNode::create( firstTransform.transform = TransformPaintPropertyNode::create(
nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform); chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform);
PaintChunkProperties secondTransform = rootPaintChunkProperties(); PaintChunkProperties secondTransform = defaultPaintChunkProperties();
secondTransform.transform = TransformPaintPropertyNode::create( secondTransform.transform = TransformPaintPropertyNode::create(
nullptr, TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); nullptr, TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1));
chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform);
...@@ -245,9 +236,9 @@ TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) { ...@@ -245,9 +236,9 @@ TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) {
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
Vector<PaintChunk> chunks = chunker.releasePaintChunks(); Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 1, nullptr,
ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), defaultPaintChunkProperties()),
PaintChunk(1, 2, nullptr, secondTransform))); PaintChunk(1, 2, nullptr, secondTransform)));
} }
TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) { TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) {
...@@ -262,7 +253,7 @@ TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) { ...@@ -262,7 +253,7 @@ TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) {
TestDisplayItemRequiringSeparateChunk i6(m_client); TestDisplayItemRequiringSeparateChunk i6(m_client);
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.incrementDisplayItemIndex(i1); chunker.incrementDisplayItemIndex(i1);
chunker.incrementDisplayItemIndex(i2); chunker.incrementDisplayItemIndex(i2);
...@@ -282,13 +273,14 @@ TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) { ...@@ -282,13 +273,14 @@ TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) {
DisplayItem::Id id3 = i3.getId(); DisplayItem::Id id3 = i3.getId();
DisplayItem::Id id6 = i6.getId(); DisplayItem::Id id6 = i6.getId();
Vector<PaintChunk> chunks = chunker.releasePaintChunks(); Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, EXPECT_THAT(
ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), chunks,
PaintChunk(1, 2, &id1, rootPaintChunkProperties()), ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()),
PaintChunk(2, 3, &id2, rootPaintChunkProperties()), PaintChunk(1, 2, &id1, defaultPaintChunkProperties()),
PaintChunk(3, 4, &id3, rootPaintChunkProperties()), PaintChunk(2, 3, &id2, defaultPaintChunkProperties()),
PaintChunk(4, 6, nullptr, rootPaintChunkProperties()), PaintChunk(3, 4, &id3, defaultPaintChunkProperties()),
PaintChunk(6, 7, &id6, rootPaintChunkProperties()))); PaintChunk(4, 6, nullptr, defaultPaintChunkProperties()),
PaintChunk(6, 7, &id6, defaultPaintChunkProperties())));
} }
TEST_F(PaintChunkerTest, ChunkIds) { TEST_F(PaintChunkerTest, ChunkIds) {
...@@ -299,11 +291,11 @@ TEST_F(PaintChunkerTest, ChunkIds) { ...@@ -299,11 +291,11 @@ TEST_F(PaintChunkerTest, ChunkIds) {
DisplayItem::Id id2 = i2.getId(); DisplayItem::Id id2 = i2.getId();
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
PaintChunkProperties simpleTransform = rootPaintChunkProperties(); PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
simpleTransform.transform = TransformPaintPropertyNode::create( simpleTransform.transform = TransformPaintPropertyNode::create(
nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
...@@ -314,17 +306,17 @@ TEST_F(PaintChunkerTest, ChunkIds) { ...@@ -314,17 +306,17 @@ TEST_F(PaintChunkerTest, ChunkIds) {
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
Vector<PaintChunk> chunks = chunker.releasePaintChunks(); Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT( EXPECT_THAT(
chunks, chunks,
ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()),
PaintChunk(2, 4, &id1, simpleTransform), PaintChunk(2, 4, &id1, simpleTransform),
PaintChunk(4, 5, &id2, simpleTransform), PaintChunk(4, 5, &id2, simpleTransform),
PaintChunk(5, 6, nullptr, simpleTransform), PaintChunk(5, 6, nullptr, simpleTransform),
PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); PaintChunk(6, 7, nullptr, defaultPaintChunkProperties())));
} }
TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) { TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) {
...@@ -336,11 +328,11 @@ TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) { ...@@ -336,11 +328,11 @@ TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) {
i2.setSkippedCache(); i2.setSkippedCache();
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
PaintChunkProperties simpleTransform = rootPaintChunkProperties(); PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
simpleTransform.transform = TransformPaintPropertyNode::create( simpleTransform.transform = TransformPaintPropertyNode::create(
nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
...@@ -351,17 +343,17 @@ TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) { ...@@ -351,17 +343,17 @@ TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) {
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
chunker.updateCurrentPaintChunkProperties(nullptr, chunker.updateCurrentPaintChunkProperties(nullptr,
rootPaintChunkProperties()); defaultPaintChunkProperties());
chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
Vector<PaintChunk> chunks = chunker.releasePaintChunks(); Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT( EXPECT_THAT(
chunks, chunks,
ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()),
PaintChunk(2, 4, nullptr, simpleTransform), PaintChunk(2, 4, nullptr, simpleTransform),
PaintChunk(4, 5, nullptr, simpleTransform), PaintChunk(4, 5, nullptr, simpleTransform),
PaintChunk(5, 6, nullptr, simpleTransform), PaintChunk(5, 6, nullptr, simpleTransform),
PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); PaintChunk(6, 7, nullptr, defaultPaintChunkProperties())));
} }
} // namespace } // namespace
......
...@@ -14,15 +14,18 @@ ...@@ -14,15 +14,18 @@
#include "platform/graphics/paint/DrawingRecorder.h" #include "platform/graphics/paint/DrawingRecorder.h"
#include "platform/graphics/paint/SubsequenceRecorder.h" #include "platform/graphics/paint/SubsequenceRecorder.h"
#include "platform/testing/FakeDisplayItemClient.h" #include "platform/testing/FakeDisplayItemClient.h"
#include "platform/testing/PaintPropertyTestHelpers.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <memory> #include <memory>
using blink::testing::createOpacityOnlyEffect;
using blink::testing::defaultPaintChunkProperties;
using testing::UnorderedElementsAre; using testing::UnorderedElementsAre;
namespace blink { namespace blink {
class PaintControllerTestBase : public testing::Test { class PaintControllerTestBase : public ::testing::Test {
public: public:
PaintControllerTestBase() : m_paintController(PaintController::create()) {} PaintControllerTestBase() : m_paintController(PaintController::create()) {}
...@@ -54,15 +57,6 @@ class PaintControllerTestBase : public testing::Test { ...@@ -54,15 +57,6 @@ class PaintControllerTestBase : public testing::Test {
RuntimeEnabledFeatures::Backup m_featuresBackup; RuntimeEnabledFeatures::Backup m_featuresBackup;
}; };
PaintChunkProperties rootPaintChunkProperties() {
PaintChunkProperties rootProperties;
rootProperties.transform = TransformPaintPropertyNode::root();
rootProperties.clip = ClipPaintPropertyNode::root();
rootProperties.effect = EffectPaintPropertyNode::root();
rootProperties.scroll = ScrollPaintPropertyNode::root();
return rootProperties;
}
const DisplayItem::Type foregroundDrawingType = const DisplayItem::Type foregroundDrawingType =
static_cast<DisplayItem::Type>(DisplayItem::kDrawingPaintPhaseFirst + 4); static_cast<DisplayItem::Type>(DisplayItem::kDrawingPaintPhaseFirst + 4);
const DisplayItem::Type backgroundDrawingType = const DisplayItem::Type backgroundDrawingType =
...@@ -136,7 +130,7 @@ enum TestConfigurations { ...@@ -136,7 +130,7 @@ enum TestConfigurations {
// enabled and disabled. // enabled and disabled.
class PaintControllerTest class PaintControllerTest
: public PaintControllerTestBase, : public PaintControllerTestBase,
public testing::WithParamInterface<TestConfigurations> { public ::testing::WithParamInterface<TestConfigurations> {
public: public:
PaintControllerTest() PaintControllerTest()
: m_rootPaintPropertyClient("root"), : m_rootPaintPropertyClient("root"),
...@@ -177,7 +171,7 @@ TEST_P(PaintControllerTest, NestedRecorders) { ...@@ -177,7 +171,7 @@ TEST_P(PaintControllerTest, NestedRecorders) {
FakeDisplayItemClient client("client", LayoutRect(100, 100, 200, 200)); FakeDisplayItemClient client("client", LayoutRect(100, 100, 200, 200));
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawClippedRect(context, client, clipType, backgroundDrawingType, drawClippedRect(context, client, clipType, backgroundDrawingType,
...@@ -203,7 +197,7 @@ TEST_P(PaintControllerTest, UpdateBasic) { ...@@ -203,7 +197,7 @@ TEST_P(PaintControllerTest, UpdateBasic) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, first, backgroundDrawingType, drawRect(context, first, backgroundDrawingType,
...@@ -228,7 +222,7 @@ TEST_P(PaintControllerTest, UpdateBasic) { ...@@ -228,7 +222,7 @@ TEST_P(PaintControllerTest, UpdateBasic) {
UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect())));
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, first, backgroundDrawingType, drawRect(context, first, backgroundDrawingType,
...@@ -265,7 +259,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrder) { ...@@ -265,7 +259,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrder) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, first, backgroundDrawingType, drawRect(context, first, backgroundDrawingType,
...@@ -292,7 +286,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrder) { ...@@ -292,7 +286,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrder) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, second, backgroundDrawingType, drawRect(context, second, backgroundDrawingType,
FloatRect(100, 100, 50, 200)); FloatRect(100, 100, 50, 200));
...@@ -339,7 +333,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) { ...@@ -339,7 +333,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, first, backgroundDrawingType, drawRect(context, first, backgroundDrawingType,
...@@ -366,7 +360,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) { ...@@ -366,7 +360,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
first.setDisplayItemsUncached(); first.setDisplayItemsUncached();
...@@ -418,7 +412,7 @@ TEST_P(PaintControllerTest, UpdateNewItemInMiddle) { ...@@ -418,7 +412,7 @@ TEST_P(PaintControllerTest, UpdateNewItemInMiddle) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, first, backgroundDrawingType, drawRect(context, first, backgroundDrawingType,
...@@ -433,7 +427,7 @@ TEST_P(PaintControllerTest, UpdateNewItemInMiddle) { ...@@ -433,7 +427,7 @@ TEST_P(PaintControllerTest, UpdateNewItemInMiddle) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, first, backgroundDrawingType, drawRect(context, first, backgroundDrawingType,
...@@ -472,7 +466,7 @@ TEST_P(PaintControllerTest, UpdateInvalidationWithPhases) { ...@@ -472,7 +466,7 @@ TEST_P(PaintControllerTest, UpdateInvalidationWithPhases) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, first, backgroundDrawingType, drawRect(context, first, backgroundDrawingType,
...@@ -497,7 +491,7 @@ TEST_P(PaintControllerTest, UpdateInvalidationWithPhases) { ...@@ -497,7 +491,7 @@ TEST_P(PaintControllerTest, UpdateInvalidationWithPhases) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
second.setDisplayItemsUncached(); second.setDisplayItemsUncached();
...@@ -544,7 +538,7 @@ TEST_P(PaintControllerTest, UpdateAddFirstOverlap) { ...@@ -544,7 +538,7 @@ TEST_P(PaintControllerTest, UpdateAddFirstOverlap) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)); drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50));
...@@ -557,7 +551,7 @@ TEST_P(PaintControllerTest, UpdateAddFirstOverlap) { ...@@ -557,7 +551,7 @@ TEST_P(PaintControllerTest, UpdateAddFirstOverlap) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
first.setDisplayItemsUncached(); first.setDisplayItemsUncached();
...@@ -590,7 +584,7 @@ TEST_P(PaintControllerTest, UpdateAddFirstOverlap) { ...@@ -590,7 +584,7 @@ TEST_P(PaintControllerTest, UpdateAddFirstOverlap) {
FloatRect(150, 150, 100, 100))); // New bounds of |second|. FloatRect(150, 150, 100, 100))); // New bounds of |second|.
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, second, backgroundDrawingType, drawRect(context, second, backgroundDrawingType,
...@@ -626,7 +620,7 @@ TEST_P(PaintControllerTest, UpdateAddLastOverlap) { ...@@ -626,7 +620,7 @@ TEST_P(PaintControllerTest, UpdateAddLastOverlap) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, first, backgroundDrawingType, drawRect(context, first, backgroundDrawingType,
...@@ -641,7 +635,7 @@ TEST_P(PaintControllerTest, UpdateAddLastOverlap) { ...@@ -641,7 +635,7 @@ TEST_P(PaintControllerTest, UpdateAddLastOverlap) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
first.setDisplayItemsUncached(); first.setDisplayItemsUncached();
...@@ -672,7 +666,7 @@ TEST_P(PaintControllerTest, UpdateAddLastOverlap) { ...@@ -672,7 +666,7 @@ TEST_P(PaintControllerTest, UpdateAddLastOverlap) {
50))); // |second| newly appeared in the chunk. 50))); // |second| newly appeared in the chunk.
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
first.setDisplayItemsUncached(); first.setDisplayItemsUncached();
...@@ -708,7 +702,7 @@ TEST_P(PaintControllerTest, UpdateClip) { ...@@ -708,7 +702,7 @@ TEST_P(PaintControllerTest, UpdateClip) {
{ {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(first, clipType); PaintChunk::Id id(first, clipType);
PaintChunkProperties properties = rootPaintChunkProperties(); PaintChunkProperties properties = defaultPaintChunkProperties();
properties.clip = ClipPaintPropertyNode::create( properties.clip = ClipPaintPropertyNode::create(
nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2)); nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2));
getPaintController().updateCurrentPaintChunkProperties(&id, properties); getPaintController().updateCurrentPaintChunkProperties(&id, properties);
...@@ -730,7 +724,7 @@ TEST_P(PaintControllerTest, UpdateClip) { ...@@ -730,7 +724,7 @@ TEST_P(PaintControllerTest, UpdateClip) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
first.setDisplayItemsUncached(); first.setDisplayItemsUncached();
...@@ -759,7 +753,7 @@ TEST_P(PaintControllerTest, UpdateClip) { ...@@ -759,7 +753,7 @@ TEST_P(PaintControllerTest, UpdateClip) {
LayoutRect::infiniteIntRect()))); // This is a new chunk. LayoutRect::infiniteIntRect()))); // This is a new chunk.
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
second.setDisplayItemsUncached(); second.setDisplayItemsUncached();
...@@ -768,7 +762,7 @@ TEST_P(PaintControllerTest, UpdateClip) { ...@@ -768,7 +762,7 @@ TEST_P(PaintControllerTest, UpdateClip) {
{ {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(second, clipType); PaintChunk::Id id(second, clipType);
PaintChunkProperties properties = rootPaintChunkProperties(); PaintChunkProperties properties = defaultPaintChunkProperties();
properties.clip = ClipPaintPropertyNode::create( properties.clip = ClipPaintPropertyNode::create(
nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2)); nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2));
getPaintController().updateCurrentPaintChunkProperties(&id, properties); getPaintController().updateCurrentPaintChunkProperties(&id, properties);
...@@ -804,7 +798,7 @@ TEST_P(PaintControllerTest, CachedDisplayItems) { ...@@ -804,7 +798,7 @@ TEST_P(PaintControllerTest, CachedDisplayItems) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, first, backgroundDrawingType, drawRect(context, first, backgroundDrawingType,
...@@ -833,7 +827,7 @@ TEST_P(PaintControllerTest, CachedDisplayItems) { ...@@ -833,7 +827,7 @@ TEST_P(PaintControllerTest, CachedDisplayItems) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, first, backgroundDrawingType, drawRect(context, first, backgroundDrawingType,
FloatRect(100, 100, 150, 150)); FloatRect(100, 100, 150, 150));
...@@ -871,7 +865,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithChildren) { ...@@ -871,7 +865,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithChildren) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, container1, backgroundDrawingType, drawRect(context, container1, backgroundDrawingType,
...@@ -904,7 +898,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithChildren) { ...@@ -904,7 +898,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithChildren) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
// Simulate the situation when |container1| gets a z-index that is greater // Simulate the situation when |container1| gets a z-index that is greater
...@@ -959,7 +953,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithChildrenAndInvalidation) { ...@@ -959,7 +953,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithChildrenAndInvalidation) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, container1, backgroundDrawingType, drawRect(context, container1, backgroundDrawingType,
...@@ -992,7 +986,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithChildrenAndInvalidation) { ...@@ -992,7 +986,7 @@ TEST_P(PaintControllerTest, UpdateSwapOrderWithChildrenAndInvalidation) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
// Simulate the situation when |container1| gets a z-index that is greater // Simulate the situation when |container1| gets a z-index that is greater
...@@ -1049,15 +1043,14 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { ...@@ -1049,15 +1043,14 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) {
FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
PaintChunkProperties container1Properties = rootPaintChunkProperties(); PaintChunkProperties container1Properties = defaultPaintChunkProperties();
PaintChunkProperties container2Properties = rootPaintChunkProperties(); PaintChunkProperties container2Properties = defaultPaintChunkProperties();
{ {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(container1, backgroundDrawingType); PaintChunk::Id id(container1, backgroundDrawingType);
container1Properties.effect = EffectPaintPropertyNode::create( container1Properties.effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5);
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&id, container1Properties); &id, container1Properties);
} }
...@@ -1074,9 +1067,8 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { ...@@ -1074,9 +1067,8 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) {
{ {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(container2, backgroundDrawingType); PaintChunk::Id id(container2, backgroundDrawingType);
container2Properties.effect = EffectPaintPropertyNode::create( container2Properties.effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5);
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&id, container2Properties); &id, container2Properties);
} }
...@@ -1221,15 +1213,14 @@ TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks) { ...@@ -1221,15 +1213,14 @@ TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks) {
FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
PaintChunkProperties container1Properties = rootPaintChunkProperties(); PaintChunkProperties container1Properties = defaultPaintChunkProperties();
PaintChunkProperties container2Properties = rootPaintChunkProperties(); PaintChunkProperties container2Properties = defaultPaintChunkProperties();
{ {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(container1, backgroundDrawingType); PaintChunk::Id id(container1, backgroundDrawingType);
container1Properties.effect = EffectPaintPropertyNode::create( container1Properties.effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5);
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&id, container1Properties); &id, container1Properties);
} }
...@@ -1241,9 +1232,8 @@ TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks) { ...@@ -1241,9 +1232,8 @@ TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks) {
{ {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(container2, backgroundDrawingType); PaintChunk::Id id(container2, backgroundDrawingType);
container2Properties.effect = EffectPaintPropertyNode::create( container2Properties.effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5);
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&id, container2Properties); &id, container2Properties);
} }
...@@ -1335,7 +1325,7 @@ TEST_P(PaintControllerTest, OutOfOrderNoCrash) { ...@@ -1335,7 +1325,7 @@ TEST_P(PaintControllerTest, OutOfOrderNoCrash) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); drawRect(context, client, type1, FloatRect(100, 100, 100, 100));
drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); drawRect(context, client, type2, FloatRect(100, 100, 50, 200));
...@@ -1346,7 +1336,7 @@ TEST_P(PaintControllerTest, OutOfOrderNoCrash) { ...@@ -1346,7 +1336,7 @@ TEST_P(PaintControllerTest, OutOfOrderNoCrash) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); drawRect(context, client, type2, FloatRect(100, 100, 50, 200));
drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); drawRect(context, client, type3, FloatRect(100, 100, 50, 200));
...@@ -1366,20 +1356,19 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { ...@@ -1366,20 +1356,19 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
PaintChunkProperties container1BackgroundProperties = PaintChunkProperties container1BackgroundProperties =
rootPaintChunkProperties(); defaultPaintChunkProperties();
PaintChunkProperties content1Properties = rootPaintChunkProperties(); PaintChunkProperties content1Properties = defaultPaintChunkProperties();
PaintChunkProperties container1ForegroundProperties = PaintChunkProperties container1ForegroundProperties =
rootPaintChunkProperties(); defaultPaintChunkProperties();
PaintChunkProperties container2BackgroundProperties = PaintChunkProperties container2BackgroundProperties =
rootPaintChunkProperties(); defaultPaintChunkProperties();
PaintChunkProperties content2Properties = rootPaintChunkProperties(); PaintChunkProperties content2Properties = defaultPaintChunkProperties();
{ {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(container1, backgroundDrawingType); PaintChunk::Id id(container1, backgroundDrawingType);
container1BackgroundProperties.effect = EffectPaintPropertyNode::create( container1BackgroundProperties.effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5);
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&id, container1BackgroundProperties); &id, container1BackgroundProperties);
} }
...@@ -1389,9 +1378,8 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { ...@@ -1389,9 +1378,8 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) {
{ {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(content1, backgroundDrawingType); PaintChunk::Id id(content1, backgroundDrawingType);
content1Properties.effect = EffectPaintPropertyNode::create( content1Properties.effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.6);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.6);
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&id, content1Properties); &id, content1Properties);
} }
...@@ -1403,9 +1391,8 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { ...@@ -1403,9 +1391,8 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) {
} }
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(container1, foregroundDrawingType); PaintChunk::Id id(container1, foregroundDrawingType);
container1ForegroundProperties.effect = EffectPaintPropertyNode::create( container1ForegroundProperties.effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5);
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&id, container1ForegroundProperties); &id, container1ForegroundProperties);
} }
...@@ -1415,9 +1402,8 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { ...@@ -1415,9 +1402,8 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) {
{ {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(container2, backgroundDrawingType); PaintChunk::Id id(container2, backgroundDrawingType);
container2BackgroundProperties.effect = EffectPaintPropertyNode::create( container2BackgroundProperties.effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.7);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.7);
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&id, container2BackgroundProperties); &id, container2BackgroundProperties);
} }
...@@ -1427,9 +1413,8 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { ...@@ -1427,9 +1413,8 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) {
{ {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
PaintChunk::Id id(content2, backgroundDrawingType); PaintChunk::Id id(content2, backgroundDrawingType);
content2Properties.effect = EffectPaintPropertyNode::create( content2Properties.effect =
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.8);
ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.8);
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&id, content2Properties); &id, content2Properties);
} }
...@@ -1596,7 +1581,7 @@ TEST_P(PaintControllerTest, SkipCache) { ...@@ -1596,7 +1581,7 @@ TEST_P(PaintControllerTest, SkipCache) {
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
FloatRect rect1(100, 100, 50, 50); FloatRect rect1(100, 100, 50, 50);
...@@ -1633,7 +1618,7 @@ TEST_P(PaintControllerTest, SkipCache) { ...@@ -1633,7 +1618,7 @@ TEST_P(PaintControllerTest, SkipCache) {
UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect())));
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
// Draw again with nothing invalidated. // Draw again with nothing invalidated.
...@@ -1675,7 +1660,7 @@ TEST_P(PaintControllerTest, SkipCache) { ...@@ -1675,7 +1660,7 @@ TEST_P(PaintControllerTest, SkipCache) {
FloatRect(100, 100, 100, 100))); // New bounds of |content|. FloatRect(100, 100, 100, 100))); // New bounds of |content|.
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
// Now the multicol becomes 3 columns and repaints. // Now the multicol becomes 3 columns and repaints.
...@@ -1726,7 +1711,7 @@ TEST_P(PaintControllerTest, PartialSkipCache) { ...@@ -1726,7 +1711,7 @@ TEST_P(PaintControllerTest, PartialSkipCache) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
drawRect(context, content, backgroundDrawingType, rect1); drawRect(context, content, backgroundDrawingType, rect1);
getPaintController().beginSkippingCache(); getPaintController().beginSkippingCache();
...@@ -1760,7 +1745,7 @@ TEST_P(PaintControllerTest, PartialSkipCache) { ...@@ -1760,7 +1745,7 @@ TEST_P(PaintControllerTest, PartialSkipCache) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
&m_rootPaintChunkId, rootPaintChunkProperties()); &m_rootPaintChunkId, defaultPaintChunkProperties());
} }
// Draw again with nothing invalidated. // Draw again with nothing invalidated.
drawRect(context, content, backgroundDrawingType, rect1); drawRect(context, content, backgroundDrawingType, rect1);
...@@ -1851,7 +1836,7 @@ TEST_F(PaintControllerTestBase, SmallPaintControllerHasOnePaintChunk) { ...@@ -1851,7 +1836,7 @@ TEST_F(PaintControllerTestBase, SmallPaintControllerHasOnePaintChunk) {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
getPaintController().updateCurrentPaintChunkProperties( getPaintController().updateCurrentPaintChunkProperties(
nullptr, rootPaintChunkProperties()); nullptr, defaultPaintChunkProperties());
} }
GraphicsContext context(getPaintController()); GraphicsContext context(getPaintController());
drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100));
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "platform/graphics/paint/ClipPaintPropertyNode.h"
#include "platform/graphics/paint/EffectPaintPropertyNode.h"
#include "platform/graphics/paint/PaintChunkProperties.h"
#include "platform/graphics/paint/ScrollPaintPropertyNode.h"
#include "platform/graphics/paint/TransformPaintPropertyNode.h"
namespace blink {
namespace testing {
static inline PassRefPtr<EffectPaintPropertyNode> createOpacityOnlyEffect(
PassRefPtr<const EffectPaintPropertyNode> parent,
float opacity) {
RefPtr<TransformPaintPropertyNode> localTransformSpace =
const_cast<TransformPaintPropertyNode*>(parent->localTransformSpace());
RefPtr<ClipPaintPropertyNode> outputClip =
const_cast<ClipPaintPropertyNode*>(parent->outputClip());
return EffectPaintPropertyNode::create(
std::move(parent), std::move(localTransformSpace), std::move(outputClip),
CompositorFilterOperations(), opacity);
}
static inline PaintChunkProperties defaultPaintChunkProperties() {
PaintChunkProperties defaultProperties;
defaultProperties.transform = TransformPaintPropertyNode::root();
defaultProperties.clip = ClipPaintPropertyNode::root();
defaultProperties.effect = EffectPaintPropertyNode::root();
defaultProperties.scroll = ScrollPaintPropertyNode::root();
return defaultProperties;
}
} // namespace testing
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment