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

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

Issue 2798513002: Revert of Make GeometryMapper fully static (Closed)
Patch Set: 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/RuntimeEnabledFeatures.h" 7 #include "platform/RuntimeEnabledFeatures.h"
8 #include "platform/geometry/LayoutRect.h" 8 #include "platform/geometry/LayoutRect.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 const TransformationMatrix& GeometryMapper::identityMatrix() {
13 DEFINE_STATIC_LOCAL(TransformationMatrix, identity, (TransformationMatrix()));
14 return identity;
15 }
16
17 const FloatClipRect& GeometryMapper::infiniteClip() {
18 DEFINE_STATIC_LOCAL(FloatClipRect, infinite, (FloatClipRect()));
19 return infinite;
20 }
21
22 FloatClipRect& GeometryMapper::tempRect() {
23 DEFINE_STATIC_LOCAL(FloatClipRect, temp, (FloatClipRect()));
24 return temp;
25 }
26
27 void GeometryMapper::sourceToDestinationVisualRect( 12 void GeometryMapper::sourceToDestinationVisualRect(
28 const PropertyTreeState& sourceState, 13 const PropertyTreeState& sourceState,
29 const PropertyTreeState& destinationState, 14 const PropertyTreeState& destinationState,
30 FloatRect& rect) { 15 FloatRect& rect) {
31 bool success = false; 16 bool success = false;
32 sourceToDestinationVisualRectInternal(sourceState, destinationState, rect, 17 sourceToDestinationVisualRectInternal(sourceState, destinationState, rect,
33 success); 18 success);
34 DCHECK(success); 19 DCHECK(success);
35 } 20 }
36 21
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // test compositing/overflow/handle-non-ancestor-clip-parent.html (run 251 // test compositing/overflow/handle-non-ancestor-clip-parent.html (run
267 // with --enable-prefer-compositing-to-lcd-text) for details. 252 // with --enable-prefer-compositing-to-lcd-text) for details.
268 // Ignore it for SPv1 for now. 253 // Ignore it for SPv1 for now.
269 success = true; 254 success = true;
270 } 255 }
271 return result2; 256 return result2;
272 } 257 }
273 if (!result2.isInfinite()) { 258 if (!result2.isInfinite()) {
274 FloatRect rect = result2.rect(); 259 FloatRect rect = result2.rect();
275 ancestorToLocalRect(lcaTransform, destinationState.transform(), rect); 260 ancestorToLocalRect(lcaTransform, destinationState.transform(), rect);
276 FloatClipRect& temp = tempRect(); 261 m_tempRect.setRect(rect);
277 temp.setRect(rect);
278 if (result2.hasRadius()) 262 if (result2.hasRadius())
279 temp.setHasRadius(); 263 m_tempRect.setHasRadius();
280 return temp; 264 return m_tempRect;
281 } 265 }
282 return result2; 266 return result2;
283 } 267 }
284 268
285 const FloatClipRect& GeometryMapper::localToAncestorClipRectInternal( 269 const FloatClipRect& GeometryMapper::localToAncestorClipRectInternal(
286 const ClipPaintPropertyNode* descendant, 270 const ClipPaintPropertyNode* descendant,
287 const ClipPaintPropertyNode* ancestorClip, 271 const ClipPaintPropertyNode* ancestorClip,
288 const TransformPaintPropertyNode* ancestorTransform, 272 const TransformPaintPropertyNode* ancestorTransform,
289 bool& success) { 273 bool& success) {
290 FloatClipRect clip; 274 FloatClipRect clip;
291 if (descendant == ancestorClip) { 275 if (descendant == ancestorClip) {
292 success = true; 276 success = true;
293 return infiniteClip(); 277 return m_infiniteClip;
294 } 278 }
295 279
296 const ClipPaintPropertyNode* clipNode = descendant; 280 const ClipPaintPropertyNode* clipNode = descendant;
297 Vector<const ClipPaintPropertyNode*> intermediateNodes; 281 Vector<const ClipPaintPropertyNode*> intermediateNodes;
298 282
299 GeometryMapperClipCache::ClipAndTransform clipAndTransform(ancestorClip, 283 GeometryMapperClipCache::ClipAndTransform clipAndTransform(ancestorClip,
300 ancestorTransform); 284 ancestorTransform);
301 // Iterate over the path from localState.clip to ancestorState.clip. Stop if 285 // Iterate over the path from localState.clip to ancestorState.clip. Stop if
302 // we've found a memoized (precomputed) clip for any particular node. 286 // we've found a memoized (precomputed) clip for any particular node.
303 while (clipNode && clipNode != ancestorClip) { 287 while (clipNode && clipNode != ancestorClip) {
304 if (const FloatClipRect* cachedClip = 288 if (const FloatClipRect* cachedClip =
305 clipNode->getClipCache().getCachedClip(clipAndTransform)) { 289 clipNode->getClipCache().getCachedClip(clipAndTransform)) {
306 clip = *cachedClip; 290 clip = *cachedClip;
307 break; 291 break;
308 } 292 }
309 293
310 intermediateNodes.push_back(clipNode); 294 intermediateNodes.push_back(clipNode);
311 clipNode = clipNode->parent(); 295 clipNode = clipNode->parent();
312 } 296 }
313 if (!clipNode) { 297 if (!clipNode) {
314 success = false; 298 success = false;
315 return infiniteClip(); 299 return m_infiniteClip;
316 } 300 }
317 301
318 // Iterate down from the top intermediate node found in the previous loop, 302 // Iterate down from the top intermediate node found in the previous loop,
319 // computing and memoizing clip rects as we go. 303 // computing and memoizing clip rects as we go.
320 for (auto it = intermediateNodes.rbegin(); it != intermediateNodes.rend(); 304 for (auto it = intermediateNodes.rbegin(); it != intermediateNodes.rend();
321 ++it) { 305 ++it) {
322 success = false; 306 success = false;
323 const TransformationMatrix& transformMatrix = localToAncestorMatrixInternal( 307 const TransformationMatrix& transformMatrix = localToAncestorMatrixInternal(
324 (*it)->localTransformSpace(), ancestorTransform, success); 308 (*it)->localTransformSpace(), ancestorTransform, success);
325 if (!success) 309 if (!success)
326 return infiniteClip(); 310 return m_infiniteClip;
327 FloatRect mappedRect = transformMatrix.mapRect((*it)->clipRect().rect()); 311 FloatRect mappedRect = transformMatrix.mapRect((*it)->clipRect().rect());
328 clip.intersect(mappedRect); 312 clip.intersect(mappedRect);
329 if ((*it)->clipRect().isRounded()) 313 if ((*it)->clipRect().isRounded())
330 clip.setHasRadius(); 314 clip.setHasRadius();
331 315
332 (*it)->getClipCache().setCachedClip(clipAndTransform, clip); 316 (*it)->getClipCache().setCachedClip(clipAndTransform, clip);
333 } 317 }
334 318
335 success = true; 319 success = true;
336 320
(...skipping 13 matching lines...) Expand all
350 DCHECK(success); 334 DCHECK(success);
351 return result; 335 return result;
352 } 336 }
353 337
354 const TransformationMatrix& GeometryMapper::localToAncestorMatrixInternal( 338 const TransformationMatrix& GeometryMapper::localToAncestorMatrixInternal(
355 const TransformPaintPropertyNode* localTransformNode, 339 const TransformPaintPropertyNode* localTransformNode,
356 const TransformPaintPropertyNode* ancestorTransformNode, 340 const TransformPaintPropertyNode* ancestorTransformNode,
357 bool& success) { 341 bool& success) {
358 if (localTransformNode == ancestorTransformNode) { 342 if (localTransformNode == ancestorTransformNode) {
359 success = true; 343 success = true;
360 return identityMatrix(); 344 return m_identity;
361 } 345 }
362 346
363 const TransformPaintPropertyNode* transformNode = localTransformNode; 347 const TransformPaintPropertyNode* transformNode = localTransformNode;
364 Vector<const TransformPaintPropertyNode*> intermediateNodes; 348 Vector<const TransformPaintPropertyNode*> intermediateNodes;
365 TransformationMatrix transformMatrix; 349 TransformationMatrix transformMatrix;
366 350
367 // Iterate over the path from localTransformNode to ancestorState.transform. 351 // Iterate over the path from localTransformNode to ancestorState.transform.
368 // Stop if we've found a memoized (precomputed) transform for any particular 352 // Stop if we've found a memoized (precomputed) transform for any particular
369 // node. 353 // node.
370 while (transformNode && transformNode != ancestorTransformNode) { 354 while (transformNode && transformNode != ancestorTransformNode) {
371 if (const TransformationMatrix* cachedMatrix = 355 if (const TransformationMatrix* cachedMatrix =
372 transformNode->getTransformCache().getCachedTransform( 356 transformNode->getTransformCache().getCachedTransform(
373 ancestorTransformNode)) { 357 ancestorTransformNode)) {
374 transformMatrix = *cachedMatrix; 358 transformMatrix = *cachedMatrix;
375 break; 359 break;
376 } 360 }
377 361
378 intermediateNodes.push_back(transformNode); 362 intermediateNodes.push_back(transformNode);
379 transformNode = transformNode->parent(); 363 transformNode = transformNode->parent();
380 } 364 }
381 if (!transformNode) { 365 if (!transformNode) {
382 success = false; 366 success = false;
383 return identityMatrix(); 367 return m_identity;
384 } 368 }
385 369
386 // Iterate down from the top intermediate node found in the previous loop, 370 // Iterate down from the top intermediate node found in the previous loop,
387 // computing and memoizing transforms as we go. 371 // computing and memoizing transforms as we go.
388 for (auto it = intermediateNodes.rbegin(); it != intermediateNodes.rend(); 372 for (auto it = intermediateNodes.rbegin(); it != intermediateNodes.rend();
389 it++) { 373 it++) {
390 TransformationMatrix localTransformMatrix = (*it)->matrix(); 374 TransformationMatrix localTransformMatrix = (*it)->matrix();
391 localTransformMatrix.applyTransformOrigin((*it)->origin()); 375 localTransformMatrix.applyTransformOrigin((*it)->origin());
392 376
393 // Flattening Lemma: flatten(A * flatten(B)) = flatten(flatten(A) * B). 377 // Flattening Lemma: flatten(A * flatten(B)) = flatten(flatten(A) * B).
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 const TransformPaintPropertyNode*, 449 const TransformPaintPropertyNode*,
466 const TransformPaintPropertyNode*); 450 const TransformPaintPropertyNode*);
467 template const ClipPaintPropertyNode* GeometryMapper::lowestCommonAncestor( 451 template const ClipPaintPropertyNode* GeometryMapper::lowestCommonAncestor(
468 const ClipPaintPropertyNode*, 452 const ClipPaintPropertyNode*,
469 const ClipPaintPropertyNode*); 453 const ClipPaintPropertyNode*);
470 template const ScrollPaintPropertyNode* GeometryMapper::lowestCommonAncestor( 454 template const ScrollPaintPropertyNode* GeometryMapper::lowestCommonAncestor(
471 const ScrollPaintPropertyNode*, 455 const ScrollPaintPropertyNode*,
472 const ScrollPaintPropertyNode*); 456 const ScrollPaintPropertyNode*);
473 457
474 } // namespace blink 458 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698