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