| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 m_pendingDelayedPaintInvalidations( | 96 m_pendingDelayedPaintInvalidations( |
| 97 parentState.m_pendingDelayedPaintInvalidations), | 97 parentState.m_pendingDelayedPaintInvalidations), |
| 98 m_paintingLayer(parentState.childPaintingLayer(currentObject)) | 98 m_paintingLayer(parentState.childPaintingLayer(currentObject)) |
| 99 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 99 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 100 , | 100 , |
| 101 m_canCheckFastPathSlowPathEquality( | 101 m_canCheckFastPathSlowPathEquality( |
| 102 parentState.m_canCheckFastPathSlowPathEquality) | 102 parentState.m_canCheckFastPathSlowPathEquality) |
| 103 #endif | 103 #endif |
| 104 { | 104 { |
| 105 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); | 105 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); |
| 106 DCHECK(&m_paintingLayer == currentObject.paintingLayer()); | 106 DCHECK_EQ(&m_paintingLayer, currentObject.paintingLayer()); |
| 107 | 107 |
| 108 if (currentObject == parentState.m_currentObject) { | 108 if (currentObject == parentState.m_currentObject) { |
| 109 // Sometimes we create a new PaintInvalidationState from parentState on the same | 109 // Sometimes we create a new PaintInvalidationState from parentState on the same |
| 110 // object (e.g. LayoutView, and the HorriblySlowRectMapping cases in | 110 // object (e.g. LayoutView, and the HorriblySlowRectMapping cases in |
| 111 // LayoutBlock::invalidatePaintOfSubtreesIfNeeded()). | 111 // LayoutBlock::invalidatePaintOfSubtreesIfNeeded()). |
| 112 // TODO(wangxianzhu): Avoid this for | 112 // TODO(wangxianzhu): Avoid this for |
| 113 // RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled(). | 113 // RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled(). |
| 114 #if DCHECK_IS_ON() | 114 #if DCHECK_IS_ON() |
| 115 m_didUpdateForChildren = parentState.m_didUpdateForChildren; | 115 m_didUpdateForChildren = parentState.m_didUpdateForChildren; |
| 116 #endif | 116 #endif |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 return *child.paintingLayer(); | 236 return *child.paintingLayer(); |
| 237 return m_paintingLayer; | 237 return m_paintingLayer; |
| 238 } | 238 } |
| 239 | 239 |
| 240 void PaintInvalidationState::updateForCurrentObject( | 240 void PaintInvalidationState::updateForCurrentObject( |
| 241 const PaintInvalidationState& parentState) { | 241 const PaintInvalidationState& parentState) { |
| 242 if (!m_cachedOffsetsEnabled) | 242 if (!m_cachedOffsetsEnabled) |
| 243 return; | 243 return; |
| 244 | 244 |
| 245 if (m_currentObject.isLayoutView()) { | 245 if (m_currentObject.isLayoutView()) { |
| 246 DCHECK(&parentState.m_currentObject == | 246 DCHECK_EQ(&parentState.m_currentObject, |
| 247 LayoutAPIShim::layoutObjectFrom( | 247 LayoutAPIShim::layoutObjectFrom( |
| 248 toLayoutView(m_currentObject).frame()->ownerLayoutItem())); | 248 toLayoutView(m_currentObject).frame()->ownerLayoutItem())); |
| 249 m_paintOffset += | 249 m_paintOffset += |
| 250 toLayoutBox(parentState.m_currentObject).contentBoxOffset(); | 250 toLayoutBox(parentState.m_currentObject).contentBoxOffset(); |
| 251 // a LayoutView paints with a defined size but a pixel-rounded offset. | 251 // a LayoutView paints with a defined size but a pixel-rounded offset. |
| 252 m_paintOffset = LayoutSize(roundedIntSize(m_paintOffset)); | 252 m_paintOffset = LayoutSize(roundedIntSize(m_paintOffset)); |
| 253 return; | 253 return; |
| 254 } | 254 } |
| 255 | 255 |
| 256 EPosition position = m_currentObject.styleRef().position(); | 256 EPosition position = m_currentObject.styleRef().position(); |
| 257 | 257 |
| 258 if (position == EPosition::kFixed) { | 258 if (position == EPosition::kFixed) { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 if (m_currentObject.isText()) | 428 if (m_currentObject.isText()) |
| 429 return visualRectLocation; | 429 return visualRectLocation; |
| 430 | 430 |
| 431 FloatPoint point; | 431 FloatPoint point; |
| 432 if (m_paintInvalidationContainer != &m_currentObject) { | 432 if (m_paintInvalidationContainer != &m_currentObject) { |
| 433 if (m_cachedOffsetsEnabled) { | 433 if (m_cachedOffsetsEnabled) { |
| 434 if (m_currentObject.isSVGChild()) | 434 if (m_currentObject.isSVGChild()) |
| 435 point = m_svgTransform.mapPoint(point); | 435 point = m_svgTransform.mapPoint(point); |
| 436 point += FloatPoint(m_paintOffset); | 436 point += FloatPoint(m_paintOffset); |
| 437 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 437 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 438 DCHECK(point == | 438 DCHECK_EQ(point, slowLocalOriginToAncestorPoint( |
| 439 slowLocalOriginToAncestorPoint( | 439 m_currentObject, m_paintInvalidationContainer, |
| 440 m_currentObject, m_paintInvalidationContainer, FloatPoint())); | 440 FloatPoint())); |
| 441 #endif | 441 #endif |
| 442 } else { | 442 } else { |
| 443 point = slowLocalToAncestorPoint( | 443 point = slowLocalToAncestorPoint( |
| 444 m_currentObject, *m_paintInvalidationContainer, FloatPoint()); | 444 m_currentObject, *m_paintInvalidationContainer, FloatPoint()); |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 | 447 |
| 448 PaintLayer::mapPointInPaintInvalidationContainerToBacking( | 448 PaintLayer::mapPointInPaintInvalidationContainerToBacking( |
| 449 *m_paintInvalidationContainer, point); | 449 *m_paintInvalidationContainer, point); |
| 450 | 450 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 clipRect.move(m_paintOffset); | 562 clipRect.move(m_paintOffset); |
| 563 if (m_clipped) { | 563 if (m_clipped) { |
| 564 m_clipRect.intersect(clipRect); | 564 m_clipRect.intersect(clipRect); |
| 565 } else { | 565 } else { |
| 566 m_clipRect = clipRect; | 566 m_clipRect = clipRect; |
| 567 m_clipped = true; | 567 m_clipped = true; |
| 568 } | 568 } |
| 569 } | 569 } |
| 570 | 570 |
| 571 PaintLayer& PaintInvalidationState::paintingLayer() const { | 571 PaintLayer& PaintInvalidationState::paintingLayer() const { |
| 572 DCHECK(&m_paintingLayer == m_currentObject.paintingLayer()); | 572 DCHECK_EQ(&m_paintingLayer, m_currentObject.paintingLayer()); |
| 573 return m_paintingLayer; | 573 return m_paintingLayer; |
| 574 } | 574 } |
| 575 | 575 |
| 576 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 576 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 577 | 577 |
| 578 static bool mayHaveBeenSaturated(LayoutUnit value) { | 578 static bool mayHaveBeenSaturated(LayoutUnit value) { |
| 579 // This is not accurate, just to avoid too big values. | 579 // This is not accurate, just to avoid too big values. |
| 580 return value.abs() >= LayoutUnit::max() / 2; | 580 return value.abs() >= LayoutUnit::max() / 2; |
| 581 } | 581 } |
| 582 | 582 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 forcedSubtreeInvalidationFlags = | 637 forcedSubtreeInvalidationFlags = |
| 638 paintInvalidationState.m_forcedSubtreeInvalidationFlags; | 638 paintInvalidationState.m_forcedSubtreeInvalidationFlags; |
| 639 paintInvalidationContainer = | 639 paintInvalidationContainer = |
| 640 &paintInvalidationState.paintInvalidationContainer(); | 640 &paintInvalidationState.paintInvalidationContainer(); |
| 641 paintingLayer = &paintInvalidationState.paintingLayer(); | 641 paintingLayer = &paintInvalidationState.paintingLayer(); |
| 642 } | 642 } |
| 643 | 643 |
| 644 void PaintInvalidatorContextAdapter::mapLocalRectToVisualRectInBacking( | 644 void PaintInvalidatorContextAdapter::mapLocalRectToVisualRectInBacking( |
| 645 const LayoutObject& object, | 645 const LayoutObject& object, |
| 646 LayoutRect& rect) const { | 646 LayoutRect& rect) const { |
| 647 DCHECK(&object == &m_paintInvalidationState.currentObject()); | 647 DCHECK_EQ(&object, &m_paintInvalidationState.currentObject()); |
| 648 m_paintInvalidationState.mapLocalRectToVisualRectInBacking(rect); | 648 m_paintInvalidationState.mapLocalRectToVisualRectInBacking(rect); |
| 649 } | 649 } |
| 650 | 650 |
| 651 } // namespace blink | 651 } // namespace blink |
| OLD | NEW |