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

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

Issue 2565903002: [SPv2] Add createOpacityOnlyEffect test helper (Closed)
Patch Set: rebase && git cl format Created 4 years 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"
11 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" 11 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
12 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 12 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
13 #include "platform/testing/PaintPropertyTestHelpers.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class GeometryMapperTest : public ::testing::Test { 18 class GeometryMapperTest : public ::testing::Test {
18 public: 19 public:
19 RefPtr<TransformPaintPropertyNode> rootTransformNode;
20 RefPtr<ClipPaintPropertyNode> rootClipNode;
21 RefPtr<EffectPaintPropertyNode> rootEffectNode;
22 RefPtr<ScrollPaintPropertyNode> rootScrollNode;
23
24 std::unique_ptr<GeometryMapper> geometryMapper; 20 std::unique_ptr<GeometryMapper> geometryMapper;
25 21
26 PropertyTreeState rootPropertyTreeState() { 22 PropertyTreeState rootPropertyTreeState() {
27 PropertyTreeState state(rootTransformNode.get(), rootClipNode.get(), 23 PropertyTreeState state(
28 rootEffectNode.get(), rootScrollNode.get()); 24 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
25 EffectPaintPropertyNode::root(), ScrollPaintPropertyNode::root());
29 return state; 26 return state;
30 } 27 }
31 28
32 PrecomputedDataForAncestor& getPrecomputedDataForAncestor( 29 PrecomputedDataForAncestor& getPrecomputedDataForAncestor(
33 const PropertyTreeState& propertyTreeState) { 30 const PropertyTreeState& propertyTreeState) {
34 return geometryMapper->getPrecomputedDataForAncestor(propertyTreeState); 31 return geometryMapper->getPrecomputedDataForAncestor(propertyTreeState);
35 } 32 }
36 33
37 const TransformPaintPropertyNode* leastCommonAncestor( 34 const TransformPaintPropertyNode* leastCommonAncestor(
38 const TransformPaintPropertyNode* a, 35 const TransformPaintPropertyNode* a,
39 const TransformPaintPropertyNode* b) { 36 const TransformPaintPropertyNode* b) {
40 return GeometryMapper::leastCommonAncestor(a, b); 37 return GeometryMapper::leastCommonAncestor(a, b);
41 } 38 }
42 39
43 private: 40 private:
44 void SetUp() override { 41 void SetUp() override {
45 rootTransformNode = TransformPaintPropertyNode::create(
46 nullptr, TransformationMatrix(), FloatPoint3D());
47 rootClipNode = ClipPaintPropertyNode::create(
48 nullptr, rootTransformNode,
49 FloatRoundedRect(LayoutRect::infiniteIntRect()));
50 rootEffectNode = EffectPaintPropertyNode::create(
51 nullptr, rootTransformNode, rootClipNode, CompositorFilterOperations(),
52 1.0);
53 rootScrollNode = ScrollPaintPropertyNode::create(
54 nullptr, rootTransformNode, IntSize(), IntSize(), false, false, 0);
55 geometryMapper = WTF::makeUnique<GeometryMapper>(); 42 geometryMapper = WTF::makeUnique<GeometryMapper>();
56 } 43 }
57 44
58 void TearDown() override { geometryMapper.reset(); } 45 void TearDown() override { geometryMapper.reset(); }
59 }; 46 };
60 47
61 const static float kTestEpsilon = 1e-6; 48 const static float kTestEpsilon = 1e-6;
62 49
63 #define EXPECT_RECT_EQ(expected, actual) \ 50 #define EXPECT_RECT_EQ(expected, actual) \
64 do { \ 51 do { \
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 getPrecomputedDataForAncestor(ancestorPropertyTreeState) \ 96 getPrecomputedDataForAncestor(ancestorPropertyTreeState) \
110 .toAncestorTransforms.get(localPropertyTreeState.transform())); \ 97 .toAncestorTransforms.get(localPropertyTreeState.transform())); \
111 EXPECT_EQ(expectedClipInAncestorSpace, \ 98 EXPECT_EQ(expectedClipInAncestorSpace, \
112 getPrecomputedDataForAncestor(ancestorPropertyTreeState) \ 99 getPrecomputedDataForAncestor(ancestorPropertyTreeState) \
113 .toAncestorClipRects.get(localPropertyTreeState.clip())); \ 100 .toAncestorClipRects.get(localPropertyTreeState.clip())); \
114 } while (false) 101 } while (false)
115 102
116 TEST_F(GeometryMapperTest, Root) { 103 TEST_F(GeometryMapperTest, Root) {
117 FloatRect input(0, 0, 100, 100); 104 FloatRect input(0, 0, 100, 100);
118 105
119 CHECK_MAPPINGS(input, input, input, rootTransformNode->matrix(), 106 CHECK_MAPPINGS(input, input, input,
120 rootClipNode->clipRect().rect(), rootPropertyTreeState(), 107 TransformPaintPropertyNode::root()->matrix(),
121 rootPropertyTreeState()); 108 ClipPaintPropertyNode::root()->clipRect().rect(),
109 rootPropertyTreeState(), rootPropertyTreeState());
122 } 110 }
123 111
124 TEST_F(GeometryMapperTest, IdentityTransform) { 112 TEST_F(GeometryMapperTest, IdentityTransform) {
125 RefPtr<TransformPaintPropertyNode> transform = 113 RefPtr<TransformPaintPropertyNode> transform =
126 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 114 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
127 TransformationMatrix(), 115 TransformationMatrix(),
128 FloatPoint3D()); 116 FloatPoint3D());
129 PropertyTreeState localState = rootPropertyTreeState(); 117 PropertyTreeState localState = rootPropertyTreeState();
130 localState.setTransform(transform.get()); 118 localState.setTransform(transform.get());
131 119
132 FloatRect input(0, 0, 100, 100); 120 FloatRect input(0, 0, 100, 100);
133 121
134 CHECK_MAPPINGS(input, input, input, transform->matrix(), 122 CHECK_MAPPINGS(input, input, input, transform->matrix(),
135 rootClipNode->clipRect().rect(), localState, 123 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
136 rootPropertyTreeState()); 124 rootPropertyTreeState());
137 } 125 }
138 126
139 TEST_F(GeometryMapperTest, TranslationTransform) { 127 TEST_F(GeometryMapperTest, TranslationTransform) {
140 TransformationMatrix transformMatrix; 128 TransformationMatrix transformMatrix;
141 transformMatrix.translate(20, 10); 129 transformMatrix.translate(20, 10);
142 RefPtr<TransformPaintPropertyNode> transform = 130 RefPtr<TransformPaintPropertyNode> transform =
143 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 131 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
144 transformMatrix, FloatPoint3D()); 132 transformMatrix, FloatPoint3D());
145 PropertyTreeState localState = rootPropertyTreeState(); 133 PropertyTreeState localState = rootPropertyTreeState();
146 localState.setTransform(transform.get()); 134 localState.setTransform(transform.get());
147 135
148 FloatRect input(0, 0, 100, 100); 136 FloatRect input(0, 0, 100, 100);
149 FloatRect output = transformMatrix.mapRect(input); 137 FloatRect output = transformMatrix.mapRect(input);
150 138
151 CHECK_MAPPINGS(input, output, output, transform->matrix(), 139 CHECK_MAPPINGS(input, output, output, transform->matrix(),
152 rootClipNode->clipRect().rect(), localState, 140 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
153 rootPropertyTreeState()); 141 rootPropertyTreeState());
154 142
155 bool success = false; 143 bool success = false;
156 EXPECT_RECT_EQ(input, 144 EXPECT_RECT_EQ(input,
157 geometryMapper->ancestorToLocalRect( 145 geometryMapper->ancestorToLocalRect(
158 output, localState, rootPropertyTreeState(), success)); 146 output, localState, rootPropertyTreeState(), success));
159 EXPECT_TRUE(success); 147 EXPECT_TRUE(success);
160 } 148 }
161 149
162 TEST_F(GeometryMapperTest, RotationAndScaleTransform) { 150 TEST_F(GeometryMapperTest, RotationAndScaleTransform) {
163 TransformationMatrix transformMatrix; 151 TransformationMatrix transformMatrix;
164 transformMatrix.rotate(45); 152 transformMatrix.rotate(45);
165 transformMatrix.scale(2); 153 transformMatrix.scale(2);
166 RefPtr<TransformPaintPropertyNode> transform = 154 RefPtr<TransformPaintPropertyNode> transform =
167 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 155 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
168 transformMatrix, 156 transformMatrix,
169 FloatPoint3D(0, 0, 0)); 157 FloatPoint3D(0, 0, 0));
170 PropertyTreeState localState = rootPropertyTreeState(); 158 PropertyTreeState localState = rootPropertyTreeState();
171 localState.setTransform(transform.get()); 159 localState.setTransform(transform.get());
172 160
173 FloatRect input(0, 0, 100, 100); 161 FloatRect input(0, 0, 100, 100);
174 FloatRect output = transformMatrix.mapRect(input); 162 FloatRect output = transformMatrix.mapRect(input);
175 163
176 CHECK_MAPPINGS(input, output, output, transformMatrix, 164 CHECK_MAPPINGS(input, output, output, transformMatrix,
177 rootClipNode->clipRect().rect(), localState, 165 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
178 rootPropertyTreeState()); 166 rootPropertyTreeState());
179 } 167 }
180 168
181 TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) { 169 TEST_F(GeometryMapperTest, RotationAndScaleTransformWithTransformOrigin) {
182 TransformationMatrix transformMatrix; 170 TransformationMatrix transformMatrix;
183 transformMatrix.rotate(45); 171 transformMatrix.rotate(45);
184 transformMatrix.scale(2); 172 transformMatrix.scale(2);
185 RefPtr<TransformPaintPropertyNode> transform = 173 RefPtr<TransformPaintPropertyNode> transform =
186 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 174 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
187 transformMatrix, 175 transformMatrix,
188 FloatPoint3D(50, 50, 0)); 176 FloatPoint3D(50, 50, 0));
189 PropertyTreeState localState = rootPropertyTreeState(); 177 PropertyTreeState localState = rootPropertyTreeState();
190 localState.setTransform(transform.get()); 178 localState.setTransform(transform.get());
191 179
192 FloatRect input(0, 0, 100, 100); 180 FloatRect input(0, 0, 100, 100);
193 transformMatrix.applyTransformOrigin(50, 50, 0); 181 transformMatrix.applyTransformOrigin(50, 50, 0);
194 FloatRect output = transformMatrix.mapRect(input); 182 FloatRect output = transformMatrix.mapRect(input);
195 183
196 CHECK_MAPPINGS(input, output, output, transformMatrix, 184 CHECK_MAPPINGS(input, output, output, transformMatrix,
197 rootClipNode->clipRect().rect(), localState, 185 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
198 rootPropertyTreeState()); 186 rootPropertyTreeState());
199 } 187 }
200 188
201 TEST_F(GeometryMapperTest, NestedTransforms) { 189 TEST_F(GeometryMapperTest, NestedTransforms) {
202 TransformationMatrix rotateTransform; 190 TransformationMatrix rotateTransform;
203 rotateTransform.rotate(45); 191 rotateTransform.rotate(45);
204 RefPtr<TransformPaintPropertyNode> transform1 = 192 RefPtr<TransformPaintPropertyNode> transform1 =
205 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 193 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
206 rotateTransform, FloatPoint3D()); 194 rotateTransform, FloatPoint3D());
207 195
208 TransformationMatrix scaleTransform; 196 TransformationMatrix scaleTransform;
209 scaleTransform.scale(2); 197 scaleTransform.scale(2);
210 RefPtr<TransformPaintPropertyNode> transform2 = 198 RefPtr<TransformPaintPropertyNode> transform2 =
211 TransformPaintPropertyNode::create(transform1, scaleTransform, 199 TransformPaintPropertyNode::create(transform1, scaleTransform,
212 FloatPoint3D()); 200 FloatPoint3D());
213 201
214 PropertyTreeState localState = rootPropertyTreeState(); 202 PropertyTreeState localState = rootPropertyTreeState();
215 localState.setTransform(transform2.get()); 203 localState.setTransform(transform2.get());
216 204
217 FloatRect input(0, 0, 100, 100); 205 FloatRect input(0, 0, 100, 100);
218 TransformationMatrix final = rotateTransform * scaleTransform; 206 TransformationMatrix final = rotateTransform * scaleTransform;
219 FloatRect output = final.mapRect(input); 207 FloatRect output = final.mapRect(input);
220 208
221 CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect(), 209 CHECK_MAPPINGS(input, output, output, final,
222 localState, rootPropertyTreeState()); 210 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
211 rootPropertyTreeState());
223 212
224 // Check the cached matrix for the intermediate transform. 213 // Check the cached matrix for the intermediate transform.
225 EXPECT_EQ(rotateTransform, 214 EXPECT_EQ(rotateTransform,
226 getPrecomputedDataForAncestor(rootPropertyTreeState()) 215 getPrecomputedDataForAncestor(rootPropertyTreeState())
227 .toAncestorTransforms.get(transform1.get())); 216 .toAncestorTransforms.get(transform1.get()));
228 } 217 }
229 218
230 TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) { 219 TEST_F(GeometryMapperTest, NestedTransformsScaleAndTranslation) {
231 TransformationMatrix scaleTransform; 220 TransformationMatrix scaleTransform;
232 scaleTransform.scale(2); 221 scaleTransform.scale(2);
233 RefPtr<TransformPaintPropertyNode> transform1 = 222 RefPtr<TransformPaintPropertyNode> transform1 =
234 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 223 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
235 scaleTransform, FloatPoint3D()); 224 scaleTransform, FloatPoint3D());
236 225
237 TransformationMatrix translateTransform; 226 TransformationMatrix translateTransform;
238 translateTransform.translate(100, 0); 227 translateTransform.translate(100, 0);
239 RefPtr<TransformPaintPropertyNode> transform2 = 228 RefPtr<TransformPaintPropertyNode> transform2 =
240 TransformPaintPropertyNode::create(transform1, translateTransform, 229 TransformPaintPropertyNode::create(transform1, translateTransform,
241 FloatPoint3D()); 230 FloatPoint3D());
242 231
243 PropertyTreeState localState = rootPropertyTreeState(); 232 PropertyTreeState localState = rootPropertyTreeState();
244 localState.setTransform(transform2.get()); 233 localState.setTransform(transform2.get());
245 234
246 FloatRect input(0, 0, 100, 100); 235 FloatRect input(0, 0, 100, 100);
247 // Note: unlike NestedTransforms, the order of these transforms matters. This 236 // Note: unlike NestedTransforms, the order of these transforms matters. This
248 // tests correct order of matrix multiplication. 237 // tests correct order of matrix multiplication.
249 TransformationMatrix final = scaleTransform * translateTransform; 238 TransformationMatrix final = scaleTransform * translateTransform;
250 FloatRect output = final.mapRect(input); 239 FloatRect output = final.mapRect(input);
251 240
252 CHECK_MAPPINGS(input, output, output, final, rootClipNode->clipRect().rect(), 241 CHECK_MAPPINGS(input, output, output, final,
253 localState, rootPropertyTreeState()); 242 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
243 rootPropertyTreeState());
254 244
255 // Check the cached matrix for the intermediate transform. 245 // Check the cached matrix for the intermediate transform.
256 EXPECT_EQ(scaleTransform, 246 EXPECT_EQ(scaleTransform,
257 getPrecomputedDataForAncestor(rootPropertyTreeState()) 247 getPrecomputedDataForAncestor(rootPropertyTreeState())
258 .toAncestorTransforms.get(transform1.get())); 248 .toAncestorTransforms.get(transform1.get()));
259 } 249 }
260 250
261 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) { 251 TEST_F(GeometryMapperTest, NestedTransformsIntermediateDestination) {
262 TransformationMatrix rotateTransform; 252 TransformationMatrix rotateTransform;
263 rotateTransform.rotate(45); 253 rotateTransform.rotate(45);
(...skipping 10 matching lines...) Expand all
274 PropertyTreeState localState = rootPropertyTreeState(); 264 PropertyTreeState localState = rootPropertyTreeState();
275 localState.setTransform(transform2.get()); 265 localState.setTransform(transform2.get());
276 266
277 PropertyTreeState intermediateState = rootPropertyTreeState(); 267 PropertyTreeState intermediateState = rootPropertyTreeState();
278 intermediateState.setTransform(transform1.get()); 268 intermediateState.setTransform(transform1.get());
279 269
280 FloatRect input(0, 0, 100, 100); 270 FloatRect input(0, 0, 100, 100);
281 FloatRect output = scaleTransform.mapRect(input); 271 FloatRect output = scaleTransform.mapRect(input);
282 272
283 CHECK_MAPPINGS(input, output, output, scaleTransform, 273 CHECK_MAPPINGS(input, output, output, scaleTransform,
284 rootClipNode->clipRect().rect(), localState, 274 ClipPaintPropertyNode::root()->clipRect().rect(), localState,
285 intermediateState); 275 intermediateState);
286 } 276 }
287 277
288 TEST_F(GeometryMapperTest, SimpleClip) { 278 TEST_F(GeometryMapperTest, SimpleClip) {
289 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 279 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
290 rootClipNode, rootTransformNode, FloatRoundedRect(10, 10, 50, 50)); 280 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
281 FloatRoundedRect(10, 10, 50, 50));
291 282
292 PropertyTreeState localState = rootPropertyTreeState(); 283 PropertyTreeState localState = rootPropertyTreeState();
293 localState.setClip(clip.get()); 284 localState.setClip(clip.get());
294 285
295 FloatRect input(0, 0, 100, 100); 286 FloatRect input(0, 0, 100, 100);
296 FloatRect output(10, 10, 50, 50); 287 FloatRect output(10, 10, 50, 50);
297 288
298 CHECK_MAPPINGS( 289 CHECK_MAPPINGS(input, // Input
299 input, // Input 290 output, // Visual rect
300 output, // Visual rect 291 input, // Transformed rect (not clipped).
301 input, // Transformed rect (not clipped). 292 TransformPaintPropertyNode::root()
302 rootTransformNode->matrix(), // Transform matrix to ancestor space 293 ->matrix(), // Transform matrix to ancestor space
303 clip->clipRect().rect(), // Clip rect in ancestor space 294 clip->clipRect().rect(), // Clip rect in ancestor space
304 localState, rootPropertyTreeState()); 295 localState,
296 rootPropertyTreeState());
305 } 297 }
306 298
307 TEST_F(GeometryMapperTest, ClipBeforeTransform) { 299 TEST_F(GeometryMapperTest, ClipBeforeTransform) {
308 TransformationMatrix rotateTransform; 300 TransformationMatrix rotateTransform;
309 rotateTransform.rotate(45); 301 rotateTransform.rotate(45);
310 RefPtr<TransformPaintPropertyNode> transform = 302 RefPtr<TransformPaintPropertyNode> transform =
311 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 303 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
312 rotateTransform, FloatPoint3D()); 304 rotateTransform, FloatPoint3D());
313 305
314 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( 306 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
315 rootClipNode, transform.get(), FloatRoundedRect(10, 10, 50, 50)); 307 ClipPaintPropertyNode::root(), transform.get(),
308 FloatRoundedRect(10, 10, 50, 50));
316 309
317 PropertyTreeState localState = rootPropertyTreeState(); 310 PropertyTreeState localState = rootPropertyTreeState();
318 localState.setClip(clip.get()); 311 localState.setClip(clip.get());
319 localState.setTransform(transform.get()); 312 localState.setTransform(transform.get());
320 313
321 FloatRect input(0, 0, 100, 100); 314 FloatRect input(0, 0, 100, 100);
322 FloatRect output(input); 315 FloatRect output(input);
323 output.intersect(clip->clipRect().rect()); 316 output.intersect(clip->clipRect().rect());
324 output = rotateTransform.mapRect(output); 317 output = rotateTransform.mapRect(output);
325 318
326 CHECK_MAPPINGS( 319 CHECK_MAPPINGS(
327 input, // Input 320 input, // Input
328 output, // Visual rect 321 output, // Visual rect
329 rotateTransform.mapRect(input), // Transformed rect (not clipped). 322 rotateTransform.mapRect(input), // Transformed rect (not clipped).
330 rotateTransform, // Transform matrix to ancestor space 323 rotateTransform, // Transform matrix to ancestor space
331 rotateTransform.mapRect( 324 rotateTransform.mapRect(
332 clip->clipRect().rect()), // Clip rect in ancestor space 325 clip->clipRect().rect()), // Clip rect in ancestor space
333 localState, 326 localState,
334 rootPropertyTreeState()); 327 rootPropertyTreeState());
335 } 328 }
336 329
337 TEST_F(GeometryMapperTest, ClipAfterTransform) { 330 TEST_F(GeometryMapperTest, ClipAfterTransform) {
338 TransformationMatrix rotateTransform; 331 TransformationMatrix rotateTransform;
339 rotateTransform.rotate(45); 332 rotateTransform.rotate(45);
340 RefPtr<TransformPaintPropertyNode> transform = 333 RefPtr<TransformPaintPropertyNode> transform =
341 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 334 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
342 rotateTransform, FloatPoint3D()); 335 rotateTransform, FloatPoint3D());
343 336
344 RefPtr<ClipPaintPropertyNode> clip = 337 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
345 ClipPaintPropertyNode::create(rootClipNode, rootTransformNode.get(), 338 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
346 FloatRoundedRect(10, 10, 200, 200)); 339 FloatRoundedRect(10, 10, 200, 200));
347 340
348 PropertyTreeState localState = rootPropertyTreeState(); 341 PropertyTreeState localState = rootPropertyTreeState();
349 localState.setClip(clip.get()); 342 localState.setClip(clip.get());
350 localState.setTransform(transform.get()); 343 localState.setTransform(transform.get());
351 344
352 FloatRect input(0, 0, 100, 100); 345 FloatRect input(0, 0, 100, 100);
353 FloatRect output(input); 346 FloatRect output(input);
354 output = rotateTransform.mapRect(output); 347 output = rotateTransform.mapRect(output);
355 output.intersect(clip->clipRect().rect()); 348 output.intersect(clip->clipRect().rect());
356 349
357 CHECK_MAPPINGS( 350 CHECK_MAPPINGS(
358 input, // Input 351 input, // Input
359 output, // Visual rect 352 output, // Visual rect
360 rotateTransform.mapRect(input), // Transformed rect (not clipped) 353 rotateTransform.mapRect(input), // Transformed rect (not clipped)
361 rotateTransform, // Transform matrix to ancestor space 354 rotateTransform, // Transform matrix to ancestor space
362 clip->clipRect().rect(), // Clip rect in ancestor space 355 clip->clipRect().rect(), // Clip rect in ancestor space
363 localState, rootPropertyTreeState()); 356 localState, rootPropertyTreeState());
364 } 357 }
365 358
366 TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween) { 359 TEST_F(GeometryMapperTest, TwoClipsWithTransformBetween) {
367 RefPtr<ClipPaintPropertyNode> clip1 = 360 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
368 ClipPaintPropertyNode::create(rootClipNode, rootTransformNode.get(), 361 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
369 FloatRoundedRect(10, 10, 200, 200)); 362 FloatRoundedRect(10, 10, 200, 200));
370 363
371 TransformationMatrix rotateTransform; 364 TransformationMatrix rotateTransform;
372 rotateTransform.rotate(45); 365 rotateTransform.rotate(45);
373 RefPtr<TransformPaintPropertyNode> transform = 366 RefPtr<TransformPaintPropertyNode> transform =
374 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), 367 TransformPaintPropertyNode::create(rootPropertyTreeState().transform(),
375 rotateTransform, FloatPoint3D()); 368 rotateTransform, FloatPoint3D());
376 369
377 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( 370 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(
378 clip1, transform.get(), FloatRoundedRect(10, 10, 200, 200)); 371 clip1, transform.get(), FloatRoundedRect(10, 10, 200, 200));
379 372
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 EXPECT_EQ(rootPropertyTreeState().transform(), 572 EXPECT_EQ(rootPropertyTreeState().transform(),
580 leastCommonAncestor(childOfChild2.get(), 573 leastCommonAncestor(childOfChild2.get(),
581 rootPropertyTreeState().transform())); 574 rootPropertyTreeState().transform()));
582 EXPECT_EQ(child2, leastCommonAncestor(childOfChild2.get(), child2.get())); 575 EXPECT_EQ(child2, leastCommonAncestor(childOfChild2.get(), child2.get()));
583 576
584 EXPECT_EQ(rootPropertyTreeState().transform(), 577 EXPECT_EQ(rootPropertyTreeState().transform(),
585 leastCommonAncestor(child1.get(), child2.get())); 578 leastCommonAncestor(child1.get(), child2.get()));
586 } 579 }
587 580
588 } // namespace blink 581 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698