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

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

Issue 2428513004: [SPv2] Create effect nodes for CSS filter (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 19 matching lines...) Expand all
30 namespace { 30 namespace {
31 31
32 using ::testing::Pointee; 32 using ::testing::Pointee;
33 33
34 gfx::Transform translation(SkMScalar x, SkMScalar y) { 34 gfx::Transform translation(SkMScalar x, SkMScalar y) {
35 gfx::Transform transform; 35 gfx::Transform transform;
36 transform.Translate(x, y); 36 transform.Translate(x, y);
37 return transform; 37 return transform;
38 } 38 }
39 39
40 TransformPaintPropertyNode* dummyRootTransform() {
41 DEFINE_STATIC_REF(TransformPaintPropertyNode, rootTransform,
42 (TransformPaintPropertyNode::create(
43 nullptr, TransformationMatrix(), FloatPoint3D())));
44 return rootTransform;
45 }
46
47 ClipPaintPropertyNode* dummyRootClip() {
48 DEFINE_STATIC_REF(ClipPaintPropertyNode, rootClip,
49 (ClipPaintPropertyNode::create(
50 nullptr, dummyRootTransform(),
51 FloatRoundedRect(LayoutRect::infiniteIntRect()))));
52 return rootClip;
53 }
54
40 EffectPaintPropertyNode* dummyRootEffect() { 55 EffectPaintPropertyNode* dummyRootEffect() {
41 DEFINE_STATIC_REF(EffectPaintPropertyNode, node, 56 DEFINE_STATIC_REF(EffectPaintPropertyNode, rootEffect,
42 EffectPaintPropertyNode::create(nullptr, 1.0)); 57 (EffectPaintPropertyNode::create(nullptr, dummyRootTransform (), dummyRootClip(), 1.0, CompositorFilterOperations())));
43 return node; 58 return rootEffect;
44 } 59 }
45 60
46 class WebLayerTreeViewWithCompositorFrameSink 61 class WebLayerTreeViewWithCompositorFrameSink
47 : public WebLayerTreeViewImplForTesting { 62 : public WebLayerTreeViewImplForTesting {
48 public: 63 public:
49 WebLayerTreeViewWithCompositorFrameSink(const cc::LayerTreeSettings& settings) 64 WebLayerTreeViewWithCompositorFrameSink(const cc::LayerTreeSettings& settings)
50 : WebLayerTreeViewImplForTesting(settings) {} 65 : WebLayerTreeViewImplForTesting(settings) {}
51 66
52 // cc::LayerTreeHostClient 67 // cc::LayerTreeHostClient
53 void RequestNewCompositorFrameSink() override { 68 void RequestNewCompositorFrameSink() override {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 update(artifact.build()); 528 update(artifact.build());
514 529
515 ASSERT_EQ(1u, contentLayerCount()); 530 ASSERT_EQ(1u, contentLayerCount());
516 EXPECT_EQ(layer, contentLayerAt(0)); 531 EXPECT_EQ(layer, contentLayerAt(0));
517 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); 532 EXPECT_EQ(gfx::Size(400, 300), layer->bounds());
518 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); 533 EXPECT_EQ(translation(50, 100), layer->screen_space_transform());
519 } 534 }
520 535
521 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { 536 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) {
522 RefPtr<EffectPaintPropertyNode> effect1 = 537 RefPtr<EffectPaintPropertyNode> effect1 =
523 EffectPaintPropertyNode::create(dummyRootEffect(), 0.5); 538 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform(), d ummyRootClip(), 0.5, CompositorFilterOperations());
524 RefPtr<EffectPaintPropertyNode> effect2 = 539 RefPtr<EffectPaintPropertyNode> effect2 =
525 EffectPaintPropertyNode::create(effect1, 0.3); 540 EffectPaintPropertyNode::create(effect1, dummyRootTransform(), dummyRootCl ip(), 0.3, CompositorFilterOperations());
526 RefPtr<EffectPaintPropertyNode> effect3 = 541 RefPtr<EffectPaintPropertyNode> effect3 =
527 EffectPaintPropertyNode::create(dummyRootEffect(), 0.2); 542 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform(), d ummyRootClip(), 0.2, CompositorFilterOperations());
528 543
529 TestPaintArtifact artifact; 544 TestPaintArtifact artifact;
530 artifact.chunk(nullptr, nullptr, effect2.get()) 545 artifact.chunk(nullptr, nullptr, effect2.get())
531 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); 546 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white);
532 artifact.chunk(nullptr, nullptr, effect1.get()) 547 artifact.chunk(nullptr, nullptr, effect1.get())
533 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); 548 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white);
534 artifact.chunk(nullptr, nullptr, effect3.get()) 549 artifact.chunk(nullptr, nullptr, effect3.get())
535 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); 550 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white);
536 update(artifact.build()); 551 update(artifact.build());
537 552
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 607
593 EXPECT_EQ(gfx::ScrollOffset(-7, -9), 608 EXPECT_EQ(gfx::ScrollOffset(-7, -9),
594 scrollTree.current_scroll_offset(contentLayerAt(0)->id())); 609 scrollTree.current_scroll_offset(contentLayerAt(0)->id()));
595 610
596 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 611 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
597 scrollNode.main_thread_scrolling_reasons); 612 scrollNode.main_thread_scrolling_reasons);
598 } 613 }
599 614
600 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { 615 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) {
601 RefPtr<EffectPaintPropertyNode> effect = 616 RefPtr<EffectPaintPropertyNode> effect =
602 EffectPaintPropertyNode::create(dummyRootEffect(), 0.5); 617 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform(), d ummyRootClip(), 0.5, CompositorFilterOperations());
603 618
604 RefPtr<TransformPaintPropertyNode> scrollTranslationA = 619 RefPtr<TransformPaintPropertyNode> scrollTranslationA =
605 TransformPaintPropertyNode::create( 620 TransformPaintPropertyNode::create(
606 nullptr, TransformationMatrix().translate(11, 13), FloatPoint3D()); 621 nullptr, TransformationMatrix().translate(11, 13), FloatPoint3D());
607 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create( 622 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create(
608 nullptr, scrollTranslationA, IntSize(2, 3), IntSize(5, 7), false, true); 623 nullptr, scrollTranslationA, IntSize(2, 3), IntSize(5, 7), false, true);
609 scrollA->addMainThreadScrollingReasons( 624 scrollA->addMainThreadScrollingReasons(
610 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 625 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
611 RefPtr<TransformPaintPropertyNode> scrollTranslationB = 626 RefPtr<TransformPaintPropertyNode> scrollTranslationB =
612 TransformPaintPropertyNode::create( 627 TransformPaintPropertyNode::create(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); 667 scrollTree.current_scroll_offset(contentLayerAt(1)->id()));
653 668
654 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & 669 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons &
655 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 670 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
656 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & 671 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons &
657 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 672 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
658 } 673 }
659 674
660 } // namespace 675 } // namespace
661 } // namespace blink 676 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698