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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PropertyTreeStateTest.cpp

Issue 2144823006: Reuse existing paint property node is possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 5 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/paint/PropertyTreeState.h" 5 #include "platform/graphics/paint/PropertyTreeState.h"
6 6
7 #include "platform/geometry/LayoutRect.h" 7 #include "platform/geometry/LayoutRect.h"
8 #include "platform/graphics/paint/ClipPaintPropertyNode.h" 8 #include "platform/graphics/paint/ClipPaintPropertyNode.h"
9 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 9 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class PropertyTreeStateTest : public ::testing::Test { 15 class PropertyTreeStateTest : public ::testing::Test {
16 public: 16 public:
17 RefPtr<TransformPaintPropertyNode> rootTransformNode; 17 RefPtr<TransformPaintPropertyNode> rootTransformNode;
18 RefPtr<ClipPaintPropertyNode> rootClipNode; 18 RefPtr<ClipPaintPropertyNode> rootClipNode;
19 RefPtr<EffectPaintPropertyNode> rootEffectNode; 19 RefPtr<EffectPaintPropertyNode> rootEffectNode;
20 20
21 PropertyTreeState rootPropertyTreeState() 21 PropertyTreeState rootPropertyTreeState()
22 { 22 {
23 PropertyTreeState state(rootTransformNode.get(), rootClipNode.get(), roo tEffectNode.get()); 23 PropertyTreeState state(rootTransformNode.get(), rootClipNode.get(), roo tEffectNode.get());
24 return state; 24 return state;
25 } 25 }
26 26
27 private: 27 private:
28 void SetUp() override 28 void SetUp() override
29 { 29 {
30 rootTransformNode = TransformPaintPropertyNode::create(TransformationMat rix(), FloatPoint3D(), nullptr); 30 rootTransformNode = TransformPaintPropertyNode::create(nullptr, Transfor mationMatrix(), FloatPoint3D());
31 rootClipNode = ClipPaintPropertyNode::create(rootTransformNode, FloatRou ndedRect(LayoutRect::infiniteIntRect()), nullptr); 31 rootClipNode = ClipPaintPropertyNode::create(nullptr, rootTransformNode, FloatRoundedRect(LayoutRect::infiniteIntRect()));
32 rootEffectNode = EffectPaintPropertyNode::create(1.0, nullptr); 32 rootEffectNode = EffectPaintPropertyNode::create(nullptr, 1.0);
33 } 33 }
34 }; 34 };
35 35
36 TEST_F(PropertyTreeStateTest, LeastCommonAncestor) 36 TEST_F(PropertyTreeStateTest, LeastCommonAncestor)
37 { 37 {
38 TransformationMatrix matrix; 38 TransformationMatrix matrix;
39 RefPtr<TransformPaintPropertyNode> child1 = TransformPaintPropertyNode::crea te(matrix, FloatPoint3D(), rootPropertyTreeState().transform); 39 RefPtr<TransformPaintPropertyNode> child1 = TransformPaintPropertyNode::crea te(rootPropertyTreeState().transform, matrix, FloatPoint3D());
40 RefPtr<TransformPaintPropertyNode> child2 = TransformPaintPropertyNode::crea te(matrix, FloatPoint3D(), rootPropertyTreeState().transform); 40 RefPtr<TransformPaintPropertyNode> child2 = TransformPaintPropertyNode::crea te(rootPropertyTreeState().transform, matrix, FloatPoint3D());
41 41
42 RefPtr<TransformPaintPropertyNode> childOfChild1 = TransformPaintPropertyNod e::create(matrix, FloatPoint3D(), child1); 42 RefPtr<TransformPaintPropertyNode> childOfChild1 = TransformPaintPropertyNod e::create(child1, matrix, FloatPoint3D());
43 RefPtr<TransformPaintPropertyNode> childOfChild2 = TransformPaintPropertyNod e::create(matrix, FloatPoint3D(), child2); 43 RefPtr<TransformPaintPropertyNode> childOfChild2 = TransformPaintPropertyNod e::create(child2, matrix, FloatPoint3D());
44 44
45 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild1.get(), childOfChild2.get())); 45 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild1.get(), childOfChild2.get()));
46 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild1.get(), child2.get())); 46 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild1.get(), child2.get()));
47 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild1.get(), rootPropertyTreeState().tran sform.get())); 47 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild1.get(), rootPropertyTreeState().tran sform.get()));
48 EXPECT_EQ(child1, propertyTreeNearestCommonAncestor<TransformPaintPropertyNo de>(childOfChild1.get(), child1.get())); 48 EXPECT_EQ(child1, propertyTreeNearestCommonAncestor<TransformPaintPropertyNo de>(childOfChild1.get(), child1.get()));
49 49
50 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild2.get(), childOfChild1.get())); 50 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild2.get(), childOfChild1.get()));
51 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild2.get(), child1.get())); 51 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild2.get(), child1.get()));
52 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild2.get(), rootPropertyTreeState().tran sform.get())); 52 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(childOfChild2.get(), rootPropertyTreeState().tran sform.get()));
53 EXPECT_EQ(child2, propertyTreeNearestCommonAncestor<TransformPaintPropertyNo de>(childOfChild2.get(), child2.get())); 53 EXPECT_EQ(child2, propertyTreeNearestCommonAncestor<TransformPaintPropertyNo de>(childOfChild2.get(), child2.get()));
54 54
55 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(child1.get(), child2.get())); 55 EXPECT_EQ(rootPropertyTreeState().transform, propertyTreeNearestCommonAncest or<TransformPaintPropertyNode>(child1.get(), child2.get()));
56 } 56 }
57 57
58 } // namespace blink 58 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698