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

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

Issue 2329463004: ABANDONED CL: Changes needed to make things compile after running rewrite_to_chrome_style tool. (Closed)
Patch Set: Rebasing the fixes... Created 3 years, 10 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"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 << ", expected: " << expected.width(); \ 103 << ", expected: " << expected.width(); \
104 EXPECT_TRUE(GeometryTest::ApproximatelyEqual( \ 104 EXPECT_TRUE(GeometryTest::ApproximatelyEqual( \
105 expected.height(), actualRect.height(), kTestEpsilon)) \ 105 expected.height(), actualRect.height(), kTestEpsilon)) \
106 << "actual: " << actualRect.height() \ 106 << "actual: " << actualRect.height() \
107 << ", expected: " << expected.height(); \ 107 << ", expected: " << expected.height(); \
108 } while (false) 108 } while (false)
109 109
110 #define CHECK_MAPPINGS(inputRect, expectedVisualRect, expectedTransformedRect, \ 110 #define CHECK_MAPPINGS(inputRect, expectedVisualRect, expectedTransformedRect, \
111 expectedTransformToAncestor, \ 111 expectedTransformToAncestor, \
112 expectedClipInAncestorSpace, localPropertyTreeState, \ 112 expectedClipInAncestorSpace, localPropertyTreeState, \
113 ancestorPropertyTreeState, hasRadius) \ 113 ancestorPropertyTreeState) \
114 do { \ 114 do { \
115 FloatClipRect clipRect = geometryMapper->localToAncestorVisualRect( \ 115 FloatClipRect clipRect = geometryMapper->localToAncestorVisualRect( \
116 inputRect, localPropertyTreeState, ancestorPropertyTreeState); \ 116 inputRect, localPropertyTreeState, ancestorPropertyTreeState); \
117 EXPECT_EQ(hasRadius, clipRect.hasRadius()); \ 117 EXPECT_EQ(has_radius, clipRect.HasRadius()); \
118 EXPECT_RECT_EQ(expectedVisualRect, clipRect.rect()); \ 118 EXPECT_RECT_EQ(expectedVisualRect, clipRect.rect()); \
119 clipRect = geometryMapper->localToAncestorClipRect( \ 119 clipRect = geometryMapper->localToAncestorClipRect( \
120 localPropertyTreeState, ancestorPropertyTreeState); \ 120 localPropertyTreeState, ancestorPropertyTreeState); \
121 EXPECT_EQ(hasRadius, clipRect.hasRadius()); \ 121 EXPECT_EQ(has_radius, clipRect.HasRadius()); \
122 EXPECT_RECT_EQ(expectedClipInAncestorSpace, clipRect.rect()); \ 122 EXPECT_RECT_EQ(expectedClipInAncestorSpace, clipRect.rect()); \
123 clipRect = geometryMapper->sourceToDestinationVisualRect( \ 123 clipRect = geometryMapper->sourceToDestinationVisualRect( \
124 inputRect, localPropertyTreeState, ancestorPropertyTreeState); \ 124 inputRect, localPropertyTreeState, ancestorPropertyTreeState); \
125 EXPECT_EQ(hasRadius, clipRect.hasRadius()); \ 125 EXPECT_EQ(has_radius, clipRect.HasRadius()); \
126 EXPECT_RECT_EQ(expectedVisualRect, clipRect.rect()); \ 126 EXPECT_RECT_EQ(expectedVisualRect, clipRect.rect()); \
127 EXPECT_RECT_EQ(expectedTransformedRect, \ 127 EXPECT_RECT_EQ(expectedTransformedRect, \
128 geometryMapper->localToAncestorRect( \ 128 geometryMapper->localToAncestorRect( \
129 inputRect, localPropertyTreeState.transform(), \ 129 inputRect, localPropertyTreeState.transform(), \
130 ancestorPropertyTreeState.transform())); \ 130 ancestorPropertyTreeState.transform())); \
131 EXPECT_RECT_EQ(expectedTransformedRect, \ 131 EXPECT_RECT_EQ(expectedTransformedRect, \
132 geometryMapper->sourceToDestinationRect( \ 132 geometryMapper->sourceToDestinationRect( \
133 inputRect, localPropertyTreeState.transform(), \ 133 inputRect, localPropertyTreeState.transform(), \
134 ancestorPropertyTreeState.transform())); \ 134 ancestorPropertyTreeState.transform())); \
135 if (ancestorPropertyTreeState.transform() != \ 135 if (ancestorPropertyTreeState.transform() != \
(...skipping 10 matching lines...) Expand all
146 } \ 146 } \
147 } while (false) 147 } while (false)
148 148
149 TEST_F(GeometryMapperTest, Root) { 149 TEST_F(GeometryMapperTest, Root) {
150 FloatRect input(0, 0, 100, 100); 150 FloatRect input(0, 0, 100, 100);
151 151
152 bool hasRadius = false; 152 bool hasRadius = false;
153 CHECK_MAPPINGS(input, input, input, 153 CHECK_MAPPINGS(input, input, input,
154 TransformPaintPropertyNode::root()->matrix(), 154 TransformPaintPropertyNode::root()->matrix(),
155 ClipPaintPropertyNode::root()->clipRect().rect(), 155 ClipPaintPropertyNode::root()->clipRect().rect(),
156 rootPropertyTreeState(), rootPropertyTreeState(), hasRadius); 156 rootPropertyTreeState(), rootPropertyTreeState());
157 } 157 }
158 158
159 TEST_F(GeometryMapperTest, IdentityTransform) { 159 TEST_F(GeometryMapperTest, IdentityTransform) {
160 RefPtr<TransformPaintPropertyNode> transform = 160 RefPtr<TransformPaintPropertyNode> transform =
161 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 161 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
162 TransformationMatrix(), 162 TransformationMatrix(),
163 FloatPoint3D()); 163 FloatPoint3D());
164 PropertyTreeState localState = rootPropertyTreeState(); 164 PropertyTreeState localState = rootPropertyTreeState();
165 localState.setTransform(transform.get()); 165 localState.setTransform(transform.get());
166 166
167 FloatRect input(0, 0, 100, 100); 167 FloatRect input(0, 0, 100, 100);
168 168
169 bool hasRadius = false; 169 bool hasRadius = false;
170 CHECK_MAPPINGS(input, input, input, transform->matrix(), 170 CHECK_MAPPINGS(input, input, input, transform->matrix(),
171 ClipPaintPropertyNode::root()->clipRect().rect(), localState, 171 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
172 rootPropertyTreeState(), hasRadius); 172 rootPropertyTreeState());
173 } 173 }
174 174
175 TEST_F(GeometryMapperTest, TranslationTransform) { 175 TEST_F(GeometryMapperTest, TranslationTransform) {
176 TransformationMatrix transformMatrix; 176 TransformationMatrix transformMatrix;
177 transformMatrix.translate(20, 10); 177 transformMatrix.translate(20, 10);
178 RefPtr<TransformPaintPropertyNode> transform = 178 RefPtr<TransformPaintPropertyNode> transform =
179 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 179 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
180 transformMatrix, FloatPoint3D()); 180 transformMatrix, FloatPoint3D());
181 PropertyTreeState localState = rootPropertyTreeState(); 181 PropertyTreeState localState = rootPropertyTreeState();
182 localState.setTransform(transform.get()); 182 localState.setTransform(transform.get());
183 183
184 FloatRect input(0, 0, 100, 100); 184 FloatRect input(0, 0, 100, 100);
185 FloatRect output = transformMatrix.mapRect(input); 185 FloatRect output = transformMatrix.mapRect(input);
186 186
187 bool hasRadius = false; 187 bool hasRadius = false;
188 CHECK_MAPPINGS(input, output, output, transform->matrix(), 188 CHECK_MAPPINGS(input, output, output, transform->matrix(),
189 ClipPaintPropertyNode::root()->clipRect().rect(), localState, 189 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
190 rootPropertyTreeState(), hasRadius); 190 rootPropertyTreeState());
191 191
192 EXPECT_RECT_EQ(input, geometryMapper->ancestorToLocalRect( 192 EXPECT_RECT_EQ(input, geometryMapper->ancestorToLocalRect(
193 output, rootPropertyTreeState().transform(), 193 output, rootPropertyTreeState().transform(),
194 localState.transform())); 194 localState.transform()));
195 } 195 }
196 196
197 TEST_F(GeometryMapperTest, RotationAndScaleTransform) { 197 TEST_F(GeometryMapperTest, RotationAndScaleTransform) {
198 TransformationMatrix transformMatrix; 198 TransformationMatrix transformMatrix;
199 transformMatrix.rotate(45); 199 transformMatrix.rotate(45);
200 transformMatrix.scale(2); 200 transformMatrix.scale(2);
201 RefPtr<TransformPaintPropertyNode> transform = 201 RefPtr<TransformPaintPropertyNode> transform =
202 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 202 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
203 transformMatrix, 203 transformMatrix,
204 FloatPoint3D(0, 0, 0)); 204 FloatPoint3D(0, 0, 0));
205 PropertyTreeState localState = rootPropertyTreeState(); 205 PropertyTreeState localState = rootPropertyTreeState();
206 localState.setTransform(transform.get()); 206 localState.setTransform(transform.get());
207 207
208 FloatRect input(0, 0, 100, 100); 208 FloatRect input(0, 0, 100, 100);
209 FloatRect output = transformMatrix.mapRect(input); 209 FloatRect output = transformMatrix.mapRect(input);
210 210
211 bool hasRadius = false; 211 bool hasRadius = false;
212 CHECK_MAPPINGS(input, output, output, transformMatrix, 212 CHECK_MAPPINGS(input, output, output, transformMatrix,
213 ClipPaintPropertyNode::root()->clipRect().rect(), localState, 213 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
214 rootPropertyTreeState(), hasRadius); 214 rootPropertyTreeState());
215 } 215 }
216 216
217 TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) { 217 TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) {
218 TransformationMatrix transformMatrix; 218 TransformationMatrix transformMatrix;
219 transformMatrix.rotate(45); 219 transformMatrix.rotate(45);
220 transformMatrix.scale(2); 220 transformMatrix.scale(2);
221 RefPtr<TransformPaintPropertyNode> transform = 221 RefPtr<TransformPaintPropertyNode> transform =
222 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 222 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
223 transformMatrix, 223 transformMatrix,
224 FloatPoint3D(50, 50, 0)); 224 FloatPoint3D(50, 50, 0));
225 PropertyTreeState localState = rootPropertyTreeState(); 225 PropertyTreeState localState = rootPropertyTreeState();
226 localState.setTransform(transform.get()); 226 localState.setTransform(transform.get());
227 227
228 FloatRect input(0, 0, 100, 100); 228 FloatRect input(0, 0, 100, 100);
229 transformMatrix.applyTransformOrigin(50, 50, 0); 229 transformMatrix.applyTransformOrigin(50, 50, 0);
230 FloatRect output = transformMatrix.mapRect(input); 230 FloatRect output = transformMatrix.mapRect(input);
231 231
232 bool hasRadius = false; 232 bool hasRadius = false;
233 CHECK_MAPPINGS(input, output, output, transformMatrix, 233 CHECK_MAPPINGS(input, output, output, transformMatrix,
234 ClipPaintPropertyNode::root()->clipRect().rect(), localState, 234 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
235 rootPropertyTreeState(), hasRadius); 235 rootPropertyTreeState());
236 } 236 }
237 237
238 TEST_F(GeometryMapperTest, NestedTransforms) { 238 TEST_F(GeometryMapperTest, NestedTransforms) {
239 TransformationMatrix rotateTransform; 239 TransformationMatrix rotateTransform;
240 rotateTransform.rotate(45); 240 rotateTransform.rotate(45);
241 RefPtr<TransformPaintPropertyNode> transform1 = 241 RefPtr<TransformPaintPropertyNode> transform1 =
242 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 242 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
243 rotateTransform, FloatPoint3D()); 243 rotateTransform, FloatPoint3D());
244 244
245 TransformationMatrix scaleTransform; 245 TransformationMatrix scaleTransform;
246 scaleTransform.scale(2); 246 scaleTransform.scale(2);
247 RefPtr<TransformPaintPropertyNode> transform2 = 247 RefPtr<TransformPaintPropertyNode> transform2 =
248 TransformPaintPropertyNode::create(transform1, scaleTransform, 248 TransformPaintPropertyNode::create(transform1, scaleTransform,
249 FloatPoint3D()); 249 FloatPoint3D());
250 250
251 PropertyTreeState localState = rootPropertyTreeState(); 251 PropertyTreeState localState = rootPropertyTreeState();
252 localState.setTransform(transform2.get()); 252 localState.setTransform(transform2.get());
253 253
254 FloatRect input(0, 0, 100, 100); 254 FloatRect input(0, 0, 100, 100);
255 TransformationMatrix final = rotateTransform * scaleTransform; 255 TransformationMatrix final = rotateTransform * scaleTransform;
256 FloatRect output = final.mapRect(input); 256 FloatRect output = final.mapRect(input);
257 257
258 bool hasRadius = false; 258 bool hasRadius = false;
259 CHECK_MAPPINGS(input, output, output, final, 259 CHECK_MAPPINGS(input, output, output, final,
260 ClipPaintPropertyNode::root()->clipRect().rect(), localState, 260 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
261 rootPropertyTreeState(), hasRadius); 261 rootPropertyTreeState());
262 262
263 // Check the cached matrix for the intermediate transform. 263 // Check the cached matrix for the intermediate transform.
264 EXPECT_EQ(rotateTransform, 264 EXPECT_EQ(rotateTransform,
265 getTransformCache(rootPropertyTreeState()).get(transform1.get())); 265 getTransformCache(rootPropertyTreeState()).get(transform1.get()));
266 } 266 }
267 267
268 TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) { 268 TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) {
269 TransformationMatrix scaleTransform; 269 TransformationMatrix scaleTransform;
270 scaleTransform.scale(2); 270 scaleTransform.scale(2);
271 RefPtr<TransformPaintPropertyNode> transform1 = 271 RefPtr<TransformPaintPropertyNode> transform1 =
(...skipping 11 matching lines...) Expand all
283 283
284 FloatRect input(0, 0, 100, 100); 284 FloatRect input(0, 0, 100, 100);
285 // Note: unlike NestedTransforms, the order of these transforms matters. This 285 // Note: unlike NestedTransforms, the order of these transforms matters. This
286 // tests correct order of matrix multiplication. 286 // tests correct order of matrix multiplication.
287 TransformationMatrix final = scaleTransform * translateTransform; 287 TransformationMatrix final = scaleTransform * translateTransform;
288 FloatRect output = final.mapRect(input); 288 FloatRect output = final.mapRect(input);
289 289
290 bool hasRadius = false; 290 bool hasRadius = false;
291 CHECK_MAPPINGS(input, output, output, final, 291 CHECK_MAPPINGS(input, output, output, final,
292 ClipPaintPropertyNode::root()->clipRect().rect(), localState, 292 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
293 rootPropertyTreeState(), hasRadius); 293 rootPropertyTreeState());
294 294
295 // Check the cached matrix for the intermediate transform. 295 // Check the cached matrix for the intermediate transform.
296 EXPECT_EQ(scaleTransform, getTransformCache(rootPropertyTreeState()) 296 EXPECT_EQ(scaleTransform, getTransformCache(rootPropertyTreeState())
297 297
298 .get(transform1.get())); 298 .get(transform1.get()));
299 } 299 }
300 300
301 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) { 301 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) {
302 TransformationMatrix rotateTransform; 302 TransformationMatrix rotateTransform;
303 rotateTransform.rotate(45); 303 rotateTransform.rotate(45);
(...skipping 12 matching lines...) Expand all
316 316
317 PropertyTreeState intermediateState = rootPropertyTreeState(); 317 PropertyTreeState intermediateState = rootPropertyTreeState();
318 intermediateState.setTransform(transform1.get()); 318 intermediateState.setTransform(transform1.get());
319 319
320 FloatRect input(0, 0, 100, 100); 320 FloatRect input(0, 0, 100, 100);
321 FloatRect output = scaleTransform.mapRect(input); 321 FloatRect output = scaleTransform.mapRect(input);
322 322
323 bool hasRadius = false; 323 bool hasRadius = false;
324 CHECK_MAPPINGS(input, output, output, scaleTransform, 324 CHECK_MAPPINGS(input, output, output, scaleTransform,
325 ClipPaintPropertyNode::root()->clipRect().rect(), localState, 325 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
326 intermediateState, hasRadius); 326 intermediateState);
327 } 327 }
328 328
329 TEST_F(GeometryMapperTest, SimpleClip) { 329 TEST_F(GeometryMapperTest, SimpleClip) {
330 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 330 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
331 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 331 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
332 FloatRoundedRect(10, 10, 50, 50)); 332 FloatRoundedRect(10, 10, 50, 50));
333 333
334 PropertyTreeState localState = rootPropertyTreeState(); 334 PropertyTreeState localState = rootPropertyTreeState();
335 localState.setClip(clip.get()); 335 localState.setClip(clip.get());
336 336
337 FloatRect input(0, 0, 100, 100); 337 FloatRect input(0, 0, 100, 100);
338 FloatRect output(10, 10, 50, 50); 338 FloatRect output(10, 10, 50, 50);
339 339
340 bool hasRadius = false; 340 bool hasRadius = false;
341 CHECK_MAPPINGS(input, // Input 341 CHECK_MAPPINGS(input, // Input
342 output, // Visual rect 342 output, // Visual rect
343 input, // Transformed rect (not clipped). 343 input, // Transformed rect (not clipped).
344 TransformPaintPropertyNode::root() 344 TransformPaintPropertyNode::root()
345 ->matrix(), // Transform matrix to ancestor space 345 ->matrix(), // Transform matrix to ancestor space
346 clip->clipRect().rect(), // Clip rect in ancestor space 346 clip->clipRect().rect(), // Clip rect in ancestor space
347 localState, 347 localState,
348 rootPropertyTreeState(), hasRadius); 348 rootPropertyTreeState());
349 } 349 }
350 350
351 TEST_F(GeometryMapperTest, RoundedClip) { 351 TEST_F(GeometryMapperTest, RoundedClip) {
352 FloatRoundedRect rect(FloatRect(10, 10, 50, 50), 352 FloatRoundedRect rect(FloatRect(10, 10, 50, 50),
353 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), 353 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(),
354 FloatSize(), FloatSize())); 354 FloatSize(), FloatSize()));
355 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 355 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
356 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), rect); 356 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), rect);
357 357
358 PropertyTreeState localState = rootPropertyTreeState(); 358 PropertyTreeState localState = rootPropertyTreeState();
359 localState.setClip(clip.get()); 359 localState.setClip(clip.get());
360 360
361 FloatRect input(0, 0, 100, 100); 361 FloatRect input(0, 0, 100, 100);
362 FloatRect output(10, 10, 50, 50); 362 FloatRect output(10, 10, 50, 50);
363 363
364 bool hasRadius = true; 364 bool hasRadius = true;
365 CHECK_MAPPINGS(input, // Input 365 CHECK_MAPPINGS(input, // Input
366 output, // Visual rect 366 output, // Visual rect
367 input, // Transformed rect (not clipped). 367 input, // Transformed rect (not clipped).
368 TransformPaintPropertyNode::root() 368 TransformPaintPropertyNode::root()
369 ->matrix(), // Transform matrix to ancestor space 369 ->matrix(), // Transform matrix to ancestor space
370 clip->clipRect().rect(), // Clip rect in ancestor space 370 clip->clipRect().rect(), // Clip rect in ancestor space
371 localState, 371 localState,
372 rootPropertyTreeState(), hasRadius); 372 rootPropertyTreeState());
373 } 373 }
374 374
375 TEST_F(GeometryMapperTest, TwoClips) { 375 TEST_F(GeometryMapperTest, TwoClips) {
376 FloatRoundedRect clipRect1( 376 FloatRoundedRect clipRect1(
377 FloatRect(10, 10, 30, 40), 377 FloatRect(10, 10, 30, 40),
378 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), FloatSize(), 378 FloatRoundedRect::Radii(FloatSize(1, 1), FloatSize(), FloatSize(),
379 FloatSize())); 379 FloatSize()));
380 380
381 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( 381 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
382 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 382 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
(...skipping 11 matching lines...) Expand all
394 FloatRect output1(10, 10, 30, 40); 394 FloatRect output1(10, 10, 30, 40);
395 395
396 bool hasRadius = true; 396 bool hasRadius = true;
397 CHECK_MAPPINGS(input, // Input 397 CHECK_MAPPINGS(input, // Input
398 output1, // Visual rect 398 output1, // Visual rect
399 input, // Transformed rect (not clipped). 399 input, // Transformed rect (not clipped).
400 TransformPaintPropertyNode::root() 400 TransformPaintPropertyNode::root()
401 ->matrix(), // Transform matrix to ancestor space 401 ->matrix(), // Transform matrix to ancestor space
402 clip1->clipRect().rect(), // Clip rect in ancestor space 402 clip1->clipRect().rect(), // Clip rect in ancestor space
403 localState, 403 localState,
404 ancestorState, hasRadius); 404 ancestorState);
405 405
406 ancestorState.setClip(clip1.get()); 406 ancestorState.setClip(clip1.get());
407 FloatRect output2(10, 10, 50, 50); 407 FloatRect output2(10, 10, 50, 50);
408 408
409 hasRadius = false; 409 hasRadius = false;
410 CHECK_MAPPINGS(input, // Input 410 CHECK_MAPPINGS(input, // Input
411 output2, // Visual rect 411 output2, // Visual rect
412 input, // Transformed rect (not clipped). 412 input, // Transformed rect (not clipped).
413 TransformPaintPropertyNode::root() 413 TransformPaintPropertyNode::root()
414 ->matrix(), // Transform matrix to ancestor space 414 ->matrix(), // Transform matrix to ancestor space
415 clip2->clipRect().rect(), // Clip rect in ancestor space 415 clip2->clipRect().rect(), // Clip rect in ancestor space
416 localState, 416 localState,
417 ancestorState, hasRadius); 417 ancestorState);
418 } 418 }
419 419
420 TEST_F(GeometryMapperTest, ClipBeforeTransform) { 420 TEST_F(GeometryMapperTest, ClipBeforeTransform) {
421 TransformationMatrix rotateTransform; 421 TransformationMatrix rotateTransform;
422 rotateTransform.rotate(45); 422 rotateTransform.rotate(45);
423 RefPtr<TransformPaintPropertyNode> transform = 423 RefPtr<TransformPaintPropertyNode> transform =
424 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 424 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
425 rotateTransform, FloatPoint3D()); 425 rotateTransform, FloatPoint3D());
426 426
427 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 427 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
(...skipping 11 matching lines...) Expand all
439 439
440 bool hasRadius = false; 440 bool hasRadius = false;
441 CHECK_MAPPINGS( 441 CHECK_MAPPINGS(
442 input, // Input 442 input, // Input
443 output, // Visual rect 443 output, // Visual rect
444 rotateTransform.mapRect(input), // Transformed rect (not clipped). 444 rotateTransform.mapRect(input), // Transformed rect (not clipped).
445 rotateTransform, // Transform matrix to ancestor space 445 rotateTransform, // Transform matrix to ancestor space
446 rotateTransform.mapRect( 446 rotateTransform.mapRect(
447 clip->clipRect().rect()), // Clip rect in ancestor space 447 clip->clipRect().rect()), // Clip rect in ancestor space
448 localState, 448 localState,
449 rootPropertyTreeState(), hasRadius); 449 rootPropertyTreeState());
450 } 450 }
451 451
452 TEST_F(GeometryMapperTest, ClipAfterTransform) { 452 TEST_F(GeometryMapperTest, ClipAfterTransform) {
453 TransformationMatrix rotateTransform; 453 TransformationMatrix rotateTransform;
454 rotateTransform.rotate(45); 454 rotateTransform.rotate(45);
455 RefPtr<TransformPaintPropertyNode> transform = 455 RefPtr<TransformPaintPropertyNode> transform =
456 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 456 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
457 rotateTransform, FloatPoint3D()); 457 rotateTransform, FloatPoint3D());
458 458
459 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 459 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
460 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 460 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
461 FloatRoundedRect(10, 10, 200, 200)); 461 FloatRoundedRect(10, 10, 200, 200));
462 462
463 PropertyTreeState localState = rootPropertyTreeState(); 463 PropertyTreeState localState = rootPropertyTreeState();
464 localState.setClip(clip.get()); 464 localState.setClip(clip.get());
465 localState.setTransform(transform.get()); 465 localState.setTransform(transform.get());
466 466
467 FloatRect input(0, 0, 100, 100); 467 FloatRect input(0, 0, 100, 100);
468 FloatRect output(input); 468 FloatRect output(input);
469 output = rotateTransform.mapRect(output); 469 output = rotateTransform.mapRect(output);
470 output.intersect(clip->clipRect().rect()); 470 output.intersect(clip->clipRect().rect());
471 471
472 bool hasRadius = false; 472 bool hasRadius = false;
473 CHECK_MAPPINGS( 473 CHECK_MAPPINGS(
474 input, // Input 474 input, // Input
475 output, // Visual rect 475 output, // Visual rect
476 rotateTransform.mapRect(input), // Transformed rect (not clipped) 476 rotateTransform.mapRect(input), // Transformed rect (not clipped)
477 rotateTransform, // Transform matrix to ancestor space 477 rotateTransform, // Transform matrix to ancestor space
478 clip->clipRect().rect(), // Clip rect in ancestor space 478 clip->clipRect().rect(), // Clip rect in ancestor space
479 localState, rootPropertyTreeState(), hasRadius); 479 localState, rootPropertyTreeState());
480 } 480 }
481 481
482 TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween) { 482 TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween) {
483 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( 483 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
484 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 484 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
485 FloatRoundedRect(10, 10, 200, 200)); 485 FloatRoundedRect(10, 10, 200, 200));
486 486
487 TransformationMatrix rotateTransform; 487 TransformationMatrix rotateTransform;
488 rotateTransform.rotate(45); 488 rotateTransform.rotate(45);
489 RefPtr<TransformPaintPropertyNode> transform = 489 RefPtr<TransformPaintPropertyNode> transform =
(...skipping 14 matching lines...) Expand all
504 FloatRect output(input); 504 FloatRect output(input);
505 output = rotateTransform.mapRect(output); 505 output = rotateTransform.mapRect(output);
506 output.intersect(clip1->clipRect().rect()); 506 output.intersect(clip1->clipRect().rect());
507 507
508 CHECK_MAPPINGS( 508 CHECK_MAPPINGS(
509 input, // Input 509 input, // Input
510 output, // Visual rect 510 output, // Visual rect
511 rotateTransform.mapRect(input), // Transformed rect (not clipped) 511 rotateTransform.mapRect(input), // Transformed rect (not clipped)
512 rotateTransform, // Transform matrix to ancestor space 512 rotateTransform, // Transform matrix to ancestor space
513 clip1->clipRect().rect(), // Clip rect in ancestor space 513 clip1->clipRect().rect(), // Clip rect in ancestor space
514 localState, rootPropertyTreeState(), hasRadius); 514 localState, rootPropertyTreeState());
515 } 515 }
516 516
517 { 517 {
518 PropertyTreeState localState = rootPropertyTreeState(); 518 PropertyTreeState localState = rootPropertyTreeState();
519 localState.setClip(clip2.get()); 519 localState.setClip(clip2.get());
520 localState.setTransform(transform.get()); 520 localState.setTransform(transform.get());
521 521
522 FloatRect mappedClip = rotateTransform.mapRect(clip2->clipRect().rect()); 522 FloatRect mappedClip = rotateTransform.mapRect(clip2->clipRect().rect());
523 mappedClip.intersect(clip1->clipRect().rect()); 523 mappedClip.intersect(clip1->clipRect().rect());
524 524
525 // All clips are performed in the space of the ancestor. In cases such as 525 // All clips are performed in the space of the ancestor. In cases such as
526 // this, this means the clip is a bit lossy. 526 // this, this means the clip is a bit lossy.
527 FloatRect output(input); 527 FloatRect output(input);
528 // Map to transformed rect in ancestor space. 528 // Map to transformed rect in ancestor space.
529 output = rotateTransform.mapRect(output); 529 output = rotateTransform.mapRect(output);
530 // Intersect with all clips between local and ancestor, independently mapped 530 // Intersect with all clips between local and ancestor, independently mapped
531 // to ancestor space. 531 // to ancestor space.
532 output.intersect(mappedClip); 532 output.intersect(mappedClip);
533 533
534 CHECK_MAPPINGS( 534 CHECK_MAPPINGS(
535 input, // Input 535 input, // Input
536 output, // Visual rect 536 output, // Visual rect
537 rotateTransform.mapRect(input), // Transformed rect (not clipped) 537 rotateTransform.mapRect(input), // Transformed rect (not clipped)
538 rotateTransform, // Transform matrix to ancestor space 538 rotateTransform, // Transform matrix to ancestor space
539 mappedClip, // Clip rect in ancestor space 539 mappedClip, // Clip rect in ancestor space
540 localState, rootPropertyTreeState(), hasRadius); 540 localState, rootPropertyTreeState());
541 } 541 }
542 } 542 }
543 543
544 TEST_F(GeometryMapperTest, SiblingTransforms) { 544 TEST_F(GeometryMapperTest, SiblingTransforms) {
545 // These transforms are siblings. Thus mapping from one to the other requires 545 // These transforms are siblings. Thus mapping from one to the other requires
546 // going through the root. 546 // going through the root.
547 TransformationMatrix rotateTransform1; 547 TransformationMatrix rotateTransform1;
548 rotateTransform1.rotate(45); 548 rotateTransform1.rotate(45);
549 RefPtr<TransformPaintPropertyNode> transform1 = 549 RefPtr<TransformPaintPropertyNode> transform1 =
550 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 550 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 output.intersect(clipAboveEffect->clipRect().rect()); 742 output.intersect(clipAboveEffect->clipRect().rect());
743 EXPECT_EQ(FloatRect(-50, -50, 150, 150), output); 743 EXPECT_EQ(FloatRect(-50, -50, 150, 150), output);
744 // 5. transformAboveEffect 744 // 5. transformAboveEffect
745 output = transformAboveEffect->matrix().mapRect(output); 745 output = transformAboveEffect->matrix().mapRect(output);
746 EXPECT_EQ(FloatRect(-150, -150, 450, 450), output); 746 EXPECT_EQ(FloatRect(-150, -150, 450, 450), output);
747 747
748 bool hasRadius = false; 748 bool hasRadius = false;
749 CHECK_MAPPINGS( 749 CHECK_MAPPINGS(
750 input, output, FloatRect(0, 0, 300, 300), 750 input, output, FloatRect(0, 0, 300, 300),
751 transformAboveEffect->matrix() * transformBelowEffect->matrix(), 751 transformAboveEffect->matrix() * transformBelowEffect->matrix(),
752 FloatRect(30, 30, 270, 270), localState, rootPropertyTreeState(), 752 FloatRect(30, 30, 270, 270), localState, rootPropertyTreeState());
753 hasRadius);
754 } 753 }
755 754
756 TEST_F(GeometryMapperTest, ReflectionWithPaintOffset) { 755 TEST_F(GeometryMapperTest, ReflectionWithPaintOffset) {
757 CompositorFilterOperations filters; 756 CompositorFilterOperations filters;
758 filters.appendReferenceFilter(SkiaImageFilterBuilder::buildBoxReflectFilter( 757 filters.appendReferenceFilter(SkiaImageFilterBuilder::buildBoxReflectFilter(
759 BoxReflection(BoxReflection::HorizontalReflection, 0), nullptr)); 758 BoxReflection(BoxReflection::HorizontalReflection, 0), nullptr));
760 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( 759 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create(
761 rootPropertyTreeState().effect(), rootPropertyTreeState().transform(), 760 rootPropertyTreeState().effect(), rootPropertyTreeState().transform(),
762 rootPropertyTreeState().clip(), filters, 1.0, SkBlendMode::kSrcOver, 761 rootPropertyTreeState().clip(), filters, 1.0, SkBlendMode::kSrcOver,
763 CompositingReasonNone, CompositorElementId(), FloatPoint(100, 100)); 762 CompositingReasonNone, CompositorElementId(), FloatPoint(100, 100));
764 763
765 PropertyTreeState localState = rootPropertyTreeState(); 764 PropertyTreeState localState = rootPropertyTreeState();
766 localState.setEffect(effect); 765 localState.setEffect(effect);
767 766
768 FloatRect input(100, 100, 50, 50); 767 FloatRect input(100, 100, 50, 50);
769 // Reflection is at (50, 100, 50, 50). 768 // Reflection is at (50, 100, 50, 50).
770 FloatRect output(50, 100, 100, 50); 769 FloatRect output(50, 100, 100, 50);
771 770
772 bool hasRadius = false; 771 bool hasRadius = false;
773 CHECK_MAPPINGS(input, output, input, TransformationMatrix(), 772 CHECK_MAPPINGS(input, output, input, TransformationMatrix(),
774 ClipPaintPropertyNode::root()->clipRect().rect(), localState, 773 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
775 rootPropertyTreeState(), hasRadius); 774 rootPropertyTreeState());
776 } 775 }
777 776
778 } // namespace blink 777 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698