| 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_compositor_frame_sink.h" | 10 #include "cc/test/fake_compositor_frame_sink.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ | 35 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ |
| 36 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ | 36 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ |
| 37 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \ | 37 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \ |
| 38 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \ | 38 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \ |
| 39 } while (false) | 39 } while (false) |
| 40 | 40 |
| 41 using ::blink::testing::createOpacityOnlyEffect; | 41 using ::blink::testing::createOpacityOnlyEffect; |
| 42 using ::testing::Pointee; | 42 using ::testing::Pointee; |
| 43 | 43 |
| 44 PaintChunkProperties defaultPaintChunkProperties() { | 44 PaintChunkProperties defaultPaintChunkProperties() { |
| 45 PropertyTreeState propertyTreeState( | 45 PropertyTreeState propertyTreeState(TransformPaintPropertyNode::root(), |
| 46 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 46 ClipPaintPropertyNode::root(), |
| 47 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); | 47 EffectPaintPropertyNode::root()); |
| 48 return PaintChunkProperties(propertyTreeState); | 48 return PaintChunkProperties(propertyTreeState); |
| 49 } | 49 } |
| 50 | 50 |
| 51 gfx::Transform translation(SkMScalar x, SkMScalar y) { | 51 gfx::Transform translation(SkMScalar x, SkMScalar y) { |
| 52 gfx::Transform transform; | 52 gfx::Transform transform; |
| 53 transform.Translate(x, y); | 53 transform.Translate(x, y); |
| 54 return transform; | 54 return transform; |
| 55 } | 55 } |
| 56 | 56 |
| 57 class WebLayerTreeViewWithCompositorFrameSink | 57 class WebLayerTreeViewWithCompositorFrameSink |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 165 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
| 166 EXPECT_EQ(translation(50, -50), child->screen_space_transform()); | 166 EXPECT_EQ(translation(50, -50), child->screen_space_transform()); |
| 167 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); | 167 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); |
| 168 } | 168 } |
| 169 | 169 |
| 170 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) { | 170 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) { |
| 171 // A 90 degree clockwise rotation about (100, 100). | 171 // A 90 degree clockwise rotation about (100, 100). |
| 172 RefPtr<TransformPaintPropertyNode> transform = | 172 RefPtr<TransformPaintPropertyNode> transform = |
| 173 TransformPaintPropertyNode::create( | 173 TransformPaintPropertyNode::create( |
| 174 TransformPaintPropertyNode::root(), TransformationMatrix().rotate(90), | 174 TransformPaintPropertyNode::root(), TransformationMatrix().rotate(90), |
| 175 FloatPoint3D(100, 100, 0), nullptr, false, 0, | 175 FloatPoint3D(100, 100, 0), false, 0, CompositingReason3DTransform); |
| 176 CompositingReason3DTransform); | |
| 177 | 176 |
| 178 TestPaintArtifact artifact; | 177 TestPaintArtifact artifact; |
| 179 artifact | 178 artifact |
| 180 .chunk(transform, ClipPaintPropertyNode::root(), | 179 .chunk(transform, ClipPaintPropertyNode::root(), |
| 181 EffectPaintPropertyNode::root()) | 180 EffectPaintPropertyNode::root()) |
| 182 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 181 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 183 artifact | 182 artifact |
| 184 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 183 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 185 EffectPaintPropertyNode::root()) | 184 EffectPaintPropertyNode::root()) |
| 186 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); | 185 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 212 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::gray))); | 211 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::gray))); |
| 213 EXPECT_EQ(gfx::Transform(), layer->screen_space_transform()); | 212 EXPECT_EQ(gfx::Transform(), layer->screen_space_transform()); |
| 214 } | 213 } |
| 215 } | 214 } |
| 216 | 215 |
| 217 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) { | 216 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) { |
| 218 // A translation by (5, 5) within a 2x scale about (10, 10). | 217 // A translation by (5, 5) within a 2x scale about (10, 10). |
| 219 RefPtr<TransformPaintPropertyNode> transform1 = | 218 RefPtr<TransformPaintPropertyNode> transform1 = |
| 220 TransformPaintPropertyNode::create( | 219 TransformPaintPropertyNode::create( |
| 221 TransformPaintPropertyNode::root(), TransformationMatrix().scale(2), | 220 TransformPaintPropertyNode::root(), TransformationMatrix().scale(2), |
| 222 FloatPoint3D(10, 10, 0), nullptr, false, 0, | 221 FloatPoint3D(10, 10, 0), false, 0, CompositingReason3DTransform); |
| 223 CompositingReason3DTransform); | |
| 224 RefPtr<TransformPaintPropertyNode> transform2 = | 222 RefPtr<TransformPaintPropertyNode> transform2 = |
| 225 TransformPaintPropertyNode::create( | 223 TransformPaintPropertyNode::create( |
| 226 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D(), | 224 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D(), |
| 227 nullptr, false, 0, CompositingReason3DTransform); | 225 false, 0, CompositingReason3DTransform); |
| 228 | 226 |
| 229 TestPaintArtifact artifact; | 227 TestPaintArtifact artifact; |
| 230 artifact | 228 artifact |
| 231 .chunk(transform1, ClipPaintPropertyNode::root(), | 229 .chunk(transform1, ClipPaintPropertyNode::root(), |
| 232 EffectPaintPropertyNode::root()) | 230 EffectPaintPropertyNode::root()) |
| 233 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 231 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
| 234 artifact | 232 artifact |
| 235 .chunk(transform2, ClipPaintPropertyNode::root(), | 233 .chunk(transform2, ClipPaintPropertyNode::root(), |
| 236 EffectPaintPropertyNode::root()) | 234 EffectPaintPropertyNode::root()) |
| 237 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); | 235 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(), | 271 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(), |
| 274 TransformationMatrix(), | 272 TransformationMatrix(), |
| 275 FloatPoint3D()); | 273 FloatPoint3D()); |
| 276 RefPtr<TransformPaintPropertyNode> transform2 = | 274 RefPtr<TransformPaintPropertyNode> transform2 = |
| 277 TransformPaintPropertyNode::create( | 275 TransformPaintPropertyNode::create( |
| 278 transform1, TransformationMatrix().rotate3d(0, 45, 0), | 276 transform1, TransformationMatrix().rotate3d(0, 45, 0), |
| 279 FloatPoint3D()); | 277 FloatPoint3D()); |
| 280 RefPtr<TransformPaintPropertyNode> transform3 = | 278 RefPtr<TransformPaintPropertyNode> transform3 = |
| 281 TransformPaintPropertyNode::create( | 279 TransformPaintPropertyNode::create( |
| 282 transform2, TransformationMatrix().rotate3d(0, 45, 0), | 280 transform2, TransformationMatrix().rotate3d(0, 45, 0), |
| 283 FloatPoint3D(), nullptr, transformIsFlattened); | 281 FloatPoint3D(), transformIsFlattened); |
| 284 | 282 |
| 285 TestPaintArtifact artifact; | 283 TestPaintArtifact artifact; |
| 286 artifact | 284 artifact |
| 287 .chunk(transform3, ClipPaintPropertyNode::root(), | 285 .chunk(transform3, ClipPaintPropertyNode::root(), |
| 288 EffectPaintPropertyNode::root()) | 286 EffectPaintPropertyNode::root()) |
| 289 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 287 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
| 290 update(artifact.build()); | 288 update(artifact.build()); |
| 291 | 289 |
| 292 ASSERT_EQ(1u, contentLayerCount()); | 290 ASSERT_EQ(1u, contentLayerCount()); |
| 293 const cc::Layer* layer = contentLayerAt(0); | 291 const cc::Layer* layer = contentLayerAt(0); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 320 | 318 |
| 321 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SortingContextID) { | 319 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SortingContextID) { |
| 322 // Has no 3D rendering context. | 320 // Has no 3D rendering context. |
| 323 RefPtr<TransformPaintPropertyNode> transform1 = | 321 RefPtr<TransformPaintPropertyNode> transform1 = |
| 324 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(), | 322 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(), |
| 325 TransformationMatrix(), | 323 TransformationMatrix(), |
| 326 FloatPoint3D()); | 324 FloatPoint3D()); |
| 327 // Establishes a 3D rendering context. | 325 // Establishes a 3D rendering context. |
| 328 RefPtr<TransformPaintPropertyNode> transform2 = | 326 RefPtr<TransformPaintPropertyNode> transform2 = |
| 329 TransformPaintPropertyNode::create(transform1, TransformationMatrix(), | 327 TransformPaintPropertyNode::create(transform1, TransformationMatrix(), |
| 330 FloatPoint3D(), nullptr, false, 1, | 328 FloatPoint3D(), false, 1, |
| 331 CompositingReason3DTransform); | 329 CompositingReason3DTransform); |
| 332 // Extends the 3D rendering context of transform2. | 330 // Extends the 3D rendering context of transform2. |
| 333 RefPtr<TransformPaintPropertyNode> transform3 = | 331 RefPtr<TransformPaintPropertyNode> transform3 = |
| 334 TransformPaintPropertyNode::create(transform2, TransformationMatrix(), | 332 TransformPaintPropertyNode::create(transform2, TransformationMatrix(), |
| 335 FloatPoint3D(), nullptr, false, 1, | 333 FloatPoint3D(), false, 1, |
| 336 CompositingReason3DTransform); | 334 CompositingReason3DTransform); |
| 337 // Establishes a 3D rendering context distinct from transform2. | 335 // Establishes a 3D rendering context distinct from transform2. |
| 338 RefPtr<TransformPaintPropertyNode> transform4 = | 336 RefPtr<TransformPaintPropertyNode> transform4 = |
| 339 TransformPaintPropertyNode::create(transform2, TransformationMatrix(), | 337 TransformPaintPropertyNode::create(transform2, TransformationMatrix(), |
| 340 FloatPoint3D(), nullptr, false, 2, | 338 FloatPoint3D(), false, 2, |
| 341 CompositingReason3DTransform); | 339 CompositingReason3DTransform); |
| 342 | 340 |
| 343 TestPaintArtifact artifact; | 341 TestPaintArtifact artifact; |
| 344 artifact | 342 artifact |
| 345 .chunk(transform1, ClipPaintPropertyNode::root(), | 343 .chunk(transform1, ClipPaintPropertyNode::root(), |
| 346 EffectPaintPropertyNode::root()) | 344 EffectPaintPropertyNode::root()) |
| 347 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 345 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
| 348 artifact | 346 artifact |
| 349 .chunk(transform2, ClipPaintPropertyNode::root(), | 347 .chunk(transform2, ClipPaintPropertyNode::root(), |
| 350 EffectPaintPropertyNode::root()) | 348 EffectPaintPropertyNode::root()) |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 const cc::EffectNode& convertedEffect3 = *effectTree.Node(4); | 662 const cc::EffectNode& convertedEffect3 = *effectTree.Node(4); |
| 665 EXPECT_EQ(convertedRootEffect.id, convertedEffect3.parent_id); | 663 EXPECT_EQ(convertedRootEffect.id, convertedEffect3.parent_id); |
| 666 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); | 664 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); |
| 667 | 665 |
| 668 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); | 666 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); |
| 669 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); | 667 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); |
| 670 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); | 668 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); |
| 671 } | 669 } |
| 672 | 670 |
| 673 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) { | 671 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) { |
| 674 RefPtr<ScrollPaintPropertyNode> scroll = ScrollPaintPropertyNode::create( | |
| 675 ScrollPaintPropertyNode::root(), IntSize(11, 13), IntSize(27, 31), true, | |
| 676 false, 0 /* mainThreadScrollingReasons */); | |
| 677 CompositorElementId expectedCompositorElementId = CompositorElementId(2, 0); | 672 CompositorElementId expectedCompositorElementId = CompositorElementId(2, 0); |
| 678 RefPtr<TransformPaintPropertyNode> scrollTranslation = | 673 RefPtr<TransformPaintPropertyNode> scrollTranslation = |
| 679 TransformPaintPropertyNode::create( | 674 TransformPaintPropertyNode::createScrollTranslation( |
| 680 TransformPaintPropertyNode::root(), | 675 TransformPaintPropertyNode::root(), |
| 681 TransformationMatrix().translate(7, 9), FloatPoint3D(), scroll.get(), | 676 TransformationMatrix().translate(7, 9), FloatPoint3D(), false, 0, |
| 682 false, 0, CompositingReasonNone, expectedCompositorElementId); | 677 CompositingReasonNone, expectedCompositorElementId, |
| 678 ScrollPaintPropertyNode::root(), IntSize(11, 13), IntSize(27, 31), |
| 679 true, false, 0 /* mainThreadScrollingReasons */); |
| 683 | 680 |
| 684 TestPaintArtifact artifact; | 681 TestPaintArtifact artifact; |
| 685 artifact | 682 artifact |
| 686 .chunk(scrollTranslation, ClipPaintPropertyNode::root(), | 683 .chunk(scrollTranslation, ClipPaintPropertyNode::root(), |
| 687 EffectPaintPropertyNode::root(), scroll) | 684 EffectPaintPropertyNode::root()) |
| 688 .rectDrawing(FloatRect(11, 13, 17, 19), Color::white); | 685 .rectDrawing(FloatRect(11, 13, 17, 19), Color::white); |
| 689 update(artifact.build()); | 686 update(artifact.build()); |
| 690 | 687 |
| 691 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree; | 688 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree; |
| 692 // Node #0 reserved for null; #1 for root render surface. | 689 // Node #0 reserved for null; #1 for root render surface. |
| 693 ASSERT_EQ(3u, scrollTree.size()); | 690 ASSERT_EQ(3u, scrollTree.size()); |
| 694 const cc::ScrollNode& scrollNode = *scrollTree.Node(2); | 691 const cc::ScrollNode& scrollNode = *scrollTree.Node(2); |
| 695 EXPECT_EQ(gfx::Size(11, 13), scrollNode.scroll_clip_layer_bounds); | 692 EXPECT_EQ(gfx::Size(11, 13), scrollNode.scroll_clip_layer_bounds); |
| 696 EXPECT_EQ(gfx::Size(27, 31), scrollNode.bounds); | 693 EXPECT_EQ(gfx::Size(27, 31), scrollNode.bounds); |
| 697 EXPECT_TRUE(scrollNode.user_scrollable_horizontal); | 694 EXPECT_TRUE(scrollNode.user_scrollable_horizontal); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 709 EXPECT_EQ(gfx::ScrollOffset(-7, -9), transformNode.scroll_offset); | 706 EXPECT_EQ(gfx::ScrollOffset(-7, -9), transformNode.scroll_offset); |
| 710 | 707 |
| 711 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 708 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 712 scrollNode.main_thread_scrolling_reasons); | 709 scrollNode.main_thread_scrolling_reasons); |
| 713 } | 710 } |
| 714 | 711 |
| 715 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { | 712 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { |
| 716 RefPtr<EffectPaintPropertyNode> effect = | 713 RefPtr<EffectPaintPropertyNode> effect = |
| 717 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); | 714 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); |
| 718 | 715 |
| 719 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create( | |
| 720 ScrollPaintPropertyNode::root(), IntSize(2, 3), IntSize(5, 7), false, | |
| 721 true, MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | |
| 722 CompositorElementId expectedCompositorElementIdA = CompositorElementId(2, 0); | 716 CompositorElementId expectedCompositorElementIdA = CompositorElementId(2, 0); |
| 723 RefPtr<TransformPaintPropertyNode> scrollTranslationA = | 717 RefPtr<TransformPaintPropertyNode> scrollTranslationA = |
| 724 TransformPaintPropertyNode::create( | 718 TransformPaintPropertyNode::createScrollTranslation( |
| 725 TransformPaintPropertyNode::root(), | 719 TransformPaintPropertyNode::root(), |
| 726 TransformationMatrix().translate(11, 13), FloatPoint3D(), | 720 TransformationMatrix().translate(11, 13), FloatPoint3D(), false, 0, |
| 727 scrollA.get(), false, 0, CompositingReasonNone, | 721 CompositingReasonNone, expectedCompositorElementIdA, |
| 728 expectedCompositorElementIdA); | 722 ScrollPaintPropertyNode::root(), IntSize(2, 3), IntSize(5, 7), false, |
| 729 RefPtr<ScrollPaintPropertyNode> scrollB = ScrollPaintPropertyNode::create( | 723 true, |
| 730 scrollA, IntSize(19, 23), IntSize(29, 31), true, false, | 724 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 731 0 /* mainThreadScrollingReasons */); | 725 |
| 732 CompositorElementId expectedCompositorElementIdB = CompositorElementId(3, 0); | 726 CompositorElementId expectedCompositorElementIdB = CompositorElementId(3, 0); |
| 733 RefPtr<TransformPaintPropertyNode> scrollTranslationB = | 727 RefPtr<TransformPaintPropertyNode> scrollTranslationB = |
| 734 TransformPaintPropertyNode::create( | 728 TransformPaintPropertyNode::createScrollTranslation( |
| 735 scrollTranslationA, TransformationMatrix().translate(37, 41), | 729 scrollTranslationA, TransformationMatrix().translate(37, 41), |
| 736 FloatPoint3D(), scrollB.get(), false, 0, CompositingReasonNone, | 730 FloatPoint3D(), false, 0, CompositingReasonNone, |
| 737 expectedCompositorElementIdB); | 731 expectedCompositorElementIdB, scrollTranslationA->scrollNode(), |
| 732 IntSize(19, 23), IntSize(29, 31), true, false, |
| 733 0 /* mainThreadScrollingReasons */); |
| 738 TestPaintArtifact artifact; | 734 TestPaintArtifact artifact; |
| 739 artifact | 735 artifact.chunk(scrollTranslationA, ClipPaintPropertyNode::root(), effect) |
| 740 .chunk(scrollTranslationA, ClipPaintPropertyNode::root(), effect, scrollA) | |
| 741 .rectDrawing(FloatRect(7, 11, 13, 17), Color::white); | 736 .rectDrawing(FloatRect(7, 11, 13, 17), Color::white); |
| 742 artifact | 737 artifact.chunk(scrollTranslationB, ClipPaintPropertyNode::root(), effect) |
| 743 .chunk(scrollTranslationB, ClipPaintPropertyNode::root(), effect, scrollB) | |
| 744 .rectDrawing(FloatRect(1, 2, 3, 5), Color::white); | 738 .rectDrawing(FloatRect(1, 2, 3, 5), Color::white); |
| 745 update(artifact.build()); | 739 update(artifact.build()); |
| 746 | 740 |
| 747 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree; | 741 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree; |
| 748 // Node #0 reserved for null; #1 for root render surface. | 742 // Node #0 reserved for null; #1 for root render surface. |
| 749 ASSERT_EQ(4u, scrollTree.size()); | 743 ASSERT_EQ(3u, scrollTree.size()); |
| 750 const cc::ScrollNode& scrollNodeA = *scrollTree.Node(2); | 744 const cc::ScrollNode& scrollNode = *scrollTree.Node(2); |
| 751 EXPECT_EQ(gfx::Size(2, 3), scrollNodeA.scroll_clip_layer_bounds); | 745 EXPECT_EQ(gfx::Size(2, 3), scrollNode.scroll_clip_layer_bounds); |
| 752 EXPECT_EQ(gfx::Size(5, 7), scrollNodeA.bounds); | 746 EXPECT_EQ(gfx::Size(5, 7), scrollNode.bounds); |
| 753 EXPECT_FALSE(scrollNodeA.user_scrollable_horizontal); | 747 EXPECT_FALSE(scrollNode.user_scrollable_horizontal); |
| 754 EXPECT_TRUE(scrollNodeA.user_scrollable_vertical); | 748 EXPECT_TRUE(scrollNode.user_scrollable_vertical); |
| 755 EXPECT_EQ(1, scrollNodeA.parent_id); | 749 EXPECT_EQ(1, scrollNode.parent_id); |
| 756 const cc::ScrollNode& scrollNodeB = *scrollTree.Node(3); | 750 EXPECT_EQ(expectedCompositorElementIdA, scrollNode.element_id); |
| 757 EXPECT_EQ(gfx::Size(19, 23), scrollNodeB.scroll_clip_layer_bounds); | 751 EXPECT_EQ(scrollNode.id, |
| 758 EXPECT_EQ(gfx::Size(29, 31), scrollNodeB.bounds); | |
| 759 EXPECT_TRUE(scrollNodeB.user_scrollable_horizontal); | |
| 760 EXPECT_FALSE(scrollNodeB.user_scrollable_vertical); | |
| 761 EXPECT_EQ(scrollNodeA.id, scrollNodeB.parent_id); | |
| 762 EXPECT_EQ(expectedCompositorElementIdA, scrollNodeA.element_id); | |
| 763 EXPECT_EQ(scrollNodeA.id, | |
| 764 elementIdToScrollNodeIndex(expectedCompositorElementIdA)); | 752 elementIdToScrollNodeIndex(expectedCompositorElementIdA)); |
| 765 EXPECT_EQ(expectedCompositorElementIdB, scrollNodeB.element_id); | 753 |
| 766 EXPECT_EQ(scrollNodeB.id, | |
| 767 elementIdToScrollNodeIndex(expectedCompositorElementIdB)); | |
| 768 EXPECT_EQ(expectedCompositorElementIdA, contentLayerAt(0)->element_id()); | 754 EXPECT_EQ(expectedCompositorElementIdA, contentLayerAt(0)->element_id()); |
| 769 EXPECT_EQ(expectedCompositorElementIdB, contentLayerAt(1)->element_id()); | |
| 770 | 755 |
| 771 const cc::TransformTree& transformTree = propertyTrees().transform_tree; | 756 const cc::TransformTree& transformTree = propertyTrees().transform_tree; |
| 772 const cc::TransformNode& transformNodeA = | 757 const cc::TransformNode& transformNodeA = |
| 773 *transformTree.Node(scrollNodeA.transform_id); | 758 *transformTree.Node(scrollNode.transform_id); |
| 774 EXPECT_TRUE(transformNodeA.local.IsIdentity()); | 759 EXPECT_TRUE(transformNodeA.local.IsIdentity()); |
| 775 EXPECT_EQ(gfx::ScrollOffset(-11, -13), transformNodeA.scroll_offset); | 760 EXPECT_EQ(gfx::ScrollOffset(-11, -13), transformNodeA.scroll_offset); |
| 776 | 761 |
| 777 const cc::TransformNode& transformNodeB = | 762 EXPECT_TRUE(scrollNode.main_thread_scrolling_reasons & |
| 778 *transformTree.Node(scrollNodeB.transform_id); | |
| 779 EXPECT_EQ(gfx::ScrollOffset(-37, -41), transformNodeB.scroll_offset); | |
| 780 | |
| 781 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & | |
| 782 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 763 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 783 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & | |
| 784 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | |
| 785 } | 764 } |
| 786 | 765 |
| 787 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeSimpleChunks) { | 766 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeSimpleChunks) { |
| 788 TestPaintArtifact testArtifact; | 767 TestPaintArtifact testArtifact; |
| 789 testArtifact | 768 testArtifact |
| 790 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 769 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 791 EffectPaintPropertyNode::root()) | 770 EffectPaintPropertyNode::root()) |
| 792 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 771 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 793 testArtifact | 772 testArtifact |
| 794 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 773 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 const cc::Layer* layer = contentLayerAt(0); | 841 const cc::Layer* layer = contentLayerAt(0); |
| 863 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); | 842 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); |
| 864 } | 843 } |
| 865 } | 844 } |
| 866 | 845 |
| 867 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, Merge2DTransform) { | 846 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, Merge2DTransform) { |
| 868 RefPtr<TransformPaintPropertyNode> transform = | 847 RefPtr<TransformPaintPropertyNode> transform = |
| 869 TransformPaintPropertyNode::create( | 848 TransformPaintPropertyNode::create( |
| 870 TransformPaintPropertyNode::root(), | 849 TransformPaintPropertyNode::root(), |
| 871 TransformationMatrix().translate(50, 50), FloatPoint3D(100, 100, 0), | 850 TransformationMatrix().translate(50, 50), FloatPoint3D(100, 100, 0), |
| 872 nullptr, false, 0); | 851 false, 0); |
| 873 | 852 |
| 874 TestPaintArtifact testArtifact; | 853 TestPaintArtifact testArtifact; |
| 875 testArtifact | 854 testArtifact |
| 876 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 855 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 877 EffectPaintPropertyNode::root()) | 856 EffectPaintPropertyNode::root()) |
| 878 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 857 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 879 testArtifact | 858 testArtifact |
| 880 .chunk(transform.get(), ClipPaintPropertyNode::root(), | 859 .chunk(transform.get(), ClipPaintPropertyNode::root(), |
| 881 EffectPaintPropertyNode::root()) | 860 EffectPaintPropertyNode::root()) |
| 882 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); | 861 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 911 const cc::Layer* layer = contentLayerAt(0); | 890 const cc::Layer* layer = contentLayerAt(0); |
| 912 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); | 891 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); |
| 913 } | 892 } |
| 914 } | 893 } |
| 915 | 894 |
| 916 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, | 895 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, |
| 917 Merge2DTransformDirectAncestor) { | 896 Merge2DTransformDirectAncestor) { |
| 918 RefPtr<TransformPaintPropertyNode> transform = | 897 RefPtr<TransformPaintPropertyNode> transform = |
| 919 TransformPaintPropertyNode::create( | 898 TransformPaintPropertyNode::create( |
| 920 TransformPaintPropertyNode::root(), TransformationMatrix(), | 899 TransformPaintPropertyNode::root(), TransformationMatrix(), |
| 921 FloatPoint3D(), nullptr, false, 0, CompositingReason3DTransform); | 900 FloatPoint3D(), false, 0, CompositingReason3DTransform); |
| 922 | 901 |
| 923 RefPtr<TransformPaintPropertyNode> transform2 = | 902 RefPtr<TransformPaintPropertyNode> transform2 = |
| 924 TransformPaintPropertyNode::create( | 903 TransformPaintPropertyNode::create( |
| 925 transform.get(), TransformationMatrix().translate(50, 50), | 904 transform.get(), TransformationMatrix().translate(50, 50), |
| 926 FloatPoint3D(100, 100, 0), nullptr, false, 0); | 905 FloatPoint3D(100, 100, 0), false, 0); |
| 927 | 906 |
| 928 TestPaintArtifact testArtifact; | 907 TestPaintArtifact testArtifact; |
| 929 testArtifact | 908 testArtifact |
| 930 .chunk(transform.get(), ClipPaintPropertyNode::root(), | 909 .chunk(transform.get(), ClipPaintPropertyNode::root(), |
| 931 EffectPaintPropertyNode::root()) | 910 EffectPaintPropertyNode::root()) |
| 932 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 911 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 933 // The second chunk can merge into the first because it has a descendant | 912 // The second chunk can merge into the first because it has a descendant |
| 934 // state of the first's transform and no direct compositing reason. | 913 // state of the first's transform and no direct compositing reason. |
| 935 testArtifact | 914 testArtifact |
| 936 .chunk(transform2.get(), ClipPaintPropertyNode::root(), | 915 .chunk(transform2.get(), ClipPaintPropertyNode::root(), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 955 rectsWithColor.push_back( | 934 rectsWithColor.push_back( |
| 956 RectWithColor(FloatRect(50, 50, 100, 100), Color::black)); | 935 RectWithColor(FloatRect(50, 50, 100, 100), Color::black)); |
| 957 | 936 |
| 958 const cc::Layer* layer = contentLayerAt(0); | 937 const cc::Layer* layer = contentLayerAt(0); |
| 959 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); | 938 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); |
| 960 } | 939 } |
| 961 } | 940 } |
| 962 | 941 |
| 963 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeTransformOrigin) { | 942 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeTransformOrigin) { |
| 964 RefPtr<TransformPaintPropertyNode> transform = | 943 RefPtr<TransformPaintPropertyNode> transform = |
| 965 TransformPaintPropertyNode::create( | 944 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(), |
| 966 TransformPaintPropertyNode::root(), TransformationMatrix().rotate(45), | 945 TransformationMatrix().rotate(45), |
| 967 FloatPoint3D(100, 100, 0), nullptr, false, 0); | 946 FloatPoint3D(100, 100, 0), false, 0); |
| 968 | 947 |
| 969 TestPaintArtifact testArtifact; | 948 TestPaintArtifact testArtifact; |
| 970 testArtifact | 949 testArtifact |
| 971 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 950 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 972 EffectPaintPropertyNode::root()) | 951 EffectPaintPropertyNode::root()) |
| 973 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 952 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 974 testArtifact | 953 testArtifact |
| 975 .chunk(transform.get(), ClipPaintPropertyNode::root(), | 954 .chunk(transform.get(), ClipPaintPropertyNode::root(), |
| 976 EffectPaintPropertyNode::root()) | 955 EffectPaintPropertyNode::root()) |
| 977 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); | 956 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 } | 1037 } |
| 1059 | 1038 |
| 1060 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeNested) { | 1039 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeNested) { |
| 1061 // Tests merging of an opacity effect, inside of a clip, inside of a | 1040 // Tests merging of an opacity effect, inside of a clip, inside of a |
| 1062 // transform. | 1041 // transform. |
| 1063 | 1042 |
| 1064 RefPtr<TransformPaintPropertyNode> transform = | 1043 RefPtr<TransformPaintPropertyNode> transform = |
| 1065 TransformPaintPropertyNode::create( | 1044 TransformPaintPropertyNode::create( |
| 1066 TransformPaintPropertyNode::root(), | 1045 TransformPaintPropertyNode::root(), |
| 1067 TransformationMatrix().translate(50, 50), FloatPoint3D(100, 100, 0), | 1046 TransformationMatrix().translate(50, 50), FloatPoint3D(100, 100, 0), |
| 1068 nullptr, false, 0); | 1047 false, 0); |
| 1069 | 1048 |
| 1070 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( | 1049 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( |
| 1071 ClipPaintPropertyNode::root(), transform.get(), | 1050 ClipPaintPropertyNode::root(), transform.get(), |
| 1072 FloatRoundedRect(10, 20, 50, 60)); | 1051 FloatRoundedRect(10, 20, 50, 60)); |
| 1073 | 1052 |
| 1074 float opacity = 2.0 / 255.0; | 1053 float opacity = 2.0 / 255.0; |
| 1075 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( | 1054 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( |
| 1076 EffectPaintPropertyNode::root(), transform.get(), clip.get(), | 1055 EffectPaintPropertyNode::root(), transform.get(), clip.get(), |
| 1077 CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver); | 1056 CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver); |
| 1078 | 1057 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 | 1097 |
| 1119 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, ClipPushedUp) { | 1098 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, ClipPushedUp) { |
| 1120 // Tests merging of an element which has a clipapplied to it, | 1099 // Tests merging of an element which has a clipapplied to it, |
| 1121 // but has an ancestor transform of them. This can happen for fixed- | 1100 // but has an ancestor transform of them. This can happen for fixed- |
| 1122 // or absolute-position elements which escape scroll transforms. | 1101 // or absolute-position elements which escape scroll transforms. |
| 1123 | 1102 |
| 1124 RefPtr<TransformPaintPropertyNode> transform = | 1103 RefPtr<TransformPaintPropertyNode> transform = |
| 1125 TransformPaintPropertyNode::create( | 1104 TransformPaintPropertyNode::create( |
| 1126 TransformPaintPropertyNode::root(), | 1105 TransformPaintPropertyNode::root(), |
| 1127 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), | 1106 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), |
| 1128 nullptr, false, 0); | 1107 false, 0); |
| 1129 | 1108 |
| 1130 RefPtr<TransformPaintPropertyNode> transform2 = | 1109 RefPtr<TransformPaintPropertyNode> transform2 = |
| 1131 TransformPaintPropertyNode::create( | 1110 TransformPaintPropertyNode::create( |
| 1132 transform.get(), TransformationMatrix().translate(20, 25), | 1111 transform.get(), TransformationMatrix().translate(20, 25), |
| 1133 FloatPoint3D(100, 100, 0), nullptr, false, 0); | 1112 FloatPoint3D(100, 100, 0), false, 0); |
| 1134 | 1113 |
| 1135 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( | 1114 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( |
| 1136 ClipPaintPropertyNode::root(), transform2.get(), | 1115 ClipPaintPropertyNode::root(), transform2.get(), |
| 1137 FloatRoundedRect(10, 20, 50, 60)); | 1116 FloatRoundedRect(10, 20, 50, 60)); |
| 1138 | 1117 |
| 1139 TestPaintArtifact testArtifact; | 1118 TestPaintArtifact testArtifact; |
| 1140 testArtifact | 1119 testArtifact |
| 1141 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1120 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1142 EffectPaintPropertyNode::root()) | 1121 EffectPaintPropertyNode::root()) |
| 1143 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 1122 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 | 1159 |
| 1181 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectPushedUp) { | 1160 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectPushedUp) { |
| 1182 // Tests merging of an element which has an effect applied to it, | 1161 // Tests merging of an element which has an effect applied to it, |
| 1183 // but has an ancestor transform of them. This can happen for fixed- | 1162 // but has an ancestor transform of them. This can happen for fixed- |
| 1184 // or absolute-position elements which escape scroll transforms. | 1163 // or absolute-position elements which escape scroll transforms. |
| 1185 | 1164 |
| 1186 RefPtr<TransformPaintPropertyNode> transform = | 1165 RefPtr<TransformPaintPropertyNode> transform = |
| 1187 TransformPaintPropertyNode::create( | 1166 TransformPaintPropertyNode::create( |
| 1188 TransformPaintPropertyNode::root(), | 1167 TransformPaintPropertyNode::root(), |
| 1189 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), | 1168 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), |
| 1190 nullptr, false, 0); | 1169 false, 0); |
| 1191 | 1170 |
| 1192 RefPtr<TransformPaintPropertyNode> transform2 = | 1171 RefPtr<TransformPaintPropertyNode> transform2 = |
| 1193 TransformPaintPropertyNode::create( | 1172 TransformPaintPropertyNode::create( |
| 1194 transform.get(), TransformationMatrix().translate(20, 25), | 1173 transform.get(), TransformationMatrix().translate(20, 25), |
| 1195 FloatPoint3D(100, 100, 0), nullptr, false, 0); | 1174 FloatPoint3D(100, 100, 0), false, 0); |
| 1196 | 1175 |
| 1197 float opacity = 2.0 / 255.0; | 1176 float opacity = 2.0 / 255.0; |
| 1198 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( | 1177 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( |
| 1199 EffectPaintPropertyNode::root(), transform2.get(), | 1178 EffectPaintPropertyNode::root(), transform2.get(), |
| 1200 ClipPaintPropertyNode::root(), CompositorFilterOperations(), opacity, | 1179 ClipPaintPropertyNode::root(), CompositorFilterOperations(), opacity, |
| 1201 SkBlendMode::kSrcOver); | 1180 SkBlendMode::kSrcOver); |
| 1202 | 1181 |
| 1203 TestPaintArtifact testArtifact; | 1182 TestPaintArtifact testArtifact; |
| 1204 testArtifact | 1183 testArtifact |
| 1205 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1184 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 | 1222 |
| 1244 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectAndClipPushedUp) { | 1223 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectAndClipPushedUp) { |
| 1245 // Tests merging of an element which has an effect applied to it, | 1224 // Tests merging of an element which has an effect applied to it, |
| 1246 // but has an ancestor transform of them. This can happen for fixed- | 1225 // but has an ancestor transform of them. This can happen for fixed- |
| 1247 // or absolute-position elements which escape scroll transforms. | 1226 // or absolute-position elements which escape scroll transforms. |
| 1248 | 1227 |
| 1249 RefPtr<TransformPaintPropertyNode> transform = | 1228 RefPtr<TransformPaintPropertyNode> transform = |
| 1250 TransformPaintPropertyNode::create( | 1229 TransformPaintPropertyNode::create( |
| 1251 TransformPaintPropertyNode::root(), | 1230 TransformPaintPropertyNode::root(), |
| 1252 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), | 1231 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), |
| 1253 nullptr, false, 0); | 1232 false, 0); |
| 1254 | 1233 |
| 1255 RefPtr<TransformPaintPropertyNode> transform2 = | 1234 RefPtr<TransformPaintPropertyNode> transform2 = |
| 1256 TransformPaintPropertyNode::create( | 1235 TransformPaintPropertyNode::create( |
| 1257 transform.get(), TransformationMatrix().translate(20, 25), | 1236 transform.get(), TransformationMatrix().translate(20, 25), |
| 1258 FloatPoint3D(100, 100, 0), nullptr, false, 0); | 1237 FloatPoint3D(100, 100, 0), false, 0); |
| 1259 | 1238 |
| 1260 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( | 1239 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( |
| 1261 ClipPaintPropertyNode::root(), transform.get(), | 1240 ClipPaintPropertyNode::root(), transform.get(), |
| 1262 FloatRoundedRect(10, 20, 50, 60)); | 1241 FloatRoundedRect(10, 20, 50, 60)); |
| 1263 | 1242 |
| 1264 float opacity = 2.0 / 255.0; | 1243 float opacity = 2.0 / 255.0; |
| 1265 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( | 1244 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( |
| 1266 EffectPaintPropertyNode::root(), transform2.get(), clip.get(), | 1245 EffectPaintPropertyNode::root(), transform2.get(), clip.get(), |
| 1267 CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver); | 1246 CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver); |
| 1268 | 1247 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 const cc::Layer* layer = contentLayerAt(0); | 1391 const cc::Layer* layer = contentLayerAt(0); |
| 1413 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); | 1392 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); |
| 1414 } | 1393 } |
| 1415 } | 1394 } |
| 1416 | 1395 |
| 1417 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TwoTransformsClipBetween) { | 1396 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TwoTransformsClipBetween) { |
| 1418 RefPtr<TransformPaintPropertyNode> transform = | 1397 RefPtr<TransformPaintPropertyNode> transform = |
| 1419 TransformPaintPropertyNode::create( | 1398 TransformPaintPropertyNode::create( |
| 1420 TransformPaintPropertyNode::root(), | 1399 TransformPaintPropertyNode::root(), |
| 1421 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), | 1400 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), |
| 1422 nullptr, false, 0); | 1401 false, 0); |
| 1423 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( | 1402 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( |
| 1424 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | 1403 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
| 1425 FloatRoundedRect(0, 0, 50, 60)); | 1404 FloatRoundedRect(0, 0, 50, 60)); |
| 1426 RefPtr<TransformPaintPropertyNode> transform2 = | 1405 RefPtr<TransformPaintPropertyNode> transform2 = |
| 1427 TransformPaintPropertyNode::create( | 1406 TransformPaintPropertyNode::create( |
| 1428 transform.get(), TransformationMatrix().translate(20, 25), | 1407 transform.get(), TransformationMatrix().translate(20, 25), |
| 1429 FloatPoint3D(100, 100, 0), nullptr, false, 0); | 1408 FloatPoint3D(100, 100, 0), false, 0); |
| 1430 TestPaintArtifact testArtifact; | 1409 TestPaintArtifact testArtifact; |
| 1431 testArtifact | 1410 testArtifact |
| 1432 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1411 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1433 EffectPaintPropertyNode::root()) | 1412 EffectPaintPropertyNode::root()) |
| 1434 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 1413 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 1435 testArtifact | 1414 testArtifact |
| 1436 .chunk(transform2.get(), clip.get(), EffectPaintPropertyNode::root()) | 1415 .chunk(transform2.get(), clip.get(), EffectPaintPropertyNode::root()) |
| 1437 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); | 1416 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); |
| 1438 testArtifact | 1417 testArtifact |
| 1439 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1418 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1460 const cc::Layer* layer = contentLayerAt(0); | 1439 const cc::Layer* layer = contentLayerAt(0); |
| 1461 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); | 1440 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); |
| 1462 } | 1441 } |
| 1463 } | 1442 } |
| 1464 | 1443 |
| 1465 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OverlapTransform) { | 1444 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OverlapTransform) { |
| 1466 RefPtr<TransformPaintPropertyNode> transform = | 1445 RefPtr<TransformPaintPropertyNode> transform = |
| 1467 TransformPaintPropertyNode::create( | 1446 TransformPaintPropertyNode::create( |
| 1468 TransformPaintPropertyNode::root(), | 1447 TransformPaintPropertyNode::root(), |
| 1469 TransformationMatrix().translate(50, 50), FloatPoint3D(100, 100, 0), | 1448 TransformationMatrix().translate(50, 50), FloatPoint3D(100, 100, 0), |
| 1470 nullptr, false, 0, CompositingReason3DTransform); | 1449 false, 0, CompositingReason3DTransform); |
| 1471 | 1450 |
| 1472 TestPaintArtifact testArtifact; | 1451 TestPaintArtifact testArtifact; |
| 1473 testArtifact.chunk(defaultPaintChunkProperties()) | 1452 testArtifact.chunk(defaultPaintChunkProperties()) |
| 1474 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 1453 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 1475 testArtifact | 1454 testArtifact |
| 1476 .chunk(transform.get(), ClipPaintPropertyNode::root(), | 1455 .chunk(transform.get(), ClipPaintPropertyNode::root(), |
| 1477 EffectPaintPropertyNode::root()) | 1456 EffectPaintPropertyNode::root()) |
| 1478 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); | 1457 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); |
| 1479 testArtifact.chunk(defaultPaintChunkProperties()) | 1458 testArtifact.chunk(defaultPaintChunkProperties()) |
| 1480 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 1459 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 | 1494 |
| 1516 GeometryMapper geometryMapper; | 1495 GeometryMapper geometryMapper; |
| 1517 PaintArtifactCompositor::PendingLayer pendingLayer(paintChunk); | 1496 PaintArtifactCompositor::PendingLayer pendingLayer(paintChunk); |
| 1518 EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer, | 1497 EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer, |
| 1519 geometryMapper)); | 1498 geometryMapper)); |
| 1520 | 1499 |
| 1521 RefPtr<TransformPaintPropertyNode> transform = | 1500 RefPtr<TransformPaintPropertyNode> transform = |
| 1522 TransformPaintPropertyNode::create( | 1501 TransformPaintPropertyNode::create( |
| 1523 TransformPaintPropertyNode::root(), | 1502 TransformPaintPropertyNode::root(), |
| 1524 TransformationMatrix().translate(99, 0), FloatPoint3D(100, 100, 0), | 1503 TransformationMatrix().translate(99, 0), FloatPoint3D(100, 100, 0), |
| 1525 nullptr, false); | 1504 false); |
| 1526 | 1505 |
| 1527 paintChunk2.properties.propertyTreeState.setTransform(transform.get()); | 1506 paintChunk2.properties.propertyTreeState.setTransform(transform.get()); |
| 1528 EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer, | 1507 EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer, |
| 1529 geometryMapper)); | 1508 geometryMapper)); |
| 1530 | 1509 |
| 1531 RefPtr<TransformPaintPropertyNode> transform2 = | 1510 RefPtr<TransformPaintPropertyNode> transform2 = |
| 1532 TransformPaintPropertyNode::create( | 1511 TransformPaintPropertyNode::create( |
| 1533 TransformPaintPropertyNode::root(), | 1512 TransformPaintPropertyNode::root(), |
| 1534 TransformationMatrix().translate(100, 0), FloatPoint3D(100, 100, 0), | 1513 TransformationMatrix().translate(100, 0), FloatPoint3D(100, 100, 0), |
| 1535 nullptr, false); | 1514 false); |
| 1536 paintChunk2.properties.propertyTreeState.setTransform(transform2.get()); | 1515 paintChunk2.properties.propertyTreeState.setTransform(transform2.get()); |
| 1537 | 1516 |
| 1538 EXPECT_FALSE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer, | 1517 EXPECT_FALSE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer, |
| 1539 geometryMapper)); | 1518 geometryMapper)); |
| 1540 } | 1519 } |
| 1541 | 1520 |
| 1542 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayer) { | 1521 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayer) { |
| 1543 PaintChunk chunk1; | 1522 PaintChunk chunk1; |
| 1544 chunk1.properties.propertyTreeState = PropertyTreeState( | 1523 chunk1.properties.propertyTreeState = PropertyTreeState( |
| 1545 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1524 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1546 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); | 1525 EffectPaintPropertyNode::root()); |
| 1547 chunk1.properties.backfaceHidden = true; | 1526 chunk1.properties.backfaceHidden = true; |
| 1548 chunk1.knownToBeOpaque = true; | 1527 chunk1.knownToBeOpaque = true; |
| 1549 chunk1.bounds = FloatRect(0, 0, 30, 40); | 1528 chunk1.bounds = FloatRect(0, 0, 30, 40); |
| 1550 | 1529 |
| 1551 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); | 1530 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); |
| 1552 | 1531 |
| 1553 EXPECT_TRUE(pendingLayer.backfaceHidden); | 1532 EXPECT_TRUE(pendingLayer.backfaceHidden); |
| 1554 EXPECT_TRUE(pendingLayer.knownToBeOpaque); | 1533 EXPECT_TRUE(pendingLayer.knownToBeOpaque); |
| 1555 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); | 1534 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); |
| 1556 | 1535 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1576 EXPECT_TRUE(pendingLayer.backfaceHidden); | 1555 EXPECT_TRUE(pendingLayer.backfaceHidden); |
| 1577 EXPECT_FALSE(pendingLayer.knownToBeOpaque); | 1556 EXPECT_FALSE(pendingLayer.knownToBeOpaque); |
| 1578 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(-5, -25, 45, 85), pendingLayer.bounds); | 1557 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(-5, -25, 45, 85), pendingLayer.bounds); |
| 1579 } | 1558 } |
| 1580 | 1559 |
| 1581 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerWithGeometry) { | 1560 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerWithGeometry) { |
| 1582 RefPtr<TransformPaintPropertyNode> transform = | 1561 RefPtr<TransformPaintPropertyNode> transform = |
| 1583 TransformPaintPropertyNode::create( | 1562 TransformPaintPropertyNode::create( |
| 1584 TransformPaintPropertyNode::root(), | 1563 TransformPaintPropertyNode::root(), |
| 1585 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), | 1564 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), |
| 1586 nullptr, false, 0); | 1565 false, 0); |
| 1587 | 1566 |
| 1588 PaintChunk chunk1; | 1567 PaintChunk chunk1; |
| 1589 chunk1.properties.propertyTreeState = PropertyTreeState( | 1568 chunk1.properties.propertyTreeState = PropertyTreeState( |
| 1590 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1569 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1591 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); | 1570 EffectPaintPropertyNode::root()); |
| 1592 chunk1.bounds = FloatRect(0, 0, 30, 40); | 1571 chunk1.bounds = FloatRect(0, 0, 30, 40); |
| 1593 | 1572 |
| 1594 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); | 1573 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); |
| 1595 | 1574 |
| 1596 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); | 1575 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); |
| 1597 | 1576 |
| 1598 PaintChunk chunk2; | 1577 PaintChunk chunk2; |
| 1599 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; | 1578 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; |
| 1600 chunk2.properties.propertyTreeState.setTransform(transform); | 1579 chunk2.properties.propertyTreeState.setTransform(transform); |
| 1601 chunk2.bounds = FloatRect(0, 0, 50, 60); | 1580 chunk2.bounds = FloatRect(0, 0, 50, 60); |
| 1602 GeometryMapper geometryMapper; | 1581 GeometryMapper geometryMapper; |
| 1603 pendingLayer.add(chunk2, &geometryMapper); | 1582 pendingLayer.add(chunk2, &geometryMapper); |
| 1604 | 1583 |
| 1605 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 70, 85), pendingLayer.bounds); | 1584 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 70, 85), pendingLayer.bounds); |
| 1606 } | 1585 } |
| 1607 | 1586 |
| 1608 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerKnownOpaque) { | 1587 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerKnownOpaque) { |
| 1609 PaintChunk chunk1; | 1588 PaintChunk chunk1; |
| 1610 chunk1.properties.propertyTreeState = PropertyTreeState( | 1589 chunk1.properties.propertyTreeState = PropertyTreeState( |
| 1611 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1590 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1612 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root()); | 1591 EffectPaintPropertyNode::root()); |
| 1613 chunk1.bounds = FloatRect(0, 0, 30, 40); | 1592 chunk1.bounds = FloatRect(0, 0, 30, 40); |
| 1614 chunk1.knownToBeOpaque = false; | 1593 chunk1.knownToBeOpaque = false; |
| 1615 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); | 1594 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); |
| 1616 | 1595 |
| 1617 EXPECT_FALSE(pendingLayer.knownToBeOpaque); | 1596 EXPECT_FALSE(pendingLayer.knownToBeOpaque); |
| 1618 | 1597 |
| 1619 PaintChunk chunk2; | 1598 PaintChunk chunk2; |
| 1620 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; | 1599 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; |
| 1621 chunk2.bounds = FloatRect(0, 0, 25, 35); | 1600 chunk2.bounds = FloatRect(0, 0, 25, 35); |
| 1622 chunk2.knownToBeOpaque = true; | 1601 chunk2.knownToBeOpaque = true; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1633 | 1612 |
| 1634 // Chunk 3 covers the entire layer, so now it's opaque. | 1613 // Chunk 3 covers the entire layer, so now it's opaque. |
| 1635 EXPECT_TRUE(pendingLayer.knownToBeOpaque); | 1614 EXPECT_TRUE(pendingLayer.knownToBeOpaque); |
| 1636 } | 1615 } |
| 1637 | 1616 |
| 1638 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) { | 1617 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) { |
| 1639 CompositorElementId expectedCompositorElementId(2, 0); | 1618 CompositorElementId expectedCompositorElementId(2, 0); |
| 1640 RefPtr<TransformPaintPropertyNode> transform = | 1619 RefPtr<TransformPaintPropertyNode> transform = |
| 1641 TransformPaintPropertyNode::create( | 1620 TransformPaintPropertyNode::create( |
| 1642 TransformPaintPropertyNode::root(), TransformationMatrix().rotate(90), | 1621 TransformPaintPropertyNode::root(), TransformationMatrix().rotate(90), |
| 1643 FloatPoint3D(100, 100, 0), nullptr, false, 0, | 1622 FloatPoint3D(100, 100, 0), false, 0, CompositingReason3DTransform, |
| 1644 CompositingReason3DTransform, expectedCompositorElementId); | 1623 expectedCompositorElementId); |
| 1645 | 1624 |
| 1646 TestPaintArtifact artifact; | 1625 TestPaintArtifact artifact; |
| 1647 artifact | 1626 artifact |
| 1648 .chunk(transform, ClipPaintPropertyNode::root(), | 1627 .chunk(transform, ClipPaintPropertyNode::root(), |
| 1649 EffectPaintPropertyNode::root()) | 1628 EffectPaintPropertyNode::root()) |
| 1650 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); | 1629 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); |
| 1651 update(artifact.build()); | 1630 update(artifact.build()); |
| 1652 | 1631 |
| 1653 EXPECT_EQ(2, elementIdToTransformNodeIndex(expectedCompositorElementId)); | 1632 EXPECT_EQ(2, elementIdToTransformNodeIndex(expectedCompositorElementId)); |
| 1654 } | 1633 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1666 artifact | 1645 artifact |
| 1667 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1646 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1668 effect.get()) | 1647 effect.get()) |
| 1669 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); | 1648 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); |
| 1670 update(artifact.build()); | 1649 update(artifact.build()); |
| 1671 | 1650 |
| 1672 EXPECT_EQ(2, elementIdToEffectNodeIndex(expectedCompositorElementId)); | 1651 EXPECT_EQ(2, elementIdToEffectNodeIndex(expectedCompositorElementId)); |
| 1673 } | 1652 } |
| 1674 | 1653 |
| 1675 } // namespace blink | 1654 } // namespace blink |
| OLD | NEW |