| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" | 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
| 6 | 6 |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_output_surface.h" |
| 11 #include "cc/test/geometry_test_utils.h" | 11 #include "cc/test/geometry_test_utils.h" |
| 12 #include "cc/trees/clip_node.h" | 12 #include "cc/trees/clip_node.h" |
| 13 #include "cc/trees/effect_node.h" | 13 #include "cc/trees/effect_node.h" |
| 14 #include "cc/trees/layer_tree_host.h" | 14 #include "cc/trees/layer_tree_host.h" |
| 15 #include "cc/trees/layer_tree_settings.h" | 15 #include "cc/trees/layer_tree_settings.h" |
| 16 #include "cc/trees/scroll_node.h" |
| 16 #include "cc/trees/transform_node.h" | 17 #include "cc/trees/transform_node.h" |
| 17 #include "platform/RuntimeEnabledFeatures.h" | 18 #include "platform/RuntimeEnabledFeatures.h" |
| 18 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 19 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 19 #include "platform/graphics/paint/PaintArtifact.h" | 20 #include "platform/graphics/paint/PaintArtifact.h" |
| 21 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
| 20 #include "platform/testing/PictureMatchers.h" | 22 #include "platform/testing/PictureMatchers.h" |
| 21 #include "platform/testing/TestPaintArtifact.h" | 23 #include "platform/testing/TestPaintArtifact.h" |
| 22 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 24 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "wtf/PtrUtil.h" | 27 #include "wtf/PtrUtil.h" |
| 26 #include <memory> | 28 #include <memory> |
| 27 | 29 |
| 28 namespace blink { | 30 namespace blink { |
| 29 namespace { | 31 namespace { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); | 102 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); |
| 101 } | 103 } |
| 102 | 104 |
| 103 TEST_F(PaintArtifactCompositorTest, OneTransform) | 105 TEST_F(PaintArtifactCompositorTest, OneTransform) |
| 104 { | 106 { |
| 105 // A 90 degree clockwise rotation about (100, 100). | 107 // A 90 degree clockwise rotation about (100, 100). |
| 106 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( | 108 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( |
| 107 nullptr, TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0)); | 109 nullptr, TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0)); |
| 108 | 110 |
| 109 TestPaintArtifact artifact; | 111 TestPaintArtifact artifact; |
| 110 artifact.chunk(transform, nullptr, dummyRootEffect()) | 112 artifact.chunk(transform, nullptr, dummyRootEffect(), nullptr) |
| 111 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 113 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 112 artifact.chunk(nullptr, nullptr, dummyRootEffect()) | 114 artifact.chunk(nullptr, nullptr, dummyRootEffect(), nullptr) |
| 113 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); | 115 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); |
| 114 artifact.chunk(transform, nullptr, dummyRootEffect()) | 116 artifact.chunk(transform, nullptr, dummyRootEffect(), nullptr) |
| 115 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); | 117 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); |
| 116 update(artifact.build()); | 118 update(artifact.build()); |
| 117 | 119 |
| 118 ASSERT_EQ(3u, rootLayer()->children().size()); | 120 ASSERT_EQ(3u, rootLayer()->children().size()); |
| 119 { | 121 { |
| 120 const cc::Layer* layer = rootLayer()->child_at(0); | 122 const cc::Layer* layer = rootLayer()->child_at(0); |
| 121 EXPECT_THAT(layer->GetPicture(), | 123 EXPECT_THAT(layer->GetPicture(), |
| 122 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 124 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
| 123 gfx::RectF mappedRect(0, 0, 100, 100); | 125 gfx::RectF mappedRect(0, 0, 100, 100); |
| 124 layer->transform().TransformRect(&mappedRect); | 126 layer->transform().TransformRect(&mappedRect); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 142 | 144 |
| 143 TEST_F(PaintArtifactCompositorTest, TransformCombining) | 145 TEST_F(PaintArtifactCompositorTest, TransformCombining) |
| 144 { | 146 { |
| 145 // A translation by (5, 5) within a 2x scale about (10, 10). | 147 // A translation by (5, 5) within a 2x scale about (10, 10). |
| 146 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create( | 148 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create( |
| 147 nullptr, TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); | 149 nullptr, TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); |
| 148 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( | 150 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( |
| 149 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D()); | 151 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D()); |
| 150 | 152 |
| 151 TestPaintArtifact artifact; | 153 TestPaintArtifact artifact; |
| 152 artifact.chunk(transform1, nullptr, dummyRootEffect()) | 154 artifact.chunk(transform1, nullptr, dummyRootEffect(), nullptr) |
| 153 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 155 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
| 154 artifact.chunk(transform2, nullptr, dummyRootEffect()) | 156 artifact.chunk(transform2, nullptr, dummyRootEffect(), nullptr) |
| 155 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); | 157 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); |
| 156 update(artifact.build()); | 158 update(artifact.build()); |
| 157 | 159 |
| 158 ASSERT_EQ(2u, rootLayer()->children().size()); | 160 ASSERT_EQ(2u, rootLayer()->children().size()); |
| 159 { | 161 { |
| 160 const cc::Layer* layer = rootLayer()->child_at(0); | 162 const cc::Layer* layer = rootLayer()->child_at(0); |
| 161 EXPECT_THAT(layer->GetPicture(), | 163 EXPECT_THAT(layer->GetPicture(), |
| 162 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 164 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
| 163 gfx::RectF mappedRect(0, 0, 300, 200); | 165 gfx::RectF mappedRect(0, 0, 300, 200); |
| 164 layer->transform().TransformRect(&mappedRect); | 166 layer->transform().TransformRect(&mappedRect); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 175 } | 177 } |
| 176 | 178 |
| 177 TEST_F(PaintArtifactCompositorTest, LayerOriginCancellation) | 179 TEST_F(PaintArtifactCompositorTest, LayerOriginCancellation) |
| 178 { | 180 { |
| 179 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( | 181 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( |
| 180 nullptr, nullptr, FloatRoundedRect(100, 100, 100, 100)); | 182 nullptr, nullptr, FloatRoundedRect(100, 100, 100, 100)); |
| 181 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( | 183 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( |
| 182 nullptr, TransformationMatrix().scale(2), FloatPoint3D()); | 184 nullptr, TransformationMatrix().scale(2), FloatPoint3D()); |
| 183 | 185 |
| 184 TestPaintArtifact artifact; | 186 TestPaintArtifact artifact; |
| 185 artifact.chunk(transform, clip, nullptr) | 187 artifact.chunk(transform, clip, nullptr, nullptr) |
| 186 .rectDrawing(FloatRect(12, 34, 56, 78), Color::white); | 188 .rectDrawing(FloatRect(12, 34, 56, 78), Color::white); |
| 187 update(artifact.build()); | 189 update(artifact.build()); |
| 188 | 190 |
| 189 ASSERT_EQ(1u, rootLayer()->children().size()); | 191 ASSERT_EQ(1u, rootLayer()->children().size()); |
| 190 cc::Layer* clipLayer = rootLayer()->child_at(0); | 192 cc::Layer* clipLayer = rootLayer()->child_at(0); |
| 191 EXPECT_EQ(gfx::Size(100, 100), clipLayer->bounds()); | 193 EXPECT_EQ(gfx::Size(100, 100), clipLayer->bounds()); |
| 192 EXPECT_EQ(translation(100, 100), clipLayer->transform()); | 194 EXPECT_EQ(translation(100, 100), clipLayer->transform()); |
| 193 EXPECT_TRUE(clipLayer->masks_to_bounds()); | 195 EXPECT_TRUE(clipLayer->masks_to_bounds()); |
| 194 | 196 |
| 195 ASSERT_EQ(1u, clipLayer->children().size()); | 197 ASSERT_EQ(1u, clipLayer->children().size()); |
| 196 cc::Layer* layer = clipLayer->child_at(0); | 198 cc::Layer* layer = clipLayer->child_at(0); |
| 197 EXPECT_EQ(gfx::Size(56, 78), layer->bounds()); | 199 EXPECT_EQ(gfx::Size(56, 78), layer->bounds()); |
| 198 gfx::Transform expectedTransform; | 200 gfx::Transform expectedTransform; |
| 199 expectedTransform.Translate(-100, -100); | 201 expectedTransform.Translate(-100, -100); |
| 200 expectedTransform.Scale(2, 2); | 202 expectedTransform.Scale(2, 2); |
| 201 expectedTransform.Translate(12, 34); | 203 expectedTransform.Translate(12, 34); |
| 202 EXPECT_EQ(expectedTransform, layer->transform()); | 204 EXPECT_EQ(expectedTransform, layer->transform()); |
| 203 } | 205 } |
| 204 | 206 |
| 205 TEST_F(PaintArtifactCompositorTest, OneClip) | 207 TEST_F(PaintArtifactCompositorTest, OneClip) |
| 206 { | 208 { |
| 207 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( | 209 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( |
| 208 nullptr, nullptr, FloatRoundedRect(100, 100, 300, 200)); | 210 nullptr, nullptr, FloatRoundedRect(100, 100, 300, 200)); |
| 209 | 211 |
| 210 TestPaintArtifact artifact; | 212 TestPaintArtifact artifact; |
| 211 artifact.chunk(nullptr, clip, nullptr) | 213 artifact.chunk(nullptr, clip, nullptr, nullptr) |
| 212 .rectDrawing(FloatRect(220, 80, 300, 200), Color::black); | 214 .rectDrawing(FloatRect(220, 80, 300, 200), Color::black); |
| 213 update(artifact.build()); | 215 update(artifact.build()); |
| 214 | 216 |
| 215 ASSERT_EQ(1u, rootLayer()->children().size()); | 217 ASSERT_EQ(1u, rootLayer()->children().size()); |
| 216 cc::Layer* clipLayer = rootLayer()->child_at(0); | 218 cc::Layer* clipLayer = rootLayer()->child_at(0); |
| 217 EXPECT_TRUE(clipLayer->masks_to_bounds()); | 219 EXPECT_TRUE(clipLayer->masks_to_bounds()); |
| 218 EXPECT_EQ(gfx::Size(300, 200), clipLayer->bounds()); | 220 EXPECT_EQ(gfx::Size(300, 200), clipLayer->bounds()); |
| 219 EXPECT_EQ(translation(100, 100), clipLayer->transform()); | 221 EXPECT_EQ(translation(100, 100), clipLayer->transform()); |
| 220 | 222 |
| 221 ASSERT_EQ(1u, clipLayer->children().size()); | 223 ASSERT_EQ(1u, clipLayer->children().size()); |
| 222 const cc::Layer* layer = clipLayer->child_at(0); | 224 const cc::Layer* layer = clipLayer->child_at(0); |
| 223 EXPECT_THAT(layer->GetPicture(), | 225 EXPECT_THAT(layer->GetPicture(), |
| 224 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); | 226 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); |
| 225 EXPECT_EQ(translation(120, -20), layer->transform()); | 227 EXPECT_EQ(translation(120, -20), layer->transform()); |
| 226 } | 228 } |
| 227 | 229 |
| 228 TEST_F(PaintArtifactCompositorTest, NestedClips) | 230 TEST_F(PaintArtifactCompositorTest, NestedClips) |
| 229 { | 231 { |
| 230 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 232 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
| 231 nullptr, nullptr, FloatRoundedRect(100, 100, 700, 700)); | 233 nullptr, nullptr, FloatRoundedRect(100, 100, 700, 700)); |
| 232 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 234 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
| 233 clip1, nullptr, FloatRoundedRect(200, 200, 700, 100)); | 235 clip1, nullptr, FloatRoundedRect(200, 200, 700, 100)); |
| 234 | 236 |
| 235 TestPaintArtifact artifact; | 237 TestPaintArtifact artifact; |
| 236 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 238 artifact.chunk(nullptr, clip1, dummyRootEffect(), nullptr) |
| 237 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); | 239 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); |
| 238 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 240 artifact.chunk(nullptr, clip2, dummyRootEffect(), nullptr) |
| 239 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); | 241 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); |
| 240 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 242 artifact.chunk(nullptr, clip1, dummyRootEffect(), nullptr) |
| 241 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); | 243 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); |
| 242 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 244 artifact.chunk(nullptr, clip2, dummyRootEffect(), nullptr) |
| 243 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); | 245 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); |
| 244 update(artifact.build()); | 246 update(artifact.build()); |
| 245 | 247 |
| 246 ASSERT_EQ(1u, rootLayer()->children().size()); | 248 ASSERT_EQ(1u, rootLayer()->children().size()); |
| 247 cc::Layer* clipLayer1 = rootLayer()->child_at(0); | 249 cc::Layer* clipLayer1 = rootLayer()->child_at(0); |
| 248 EXPECT_TRUE(clipLayer1->masks_to_bounds()); | 250 EXPECT_TRUE(clipLayer1->masks_to_bounds()); |
| 249 EXPECT_EQ(gfx::Size(700, 700), clipLayer1->bounds()); | 251 EXPECT_EQ(gfx::Size(700, 700), clipLayer1->bounds()); |
| 250 EXPECT_EQ(translation(100, 100), clipLayer1->transform()); | 252 EXPECT_EQ(translation(100, 100), clipLayer1->transform()); |
| 251 | 253 |
| 252 ASSERT_EQ(4u, clipLayer1->children().size()); | 254 ASSERT_EQ(4u, clipLayer1->children().size()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 TEST_F(PaintArtifactCompositorTest, DeeplyNestedClips) | 291 TEST_F(PaintArtifactCompositorTest, DeeplyNestedClips) |
| 290 { | 292 { |
| 291 Vector<RefPtr<ClipPaintPropertyNode>> clips; | 293 Vector<RefPtr<ClipPaintPropertyNode>> clips; |
| 292 for (unsigned i = 1; i <= 10; i++) { | 294 for (unsigned i = 1; i <= 10; i++) { |
| 293 clips.append(ClipPaintPropertyNode::create( | 295 clips.append(ClipPaintPropertyNode::create( |
| 294 clips.isEmpty() ? nullptr : clips.last(), | 296 clips.isEmpty() ? nullptr : clips.last(), |
| 295 nullptr, FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i))); | 297 nullptr, FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i))); |
| 296 } | 298 } |
| 297 | 299 |
| 298 TestPaintArtifact artifact; | 300 TestPaintArtifact artifact; |
| 299 artifact.chunk(nullptr, clips.last(), nullptr) | 301 artifact.chunk(nullptr, clips.last(), nullptr, nullptr) |
| 300 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white); | 302 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white); |
| 301 update(artifact.build()); | 303 update(artifact.build()); |
| 302 | 304 |
| 303 // Check the clip layers. | 305 // Check the clip layers. |
| 304 cc::Layer* layer = rootLayer(); | 306 cc::Layer* layer = rootLayer(); |
| 305 for (const auto& clipNode : clips) { | 307 for (const auto& clipNode : clips) { |
| 306 ASSERT_EQ(1u, layer->children().size()); | 308 ASSERT_EQ(1u, layer->children().size()); |
| 307 layer = layer->child_at(0); | 309 layer = layer->child_at(0); |
| 308 EXPECT_EQ(clipNode->clipRect().rect().width(), layer->bounds().width()); | 310 EXPECT_EQ(clipNode->clipRect().rect().width(), layer->bounds().width()); |
| 309 EXPECT_EQ(clipNode->clipRect().rect().height(), layer->bounds().height()
); | 311 EXPECT_EQ(clipNode->clipRect().rect().height(), layer->bounds().height()
); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 321 TEST_F(PaintArtifactCompositorTest, SiblingClips) | 323 TEST_F(PaintArtifactCompositorTest, SiblingClips) |
| 322 { | 324 { |
| 323 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( | 325 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( |
| 324 nullptr, nullptr, FloatRoundedRect(0, 0, 800, 600)); | 326 nullptr, nullptr, FloatRoundedRect(0, 0, 800, 600)); |
| 325 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 327 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
| 326 commonClip, nullptr, FloatRoundedRect(0, 0, 400, 600)); | 328 commonClip, nullptr, FloatRoundedRect(0, 0, 400, 600)); |
| 327 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 329 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
| 328 commonClip, nullptr, FloatRoundedRect(400, 0, 400, 600)); | 330 commonClip, nullptr, FloatRoundedRect(400, 0, 400, 600)); |
| 329 | 331 |
| 330 TestPaintArtifact artifact; | 332 TestPaintArtifact artifact; |
| 331 artifact.chunk(nullptr, clip1, nullptr) | 333 artifact.chunk(nullptr, clip1, nullptr, nullptr) |
| 332 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); | 334 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); |
| 333 artifact.chunk(nullptr, clip2, nullptr) | 335 artifact.chunk(nullptr, clip2, nullptr, nullptr) |
| 334 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); | 336 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); |
| 335 update(artifact.build()); | 337 update(artifact.build()); |
| 336 | 338 |
| 337 ASSERT_EQ(1u, rootLayer()->children().size()); | 339 ASSERT_EQ(1u, rootLayer()->children().size()); |
| 338 cc::Layer* commonClipLayer = rootLayer()->child_at(0); | 340 cc::Layer* commonClipLayer = rootLayer()->child_at(0); |
| 339 EXPECT_TRUE(commonClipLayer->masks_to_bounds()); | 341 EXPECT_TRUE(commonClipLayer->masks_to_bounds()); |
| 340 EXPECT_EQ(gfx::Size(800, 600), commonClipLayer->bounds()); | 342 EXPECT_EQ(gfx::Size(800, 600), commonClipLayer->bounds()); |
| 341 EXPECT_EQ(gfx::Transform(), commonClipLayer->transform()); | 343 EXPECT_EQ(gfx::Transform(), commonClipLayer->transform()); |
| 342 ASSERT_EQ(2u, commonClipLayer->children().size()); | 344 ASSERT_EQ(2u, commonClipLayer->children().size()); |
| 343 { | 345 { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); | 459 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); |
| 458 } | 460 } |
| 459 | 461 |
| 460 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) | 462 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) |
| 461 { | 463 { |
| 462 // A 90 degree clockwise rotation about (100, 100). | 464 // A 90 degree clockwise rotation about (100, 100). |
| 463 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( | 465 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c
reate( |
| 464 nullptr, TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0)); | 466 nullptr, TransformationMatrix().rotate(90), FloatPoint3D(100, 100, 0)); |
| 465 | 467 |
| 466 TestPaintArtifact artifact; | 468 TestPaintArtifact artifact; |
| 467 artifact.chunk(transform, nullptr, dummyRootEffect()) | 469 artifact.chunk(transform, nullptr, dummyRootEffect(), nullptr) |
| 468 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 470 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 469 artifact.chunk(nullptr, nullptr, dummyRootEffect()) | 471 artifact.chunk(nullptr, nullptr, dummyRootEffect(), nullptr) |
| 470 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); | 472 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); |
| 471 artifact.chunk(transform, nullptr, dummyRootEffect()) | 473 artifact.chunk(transform, nullptr, dummyRootEffect(), nullptr) |
| 472 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); | 474 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); |
| 473 update(artifact.build()); | 475 update(artifact.build()); |
| 474 | 476 |
| 475 ASSERT_EQ(3u, contentLayerCount()); | 477 ASSERT_EQ(3u, contentLayerCount()); |
| 476 { | 478 { |
| 477 const cc::Layer* layer = contentLayerAt(0); | 479 const cc::Layer* layer = contentLayerAt(0); |
| 478 EXPECT_THAT(layer->GetPicture(), | 480 EXPECT_THAT(layer->GetPicture(), |
| 479 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 481 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
| 480 gfx::RectF mappedRect(0, 0, 100, 100); | 482 gfx::RectF mappedRect(0, 0, 100, 100); |
| 481 layer->screen_space_transform().TransformRect(&mappedRect); | 483 layer->screen_space_transform().TransformRect(&mappedRect); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 499 | 501 |
| 500 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) | 502 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) |
| 501 { | 503 { |
| 502 // A translation by (5, 5) within a 2x scale about (10, 10). | 504 // A translation by (5, 5) within a 2x scale about (10, 10). |
| 503 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create( | 505 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode::
create( |
| 504 nullptr, TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); | 506 nullptr, TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); |
| 505 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( | 507 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( |
| 506 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D()); | 508 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D()); |
| 507 | 509 |
| 508 TestPaintArtifact artifact; | 510 TestPaintArtifact artifact; |
| 509 artifact.chunk(transform1, nullptr, dummyRootEffect()) | 511 artifact.chunk(transform1, nullptr, dummyRootEffect(), nullptr) |
| 510 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 512 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
| 511 artifact.chunk(transform2, nullptr, dummyRootEffect()) | 513 artifact.chunk(transform2, nullptr, dummyRootEffect(), nullptr) |
| 512 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); | 514 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); |
| 513 update(artifact.build()); | 515 update(artifact.build()); |
| 514 | 516 |
| 515 ASSERT_EQ(2u, contentLayerCount()); | 517 ASSERT_EQ(2u, contentLayerCount()); |
| 516 { | 518 { |
| 517 const cc::Layer* layer = contentLayerAt(0); | 519 const cc::Layer* layer = contentLayerAt(0); |
| 518 EXPECT_THAT(layer->GetPicture(), | 520 EXPECT_THAT(layer->GetPicture(), |
| 519 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 521 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
| 520 gfx::RectF mappedRect(0, 0, 300, 200); | 522 gfx::RectF mappedRect(0, 0, 300, 200); |
| 521 layer->screen_space_transform().TransformRect(&mappedRect); | 523 layer->screen_space_transform().TransformRect(&mappedRect); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 545 // is flattened, while cc's notion applies in the parent's coordinate sp
ace. | 547 // is flattened, while cc's notion applies in the parent's coordinate sp
ace. |
| 546 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNo
de::create( | 548 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNo
de::create( |
| 547 nullptr, TransformationMatrix(), FloatPoint3D()); | 549 nullptr, TransformationMatrix(), FloatPoint3D()); |
| 548 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNo
de::create( | 550 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNo
de::create( |
| 549 transform1, TransformationMatrix().rotate3d(0, 45, 0), FloatPoint3D(
)); | 551 transform1, TransformationMatrix().rotate3d(0, 45, 0), FloatPoint3D(
)); |
| 550 RefPtr<TransformPaintPropertyNode> transform3 = TransformPaintPropertyNo
de::create( | 552 RefPtr<TransformPaintPropertyNode> transform3 = TransformPaintPropertyNo
de::create( |
| 551 transform2, TransformationMatrix().rotate3d(0, 45, 0), FloatPoint3D(
), | 553 transform2, TransformationMatrix().rotate3d(0, 45, 0), FloatPoint3D(
), |
| 552 transformIsFlattened); | 554 transformIsFlattened); |
| 553 | 555 |
| 554 TestPaintArtifact artifact; | 556 TestPaintArtifact artifact; |
| 555 artifact.chunk(transform3, nullptr, nullptr) | 557 artifact.chunk(transform3, nullptr, nullptr, nullptr) |
| 556 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 558 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
| 557 update(artifact.build()); | 559 update(artifact.build()); |
| 558 | 560 |
| 559 ASSERT_EQ(1u, contentLayerCount()); | 561 ASSERT_EQ(1u, contentLayerCount()); |
| 560 const cc::Layer* layer = contentLayerAt(0); | 562 const cc::Layer* layer = contentLayerAt(0); |
| 561 EXPECT_THAT(layer->GetPicture(), | 563 EXPECT_THAT(layer->GetPicture(), |
| 562 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 564 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
| 563 | 565 |
| 564 // The leaf transform node should flatten its inherited transform node | 566 // The leaf transform node should flatten its inherited transform node |
| 565 // if and only if the intermediate rotation transform in the Blink tree | 567 // if and only if the intermediate rotation transform in the Blink tree |
| (...skipping 25 matching lines...) Expand all Loading... |
| 591 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( | 593 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode::
create( |
| 592 transform1, TransformationMatrix(), FloatPoint3D(), false, 1); | 594 transform1, TransformationMatrix(), FloatPoint3D(), false, 1); |
| 593 // Extends the 3D rendering context of transform2. | 595 // Extends the 3D rendering context of transform2. |
| 594 RefPtr<TransformPaintPropertyNode> transform3 = TransformPaintPropertyNode::
create( | 596 RefPtr<TransformPaintPropertyNode> transform3 = TransformPaintPropertyNode::
create( |
| 595 transform2, TransformationMatrix(), FloatPoint3D(), false, 1); | 597 transform2, TransformationMatrix(), FloatPoint3D(), false, 1); |
| 596 // Establishes a 3D rendering context distinct from transform2. | 598 // Establishes a 3D rendering context distinct from transform2. |
| 597 RefPtr<TransformPaintPropertyNode> transform4 = TransformPaintPropertyNode::
create( | 599 RefPtr<TransformPaintPropertyNode> transform4 = TransformPaintPropertyNode::
create( |
| 598 transform2, TransformationMatrix(), FloatPoint3D(), false, 2); | 600 transform2, TransformationMatrix(), FloatPoint3D(), false, 2); |
| 599 | 601 |
| 600 TestPaintArtifact artifact; | 602 TestPaintArtifact artifact; |
| 601 artifact.chunk(transform1, nullptr, dummyRootEffect()) | 603 artifact.chunk(transform1, nullptr, dummyRootEffect(), nullptr) |
| 602 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 604 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
| 603 artifact.chunk(transform2, nullptr, dummyRootEffect()) | 605 artifact.chunk(transform2, nullptr, dummyRootEffect(), nullptr) |
| 604 .rectDrawing(FloatRect(0, 0, 300, 200), Color::lightGray); | 606 .rectDrawing(FloatRect(0, 0, 300, 200), Color::lightGray); |
| 605 artifact.chunk(transform3, nullptr, dummyRootEffect()) | 607 artifact.chunk(transform3, nullptr, dummyRootEffect(), nullptr) |
| 606 .rectDrawing(FloatRect(0, 0, 300, 200), Color::darkGray); | 608 .rectDrawing(FloatRect(0, 0, 300, 200), Color::darkGray); |
| 607 artifact.chunk(transform4, nullptr, dummyRootEffect()) | 609 artifact.chunk(transform4, nullptr, dummyRootEffect(), nullptr) |
| 608 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); | 610 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); |
| 609 update(artifact.build()); | 611 update(artifact.build()); |
| 610 | 612 |
| 611 ASSERT_EQ(4u, contentLayerCount()); | 613 ASSERT_EQ(4u, contentLayerCount()); |
| 612 | 614 |
| 613 // The white layer is not 3D sorted. | 615 // The white layer is not 3D sorted. |
| 614 const cc::Layer* whiteLayer = contentLayerAt(0); | 616 const cc::Layer* whiteLayer = contentLayerAt(0); |
| 615 EXPECT_THAT(whiteLayer->GetPicture(), | 617 EXPECT_THAT(whiteLayer->GetPicture(), |
| 616 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 618 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
| 617 int whiteSortingContextId = transformNode(whiteLayer).sorting_context_id; | 619 int whiteSortingContextId = transformNode(whiteLayer).sorting_context_id; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 646 EXPECT_NE(0, blackSortingContextId); | 648 EXPECT_NE(0, blackSortingContextId); |
| 647 EXPECT_NE(lightGraySortingContextId, blackSortingContextId); | 649 EXPECT_NE(lightGraySortingContextId, blackSortingContextId); |
| 648 } | 650 } |
| 649 | 651 |
| 650 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneClip) | 652 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneClip) |
| 651 { | 653 { |
| 652 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( | 654 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( |
| 653 nullptr, nullptr, FloatRoundedRect(100, 100, 300, 200)); | 655 nullptr, nullptr, FloatRoundedRect(100, 100, 300, 200)); |
| 654 | 656 |
| 655 TestPaintArtifact artifact; | 657 TestPaintArtifact artifact; |
| 656 artifact.chunk(nullptr, clip, nullptr) | 658 artifact.chunk(nullptr, clip, nullptr, nullptr) |
| 657 .rectDrawing(FloatRect(220, 80, 300, 200), Color::black); | 659 .rectDrawing(FloatRect(220, 80, 300, 200), Color::black); |
| 658 update(artifact.build()); | 660 update(artifact.build()); |
| 659 | 661 |
| 660 ASSERT_EQ(1u, contentLayerCount()); | 662 ASSERT_EQ(1u, contentLayerCount()); |
| 661 const cc::Layer* layer = contentLayerAt(0); | 663 const cc::Layer* layer = contentLayerAt(0); |
| 662 EXPECT_THAT(layer->GetPicture(), | 664 EXPECT_THAT(layer->GetPicture(), |
| 663 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); | 665 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); |
| 664 EXPECT_EQ(translation(220, 80), layer->screen_space_transform()); | 666 EXPECT_EQ(translation(220, 80), layer->screen_space_transform()); |
| 665 | 667 |
| 666 const cc::ClipNode* clipNode = propertyTrees().clip_tree.Node(layer->clip_tr
ee_index()); | 668 const cc::ClipNode* clipNode = propertyTrees().clip_tree.Node(layer->clip_tr
ee_index()); |
| 667 EXPECT_TRUE(clipNode->applies_local_clip); | 669 EXPECT_TRUE(clipNode->applies_local_clip); |
| 668 EXPECT_TRUE(clipNode->layers_are_clipped); | 670 EXPECT_TRUE(clipNode->layers_are_clipped); |
| 669 EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clipNode->clip); | 671 EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clipNode->clip); |
| 670 } | 672 } |
| 671 | 673 |
| 672 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) | 674 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) |
| 673 { | 675 { |
| 674 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 676 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
| 675 nullptr, nullptr, FloatRoundedRect(100, 100, 700, 700)); | 677 nullptr, nullptr, FloatRoundedRect(100, 100, 700, 700)); |
| 676 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 678 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
| 677 clip1, nullptr, FloatRoundedRect(200, 200, 700, 100)); | 679 clip1, nullptr, FloatRoundedRect(200, 200, 700, 100)); |
| 678 | 680 |
| 679 TestPaintArtifact artifact; | 681 TestPaintArtifact artifact; |
| 680 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 682 artifact.chunk(nullptr, clip1, dummyRootEffect(), nullptr) |
| 681 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); | 683 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); |
| 682 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 684 artifact.chunk(nullptr, clip2, dummyRootEffect(), nullptr) |
| 683 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); | 685 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); |
| 684 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 686 artifact.chunk(nullptr, clip1, dummyRootEffect(), nullptr) |
| 685 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); | 687 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); |
| 686 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 688 artifact.chunk(nullptr, clip2, dummyRootEffect(), nullptr) |
| 687 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); | 689 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); |
| 688 update(artifact.build()); | 690 update(artifact.build()); |
| 689 | 691 |
| 690 ASSERT_EQ(4u, contentLayerCount()); | 692 ASSERT_EQ(4u, contentLayerCount()); |
| 691 | 693 |
| 692 const cc::Layer* whiteLayer = contentLayerAt(0); | 694 const cc::Layer* whiteLayer = contentLayerAt(0); |
| 693 EXPECT_THAT(whiteLayer->GetPicture(), | 695 EXPECT_THAT(whiteLayer->GetPicture(), |
| 694 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 696 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
| 695 EXPECT_EQ(translation(300, 350), whiteLayer->screen_space_transform()); | 697 EXPECT_EQ(translation(300, 350), whiteLayer->screen_space_transform()); |
| 696 | 698 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 726 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) | 728 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) |
| 727 { | 729 { |
| 728 Vector<RefPtr<ClipPaintPropertyNode>> clips; | 730 Vector<RefPtr<ClipPaintPropertyNode>> clips; |
| 729 for (unsigned i = 1; i <= 10; i++) { | 731 for (unsigned i = 1; i <= 10; i++) { |
| 730 clips.append(ClipPaintPropertyNode::create( | 732 clips.append(ClipPaintPropertyNode::create( |
| 731 clips.isEmpty() ? nullptr : clips.last(), | 733 clips.isEmpty() ? nullptr : clips.last(), |
| 732 nullptr, FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i))); | 734 nullptr, FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i))); |
| 733 } | 735 } |
| 734 | 736 |
| 735 TestPaintArtifact artifact; | 737 TestPaintArtifact artifact; |
| 736 artifact.chunk(nullptr, clips.last(), dummyRootEffect()) | 738 artifact.chunk(nullptr, clips.last(), dummyRootEffect(), nullptr) |
| 737 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white); | 739 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white); |
| 738 update(artifact.build()); | 740 update(artifact.build()); |
| 739 | 741 |
| 740 // Check the drawing layer. | 742 // Check the drawing layer. |
| 741 ASSERT_EQ(1u, contentLayerCount()); | 743 ASSERT_EQ(1u, contentLayerCount()); |
| 742 const cc::Layer* drawingLayer = contentLayerAt(0); | 744 const cc::Layer* drawingLayer = contentLayerAt(0); |
| 743 EXPECT_THAT(drawingLayer->GetPicture(), | 745 EXPECT_THAT(drawingLayer->GetPicture(), |
| 744 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white))); | 746 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white))); |
| 745 EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform()); | 747 EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform()); |
| 746 | 748 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 758 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) | 760 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) |
| 759 { | 761 { |
| 760 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( | 762 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( |
| 761 nullptr, nullptr, FloatRoundedRect(0, 0, 800, 600)); | 763 nullptr, nullptr, FloatRoundedRect(0, 0, 800, 600)); |
| 762 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 764 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
| 763 commonClip, nullptr, FloatRoundedRect(0, 0, 400, 600)); | 765 commonClip, nullptr, FloatRoundedRect(0, 0, 400, 600)); |
| 764 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 766 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
| 765 commonClip, nullptr, FloatRoundedRect(400, 0, 400, 600)); | 767 commonClip, nullptr, FloatRoundedRect(400, 0, 400, 600)); |
| 766 | 768 |
| 767 TestPaintArtifact artifact; | 769 TestPaintArtifact artifact; |
| 768 artifact.chunk(nullptr, clip1, dummyRootEffect()) | 770 artifact.chunk(nullptr, clip1, dummyRootEffect(), nullptr) |
| 769 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); | 771 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); |
| 770 artifact.chunk(nullptr, clip2, dummyRootEffect()) | 772 artifact.chunk(nullptr, clip2, dummyRootEffect(), nullptr) |
| 771 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); | 773 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); |
| 772 update(artifact.build()); | 774 update(artifact.build()); |
| 773 | 775 |
| 774 ASSERT_EQ(2u, contentLayerCount()); | 776 ASSERT_EQ(2u, contentLayerCount()); |
| 775 | 777 |
| 776 const cc::Layer* whiteLayer = contentLayerAt(0); | 778 const cc::Layer* whiteLayer = contentLayerAt(0); |
| 777 EXPECT_THAT(whiteLayer->GetPicture(), | 779 EXPECT_THAT(whiteLayer->GetPicture(), |
| 778 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); | 780 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); |
| 779 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); | 781 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); |
| 780 const cc::ClipNode* whiteClip = propertyTrees().clip_tree.Node(whiteLayer->c
lip_tree_index()); | 782 const cc::ClipNode* whiteClip = propertyTrees().clip_tree.Node(whiteLayer->c
lip_tree_index()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); | 815 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); |
| 814 } | 816 } |
| 815 | 817 |
| 816 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) | 818 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) |
| 817 { | 819 { |
| 818 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create(du
mmyRootEffect(), 0.5); | 820 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create(du
mmyRootEffect(), 0.5); |
| 819 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create(ef
fect1, 0.3); | 821 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create(ef
fect1, 0.3); |
| 820 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create(du
mmyRootEffect(), 0.2); | 822 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create(du
mmyRootEffect(), 0.2); |
| 821 | 823 |
| 822 TestPaintArtifact artifact; | 824 TestPaintArtifact artifact; |
| 823 artifact.chunk(nullptr, nullptr, effect2.get()) | 825 artifact.chunk(nullptr, nullptr, effect2.get(), nullptr) |
| 824 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 826 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 825 artifact.chunk(nullptr, nullptr, effect1.get()) | 827 artifact.chunk(nullptr, nullptr, effect1.get(), nullptr) |
| 826 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 828 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 827 artifact.chunk(nullptr, nullptr, effect3.get()) | 829 artifact.chunk(nullptr, nullptr, effect3.get(), nullptr) |
| 828 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 830 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 829 update(artifact.build()); | 831 update(artifact.build()); |
| 830 | 832 |
| 831 ASSERT_EQ(3u, contentLayerCount()); | 833 ASSERT_EQ(3u, contentLayerCount()); |
| 832 | 834 |
| 833 const cc::EffectTree& effectTree = propertyTrees().effect_tree; | 835 const cc::EffectTree& effectTree = propertyTrees().effect_tree; |
| 834 // Node #0 reserved for null; #1 for root render surface; #2 for dummyRootEf
fect, | 836 // Node #0 reserved for null; #1 for root render surface; #2 for dummyRootEf
fect, |
| 835 // plus 3 nodes for those created by this test. | 837 // plus 3 nodes for those created by this test. |
| 836 ASSERT_EQ(6u, effectTree.size()); | 838 ASSERT_EQ(6u, effectTree.size()); |
| 837 | 839 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 848 | 850 |
| 849 const cc::EffectNode& convertedEffect3 = *effectTree.Node(5); | 851 const cc::EffectNode& convertedEffect3 = *effectTree.Node(5); |
| 850 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id); | 852 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id); |
| 851 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); | 853 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); |
| 852 | 854 |
| 853 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); | 855 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); |
| 854 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); | 856 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); |
| 855 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); | 857 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); |
| 856 } | 858 } |
| 857 | 859 |
| 860 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) |
| 861 { |
| 862 RefPtr<TransformPaintPropertyNode> scrollTranslation = TransformPaintPropert
yNode::create( |
| 863 nullptr, TransformationMatrix().translate(7, 9), FloatPoint3D()); |
| 864 RefPtr<ScrollPaintPropertyNode> scroll = ScrollPaintPropertyNode::create( |
| 865 nullptr, scrollTranslation, FloatSize(), FloatSize(), true, true); |
| 866 |
| 867 TestPaintArtifact artifact; |
| 868 artifact.chunk(scrollTranslation, nullptr, nullptr, scroll) |
| 869 .rectDrawing(FloatRect(11, 13, 17, 19), Color::white); |
| 870 update(artifact.build()); |
| 871 |
| 872 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree; |
| 873 // Node #0 reserved for null; #1 for root render surface. |
| 874 ASSERT_EQ(3u, scrollTree.size()); |
| 875 const cc::ScrollNode& scrollNode = *scrollTree.Node(2); |
| 876 EXPECT_EQ(1, scrollNode.parent_id); |
| 877 |
| 878 const cc::TransformTree& transformTree = propertyTrees().transform_tree; |
| 879 const cc::TransformNode& transformNode = *transformTree.Node(scrollNode.tran
sform_id); |
| 880 // TransformNode no longer contain the scroll translation as a transform but
instead as a scroll offset. |
| 881 EXPECT_TRUE(transformNode.local.IsIdentity()); |
| 882 EXPECT_EQ(gfx::ScrollOffset(7, -9), transformNode.scroll_offset); |
| 883 } |
| 884 |
| 858 } // namespace | 885 } // namespace |
| 859 } // namespace blink | 886 } // namespace blink |
| OLD | NEW |