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

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

Issue 2751433002: [SPv2] Flatten property trees in PaintRecordBuilder into a single display list. (Closed)
Patch Set: none Created 3 years, 8 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/BoxReflection.h" 9 #include "platform/graphics/BoxReflection.h"
10 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" 10 #include "platform/graphics/filters/SkiaImageFilterBuilder.h"
11 #include "platform/graphics/paint/ClipPaintPropertyNode.h" 11 #include "platform/graphics/paint/ClipPaintPropertyNode.h"
12 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 12 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
13 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 13 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
14 #include "platform/testing/PaintPropertyTestHelpers.h" 14 #include "platform/testing/PaintPropertyTestHelpers.h"
15 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 15 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class GeometryMapperTest : public ::testing::Test, 20 class GeometryMapperTest : public ::testing::Test,
21 public ScopedSlimmingPaintV2ForTest { 21 public ScopedSlimmingPaintV2ForTest {
22 public: 22 public:
23 GeometryMapperTest() : ScopedSlimmingPaintV2ForTest(true) {} 23 GeometryMapperTest() : ScopedSlimmingPaintV2ForTest(true) {}
24 24
25 std::unique_ptr<GeometryMapper> geometryMapper; 25 std::unique_ptr<GeometryMapper> geometryMapper;
26 26
27 PropertyTreeState rootPropertyTreeState() {
28 PropertyTreeState state(TransformPaintPropertyNode::root(),
29 ClipPaintPropertyNode::root(),
30 EffectPaintPropertyNode::root());
31 return state;
32 }
33
34 const FloatClipRect* getClip( 27 const FloatClipRect* getClip(
35 const ClipPaintPropertyNode* descendantClip, 28 const ClipPaintPropertyNode* descendantClip,
36 const PropertyTreeState& ancestorPropertyTreeState) { 29 const PropertyTreeState& ancestorPropertyTreeState) {
37 GeometryMapperClipCache::ClipAndTransform clipAndTransform( 30 GeometryMapperClipCache::ClipAndTransform clipAndTransform(
38 ancestorPropertyTreeState.clip(), 31 ancestorPropertyTreeState.clip(),
39 ancestorPropertyTreeState.transform()); 32 ancestorPropertyTreeState.transform());
40 return descendantClip->getClipCache().getCachedClip(clipAndTransform); 33 return descendantClip->getClipCache().getCachedClip(clipAndTransform);
41 } 34 }
42 35
43 const TransformationMatrix* getTransform( 36 const TransformationMatrix* getTransform(
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 << " (hasRadius: " << outputClipForTesting->hasRadius() << ")"; \ 154 << " (hasRadius: " << outputClipForTesting->hasRadius() << ")"; \
162 } \ 155 } \
163 } while (false) 156 } while (false)
164 157
165 TEST_F(GeometryMapperTest, Root) { 158 TEST_F(GeometryMapperTest, Root) {
166 FloatRect input(0, 0, 100, 100); 159 FloatRect input(0, 0, 100, 100);
167 160
168 bool hasRadius = false; 161 bool hasRadius = false;
169 CHECK_MAPPINGS(input, input, input, 162 CHECK_MAPPINGS(input, input, input,
170 TransformPaintPropertyNode::root()->matrix(), FloatClipRect(), 163 TransformPaintPropertyNode::root()->matrix(), FloatClipRect(),
171 rootPropertyTreeState(), rootPropertyTreeState(), hasRadius); 164 PropertyTreeState::root(), PropertyTreeState::root(),
165 hasRadius);
172 } 166 }
173 167
174 TEST_F(GeometryMapperTest, IdentityTransform) { 168 TEST_F(GeometryMapperTest, IdentityTransform) {
175 RefPtr<TransformPaintPropertyNode> transform = 169 RefPtr<TransformPaintPropertyNode> transform =
176 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 170 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
177 TransformationMatrix(), 171 TransformationMatrix(),
178 FloatPoint3D()); 172 FloatPoint3D());
179 PropertyTreeState localState = rootPropertyTreeState(); 173 PropertyTreeState localState = PropertyTreeState::root();
180 localState.setTransform(transform.get()); 174 localState.setTransform(transform.get());
181 175
182 FloatRect input(0, 0, 100, 100); 176 FloatRect input(0, 0, 100, 100);
183 177
184 bool hasRadius = false; 178 bool hasRadius = false;
185 CHECK_MAPPINGS(input, input, input, transform->matrix(), FloatClipRect(), 179 CHECK_MAPPINGS(input, input, input, transform->matrix(), FloatClipRect(),
186 localState, rootPropertyTreeState(), hasRadius); 180 localState, PropertyTreeState::root(), hasRadius);
187 } 181 }
188 182
189 TEST_F(GeometryMapperTest, TranslationTransform) { 183 TEST_F(GeometryMapperTest, TranslationTransform) {
190 TransformationMatrix transformMatrix; 184 TransformationMatrix transformMatrix;
191 transformMatrix.translate(20, 10); 185 transformMatrix.translate(20, 10);
192 RefPtr<TransformPaintPropertyNode> transform = 186 RefPtr<TransformPaintPropertyNode> transform =
193 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 187 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
194 transformMatrix, FloatPoint3D()); 188 transformMatrix, FloatPoint3D());
195 PropertyTreeState localState = rootPropertyTreeState(); 189 PropertyTreeState localState = PropertyTreeState::root();
196 localState.setTransform(transform.get()); 190 localState.setTransform(transform.get());
197 191
198 FloatRect input(0, 0, 100, 100); 192 FloatRect input(0, 0, 100, 100);
199 FloatRect output = transformMatrix.mapRect(input); 193 FloatRect output = transformMatrix.mapRect(input);
200 194
201 bool hasRadius = false; 195 bool hasRadius = false;
202 CHECK_MAPPINGS(input, output, output, transform->matrix(), FloatClipRect(), 196 CHECK_MAPPINGS(input, output, output, transform->matrix(), FloatClipRect(),
203 localState, rootPropertyTreeState(), hasRadius); 197 localState, PropertyTreeState::root(), hasRadius);
204 198
205 geometryMapper->ancestorToLocalRect(rootPropertyTreeState().transform(), 199 geometryMapper->ancestorToLocalRect(TransformPaintPropertyNode::root(),
206 localState.transform(), output); 200 localState.transform(), output);
207 EXPECT_RECT_EQ(input, output); 201 EXPECT_RECT_EQ(input, output);
208 } 202 }
209 203
210 TEST_F(GeometryMapperTest, RotationAndScaleTransform) { 204 TEST_F(GeometryMapperTest, RotationAndScaleTransform) {
211 TransformationMatrix transformMatrix; 205 TransformationMatrix transformMatrix;
212 transformMatrix.rotate(45); 206 transformMatrix.rotate(45);
213 transformMatrix.scale(2); 207 transformMatrix.scale(2);
214 RefPtr<TransformPaintPropertyNode> transform = 208 RefPtr<TransformPaintPropertyNode> transform =
215 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 209 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
216 transformMatrix, 210 transformMatrix,
217 FloatPoint3D(0, 0, 0)); 211 FloatPoint3D(0, 0, 0));
218 PropertyTreeState localState = rootPropertyTreeState(); 212 PropertyTreeState localState = PropertyTreeState::root();
219 localState.setTransform(transform.get()); 213 localState.setTransform(transform.get());
220 214
221 FloatRect input(0, 0, 100, 100); 215 FloatRect input(0, 0, 100, 100);
222 FloatRect output = transformMatrix.mapRect(input); 216 FloatRect output = transformMatrix.mapRect(input);
223 217
224 bool hasRadius = false; 218 bool hasRadius = false;
225 CHECK_MAPPINGS(input, output, output, transformMatrix, FloatClipRect(), 219 CHECK_MAPPINGS(input, output, output, transformMatrix, FloatClipRect(),
226 localState, rootPropertyTreeState(), hasRadius); 220 localState, PropertyTreeState::root(), hasRadius);
227 } 221 }
228 222
229 TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) { 223 TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) {
230 TransformationMatrix transformMatrix; 224 TransformationMatrix transformMatrix;
231 transformMatrix.rotate(45); 225 transformMatrix.rotate(45);
232 transformMatrix.scale(2); 226 transformMatrix.scale(2);
233 RefPtr<TransformPaintPropertyNode> transform = 227 RefPtr<TransformPaintPropertyNode> transform =
234 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 228 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
235 transformMatrix, 229 transformMatrix,
236 FloatPoint3D(50, 50, 0)); 230 FloatPoint3D(50, 50, 0));
237 PropertyTreeState localState = rootPropertyTreeState(); 231 PropertyTreeState localState = PropertyTreeState::root();
238 localState.setTransform(transform.get()); 232 localState.setTransform(transform.get());
239 233
240 FloatRect input(0, 0, 100, 100); 234 FloatRect input(0, 0, 100, 100);
241 transformMatrix.applyTransformOrigin(50, 50, 0); 235 transformMatrix.applyTransformOrigin(50, 50, 0);
242 FloatRect output = transformMatrix.mapRect(input); 236 FloatRect output = transformMatrix.mapRect(input);
243 237
244 bool hasRadius = false; 238 bool hasRadius = false;
245 CHECK_MAPPINGS(input, output, output, transformMatrix, FloatClipRect(), 239 CHECK_MAPPINGS(input, output, output, transformMatrix, FloatClipRect(),
246 localState, rootPropertyTreeState(), hasRadius); 240 localState, PropertyTreeState::root(), hasRadius);
247 } 241 }
248 242
249 TEST_F(GeometryMapperTest, NestedTransforms) { 243 TEST_F(GeometryMapperTest, NestedTransforms) {
250 TransformationMatrix rotateTransform; 244 TransformationMatrix rotateTransform;
251 rotateTransform.rotate(45); 245 rotateTransform.rotate(45);
252 RefPtr<TransformPaintPropertyNode> transform1 = 246 RefPtr<TransformPaintPropertyNode> transform1 =
253 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 247 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
254 rotateTransform, FloatPoint3D()); 248 rotateTransform, FloatPoint3D());
255 249
256 TransformationMatrix scaleTransform; 250 TransformationMatrix scaleTransform;
257 scaleTransform.scale(2); 251 scaleTransform.scale(2);
258 RefPtr<TransformPaintPropertyNode> transform2 = 252 RefPtr<TransformPaintPropertyNode> transform2 =
259 TransformPaintPropertyNode::create(transform1, scaleTransform, 253 TransformPaintPropertyNode::create(transform1, scaleTransform,
260 FloatPoint3D()); 254 FloatPoint3D());
261 255
262 PropertyTreeState localState = rootPropertyTreeState(); 256 PropertyTreeState localState = PropertyTreeState::root();
263 localState.setTransform(transform2.get()); 257 localState.setTransform(transform2.get());
264 258
265 FloatRect input(0, 0, 100, 100); 259 FloatRect input(0, 0, 100, 100);
266 TransformationMatrix final = rotateTransform * scaleTransform; 260 TransformationMatrix final = rotateTransform * scaleTransform;
267 FloatRect output = final.mapRect(input); 261 FloatRect output = final.mapRect(input);
268 262
269 bool hasRadius = false; 263 bool hasRadius = false;
270 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), localState, 264 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), localState,
271 rootPropertyTreeState(), hasRadius); 265 PropertyTreeState::root(), hasRadius);
272 266
273 // Check the cached matrix for the intermediate transform. 267 // Check the cached matrix for the intermediate transform.
274 EXPECT_EQ( 268 EXPECT_EQ(rotateTransform, *getTransform(transform1.get(),
275 rotateTransform, 269 TransformPaintPropertyNode::root()));
276 *getTransform(transform1.get(), rootPropertyTreeState().transform()));
277 } 270 }
278 271
279 TEST_F(GeometryMapperTest, NestedTransformsFlattening) { 272 TEST_F(GeometryMapperTest, NestedTransformsFlattening) {
280 TransformationMatrix rotateTransform; 273 TransformationMatrix rotateTransform;
281 rotateTransform.rotate3d(45, 0, 0); 274 rotateTransform.rotate3d(45, 0, 0);
282 RefPtr<TransformPaintPropertyNode> transform1 = 275 RefPtr<TransformPaintPropertyNode> transform1 =
283 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 276 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
284 rotateTransform, FloatPoint3D()); 277 rotateTransform, FloatPoint3D());
285 278
286 TransformationMatrix inverseRotateTransform; 279 TransformationMatrix inverseRotateTransform;
287 inverseRotateTransform.rotate3d(-45, 0, 0); 280 inverseRotateTransform.rotate3d(-45, 0, 0);
288 RefPtr<TransformPaintPropertyNode> transform2 = 281 RefPtr<TransformPaintPropertyNode> transform2 =
289 TransformPaintPropertyNode::create(transform1, inverseRotateTransform, 282 TransformPaintPropertyNode::create(transform1, inverseRotateTransform,
290 FloatPoint3D(), 283 FloatPoint3D(),
291 true); // Flattens 284 true); // Flattens
292 285
293 PropertyTreeState localState = rootPropertyTreeState(); 286 PropertyTreeState localState = PropertyTreeState::root();
294 localState.setTransform(transform2.get()); 287 localState.setTransform(transform2.get());
295 288
296 FloatRect input(0, 0, 100, 100); 289 FloatRect input(0, 0, 100, 100);
297 rotateTransform.flattenTo2d(); 290 rotateTransform.flattenTo2d();
298 TransformationMatrix final = rotateTransform * inverseRotateTransform; 291 TransformationMatrix final = rotateTransform * inverseRotateTransform;
299 FloatRect output = final.mapRect(input); 292 FloatRect output = final.mapRect(input);
300 bool hasRadius = false; 293 bool hasRadius = false;
301 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), localState, 294 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), localState,
302 rootPropertyTreeState(), hasRadius); 295 PropertyTreeState::root(), hasRadius);
303 } 296 }
304 297
305 TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) { 298 TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) {
306 TransformationMatrix scaleTransform; 299 TransformationMatrix scaleTransform;
307 scaleTransform.scale(2); 300 scaleTransform.scale(2);
308 RefPtr<TransformPaintPropertyNode> transform1 = 301 RefPtr<TransformPaintPropertyNode> transform1 =
309 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 302 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
310 scaleTransform, FloatPoint3D()); 303 scaleTransform, FloatPoint3D());
311 304
312 TransformationMatrix translateTransform; 305 TransformationMatrix translateTransform;
313 translateTransform.translate(100, 0); 306 translateTransform.translate(100, 0);
314 RefPtr<TransformPaintPropertyNode> transform2 = 307 RefPtr<TransformPaintPropertyNode> transform2 =
315 TransformPaintPropertyNode::create(transform1, translateTransform, 308 TransformPaintPropertyNode::create(transform1, translateTransform,
316 FloatPoint3D()); 309 FloatPoint3D());
317 310
318 PropertyTreeState localState = rootPropertyTreeState(); 311 PropertyTreeState localState = PropertyTreeState::root();
319 localState.setTransform(transform2.get()); 312 localState.setTransform(transform2.get());
320 313
321 FloatRect input(0, 0, 100, 100); 314 FloatRect input(0, 0, 100, 100);
322 // Note: unlike NestedTransforms, the order of these transforms matters. This 315 // Note: unlike NestedTransforms, the order of these transforms matters. This
323 // tests correct order of matrix multiplication. 316 // tests correct order of matrix multiplication.
324 TransformationMatrix final = scaleTransform * translateTransform; 317 TransformationMatrix final = scaleTransform * translateTransform;
325 FloatRect output = final.mapRect(input); 318 FloatRect output = final.mapRect(input);
326 319
327 bool hasRadius = false; 320 bool hasRadius = false;
328 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), localState, 321 CHECK_MAPPINGS(input, output, output, final, FloatClipRect(), localState,
329 rootPropertyTreeState(), hasRadius); 322 PropertyTreeState::root(), hasRadius);
330 323
331 // Check the cached matrix for the intermediate transform. 324 // Check the cached matrix for the intermediate transform.
332 EXPECT_EQ(scaleTransform, *getTransform(transform1.get(), 325 EXPECT_EQ(scaleTransform, *getTransform(transform1.get(),
333 rootPropertyTreeState().transform())); 326 TransformPaintPropertyNode::root()));
334 } 327 }
335 328
336 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) { 329 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) {
337 TransformationMatrix rotateTransform; 330 TransformationMatrix rotateTransform;
338 rotateTransform.rotate(45); 331 rotateTransform.rotate(45);
339 RefPtr<TransformPaintPropertyNode> transform1 = 332 RefPtr<TransformPaintPropertyNode> transform1 =
340 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 333 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
341 rotateTransform, FloatPoint3D()); 334 rotateTransform, FloatPoint3D());
342 335
343 TransformationMatrix scaleTransform; 336 TransformationMatrix scaleTransform;
344 scaleTransform.scale(2); 337 scaleTransform.scale(2);
345 RefPtr<TransformPaintPropertyNode> transform2 = 338 RefPtr<TransformPaintPropertyNode> transform2 =
346 TransformPaintPropertyNode::create(transform1, scaleTransform, 339 TransformPaintPropertyNode::create(transform1, scaleTransform,
347 FloatPoint3D()); 340 FloatPoint3D());
348 341
349 PropertyTreeState localState = rootPropertyTreeState(); 342 PropertyTreeState localState = PropertyTreeState::root();
350 localState.setTransform(transform2.get()); 343 localState.setTransform(transform2.get());
351 344
352 PropertyTreeState intermediateState = rootPropertyTreeState(); 345 PropertyTreeState intermediateState = PropertyTreeState::root();
353 intermediateState.setTransform(transform1.get()); 346 intermediateState.setTransform(transform1.get());
354 347
355 FloatRect input(0, 0, 100, 100); 348 FloatRect input(0, 0, 100, 100);
356 FloatRect output = scaleTransform.mapRect(input); 349 FloatRect output = scaleTransform.mapRect(input);
357 350
358 bool hasRadius = false; 351 bool hasRadius = false;
359 CHECK_MAPPINGS(input, output, output, scaleTransform, FloatClipRect(), 352 CHECK_MAPPINGS(input, output, output, scaleTransform, FloatClipRect(),
360 localState, intermediateState, hasRadius); 353 localState, intermediateState, hasRadius);
361 } 354 }
362 355
363 TEST_F(GeometryMapperTest, SimpleClip) { 356 TEST_F(GeometryMapperTest, SimpleClip) {
364 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 357 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
365 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 358 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
366 FloatRoundedRect(10, 10, 50, 50)); 359 FloatRoundedRect(10, 10, 50, 50));
367 360
368 PropertyTreeState localState = rootPropertyTreeState(); 361 PropertyTreeState localState = PropertyTreeState::root();
369 localState.setClip(clip.get()); 362 localState.setClip(clip.get());
370 363
371 FloatRect input(0, 0, 100, 100); 364 FloatRect input(0, 0, 100, 100);
372 FloatRect output(10, 10, 50, 50); 365 FloatRect output(10, 10, 50, 50);
373 366
374 bool hasRadius = false; 367 bool hasRadius = false;
375 CHECK_MAPPINGS(input, // Input 368 CHECK_MAPPINGS(input, // Input
376 output, // Visual rect 369 output, // Visual rect
377 input, // Transformed rect (not clipped). 370 input, // Transformed rect (not clipped).
378 TransformPaintPropertyNode::root() 371 TransformPaintPropertyNode::root()
379 ->matrix(), // Transform matrix to ancestor space 372 ->matrix(), // Transform matrix to ancestor space
380 FloatClipRect(clip->clipRect().rect()), // Clip rect in 373 FloatClipRect(clip->clipRect().rect()), // Clip rect in
381 // ancestor space 374 // ancestor space
382 localState, 375 localState, PropertyTreeState::root(), hasRadius);
383 rootPropertyTreeState(), hasRadius);
384 } 376 }
385 377
386 TEST_F(GeometryMapperTest, RoundedClip) { 378 TEST_F(GeometryMapperTest, RoundedClip) {
387 FloatRoundedRect rect(FloatRect(10, 10, 50, 50), 379 FloatRoundedRect rect(FloatRect(10, 10, 50, 50),
388 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), 380 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(),
389 FloatSize(), FloatSize())); 381 FloatSize(), FloatSize()));
390 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 382 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
391 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), rect); 383 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), rect);
392 384
393 PropertyTreeState localState = rootPropertyTreeState(); 385 PropertyTreeState localState = PropertyTreeState::root();
394 localState.setClip(clip.get()); 386 localState.setClip(clip.get());
395 387
396 FloatRect input(0, 0, 100, 100); 388 FloatRect input(0, 0, 100, 100);
397 FloatRect output(10, 10, 50, 50); 389 FloatRect output(10, 10, 50, 50);
398 390
399 FloatClipRect expectedClip(clip->clipRect().rect()); 391 FloatClipRect expectedClip(clip->clipRect().rect());
400 expectedClip.setHasRadius(); 392 expectedClip.setHasRadius();
401 393
402 bool hasRadius = true; 394 bool hasRadius = true;
403 CHECK_MAPPINGS(input, // Input 395 CHECK_MAPPINGS(input, // Input
404 output, // Visual rect 396 output, // Visual rect
405 input, // Transformed rect (not clipped). 397 input, // Transformed rect (not clipped).
406 TransformPaintPropertyNode::root() 398 TransformPaintPropertyNode::root()
407 ->matrix(), // Transform matrix to ancestor space 399 ->matrix(), // Transform matrix to ancestor space
408 expectedClip, // Clip rect in ancestor space 400 expectedClip, // Clip rect in ancestor space
409 localState, 401 localState, PropertyTreeState::root(), hasRadius);
410 rootPropertyTreeState(), hasRadius);
411 } 402 }
412 403
413 TEST_F(GeometryMapperTest, TwoClips) { 404 TEST_F(GeometryMapperTest, TwoClips) {
414 FloatRoundedRect clipRect1( 405 FloatRoundedRect clipRect1(
415 FloatRect(10, 10, 30, 40), 406 FloatRect(10, 10, 30, 40),
416 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), FloatSize(), 407 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), FloatSize(),
417 FloatSize())); 408 FloatSize()));
418 409
419 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( 410 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
420 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 411 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
421 clipRect1); 412 clipRect1);
422 413
423 RefPtr<ClipPaintPropertyNode> clip2 = 414 RefPtr<ClipPaintPropertyNode> clip2 =
424 ClipPaintPropertyNode::create(clip1, TransformPaintPropertyNode::root(), 415 ClipPaintPropertyNode::create(clip1, TransformPaintPropertyNode::root(),
425 FloatRoundedRect(10, 10, 50, 50)); 416 FloatRoundedRect(10, 10, 50, 50));
426 417
427 PropertyTreeState localState = rootPropertyTreeState(); 418 PropertyTreeState localState = PropertyTreeState::root();
428 PropertyTreeState ancestorState = rootPropertyTreeState(); 419 PropertyTreeState ancestorState = PropertyTreeState::root();
429 localState.setClip(clip2.get()); 420 localState.setClip(clip2.get());
430 421
431 FloatRect input(0, 0, 100, 100); 422 FloatRect input(0, 0, 100, 100);
432 FloatRect output1(10, 10, 30, 40); 423 FloatRect output1(10, 10, 30, 40);
433 424
434 FloatClipRect clipRect(clip1->clipRect().rect()); 425 FloatClipRect clipRect(clip1->clipRect().rect());
435 clipRect.setHasRadius(); 426 clipRect.setHasRadius();
436 427
437 bool hasRadius = true; 428 bool hasRadius = true;
438 CHECK_MAPPINGS(input, // Input 429 CHECK_MAPPINGS(input, // Input
(...skipping 16 matching lines...) Expand all
455 output2, // Visual rect 446 output2, // Visual rect
456 input, // Transformed rect (not clipped). 447 input, // Transformed rect (not clipped).
457 TransformPaintPropertyNode::root() 448 TransformPaintPropertyNode::root()
458 ->matrix(), // Transform matrix to ancestor space 449 ->matrix(), // Transform matrix to ancestor space
459 clipRect2, // Clip rect in ancestor space 450 clipRect2, // Clip rect in ancestor space
460 localState, ancestorState, hasRadius); 451 localState, ancestorState, hasRadius);
461 } 452 }
462 453
463 TEST_F(GeometryMapperTest, TwoClipsTransformAbove) { 454 TEST_F(GeometryMapperTest, TwoClipsTransformAbove) {
464 RefPtr<TransformPaintPropertyNode> transform = 455 RefPtr<TransformPaintPropertyNode> transform =
465 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 456 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
466 TransformationMatrix(), 457 TransformationMatrix(),
467 FloatPoint3D()); 458 FloatPoint3D());
468 459
469 FloatRoundedRect clipRect1( 460 FloatRoundedRect clipRect1(
470 FloatRect(10, 10, 50, 50), 461 FloatRect(10, 10, 50, 50),
471 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), FloatSize(), 462 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), FloatSize(),
472 FloatSize())); 463 FloatSize()));
473 464
474 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( 465 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
475 ClipPaintPropertyNode::root(), transform.get(), clipRect1); 466 ClipPaintPropertyNode::root(), transform.get(), clipRect1);
476 467
477 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( 468 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(
478 clip1, transform.get(), FloatRoundedRect(10, 10, 30, 40)); 469 clip1, transform.get(), FloatRoundedRect(10, 10, 30, 40));
479 470
480 PropertyTreeState localState = rootPropertyTreeState(); 471 PropertyTreeState localState = PropertyTreeState::root();
481 PropertyTreeState ancestorState = rootPropertyTreeState(); 472 PropertyTreeState ancestorState = PropertyTreeState::root();
482 localState.setClip(clip2.get()); 473 localState.setClip(clip2.get());
483 474
484 FloatRect input(0, 0, 100, 100); 475 FloatRect input(0, 0, 100, 100);
485 FloatRect output1(10, 10, 30, 40); 476 FloatRect output1(10, 10, 30, 40);
486 477
487 FloatClipRect expectedClip(clip2->clipRect().rect()); 478 FloatClipRect expectedClip(clip2->clipRect().rect());
488 expectedClip.setHasRadius(); 479 expectedClip.setHasRadius();
489 480
490 bool hasRadius = true; 481 bool hasRadius = true;
491 CHECK_MAPPINGS(input, // Input 482 CHECK_MAPPINGS(input, // Input
(...skipping 15 matching lines...) Expand all
507 ->matrix(), // Transform matrix to ancestor space 498 ->matrix(), // Transform matrix to ancestor space
508 expectedClip, // Clip rect in ancestor space 499 expectedClip, // Clip rect in ancestor space
509 localState, 500 localState,
510 ancestorState, hasRadius); 501 ancestorState, hasRadius);
511 } 502 }
512 503
513 TEST_F(GeometryMapperTest, ClipBeforeTransform) { 504 TEST_F(GeometryMapperTest, ClipBeforeTransform) {
514 TransformationMatrix rotateTransform; 505 TransformationMatrix rotateTransform;
515 rotateTransform.rotate(45); 506 rotateTransform.rotate(45);
516 RefPtr<TransformPaintPropertyNode> transform = 507 RefPtr<TransformPaintPropertyNode> transform =
517 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 508 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
518 rotateTransform, FloatPoint3D()); 509 rotateTransform, FloatPoint3D());
519 510
520 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 511 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
521 ClipPaintPropertyNode::root(), transform.get(), 512 ClipPaintPropertyNode::root(), transform.get(),
522 FloatRoundedRect(10, 10, 50, 50)); 513 FloatRoundedRect(10, 10, 50, 50));
523 514
524 PropertyTreeState localState = rootPropertyTreeState(); 515 PropertyTreeState localState = PropertyTreeState::root();
525 localState.setClip(clip.get()); 516 localState.setClip(clip.get());
526 localState.setTransform(transform.get()); 517 localState.setTransform(transform.get());
527 518
528 FloatRect input(0, 0, 100, 100); 519 FloatRect input(0, 0, 100, 100);
529 FloatRect output(input); 520 FloatRect output(input);
530 output.intersect(clip->clipRect().rect()); 521 output.intersect(clip->clipRect().rect());
531 output = rotateTransform.mapRect(output); 522 output = rotateTransform.mapRect(output);
532 523
533 bool hasRadius = false; 524 bool hasRadius = false;
534 CHECK_MAPPINGS( 525 CHECK_MAPPINGS(
535 input, // Input 526 input, // Input
536 output, // Visual rect 527 output, // Visual rect
537 rotateTransform.mapRect(input), // Transformed rect (not clipped). 528 rotateTransform.mapRect(input), // Transformed rect (not clipped).
538 rotateTransform, // Transform matrix to ancestor space 529 rotateTransform, // Transform matrix to ancestor space
539 FloatClipRect(rotateTransform.mapRect( 530 FloatClipRect(rotateTransform.mapRect(
540 clip->clipRect().rect())), // Clip rect in ancestor space 531 clip->clipRect().rect())), // Clip rect in ancestor space
541 localState, 532 localState, PropertyTreeState::root(), hasRadius);
542 rootPropertyTreeState(), hasRadius);
543 } 533 }
544 534
545 TEST_F(GeometryMapperTest, ClipAfterTransform) { 535 TEST_F(GeometryMapperTest, ClipAfterTransform) {
546 TransformationMatrix rotateTransform; 536 TransformationMatrix rotateTransform;
547 rotateTransform.rotate(45); 537 rotateTransform.rotate(45);
548 RefPtr<TransformPaintPropertyNode> transform = 538 RefPtr<TransformPaintPropertyNode> transform =
549 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 539 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
550 rotateTransform, FloatPoint3D()); 540 rotateTransform, FloatPoint3D());
551 541
552 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 542 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
553 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 543 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
554 FloatRoundedRect(10, 10, 200, 200)); 544 FloatRoundedRect(10, 10, 200, 200));
555 545
556 PropertyTreeState localState = rootPropertyTreeState(); 546 PropertyTreeState localState = PropertyTreeState::root();
557 localState.setClip(clip.get()); 547 localState.setClip(clip.get());
558 localState.setTransform(transform.get()); 548 localState.setTransform(transform.get());
559 549
560 FloatRect input(0, 0, 100, 100); 550 FloatRect input(0, 0, 100, 100);
561 FloatRect output(input); 551 FloatRect output(input);
562 output = rotateTransform.mapRect(output); 552 output = rotateTransform.mapRect(output);
563 output.intersect(clip->clipRect().rect()); 553 output.intersect(clip->clipRect().rect());
564 554
565 bool hasRadius = false; 555 bool hasRadius = false;
566 CHECK_MAPPINGS( 556 CHECK_MAPPINGS(
567 input, // Input 557 input, // Input
568 output, // Visual rect 558 output, // Visual rect
569 rotateTransform.mapRect(input), // Transformed rect (not clipped) 559 rotateTransform.mapRect(input), // Transformed rect (not clipped)
570 rotateTransform, // Transform matrix to ancestor space 560 rotateTransform, // Transform matrix to ancestor space
571 FloatClipRect(clip->clipRect().rect()), // Clip rect in ancestor space 561 FloatClipRect(clip->clipRect().rect()), // Clip rect in ancestor space
572 localState, rootPropertyTreeState(), hasRadius); 562 localState, PropertyTreeState::root(), hasRadius);
573 } 563 }
574 564
575 TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween) { 565 TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween) {
576 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( 566 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
577 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 567 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
578 FloatRoundedRect(10, 10, 200, 200)); 568 FloatRoundedRect(10, 10, 200, 200));
579 569
580 TransformationMatrix rotateTransform; 570 TransformationMatrix rotateTransform;
581 rotateTransform.rotate(45); 571 rotateTransform.rotate(45);
582 RefPtr<TransformPaintPropertyNode> transform = 572 RefPtr<TransformPaintPropertyNode> transform =
583 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 573 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
584 rotateTransform, FloatPoint3D()); 574 rotateTransform, FloatPoint3D());
585 575
586 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( 576 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(
587 clip1, transform.get(), FloatRoundedRect(10, 10, 200, 200)); 577 clip1, transform.get(), FloatRoundedRect(10, 10, 200, 200));
588 578
589 FloatRect input(0, 0, 100, 100); 579 FloatRect input(0, 0, 100, 100);
590 580
591 bool hasRadius = false; 581 bool hasRadius = false;
592 { 582 {
593 PropertyTreeState localState = rootPropertyTreeState(); 583 PropertyTreeState localState = PropertyTreeState::root();
594 localState.setClip(clip1.get()); 584 localState.setClip(clip1.get());
595 localState.setTransform(transform.get()); 585 localState.setTransform(transform.get());
596 586
597 FloatRect output(input); 587 FloatRect output(input);
598 output = rotateTransform.mapRect(output); 588 output = rotateTransform.mapRect(output);
599 output.intersect(clip1->clipRect().rect()); 589 output.intersect(clip1->clipRect().rect());
600 590
601 CHECK_MAPPINGS( 591 CHECK_MAPPINGS(
602 input, // Input 592 input, // Input
603 output, // Visual rect 593 output, // Visual rect
604 rotateTransform.mapRect(input), // Transformed rect (not clipped) 594 rotateTransform.mapRect(input), // Transformed rect (not clipped)
605 rotateTransform, // Transform matrix to ancestor space 595 rotateTransform, // Transform matrix to ancestor space
606 FloatClipRect(clip1->clipRect().rect()), // Clip rect in ancestor space 596 FloatClipRect(clip1->clipRect().rect()), // Clip rect in ancestor space
607 localState, rootPropertyTreeState(), hasRadius); 597 localState, PropertyTreeState::root(), hasRadius);
608 } 598 }
609 599
610 { 600 {
611 PropertyTreeState localState = rootPropertyTreeState(); 601 PropertyTreeState localState = PropertyTreeState::root();
612 localState.setClip(clip2.get()); 602 localState.setClip(clip2.get());
613 localState.setTransform(transform.get()); 603 localState.setTransform(transform.get());
614 604
615 FloatRect mappedClip = rotateTransform.mapRect(clip2->clipRect().rect()); 605 FloatRect mappedClip = rotateTransform.mapRect(clip2->clipRect().rect());
616 mappedClip.intersect(clip1->clipRect().rect()); 606 mappedClip.intersect(clip1->clipRect().rect());
617 607
618 // All clips are performed in the space of the ancestor. In cases such as 608 // All clips are performed in the space of the ancestor. In cases such as
619 // this, this means the clip is a bit lossy. 609 // this, this means the clip is a bit lossy.
620 FloatRect output(input); 610 FloatRect output(input);
621 // Map to transformed rect in ancestor space. 611 // Map to transformed rect in ancestor space.
622 output = rotateTransform.mapRect(output); 612 output = rotateTransform.mapRect(output);
623 // Intersect with all clips between local and ancestor, independently mapped 613 // Intersect with all clips between local and ancestor, independently mapped
624 // to ancestor space. 614 // to ancestor space.
625 output.intersect(mappedClip); 615 output.intersect(mappedClip);
626 616
627 CHECK_MAPPINGS( 617 CHECK_MAPPINGS(
628 input, // Input 618 input, // Input
629 output, // Visual rect 619 output, // Visual rect
630 rotateTransform.mapRect(input), // Transformed rect (not clipped) 620 rotateTransform.mapRect(input), // Transformed rect (not clipped)
631 rotateTransform, // Transform matrix to ancestor space 621 rotateTransform, // Transform matrix to ancestor space
632 FloatClipRect(mappedClip), // Clip rect in ancestor space 622 FloatClipRect(mappedClip), // Clip rect in ancestor space
633 localState, rootPropertyTreeState(), hasRadius); 623 localState, PropertyTreeState::root(), hasRadius);
634 } 624 }
635 } 625 }
636 626
637 TEST_F(GeometryMapperTest, SiblingTransforms) { 627 TEST_F(GeometryMapperTest, SiblingTransforms) {
638 // These transforms are siblings. Thus mapping from one to the other requires 628 // These transforms are siblings. Thus mapping from one to the other requires
639 // going through the root. 629 // going through the root.
640 TransformationMatrix rotateTransform1; 630 TransformationMatrix rotateTransform1;
641 rotateTransform1.rotate(45); 631 rotateTransform1.rotate(45);
642 RefPtr<TransformPaintPropertyNode> transform1 = 632 RefPtr<TransformPaintPropertyNode> transform1 =
643 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 633 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
644 rotateTransform1, FloatPoint3D()); 634 rotateTransform1, FloatPoint3D());
645 635
646 TransformationMatrix rotateTransform2; 636 TransformationMatrix rotateTransform2;
647 rotateTransform2.rotate(-45); 637 rotateTransform2.rotate(-45);
648 RefPtr<TransformPaintPropertyNode> transform2 = 638 RefPtr<TransformPaintPropertyNode> transform2 =
649 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 639 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
650 rotateTransform2, FloatPoint3D()); 640 rotateTransform2, FloatPoint3D());
651 641
652 PropertyTreeState transform1State = rootPropertyTreeState(); 642 PropertyTreeState transform1State = PropertyTreeState::root();
653 transform1State.setTransform(transform1.get()); 643 transform1State.setTransform(transform1.get());
654 PropertyTreeState transform2State = rootPropertyTreeState(); 644 PropertyTreeState transform2State = PropertyTreeState::root();
655 transform2State.setTransform(transform2.get()); 645 transform2State.setTransform(transform2.get());
656 646
657 bool success; 647 bool success;
658 FloatRect input(0, 0, 100, 100); 648 FloatRect input(0, 0, 100, 100);
659 FloatRect result = input; 649 FloatRect result = input;
660 localToAncestorVisualRectInternal(transform1State, transform2State, result, 650 localToAncestorVisualRectInternal(transform1State, transform2State, result,
661 success); 651 success);
662 // Fails, because the transform2state is not an ancestor of transform1State. 652 // Fails, because the transform2state is not an ancestor of transform1State.
663 EXPECT_FALSE(success); 653 EXPECT_FALSE(success);
664 EXPECT_RECT_EQ(input, result); 654 EXPECT_RECT_EQ(input, result);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 result); 686 result);
697 EXPECT_RECT_EQ(expected, result); 687 EXPECT_RECT_EQ(expected, result);
698 } 688 }
699 689
700 TEST_F(GeometryMapperTest, SiblingTransformsWithClip) { 690 TEST_F(GeometryMapperTest, SiblingTransformsWithClip) {
701 // These transforms are siblings. Thus mapping from one to the other requires 691 // These transforms are siblings. Thus mapping from one to the other requires
702 // going through the root. 692 // going through the root.
703 TransformationMatrix rotateTransform1; 693 TransformationMatrix rotateTransform1;
704 rotateTransform1.rotate(45); 694 rotateTransform1.rotate(45);
705 RefPtr<TransformPaintPropertyNode> transform1 = 695 RefPtr<TransformPaintPropertyNode> transform1 =
706 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 696 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
707 rotateTransform1, FloatPoint3D()); 697 rotateTransform1, FloatPoint3D());
708 698
709 TransformationMatrix rotateTransform2; 699 TransformationMatrix rotateTransform2;
710 rotateTransform2.rotate(-45); 700 rotateTransform2.rotate(-45);
711 RefPtr<TransformPaintPropertyNode> transform2 = 701 RefPtr<TransformPaintPropertyNode> transform2 =
712 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 702 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
713 rotateTransform2, FloatPoint3D()); 703 rotateTransform2, FloatPoint3D());
714 704
715 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 705 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
716 rootPropertyTreeState().clip(), transform2.get(), 706 ClipPaintPropertyNode::root(), transform2.get(),
717 FloatRoundedRect(10, 10, 70, 70)); 707 FloatRoundedRect(10, 10, 70, 70));
718 708
719 PropertyTreeState transform1State = rootPropertyTreeState(); 709 PropertyTreeState transform1State = PropertyTreeState::root();
720 transform1State.setTransform(transform1.get()); 710 transform1State.setTransform(transform1.get());
721 PropertyTreeState transform2AndClipState = rootPropertyTreeState(); 711 PropertyTreeState transform2AndClipState = PropertyTreeState::root();
722 transform2AndClipState.setTransform(transform2.get()); 712 transform2AndClipState.setTransform(transform2.get());
723 transform2AndClipState.setClip(clip.get()); 713 transform2AndClipState.setClip(clip.get());
724 714
725 bool success; 715 bool success;
726 FloatRect input(0, 0, 100, 100); 716 FloatRect input(0, 0, 100, 100);
727 717
728 // Test map from transform1State to transform2AndClipState. 718 // Test map from transform1State to transform2AndClipState.
729 FloatRect expected = 719 FloatRect expected =
730 rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input)); 720 rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input));
731 721
(...skipping 28 matching lines...) Expand all
760 // sourceToDestinationRect applies transforms only. 750 // sourceToDestinationRect applies transforms only.
761 result = input; 751 result = input;
762 geometryMapper->sourceToDestinationRect(transform2.get(), transform1.get(), 752 geometryMapper->sourceToDestinationRect(transform2.get(), transform1.get(),
763 result); 753 result);
764 EXPECT_RECT_EQ(expectedUnclipped, result); 754 EXPECT_RECT_EQ(expectedUnclipped, result);
765 } 755 }
766 756
767 TEST_F(GeometryMapperTest, LowestCommonAncestor) { 757 TEST_F(GeometryMapperTest, LowestCommonAncestor) {
768 TransformationMatrix matrix; 758 TransformationMatrix matrix;
769 RefPtr<TransformPaintPropertyNode> child1 = 759 RefPtr<TransformPaintPropertyNode> child1 =
770 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 760 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
771 matrix, FloatPoint3D()); 761 matrix, FloatPoint3D());
772 RefPtr<TransformPaintPropertyNode> child2 = 762 RefPtr<TransformPaintPropertyNode> child2 =
773 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 763 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
774 matrix, FloatPoint3D()); 764 matrix, FloatPoint3D());
775 765
776 RefPtr<TransformPaintPropertyNode> childOfChild1 = 766 RefPtr<TransformPaintPropertyNode> childOfChild1 =
777 TransformPaintPropertyNode::create(child1, matrix, FloatPoint3D()); 767 TransformPaintPropertyNode::create(child1, matrix, FloatPoint3D());
778 RefPtr<TransformPaintPropertyNode> childOfChild2 = 768 RefPtr<TransformPaintPropertyNode> childOfChild2 =
779 TransformPaintPropertyNode::create(child2, matrix, FloatPoint3D()); 769 TransformPaintPropertyNode::create(child2, matrix, FloatPoint3D());
780 770
781 EXPECT_EQ(rootPropertyTreeState().transform(), 771 EXPECT_EQ(TransformPaintPropertyNode::root(),
782 lowestCommonAncestor(childOfChild1.get(), childOfChild2.get())); 772 lowestCommonAncestor(childOfChild1.get(), childOfChild2.get()));
783 EXPECT_EQ(rootPropertyTreeState().transform(), 773 EXPECT_EQ(TransformPaintPropertyNode::root(),
784 lowestCommonAncestor(childOfChild1.get(), child2.get())); 774 lowestCommonAncestor(childOfChild1.get(), child2.get()));
785 EXPECT_EQ(rootPropertyTreeState().transform(), 775 EXPECT_EQ(TransformPaintPropertyNode::root(),
786 lowestCommonAncestor(childOfChild1.get(), 776 lowestCommonAncestor(childOfChild1.get(),
787 rootPropertyTreeState().transform())); 777 TransformPaintPropertyNode::root()));
788 EXPECT_EQ(child1, lowestCommonAncestor(childOfChild1.get(), child1.get())); 778 EXPECT_EQ(child1, lowestCommonAncestor(childOfChild1.get(), child1.get()));
789 779
790 EXPECT_EQ(rootPropertyTreeState().transform(), 780 EXPECT_EQ(TransformPaintPropertyNode::root(),
791 lowestCommonAncestor(childOfChild2.get(), childOfChild1.get())); 781 lowestCommonAncestor(childOfChild2.get(), childOfChild1.get()));
792 EXPECT_EQ(rootPropertyTreeState().transform(), 782 EXPECT_EQ(TransformPaintPropertyNode::root(),
793 lowestCommonAncestor(childOfChild2.get(), child1.get())); 783 lowestCommonAncestor(childOfChild2.get(), child1.get()));
794 EXPECT_EQ(rootPropertyTreeState().transform(), 784 EXPECT_EQ(TransformPaintPropertyNode::root(),
795 lowestCommonAncestor(childOfChild2.get(), 785 lowestCommonAncestor(childOfChild2.get(),
796 rootPropertyTreeState().transform())); 786 TransformPaintPropertyNode::root()));
797 EXPECT_EQ(child2, lowestCommonAncestor(childOfChild2.get(), child2.get())); 787 EXPECT_EQ(child2, lowestCommonAncestor(childOfChild2.get(), child2.get()));
798 788
799 EXPECT_EQ(rootPropertyTreeState().transform(), 789 EXPECT_EQ(TransformPaintPropertyNode::root(),
800 lowestCommonAncestor(child1.get(), child2.get())); 790 lowestCommonAncestor(child1.get(), child2.get()));
801 } 791 }
802 792
803 TEST_F(GeometryMapperTest, FilterWithClipsAndTransforms) { 793 TEST_F(GeometryMapperTest, FilterWithClipsAndTransforms) {
804 RefPtr<TransformPaintPropertyNode> transformAboveEffect = 794 RefPtr<TransformPaintPropertyNode> transformAboveEffect =
805 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 795 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
806 TransformationMatrix().scale(3), 796 TransformationMatrix().scale(3),
807 FloatPoint3D()); 797 FloatPoint3D());
808 RefPtr<TransformPaintPropertyNode> transformBelowEffect = 798 RefPtr<TransformPaintPropertyNode> transformBelowEffect =
809 TransformPaintPropertyNode::create(transformAboveEffect, 799 TransformPaintPropertyNode::create(transformAboveEffect,
810 TransformationMatrix().scale(2), 800 TransformationMatrix().scale(2),
811 FloatPoint3D()); 801 FloatPoint3D());
812 802
813 // This clip is between transformAboveEffect and the effect. 803 // This clip is between transformAboveEffect and the effect.
814 RefPtr<ClipPaintPropertyNode> clipAboveEffect = ClipPaintPropertyNode::create( 804 RefPtr<ClipPaintPropertyNode> clipAboveEffect = ClipPaintPropertyNode::create(
815 rootPropertyTreeState().clip(), transformAboveEffect, 805 ClipPaintPropertyNode::root(), transformAboveEffect,
816 FloatRoundedRect(-100, -100, 200, 200)); 806 FloatRoundedRect(-100, -100, 200, 200));
817 // This clip is between the effect and transformBelowEffect. 807 // This clip is between the effect and transformBelowEffect.
818 RefPtr<ClipPaintPropertyNode> clipBelowEffect = 808 RefPtr<ClipPaintPropertyNode> clipBelowEffect =
819 ClipPaintPropertyNode::create(clipAboveEffect, transformAboveEffect, 809 ClipPaintPropertyNode::create(clipAboveEffect, transformAboveEffect,
820 FloatRoundedRect(10, 10, 200, 200)); 810 FloatRoundedRect(10, 10, 200, 200));
821 811
822 CompositorFilterOperations filters; 812 CompositorFilterOperations filters;
823 filters.appendBlurFilter(20); 813 filters.appendBlurFilter(20);
824 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( 814 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create(
825 rootPropertyTreeState().effect(), transformAboveEffect, clipAboveEffect, 815 EffectPaintPropertyNode::root(), transformAboveEffect, clipAboveEffect,
826 ColorFilterNone, filters, 1.0, SkBlendMode::kSrcOver); 816 ColorFilterNone, filters, 1.0, SkBlendMode::kSrcOver);
827 817
828 PropertyTreeState localState(transformBelowEffect.get(), 818 PropertyTreeState localState(transformBelowEffect.get(),
829 clipBelowEffect.get(), effect.get()); 819 clipBelowEffect.get(), effect.get());
830 820
831 FloatRect input(0, 0, 50, 50); 821 FloatRect input(0, 0, 50, 50);
832 // 1. transformBelowEffect 822 // 1. transformBelowEffect
833 FloatRect output = transformBelowEffect->matrix().mapRect(input); 823 FloatRect output = transformBelowEffect->matrix().mapRect(input);
834 // 2. clipBelowEffect 824 // 2. clipBelowEffect
835 output.intersect(clipBelowEffect->clipRect().rect()); 825 output.intersect(clipBelowEffect->clipRect().rect());
836 EXPECT_EQ(FloatRect(10, 10, 90, 90), output); 826 EXPECT_EQ(FloatRect(10, 10, 90, 90), output);
837 // 3. effect (the outset is 3 times of blur amount). 827 // 3. effect (the outset is 3 times of blur amount).
838 output = filters.mapRect(output); 828 output = filters.mapRect(output);
839 EXPECT_EQ(FloatRect(-50, -50, 210, 210), output); 829 EXPECT_EQ(FloatRect(-50, -50, 210, 210), output);
840 // 4. clipAboveEffect 830 // 4. clipAboveEffect
841 output.intersect(clipAboveEffect->clipRect().rect()); 831 output.intersect(clipAboveEffect->clipRect().rect());
842 EXPECT_EQ(FloatRect(-50, -50, 150, 150), output); 832 EXPECT_EQ(FloatRect(-50, -50, 150, 150), output);
843 // 5. transformAboveEffect 833 // 5. transformAboveEffect
844 output = transformAboveEffect->matrix().mapRect(output); 834 output = transformAboveEffect->matrix().mapRect(output);
845 EXPECT_EQ(FloatRect(-150, -150, 450, 450), output); 835 EXPECT_EQ(FloatRect(-150, -150, 450, 450), output);
846 836
847 bool hasRadius = false; 837 bool hasRadius = false;
848 TransformationMatrix combinedTransform = 838 TransformationMatrix combinedTransform =
849 transformAboveEffect->matrix() * transformBelowEffect->matrix(); 839 transformAboveEffect->matrix() * transformBelowEffect->matrix();
850 CHECK_MAPPINGS(input, output, FloatRect(0, 0, 300, 300), combinedTransform, 840 CHECK_MAPPINGS(input, output, FloatRect(0, 0, 300, 300), combinedTransform,
851 FloatClipRect(FloatRect(30, 30, 270, 270)), localState, 841 FloatClipRect(FloatRect(30, 30, 270, 270)), localState,
852 rootPropertyTreeState(), hasRadius); 842 PropertyTreeState::root(), hasRadius);
853 } 843 }
854 844
855 TEST_F(GeometryMapperTest, ReflectionWithPaintOffset) { 845 TEST_F(GeometryMapperTest, ReflectionWithPaintOffset) {
856 CompositorFilterOperations filters; 846 CompositorFilterOperations filters;
857 filters.appendReferenceFilter(SkiaImageFilterBuilder::buildBoxReflectFilter( 847 filters.appendReferenceFilter(SkiaImageFilterBuilder::buildBoxReflectFilter(
858 BoxReflection(BoxReflection::HorizontalReflection, 0), nullptr)); 848 BoxReflection(BoxReflection::HorizontalReflection, 0), nullptr));
859 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( 849 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create(
860 rootPropertyTreeState().effect(), rootPropertyTreeState().transform(), 850 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
861 rootPropertyTreeState().clip(), ColorFilterNone, filters, 1.0, 851 ClipPaintPropertyNode::root(), ColorFilterNone, filters, 1.0,
862 SkBlendMode::kSrcOver, CompositingReasonNone, CompositorElementId(), 852 SkBlendMode::kSrcOver, CompositingReasonNone, CompositorElementId(),
863 FloatPoint(100, 100)); 853 FloatPoint(100, 100));
864 854
865 PropertyTreeState localState = rootPropertyTreeState(); 855 PropertyTreeState localState = PropertyTreeState::root();
866 localState.setEffect(effect); 856 localState.setEffect(effect);
867 857
868 FloatRect input(100, 100, 50, 50); 858 FloatRect input(100, 100, 50, 50);
869 // Reflection is at (50, 100, 50, 50). 859 // Reflection is at (50, 100, 50, 50).
870 FloatRect output(50, 100, 100, 50); 860 FloatRect output(50, 100, 100, 50);
871 861
872 bool hasRadius = false; 862 bool hasRadius = false;
873 CHECK_MAPPINGS(input, output, input, TransformationMatrix(), FloatClipRect(), 863 CHECK_MAPPINGS(input, output, input, TransformationMatrix(), FloatClipRect(),
874 localState, rootPropertyTreeState(), hasRadius); 864 localState, PropertyTreeState::root(), hasRadius);
875 } 865 }
876 866
877 } // namespace blink 867 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698