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

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

Issue 2124753004: [SPv2] Build simple cc clip trees from Blink clip trees. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clip-tree-refactor
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b995dcb3a70a39a409627e70682cf2e6a9e53d87..dd6fb3d7cbd3be85d005d049e12fb21615e761f7 100644
--- a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
@@ -518,6 +518,157 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining)
contentLayerAt(1)->transform_tree_index());
}
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneClip)
+{
+ RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
+ nullptr, FloatRoundedRect(100, 100, 300, 200));
+
+ TestPaintArtifact artifact;
+ artifact.chunk(nullptr, clip, nullptr)
+ .rectDrawing(FloatRect(220, 80, 300, 200), Color::black);
+ update(artifact.build());
+
+ ASSERT_EQ(1u, contentLayerCount());
+ const cc::Layer* layer = contentLayerAt(0);
+ EXPECT_THAT(layer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black)));
+ EXPECT_EQ(translation(220, 80), layer->screen_space_transform());
+
+ const cc::ClipNode* clipNode = propertyTrees().clip_tree.Node(layer->clip_tree_index());
+ EXPECT_TRUE(clipNode->data.applies_local_clip);
+ EXPECT_TRUE(clipNode->data.layers_are_clipped);
+ EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clipNode->data.clip);
+}
+
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips)
+{
+ RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
+ nullptr, FloatRoundedRect(100, 100, 700, 700));
+ RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(
+ nullptr, FloatRoundedRect(200, 200, 700, 100), clip1);
+
+ TestPaintArtifact artifact;
+ artifact.chunk(nullptr, clip1, nullptr)
+ .rectDrawing(FloatRect(300, 350, 100, 100), Color::white);
+ artifact.chunk(nullptr, clip2, nullptr)
+ .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray);
+ artifact.chunk(nullptr, clip1, nullptr)
+ .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray);
+ artifact.chunk(nullptr, clip2, nullptr)
+ .rectDrawing(FloatRect(300, 350, 100, 100), Color::black);
+ update(artifact.build());
+
+ ASSERT_EQ(4u, contentLayerCount());
+
+ const cc::Layer* whiteLayer = contentLayerAt(0);
+ EXPECT_THAT(whiteLayer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white)));
+ EXPECT_EQ(translation(300, 350), whiteLayer->screen_space_transform());
+
+ const cc::Layer* lightGrayLayer = contentLayerAt(1);
+ EXPECT_THAT(lightGrayLayer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::lightGray)));
+ EXPECT_EQ(translation(300, 350), lightGrayLayer->screen_space_transform());
+
+ const cc::Layer* darkGrayLayer = contentLayerAt(2);
+ EXPECT_THAT(darkGrayLayer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::darkGray)));
+ EXPECT_EQ(translation(300, 350), darkGrayLayer->screen_space_transform());
+
+ const cc::Layer* blackLayer = contentLayerAt(3);
+ EXPECT_THAT(blackLayer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::black)));
+ EXPECT_EQ(translation(300, 350), blackLayer->screen_space_transform());
+
+ EXPECT_EQ(whiteLayer->clip_tree_index(), darkGrayLayer->clip_tree_index());
+ const cc::ClipNode* outerClip = propertyTrees().clip_tree.Node(whiteLayer->clip_tree_index());
+ EXPECT_TRUE(outerClip->data.applies_local_clip);
+ EXPECT_TRUE(outerClip->data.layers_are_clipped);
+ EXPECT_EQ(gfx::RectF(100, 100, 700, 700), outerClip->data.clip);
+
+ EXPECT_EQ(lightGrayLayer->clip_tree_index(), blackLayer->clip_tree_index());
+ const cc::ClipNode* innerClip = propertyTrees().clip_tree.Node(blackLayer->clip_tree_index());
+ EXPECT_TRUE(innerClip->data.applies_local_clip);
+ EXPECT_TRUE(innerClip->data.layers_are_clipped);
+ EXPECT_EQ(gfx::RectF(200, 200, 700, 100), innerClip->data.clip);
+ EXPECT_EQ(outerClip->id, innerClip->parent_id);
+}
+
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips)
+{
+ Vector<RefPtr<ClipPaintPropertyNode>> clips;
+ for (unsigned i = 1; i <= 10; i++) {
+ clips.append(ClipPaintPropertyNode::create(
+ nullptr, FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i),
+ clips.isEmpty() ? nullptr : clips.last()));
+ }
+
+ TestPaintArtifact artifact;
+ artifact.chunk(nullptr, clips.last(), nullptr)
+ .rectDrawing(FloatRect(0, 0, 200, 200), Color::white);
+ update(artifact.build());
+
+ // Check the drawing layer.
+ ASSERT_EQ(1u, contentLayerCount());
+ const cc::Layer* drawingLayer = contentLayerAt(0);
+ EXPECT_THAT(drawingLayer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white)));
+ EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform());
+
+ // Check the clip nodes.
+ const cc::ClipNode* clipNode = propertyTrees().clip_tree.Node(drawingLayer->clip_tree_index());
+ for (auto it = clips.rbegin(); it != clips.rend(); ++it) {
+ const ClipPaintPropertyNode* paintClipNode = it->get();
+ EXPECT_TRUE(clipNode->data.applies_local_clip);
+ EXPECT_TRUE(clipNode->data.layers_are_clipped);
+ EXPECT_EQ(paintClipNode->clipRect().rect(), clipNode->data.clip);
+ clipNode = propertyTrees().clip_tree.Node(clipNode->parent_id);
+ }
+}
+
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips)
+{
+ RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create(
+ nullptr, FloatRoundedRect(0, 0, 800, 600));
+ RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
+ nullptr, FloatRoundedRect(0, 0, 400, 600), commonClip);
+ RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(
+ nullptr, FloatRoundedRect(400, 0, 400, 600), commonClip);
+
+ TestPaintArtifact artifact;
+ artifact.chunk(nullptr, clip1, nullptr)
+ .rectDrawing(FloatRect(0, 0, 640, 480), Color::white);
+ artifact.chunk(nullptr, clip2, nullptr)
+ .rectDrawing(FloatRect(0, 0, 640, 480), Color::black);
+ update(artifact.build());
+
+ ASSERT_EQ(2u, contentLayerCount());
+
+ const cc::Layer* whiteLayer = contentLayerAt(0);
+ EXPECT_THAT(whiteLayer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white)));
+ EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform());
+ const cc::ClipNode* whiteClip = propertyTrees().clip_tree.Node(whiteLayer->clip_tree_index());
+ EXPECT_TRUE(whiteClip->data.applies_local_clip);
+ EXPECT_TRUE(whiteClip->data.layers_are_clipped);
+ ASSERT_EQ(gfx::RectF(0, 0, 400, 600), whiteClip->data.clip);
+
+ const cc::Layer* blackLayer = contentLayerAt(1);
+ EXPECT_THAT(blackLayer->GetPicture(),
+ Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::black)));
+ EXPECT_EQ(gfx::Transform(), blackLayer->screen_space_transform());
+ const cc::ClipNode* blackClip = propertyTrees().clip_tree.Node(blackLayer->clip_tree_index());
+ EXPECT_TRUE(blackClip->data.applies_local_clip);
+ EXPECT_TRUE(blackClip->data.layers_are_clipped);
+ ASSERT_EQ(gfx::RectF(400, 0, 400, 600), blackClip->data.clip);
+
+ EXPECT_EQ(whiteClip->parent_id, blackClip->parent_id);
+ const cc::ClipNode* commonClipNode = propertyTrees().clip_tree.Node(whiteClip->parent_id);
+ EXPECT_TRUE(commonClipNode->data.applies_local_clip);
+ EXPECT_TRUE(commonClipNode->data.layers_are_clipped);
+ ASSERT_EQ(gfx::RectF(0, 0, 800, 600), commonClipNode->data.clip);
+}
+
TEST_F(PaintArtifactCompositorTestWithPropertyTrees, ForeignLayerPassesThrough)
{
scoped_refptr<cc::Layer> layer = cc::Layer::Create();
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698