| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "core/layout/PaintInvalidationState.h" | 5 #include "core/layout/PaintInvalidationState.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/layout/LayoutInline.h" | 10 #include "core/layout/LayoutInline.h" |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 430 } |
| 431 } | 431 } |
| 432 | 432 |
| 433 if (m_paintInvalidationContainer->layer()->groupedMapping()) | 433 if (m_paintInvalidationContainer->layer()->groupedMapping()) |
| 434 PaintLayer::mapPointInPaintInvalidationContainerToBacking( | 434 PaintLayer::mapPointInPaintInvalidationContainerToBacking( |
| 435 *m_paintInvalidationContainer, point); | 435 *m_paintInvalidationContainer, point); |
| 436 | 436 |
| 437 return LayoutPoint(point); | 437 return LayoutPoint(point); |
| 438 } | 438 } |
| 439 | 439 |
| 440 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBacking() | 440 LayoutRect PaintInvalidationState::computeVisualRectInBacking() const { |
| 441 const { | |
| 442 #if ENABLE(ASSERT) | 441 #if ENABLE(ASSERT) |
| 443 DCHECK(!m_didUpdateForChildren); | 442 DCHECK(!m_didUpdateForChildren); |
| 444 #endif | 443 #endif |
| 445 | 444 |
| 446 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot()) | 445 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot()) |
| 447 return computePaintInvalidationRectInBackingForSVG(); | 446 return computeVisualRectInBackingForSVG(); |
| 448 | 447 |
| 449 LayoutRect rect = m_currentObject.localOverflowRectForPaintInvalidation(); | 448 LayoutRect rect = m_currentObject.localVisualRect(); |
| 450 mapLocalRectToPaintInvalidationBacking(rect); | 449 mapLocalRectToPaintInvalidationBacking(rect); |
| 451 return rect; | 450 return rect; |
| 452 } | 451 } |
| 453 | 452 |
| 454 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG() | 453 LayoutRect PaintInvalidationState::computeVisualRectInBackingForSVG() const { |
| 455 const { | |
| 456 LayoutRect rect; | 454 LayoutRect rect; |
| 457 if (m_cachedOffsetsEnabled) { | 455 if (m_cachedOffsetsEnabled) { |
| 458 FloatRect svgRect = SVGLayoutSupport::localOverflowRectForPaintInvalidation( | 456 FloatRect svgRect = SVGLayoutSupport::localVisualRect(m_currentObject); |
| 459 m_currentObject); | 457 rect = SVGLayoutSupport::transformVisualRect(m_currentObject, |
| 460 rect = SVGLayoutSupport::transformPaintInvalidationRect( | 458 m_svgTransform, svgRect); |
| 461 m_currentObject, m_svgTransform, svgRect); | |
| 462 rect.move(m_paintOffset); | 459 rect.move(m_paintOffset); |
| 463 if (m_clipped) | 460 if (m_clipped) |
| 464 rect.intersect(m_clipRect); | 461 rect.intersect(m_clipRect); |
| 465 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 462 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 466 LayoutRect slowPathRect = | 463 LayoutRect slowPathRect = SVGLayoutSupport::visualRectInAncestorSpace( |
| 467 SVGLayoutSupport::clippedOverflowRectForPaintInvalidation( | 464 m_currentObject, *m_paintInvalidationContainer); |
| 468 m_currentObject, *m_paintInvalidationContainer); | |
| 469 assertFastPathAndSlowPathRectsEqual(rect, slowPathRect); | 465 assertFastPathAndSlowPathRectsEqual(rect, slowPathRect); |
| 470 #endif | 466 #endif |
| 471 } else { | 467 } else { |
| 472 // TODO(wangxianzhu): Sometimes m_cachedOffsetsEnabled==false doesn't mean | 468 // TODO(wangxianzhu): Sometimes m_cachedOffsetsEnabled==false doesn't mean |
| 473 // we can't use cached m_svgTransform. We can use hybrid fast path (for SVG) | 469 // we can't use cached m_svgTransform. We can use hybrid fast path (for SVG) |
| 474 // and slow path (for things above the SVGRoot). | 470 // and slow path (for things above the SVGRoot). |
| 475 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation( | 471 rect = SVGLayoutSupport::visualRectInAncestorSpace( |
| 476 m_currentObject, *m_paintInvalidationContainer); | 472 m_currentObject, *m_paintInvalidationContainer); |
| 477 } | 473 } |
| 478 | 474 |
| 479 if (m_paintInvalidationContainer->layer()->groupedMapping()) | 475 if (m_paintInvalidationContainer->layer()->groupedMapping()) |
| 480 PaintLayer::mapRectInPaintInvalidationContainerToBacking( | 476 PaintLayer::mapRectInPaintInvalidationContainerToBacking( |
| 481 *m_paintInvalidationContainer, rect); | 477 *m_paintInvalidationContainer, rect); |
| 482 return rect; | 478 return rect; |
| 483 } | 479 } |
| 484 | 480 |
| 485 static void slowMapToVisualRectInAncestorSpace( | 481 static void slowMapToVisualRectInAncestorSpace( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 LayoutRect inflatedFastPathRect = fastPathRect; | 586 LayoutRect inflatedFastPathRect = fastPathRect; |
| 591 inflatedFastPathRect.inflate(1); | 587 inflatedFastPathRect.inflate(1); |
| 592 if (inflatedFastPathRect.contains(slowPathRect)) | 588 if (inflatedFastPathRect.contains(slowPathRect)) |
| 593 return; | 589 return; |
| 594 LayoutRect inflatedSlowPathRect = slowPathRect; | 590 LayoutRect inflatedSlowPathRect = slowPathRect; |
| 595 inflatedSlowPathRect.inflate(1); | 591 inflatedSlowPathRect.inflate(1); |
| 596 if (inflatedSlowPathRect.contains(fastPathRect)) | 592 if (inflatedSlowPathRect.contains(fastPathRect)) |
| 597 return; | 593 return; |
| 598 } | 594 } |
| 599 | 595 |
| 600 WTFLogAlways( | 596 LOG(ERROR) << "Fast path visual rect differs from slow path: fast: " |
| 601 "Fast path paint invalidation rect differs from slow path: fast: %s vs " | 597 << fastPathRect.toString() |
| 602 "slow: %s", | 598 << " vs slow: " << slowPathRect.toString(); |
| 603 fastPathRect.toString().ascii().data(), | |
| 604 slowPathRect.toString().ascii().data()); | |
| 605 showLayoutTree(&m_currentObject); | 599 showLayoutTree(&m_currentObject); |
| 606 | 600 |
| 607 ASSERT_NOT_REACHED(); | 601 ASSERT_NOT_REACHED(); |
| 608 } | 602 } |
| 609 | 603 |
| 610 #endif // CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 604 #endif // CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 611 | 605 |
| 612 static const PaintPropertyTreeBuilderContext& dummyTreeBuilderContext() { | 606 static const PaintPropertyTreeBuilderContext& dummyTreeBuilderContext() { |
| 613 DEFINE_STATIC_LOCAL(PaintPropertyTreeBuilderContext, dummyContext, ()); | 607 DEFINE_STATIC_LOCAL(PaintPropertyTreeBuilderContext, dummyContext, ()); |
| 614 return dummyContext; | 608 return dummyContext; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 626 } | 620 } |
| 627 | 621 |
| 628 void PaintInvalidatorContextAdapter::mapLocalRectToPaintInvalidationBacking( | 622 void PaintInvalidatorContextAdapter::mapLocalRectToPaintInvalidationBacking( |
| 629 const LayoutObject& object, | 623 const LayoutObject& object, |
| 630 LayoutRect& rect) const { | 624 LayoutRect& rect) const { |
| 631 DCHECK(&object == &m_paintInvalidationState.currentObject()); | 625 DCHECK(&object == &m_paintInvalidationState.currentObject()); |
| 632 m_paintInvalidationState.mapLocalRectToPaintInvalidationBacking(rect); | 626 m_paintInvalidationState.mapLocalRectToPaintInvalidationBacking(rect); |
| 633 } | 627 } |
| 634 | 628 |
| 635 } // namespace blink | 629 } // namespace blink |
| OLD | NEW |