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

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

Issue 2334403002: Construct cc scroll tree from blink [spv2] (Closed)
Patch Set: Better comments Created 4 years, 3 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_output_surface.h" 10 #include "cc/test/fake_output_surface.h"
11 #include "cc/test/geometry_test_utils.h" 11 #include "cc/test/geometry_test_utils.h"
12 #include "cc/trees/clip_node.h" 12 #include "cc/trees/clip_node.h"
13 #include "cc/trees/effect_node.h" 13 #include "cc/trees/effect_node.h"
14 #include "cc/trees/layer_tree_host.h" 14 #include "cc/trees/layer_tree_host.h"
15 #include "cc/trees/scroll_node.h"
15 #include "cc/trees/transform_node.h" 16 #include "cc/trees/transform_node.h"
16 #include "platform/RuntimeEnabledFeatures.h" 17 #include "platform/RuntimeEnabledFeatures.h"
17 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 18 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
18 #include "platform/graphics/paint/PaintArtifact.h" 19 #include "platform/graphics/paint/PaintArtifact.h"
20 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
19 #include "platform/testing/PictureMatchers.h" 21 #include "platform/testing/PictureMatchers.h"
20 #include "platform/testing/TestPaintArtifact.h" 22 #include "platform/testing/TestPaintArtifact.h"
21 #include "platform/testing/WebLayerTreeViewImplForTesting.h" 23 #include "platform/testing/WebLayerTreeViewImplForTesting.h"
22 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
24 #include <memory> 26 #include <memory>
25 27
26 namespace blink { 28 namespace blink {
27 namespace { 29 namespace {
28 30
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 532
531 const cc::EffectNode& convertedEffect3 = *effectTree.Node(5); 533 const cc::EffectNode& convertedEffect3 = *effectTree.Node(5);
532 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id); 534 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id);
533 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); 535 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity);
534 536
535 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); 537 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index());
536 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); 538 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index());
537 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); 539 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index());
538 } 540 }
539 541
542 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode)
543 {
544 RefPtr<TransformPaintPropertyNode> scrollTranslation = TransformPaintPropert yNode::create(
545 nullptr, TransformationMatrix().translate(7, 9), FloatPoint3D());
546 RefPtr<ScrollPaintPropertyNode> scroll = ScrollPaintPropertyNode::create(
547 nullptr, scrollTranslation, IntSize(11, 13), IntSize(27, 31), true, fals e);
548
549 TestPaintArtifact artifact;
550 artifact.chunk(scrollTranslation, nullptr, nullptr, scroll)
551 .rectDrawing(FloatRect(11, 13, 17, 19), Color::white);
552 update(artifact.build());
553
554 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree;
555 // Node #0 reserved for null; #1 for root render surface.
556 ASSERT_EQ(3u, scrollTree.size());
557 const cc::ScrollNode& scrollNode = *scrollTree.Node(2);
558 EXPECT_EQ(gfx::Size(11, 13), scrollNode.scroll_clip_layer_bounds);
559 EXPECT_EQ(gfx::Size(27, 31), scrollNode.bounds);
560 EXPECT_TRUE(scrollNode.user_scrollable_horizontal);
561 EXPECT_FALSE(scrollNode.user_scrollable_vertical);
562 EXPECT_EQ(1, scrollNode.parent_id);
563
564 const cc::TransformTree& transformTree = propertyTrees().transform_tree;
565 const cc::TransformNode& transformNode = *transformTree.Node(scrollNode.tran sform_id);
566 EXPECT_TRUE(transformNode.local.IsIdentity());
567
568 EXPECT_EQ(gfx::ScrollOffset(-7, -9), scrollTree.current_scroll_offset(conten tLayerAt(0)->id()));
569 }
570
571 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes)
572 {
573 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create(dum myRootEffect(), 0.5);
574
575 RefPtr<TransformPaintPropertyNode> scrollTranslationA = TransformPaintProper tyNode::create(
576 nullptr, TransformationMatrix().translate(11, 13), FloatPoint3D());
577 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create(
578 nullptr, scrollTranslationA, IntSize(2, 3), IntSize(5, 7), false, true);
579 RefPtr<TransformPaintPropertyNode> scrollTranslationB = TransformPaintProper tyNode::create(
580 scrollTranslationA, TransformationMatrix().translate(37, 41), FloatPoint 3D());
581 RefPtr<ScrollPaintPropertyNode> scrollB = ScrollPaintPropertyNode::create(
582 scrollA, scrollTranslationB, IntSize(19, 23), IntSize(29, 31), true, fal se);
583
584 TestPaintArtifact artifact;
585 artifact.chunk(scrollTranslationA, nullptr, effect, scrollA)
586 .rectDrawing(FloatRect(7, 11, 13, 17), Color::white);
587 artifact.chunk(scrollTranslationB, nullptr, effect, scrollB)
588 .rectDrawing(FloatRect(1, 2, 3, 5), Color::white);
589 update(artifact.build());
590
591 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree;
592 // Node #0 reserved for null; #1 for root render surface.
593 ASSERT_EQ(4u, scrollTree.size());
594 const cc::ScrollNode& scrollNodeA = *scrollTree.Node(2);
595 EXPECT_EQ(gfx::Size(2, 3), scrollNodeA.scroll_clip_layer_bounds);
596 EXPECT_EQ(gfx::Size(5, 7), scrollNodeA.bounds);
597 EXPECT_FALSE(scrollNodeA.user_scrollable_horizontal);
598 EXPECT_TRUE(scrollNodeA.user_scrollable_vertical);
599 EXPECT_EQ(1, scrollNodeA.parent_id);
600 const cc::ScrollNode& scrollNodeB = *scrollTree.Node(3);
601 EXPECT_EQ(gfx::Size(19, 23), scrollNodeB.scroll_clip_layer_bounds);
602 EXPECT_EQ(gfx::Size(29, 31), scrollNodeB.bounds);
603 EXPECT_TRUE(scrollNodeB.user_scrollable_horizontal);
604 EXPECT_FALSE(scrollNodeB.user_scrollable_vertical);
605 EXPECT_EQ(scrollNodeA.id, scrollNodeB.parent_id);
606
607 const cc::TransformTree& transformTree = propertyTrees().transform_tree;
608 const cc::TransformNode& transformNodeA = *transformTree.Node(scrollNodeA.tr ansform_id);
609 EXPECT_TRUE(transformNodeA.local.IsIdentity());
610 const cc::TransformNode& transformNodeB = *transformTree.Node(scrollNodeB.tr ansform_id);
611 EXPECT_TRUE(transformNodeB.local.IsIdentity());
612
613 EXPECT_EQ(gfx::ScrollOffset(-11, -13), scrollTree.current_scroll_offset(cont entLayerAt(0)->id()));
614 EXPECT_EQ(gfx::ScrollOffset(-37, -41), scrollTree.current_scroll_offset(cont entLayerAt(1)->id()));
615 }
616
540 } // namespace 617 } // namespace
541 } // namespace blink 618 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698