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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.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/GeometryMapper.h" 5 #include "platform/graphics/paint/GeometryMapper.h"
6 6
7 #include "platform/geometry/GeometryTestHelpers.h" 7 #include "platform/geometry/GeometryTestHelpers.h"
8 #include "platform/geometry/LayoutRect.h" 8 #include "platform/geometry/LayoutRect.h"
9 #include "platform/graphics/paint/ClipPaintPropertyNode.h" 9 #include "platform/graphics/paint/ClipPaintPropertyNode.h"
10 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 10 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 29
30 PrecomputedDataForAncestor& getPrecomputedDataForAncestor(const PropertyTree State& propertyTreeState) 30 PrecomputedDataForAncestor& getPrecomputedDataForAncestor(const PropertyTree State& propertyTreeState)
31 { 31 {
32 return geometryMapper->getPrecomputedDataForAncestor(propertyTreeState); 32 return geometryMapper->getPrecomputedDataForAncestor(propertyTreeState);
33 } 33 }
34 34
35 private: 35 private:
36 void SetUp() override 36 void SetUp() override
37 { 37 {
38 rootTransformNode = TransformPaintPropertyNode::create(TransformationMat rix(), FloatPoint3D(), nullptr); 38 rootTransformNode = TransformPaintPropertyNode::create(nullptr, Transfor mationMatrix(), FloatPoint3D());
39 rootClipNode = ClipPaintPropertyNode::create(rootTransformNode, FloatRou ndedRect(LayoutRect::infiniteIntRect()), nullptr); 39 rootClipNode = ClipPaintPropertyNode::create(nullptr, rootTransformNode, FloatRoundedRect(LayoutRect::infiniteIntRect()));
40 rootEffectNode = EffectPaintPropertyNode::create(1.0, nullptr); 40 rootEffectNode = EffectPaintPropertyNode::create(nullptr, 1.0);
41 geometryMapper = wrapUnique(new GeometryMapper()); 41 geometryMapper = wrapUnique(new GeometryMapper());
42 } 42 }
43 43
44 void TearDown() override 44 void TearDown() override
45 { 45 {
46 geometryMapper.reset(); 46 geometryMapper.reset();
47 } 47 }
48 }; 48 };
49 49
50 const static float kTestEpsilon = 1e-6; 50 const static float kTestEpsilon = 1e-6;
(...skipping 22 matching lines...) Expand all
73 73
74 TEST_F(GeometryMapperTest, Root) 74 TEST_F(GeometryMapperTest, Root)
75 { 75 {
76 FloatRect input(0, 0, 100, 100); 76 FloatRect input(0, 0, 100, 100);
77 77
78 CHECK_MAPPINGS(input, input, input, rootTransformNode->matrix(), rootClipNod e->clipRect().rect(), rootPropertyTreeState(), rootPropertyTreeState()); 78 CHECK_MAPPINGS(input, input, input, rootTransformNode->matrix(), rootClipNod e->clipRect().rect(), rootPropertyTreeState(), rootPropertyTreeState());
79 } 79 }
80 80
81 TEST_F(GeometryMapperTest, IdentityTransform) 81 TEST_F(GeometryMapperTest, IdentityTransform)
82 { 82 {
83 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(TransformationMatrix(), FloatPoint3D(), rootPropertyTreeState().transform) ; 83 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(rootPropertyTreeState().transform, TransformationMatrix(), FloatPoint3D()) ;
84 PropertyTreeState localState = rootPropertyTreeState(); 84 PropertyTreeState localState = rootPropertyTreeState();
85 localState.transform = transform.get(); 85 localState.transform = transform.get();
86 86
87 FloatRect input(0, 0, 100, 100); 87 FloatRect input(0, 0, 100, 100);
88 88
89 CHECK_MAPPINGS(input, input, input, transform->matrix(), rootClipNode->clipR ect().rect(), localState, rootPropertyTreeState()); 89 CHECK_MAPPINGS(input, input, input, transform->matrix(), rootClipNode->clipR ect().rect(), localState, rootPropertyTreeState());
90 } 90 }
91 91
92 TEST_F(GeometryMapperTest, TranslationTransform) 92 TEST_F(GeometryMapperTest, TranslationTransform)
93 { 93 {
94 TransformationMatrix transformMatrix; 94 TransformationMatrix transformMatrix;
95 transformMatrix.translate(20, 10); 95 transformMatrix.translate(20, 10);
96 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(transformMatrix, FloatPoint3D(), rootPropertyTreeState().transform); 96 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(rootPropertyTreeState().transform, transformMatrix, FloatPoint3D());
97 PropertyTreeState localState = rootPropertyTreeState(); 97 PropertyTreeState localState = rootPropertyTreeState();
98 localState.transform = transform.get(); 98 localState.transform = transform.get();
99 99
100 FloatRect input(0, 0, 100, 100); 100 FloatRect input(0, 0, 100, 100);
101 FloatRect output = transformMatrix.mapRect(input); 101 FloatRect output = transformMatrix.mapRect(input);
102 102
103 CHECK_MAPPINGS(input, output, output, transform->matrix(), rootClipNode->cli pRect().rect(), localState, rootPropertyTreeState()); 103 CHECK_MAPPINGS(input, output, output, transform->matrix(), rootClipNode->cli pRect().rect(), localState, rootPropertyTreeState());
104 104
105 bool success = false; 105 bool success = false;
106 EXPECT_RECT_EQ(input, 106 EXPECT_RECT_EQ(input,
107 geometryMapper->ancestorToLocalRect(output, localState, rootPropertyTree State(), success)); 107 geometryMapper->ancestorToLocalRect(output, localState, rootPropertyTree State(), success));
108 EXPECT_TRUE(success); 108 EXPECT_TRUE(success);
109 } 109 }
110 110
111 TEST_F(GeometryMapperTest, RotationAndScaleTransform) 111 TEST_F(GeometryMapperTest, RotationAndScaleTransform)
112 { 112 {
113 TransformationMatrix transformMatrix; 113 TransformationMatrix transformMatrix;
114 transformMatrix.rotate(45); 114 transformMatrix.rotate(45);
115 transformMatrix.scale(2); 115 transformMatrix.scale(2);
116 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(transformMatrix, FloatPoint3D(0, 0, 0), rootPropertyTreeState().transform) ; 116 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(rootPropertyTreeState().transform, transformMatrix, FloatPoint3D(0, 0, 0)) ;
117 PropertyTreeState localState = rootPropertyTreeState(); 117 PropertyTreeState localState = rootPropertyTreeState();
118 localState.transform = transform.get(); 118 localState.transform = transform.get();
119 119
120 FloatRect input(0, 0, 100, 100); 120 FloatRect input(0, 0, 100, 100);
121 FloatRect output = transformMatrix.mapRect(input); 121 FloatRect output = transformMatrix.mapRect(input);
122 122
123 CHECK_MAPPINGS(input, output, output, transformMatrix, rootClipNode->clipRec t().rect(), localState, rootPropertyTreeState()); 123 CHECK_MAPPINGS(input, output, output, transformMatrix, rootClipNode->clipRec t().rect(), localState, rootPropertyTreeState());
124 } 124 }
125 125
126 TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) 126 TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin)
127 { 127 {
128 TransformationMatrix transformMatrix; 128 TransformationMatrix transformMatrix;
129 transformMatrix.rotate(45); 129 transformMatrix.rotate(45);
130 transformMatrix.scale(2); 130 transformMatrix.scale(2);
131 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(transformMatrix, FloatPoint3D(50, 50, 0), rootPropertyTreeState().transfor m); 131 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(rootPropertyTreeState().transform, transformMatrix, FloatPoint3D(50, 50, 0 ));
132 PropertyTreeState localState = rootPropertyTreeState(); 132 PropertyTreeState localState = rootPropertyTreeState();
133 localState.transform = transform.get(); 133 localState.transform = transform.get();
134 134
135 FloatRect input(0, 0, 100, 100); 135 FloatRect input(0, 0, 100, 100);
136 transformMatrix.applyTransformOrigin(50, 50, 0); 136 transformMatrix.applyTransformOrigin(50, 50, 0);
137 FloatRect output = transformMatrix.mapRect(input); 137 FloatRect output = transformMatrix.mapRect(input);
138 138
139 CHECK_MAPPINGS(input, output, output, transformMatrix, rootClipNode->clipRec t().rect(), localState, rootPropertyTreeState()); 139 CHECK_MAPPINGS(input, output, output, transformMatrix, rootClipNode->clipRec t().rect(), localState, rootPropertyTreeState());
140 } 140 }
141 141
142 TEST_F(GeometryMapperTest, NestedTransforms) 142 TEST_F(GeometryMapperTest, NestedTransforms)
143 { 143 {
144 TransformationMatrix rotateTransform; 144 TransformationMatrix rotateTransform;
145 rotateTransform.rotate(45); 145 rotateTransform.rotate(45);
146 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode:: create(rotateTransform, FloatPoint3D(), rootPropertyTreeState().transform); 146 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode:: create(rootPropertyTreeState().transform, rotateTransform, FloatPoint3D());
147 147
148 TransformationMatrix scaleTransform; 148 TransformationMatrix scaleTransform;
149 scaleTransform.scale(2); 149 scaleTransform.scale(2);
150 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode:: create(scaleTransform, FloatPoint3D(), transform1); 150 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode:: create(transform1, scaleTransform, FloatPoint3D());
151 151
152 PropertyTreeState localState = rootPropertyTreeState(); 152 PropertyTreeState localState = rootPropertyTreeState();
153 localState.transform = transform2.get(); 153 localState.transform = transform2.get();
154 154
155 FloatRect input(0, 0, 100, 100); 155 FloatRect input(0, 0, 100, 100);
156 TransformationMatrix final = rotateTransform * scaleTransform; 156 TransformationMatrix final = rotateTransform * scaleTransform;
157 FloatRect output = final.mapRect(input); 157 FloatRect output = final.mapRect(input);
158 158
159 CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect() , localState, rootPropertyTreeState()); 159 CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect() , localState, rootPropertyTreeState());
160 160
161 // Check the cached matrix for the intermediate transform. 161 // Check the cached matrix for the intermediate transform.
162 EXPECT_EQ(rotateTransform, getPrecomputedDataForAncestor(rootPropertyTreeSta te()).toAncestorTransforms.get(transform1.get())); 162 EXPECT_EQ(rotateTransform, getPrecomputedDataForAncestor(rootPropertyTreeSta te()).toAncestorTransforms.get(transform1.get()));
163 } 163 }
164 164
165 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) 165 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination)
166 { 166 {
167 TransformationMatrix rotateTransform; 167 TransformationMatrix rotateTransform;
168 rotateTransform.rotate(45); 168 rotateTransform.rotate(45);
169 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode:: create(rotateTransform, FloatPoint3D(), rootPropertyTreeState().transform); 169 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode:: create(rootPropertyTreeState().transform, rotateTransform, FloatPoint3D());
170 170
171 TransformationMatrix scaleTransform; 171 TransformationMatrix scaleTransform;
172 scaleTransform.scale(2); 172 scaleTransform.scale(2);
173 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode:: create(scaleTransform, FloatPoint3D(), transform1); 173 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode:: create(transform1, scaleTransform, FloatPoint3D());
174 174
175 PropertyTreeState localState = rootPropertyTreeState(); 175 PropertyTreeState localState = rootPropertyTreeState();
176 localState.transform = transform2.get(); 176 localState.transform = transform2.get();
177 177
178 PropertyTreeState intermediateState = rootPropertyTreeState(); 178 PropertyTreeState intermediateState = rootPropertyTreeState();
179 intermediateState.transform = transform1.get(); 179 intermediateState.transform = transform1.get();
180 180
181 FloatRect input(0, 0, 100, 100); 181 FloatRect input(0, 0, 100, 100);
182 FloatRect output = scaleTransform.mapRect(input); 182 FloatRect output = scaleTransform.mapRect(input);
183 183
184 CHECK_MAPPINGS(input, output, output, scaleTransform, rootClipNode->clipRect ().rect(), localState, intermediateState); 184 CHECK_MAPPINGS(input, output, output, scaleTransform, rootClipNode->clipRect ().rect(), localState, intermediateState);
185 } 185 }
186 186
187 TEST_F(GeometryMapperTest, SimpleClip) 187 TEST_F(GeometryMapperTest, SimpleClip)
188 { 188 {
189 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootTrans formNode, FloatRoundedRect(10, 10, 50, 50), rootClipNode); 189 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootClipN ode, rootTransformNode, FloatRoundedRect(10, 10, 50, 50));
190 190
191 PropertyTreeState localState = rootPropertyTreeState(); 191 PropertyTreeState localState = rootPropertyTreeState();
192 localState.clip = clip.get(); 192 localState.clip = clip.get();
193 193
194 FloatRect input(0, 0, 100, 100); 194 FloatRect input(0, 0, 100, 100);
195 FloatRect output(10, 10, 50, 50); 195 FloatRect output(10, 10, 50, 50);
196 196
197 CHECK_MAPPINGS( 197 CHECK_MAPPINGS(
198 input, // Input 198 input, // Input
199 output, // Visual rect 199 output, // Visual rect
200 input, // Transformed rect (not clipped). 200 input, // Transformed rect (not clipped).
201 rootTransformNode->matrix(), // Transform matrix to ancestor space 201 rootTransformNode->matrix(), // Transform matrix to ancestor space
202 clip->clipRect().rect(), // Clip rect in ancestor space 202 clip->clipRect().rect(), // Clip rect in ancestor space
203 localState, rootPropertyTreeState()); 203 localState, rootPropertyTreeState());
204 } 204 }
205 205
206 TEST_F(GeometryMapperTest, ClipBeforeTransform) 206 TEST_F(GeometryMapperTest, ClipBeforeTransform)
207 { 207 {
208 TransformationMatrix rotateTransform; 208 TransformationMatrix rotateTransform;
209 rotateTransform.rotate(45); 209 rotateTransform.rotate(45);
210 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(rotateTransform, FloatPoint3D(), rootPropertyTreeState().transform); 210 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(rootPropertyTreeState().transform, rotateTransform, FloatPoint3D());
211 211
212 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(transform .get(), FloatRoundedRect(10, 10, 50, 50), rootClipNode); 212 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootClipN ode, transform.get(), FloatRoundedRect(10, 10, 50, 50));
213 213
214 PropertyTreeState localState = rootPropertyTreeState(); 214 PropertyTreeState localState = rootPropertyTreeState();
215 localState.clip = clip.get(); 215 localState.clip = clip.get();
216 localState.transform = transform.get(); 216 localState.transform = transform.get();
217 217
218 FloatRect input(0, 0, 100, 100); 218 FloatRect input(0, 0, 100, 100);
219 FloatRect output(input); 219 FloatRect output(input);
220 output.intersect(clip->clipRect().rect()); 220 output.intersect(clip->clipRect().rect());
221 output = rotateTransform.mapRect(output); 221 output = rotateTransform.mapRect(output);
222 222
223 CHECK_MAPPINGS( 223 CHECK_MAPPINGS(
224 input, // Input 224 input, // Input
225 output, // Visual rect 225 output, // Visual rect
226 rotateTransform.mapRect(input), // Transformed rect (not clipped). 226 rotateTransform.mapRect(input), // Transformed rect (not clipped).
227 rotateTransform, // Transform matrix to ancestor space 227 rotateTransform, // Transform matrix to ancestor space
228 rotateTransform.mapRect(clip->clipRect().rect()), // Clip rect in ancest or space 228 rotateTransform.mapRect(clip->clipRect().rect()), // Clip rect in ancest or space
229 localState, rootPropertyTreeState()); 229 localState, rootPropertyTreeState());
230 } 230 }
231 231
232 TEST_F(GeometryMapperTest, ClipAfterTransform) 232 TEST_F(GeometryMapperTest, ClipAfterTransform)
233 { 233 {
234 TransformationMatrix rotateTransform; 234 TransformationMatrix rotateTransform;
235 rotateTransform.rotate(45); 235 rotateTransform.rotate(45);
236 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(rotateTransform, FloatPoint3D(), rootPropertyTreeState().transform); 236 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(rootPropertyTreeState().transform, rotateTransform, FloatPoint3D());
237 237
238 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootTrans formNode.get(), FloatRoundedRect(10, 10, 200, 200), rootClipNode); 238 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(rootClipN ode, rootTransformNode.get(), FloatRoundedRect(10, 10, 200, 200));
239 239
240 PropertyTreeState localState = rootPropertyTreeState(); 240 PropertyTreeState localState = rootPropertyTreeState();
241 localState.clip = clip.get(); 241 localState.clip = clip.get();
242 localState.transform = transform.get(); 242 localState.transform = transform.get();
243 243
244 FloatRect input(0, 0, 100, 100); 244 FloatRect input(0, 0, 100, 100);
245 FloatRect output(input); 245 FloatRect output(input);
246 output = rotateTransform.mapRect(output); 246 output = rotateTransform.mapRect(output);
247 output.intersect(clip->clipRect().rect()); 247 output.intersect(clip->clipRect().rect());
248 248
249 CHECK_MAPPINGS( 249 CHECK_MAPPINGS(
250 input, // Input 250 input, // Input
251 output, // Visual rect 251 output, // Visual rect
252 rotateTransform.mapRect(input), // Transformed rect (not clipped) 252 rotateTransform.mapRect(input), // Transformed rect (not clipped)
253 rotateTransform, // Transform matrix to ancestor space 253 rotateTransform, // Transform matrix to ancestor space
254 clip->clipRect().rect(), // Clip rect in ancestor space 254 clip->clipRect().rect(), // Clip rect in ancestor space
255 localState, rootPropertyTreeState()); 255 localState, rootPropertyTreeState());
256 } 256 }
257 257
258 TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween) 258 TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween)
259 { 259 {
260 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(rootTran sformNode.get(), FloatRoundedRect(10, 10, 200, 200), rootClipNode); 260 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(rootClip Node, rootTransformNode.get(), FloatRoundedRect(10, 10, 200, 200));
261 261
262 TransformationMatrix rotateTransform; 262 TransformationMatrix rotateTransform;
263 rotateTransform.rotate(45); 263 rotateTransform.rotate(45);
264 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(rotateTransform, FloatPoint3D(), rootPropertyTreeState().transform); 264 RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::c reate(rootPropertyTreeState().transform, rotateTransform, FloatPoint3D());
265 265
266 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(transfor m.get(), FloatRoundedRect(10, 10, 200, 200), clip1.get()); 266 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(clip1, t ransform.get(), FloatRoundedRect(10, 10, 200, 200));
267 267
268 FloatRect input(0, 0, 100, 100); 268 FloatRect input(0, 0, 100, 100);
269 269
270 { 270 {
271 PropertyTreeState localState = rootPropertyTreeState(); 271 PropertyTreeState localState = rootPropertyTreeState();
272 localState.clip = clip1.get(); 272 localState.clip = clip1.get();
273 localState.transform = transform.get(); 273 localState.transform = transform.get();
274 274
275 FloatRect output(input); 275 FloatRect output(input);
276 output = rotateTransform.mapRect(output); 276 output = rotateTransform.mapRect(output);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 mappedClip, // Clip rect in ancestor space 310 mappedClip, // Clip rect in ancestor space
311 localState, rootPropertyTreeState()); 311 localState, rootPropertyTreeState());
312 } 312 }
313 } 313 }
314 314
315 TEST_F(GeometryMapperTest, SiblingTransforms) 315 TEST_F(GeometryMapperTest, SiblingTransforms)
316 { 316 {
317 // These transforms are siblings. Thus mapping from one to the other require s going through the root. 317 // These transforms are siblings. Thus mapping from one to the other require s going through the root.
318 TransformationMatrix rotateTransform1; 318 TransformationMatrix rotateTransform1;
319 rotateTransform1.rotate(45); 319 rotateTransform1.rotate(45);
320 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode:: create(rotateTransform1, FloatPoint3D(), rootPropertyTreeState().transform); 320 RefPtr<TransformPaintPropertyNode> transform1 = TransformPaintPropertyNode:: create(rootPropertyTreeState().transform, rotateTransform1, FloatPoint3D());
321 321
322 TransformationMatrix rotateTransform2; 322 TransformationMatrix rotateTransform2;
323 rotateTransform2.rotate(-45); 323 rotateTransform2.rotate(-45);
324 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode:: create(rotateTransform2, FloatPoint3D(), rootPropertyTreeState().transform); 324 RefPtr<TransformPaintPropertyNode> transform2 = TransformPaintPropertyNode:: create(rootPropertyTreeState().transform, rotateTransform2, FloatPoint3D());
325 325
326 PropertyTreeState transform1State = rootPropertyTreeState(); 326 PropertyTreeState transform1State = rootPropertyTreeState();
327 transform1State.transform = transform1; 327 transform1State.transform = transform1;
328 PropertyTreeState transform2State = rootPropertyTreeState(); 328 PropertyTreeState transform2State = rootPropertyTreeState();
329 transform2State.transform = transform2; 329 transform2State.transform = transform2;
330 330
331 bool success; 331 bool success;
332 FloatRect input(0, 0, 100, 100); 332 FloatRect input(0, 0, 100, 100);
333 FloatRect result = geometryMapper->localToVisualRectInAncestorSpace(input, t ransform1State, transform2State, success); 333 FloatRect result = geometryMapper->localToVisualRectInAncestorSpace(input, t ransform1State, transform2State, success);
334 // Fails, because the transform2state is not an ancestor of transform1State. 334 // Fails, because the transform2state is not an ancestor of transform1State.
335 EXPECT_FALSE(success); 335 EXPECT_FALSE(success);
336 EXPECT_RECT_EQ(input, result); 336 EXPECT_RECT_EQ(input, result);
337 337
338 result = geometryMapper->localToVisualRectInAncestorSpace(input, transform2S tate, transform1State, success); 338 result = geometryMapper->localToVisualRectInAncestorSpace(input, transform2S tate, transform1State, success);
339 // Fails, because the transform1state is not an ancestor of transform2State. 339 // Fails, because the transform1state is not an ancestor of transform2State.
340 EXPECT_FALSE(success); 340 EXPECT_FALSE(success);
341 EXPECT_RECT_EQ(input, result); 341 EXPECT_RECT_EQ(input, result);
342 342
343 FloatRect expected = rotateTransform2.inverse().mapRect(rotateTransform1.map Rect(input)); 343 FloatRect expected = rotateTransform2.inverse().mapRect(rotateTransform1.map Rect(input));
344 result = geometryMapper->mapToVisualRectInDestinationSpace(input, transform1 State, transform2State, success); 344 result = geometryMapper->mapToVisualRectInDestinationSpace(input, transform1 State, transform2State, success);
345 EXPECT_TRUE(success); 345 EXPECT_TRUE(success);
346 EXPECT_RECT_EQ(expected, result); 346 EXPECT_RECT_EQ(expected, result);
347 } 347 }
348 348
349 } // namespace blink 349 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698