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

Unified Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp

Issue 2101683002: [SPv2] Begin to convert the Blink transform tree to cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dummyTransformParent -> rootLayer Created 4 years, 6 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/compositing/PaintArtifactCompositorTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
index ef9edb44bdf3f28918831cea691c72f01de0effb..457411c1749dff58aee7c3132538a900ec05b1a6 100644
--- a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
@@ -40,6 +40,7 @@ protected:
// Delay constructing the compositor until after the feature is set.
m_paintArtifactCompositor = wrapUnique(new PaintArtifactCompositor);
+ m_paintArtifactCompositor->enableExtraDataForTesting();
}
void TearDown() override
@@ -51,6 +52,16 @@ protected:
cc::Layer* rootLayer() { return m_paintArtifactCompositor->rootLayer(); }
void update(const PaintArtifact& artifact) { m_paintArtifactCompositor->update(artifact); }
+ size_t contentLayerCount()
+ {
+ return m_paintArtifactCompositor->getExtraDataForTesting()->contentLayers.size();
+ }
+
+ cc::Layer* contentLayerAt(unsigned index)
+ {
+ return m_paintArtifactCompositor->getExtraDataForTesting()->contentLayers[index].get();
+ }
+
private:
RuntimeEnabledFeatures::Backup m_featuresBackup;
std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor;
@@ -422,13 +433,91 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset)
.rectDrawing(FloatRect(50, -50, 100, 100), Color::white);
update(artifact.build());
- ASSERT_EQ(1u, rootLayer()->children().size());
- const cc::Layer* child = rootLayer()->child_at(0);
+ ASSERT_EQ(1u, contentLayerCount());
+ const cc::Layer* child = contentLayerAt(0);
EXPECT_THAT(child->GetPicture(),
Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white)));
EXPECT_EQ(translation(50, -50), child->screen_space_transform());
EXPECT_EQ(gfx::Size(100, 100), child->bounds());
}
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform)
+{
+ // A 90 degree clockwise rotation about (100, 100).
+ RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(
+ TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0));
+
+ TestPaintArtifact artifact;
+ artifact.chunk(transform, nullptr, nullptr)
+ .rectDrawing(FloatRect(0, 0, 100, 100), Color::white);
+ artifact.chunk(nullptr, nullptr, nullptr)
+ .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray);
+ artifact.chunk(transform, nullptr, nullptr)
+ .rectDrawing(FloatRect(100, 100, 200, 100), Color::black);
+ update(artifact.build());
+
+ ASSERT_EQ(3u, contentLayerCount());
+ {
+ const cc::Layer* layer = contentLayerAt(0);
+ EXPECT_THAT(layer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white)));
+ gfx::RectF mappedRect(0, 0, 100, 100);
+ layer->screen_space_transform().TransformRect(&mappedRect);
+ EXPECT_EQ(gfx::RectF(100, 0, 100, 100), mappedRect);
+ }
+ {
+ const cc::Layer* layer = contentLayerAt(1);
+ EXPECT_THAT(layer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::gray)));
+ EXPECT_EQ(gfx::Transform(), layer->screen_space_transform());
+ }
+ {
+ const cc::Layer* layer = contentLayerAt(2);
+ EXPECT_THAT(layer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 200, 100), Color::black)));
+ gfx::RectF mappedRect(0, 0, 200, 100);
+ layer->screen_space_transform().TransformRect(&mappedRect);
+ EXPECT_EQ(gfx::RectF(0, 100, 100, 200), mappedRect);
+ }
+}
+
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining)
+{
+ // A translation by (5, 5) within a 2x scale about (10, 10).
+ RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::create(
+ TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0));
+ RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::create(
+ TransformationMatrix().translate(5, 5), FloatPoint3D(), transform1);
+
+ TestPaintArtifact artifact;
+ artifact.chunk(transform1, nullptr, nullptr)
+ .rectDrawing(FloatRect(0, 0, 300, 200), Color::white);
+ artifact.chunk(transform2, nullptr, nullptr)
+ .rectDrawing(FloatRect(0, 0, 300, 200), Color::black);
+ update(artifact.build());
+
+ ASSERT_EQ(2u, contentLayerCount());
+ {
+ const cc::Layer* layer = contentLayerAt(0);
+ EXPECT_THAT(layer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white)));
+ gfx::RectF mappedRect(0, 0, 300, 200);
+ layer->screen_space_transform().TransformRect(&mappedRect);
+ EXPECT_EQ(gfx::RectF(-10, -10, 600, 400), mappedRect);
+ }
+ {
+ const cc::Layer* layer = contentLayerAt(1);
+ EXPECT_THAT(layer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black)));
+ gfx::RectF mappedRect(0, 0, 300, 200);
+ layer->screen_space_transform().TransformRect(&mappedRect);
+ EXPECT_EQ(gfx::RectF(0, 0, 600, 400), mappedRect);
+ }
+ EXPECT_NE(
+ contentLayerAt(0)->transform_tree_index(),
+ contentLayerAt(1)->transform_tree_index());
+}
+
+
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698