| 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 "config.h" | 5 #include "config.h" | 
| 6 #include "core/layout/PaintInvalidationState.h" | 6 #include "core/layout/PaintInvalidationState.h" | 
| 7 | 7 | 
| 8 #include "core/layout/LayoutInline.h" | 8 #include "core/layout/LayoutInline.h" | 
| 9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" | 
| 10 #include "core/layout/svg/LayoutSVGModelObject.h" | 10 #include "core/layout/svg/LayoutSVGModelObject.h" | 
| 11 #include "core/layout/svg/LayoutSVGRoot.h" | 11 #include "core/layout/svg/LayoutSVGRoot.h" | 
| 12 #include "core/paint/DeprecatedPaintLayer.h" | 12 #include "core/paint/DeprecatedPaintLayer.h" | 
| 13 #include "platform/Partitions.h" | 13 #include "platform/Partitions.h" | 
| 14 | 14 | 
| 15 namespace blink { | 15 namespace blink { | 
| 16 | 16 | 
| 17 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView) | 17 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec
     tor<LayoutObject*>& pendingDelayedPaintInvalidations) | 
| 18     : m_clipped(false) | 18     : m_clipped(false) | 
| 19     , m_cachedOffsetsEnabled(true) | 19     , m_cachedOffsetsEnabled(true) | 
| 20     , m_forceCheckForPaintInvalidation(false) | 20     , m_forceCheckForPaintInvalidation(false) | 
| 21     , m_paintInvalidationContainer(*layoutView.containerForPaintInvalidation()) | 21     , m_paintInvalidationContainer(*layoutView.containerForPaintInvalidation()) | 
|  | 22     , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) | 
| 22 { | 23 { | 
| 23     bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati
     onContainer; | 24     bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati
     onContainer; | 
| 24     if (!establishesPaintInvalidationContainer) { | 25     if (!establishesPaintInvalidationContainer) { | 
| 25         if (!layoutView.supportsPaintInvalidationStateCachedOffsets()) { | 26         if (!layoutView.supportsPaintInvalidationStateCachedOffsets()) { | 
| 26             m_cachedOffsetsEnabled = false; | 27             m_cachedOffsetsEnabled = false; | 
| 27             return; | 28             return; | 
| 28         } | 29         } | 
| 29         FloatPoint point = layoutView.localToContainerPoint(FloatPoint(), &m_pai
     ntInvalidationContainer, TraverseDocumentBoundaries); | 30         FloatPoint point = layoutView.localToContainerPoint(FloatPoint(), &m_pai
     ntInvalidationContainer, TraverseDocumentBoundaries); | 
| 30         m_paintOffset = LayoutSize(point.x(), point.y()); | 31         m_paintOffset = LayoutSize(point.x(), point.y()); | 
| 31     } | 32     } | 
| 32     m_clipRect = layoutView.viewRect(); | 33     m_clipRect = layoutView.viewRect(); | 
| 33     m_clipRect.move(m_paintOffset); | 34     m_clipRect.move(m_paintOffset); | 
| 34     m_clipped = true; | 35     m_clipped = true; | 
| 35 } | 36 } | 
| 36 | 37 | 
| 37 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
     t, LayoutBoxModelObject& renderer, const LayoutBoxModelObject& paintInvalidation
     Container) | 38 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, Lay
     outBoxModelObject& renderer, const LayoutBoxModelObject& paintInvalidationContai
     ner) | 
| 38     : m_clipped(false) | 39     : m_clipped(false) | 
| 39     , m_cachedOffsetsEnabled(true) | 40     , m_cachedOffsetsEnabled(true) | 
| 40     , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | 41     , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | 
| 41     , m_paintInvalidationContainer(paintInvalidationContainer) | 42     , m_paintInvalidationContainer(paintInvalidationContainer) | 
|  | 43     , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar
     gets()) | 
| 42 { | 44 { | 
| 43     // FIXME: SVG could probably benefit from a stack-based optimization like ht
     ml does. crbug.com/391054 | 45     // FIXME: SVG could probably benefit from a stack-based optimization like ht
     ml does. crbug.com/391054 | 
| 44     bool establishesPaintInvalidationContainer = renderer == m_paintInvalidation
     Container; | 46     bool establishesPaintInvalidationContainer = renderer == m_paintInvalidation
     Container; | 
| 45     bool fixed = renderer.style()->position() == FixedPosition; | 47     bool fixed = renderer.style()->position() == FixedPosition; | 
| 46 | 48 | 
| 47     if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_cache
     dOffsetsEnabled) | 49     if (!renderer.supportsPaintInvalidationStateCachedOffsets() || !next.m_cache
     dOffsetsEnabled) | 
| 48         m_cachedOffsetsEnabled = false; | 50         m_cachedOffsetsEnabled = false; | 
| 49     if (establishesPaintInvalidationContainer) { | 51     if (establishesPaintInvalidationContainer) { | 
| 50         // When we hit a new paint invalidation container, we don't need to | 52         // When we hit a new paint invalidation container, we don't need to | 
| 51         // continue forcing a check for paint invalidation because movement | 53         // continue forcing a check for paint invalidation because movement | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 82         m_svgTransform = adoptPtr(new AffineTransform(svgRoot.localToBorderBoxTr
     ansform())); | 84         m_svgTransform = adoptPtr(new AffineTransform(svgRoot.localToBorderBoxTr
     ansform())); | 
| 83         if (svgRoot.shouldApplyViewportClip()) | 85         if (svgRoot.shouldApplyViewportClip()) | 
| 84             addClipRectRelativeToPaintOffset(LayoutSize(svgRoot.pixelSnappedSize
     ())); | 86             addClipRectRelativeToPaintOffset(LayoutSize(svgRoot.pixelSnappedSize
     ())); | 
| 85     } | 87     } | 
| 86 | 88 | 
| 87     applyClipIfNeeded(renderer); | 89     applyClipIfNeeded(renderer); | 
| 88 | 90 | 
| 89     // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip 
     if present. | 91     // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip 
     if present. | 
| 90 } | 92 } | 
| 91 | 93 | 
| 92 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
     t, const LayoutSVGModelObject& renderer) | 94 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, con
     st LayoutSVGModelObject& renderer) | 
| 93     : m_clipped(next.m_clipped) | 95     : m_clipped(next.m_clipped) | 
| 94     , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) | 96     , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) | 
| 95     , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | 97     , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) | 
| 96     , m_clipRect(next.m_clipRect) | 98     , m_clipRect(next.m_clipRect) | 
| 97     , m_paintOffset(next.m_paintOffset) | 99     , m_paintOffset(next.m_paintOffset) | 
| 98     , m_paintInvalidationContainer(next.m_paintInvalidationContainer) | 100     , m_paintInvalidationContainer(next.m_paintInvalidationContainer) | 
|  | 101     , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar
     gets()) | 
| 99 { | 102 { | 
| 100     ASSERT(renderer != m_paintInvalidationContainer); | 103     ASSERT(renderer != m_paintInvalidationContainer); | 
| 101 | 104 | 
| 102     if (m_cachedOffsetsEnabled) | 105     if (m_cachedOffsetsEnabled) | 
| 103         m_svgTransform = adoptPtr(new AffineTransform(next.svgTransform() * rend
     erer.localToParentTransform())); | 106         m_svgTransform = adoptPtr(new AffineTransform(next.svgTransform() * rend
     erer.localToParentTransform())); | 
| 104 } | 107 } | 
| 105 | 108 | 
| 106 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& 
     clipSize) | 109 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& 
     clipSize) | 
| 107 { | 110 { | 
| 108     LayoutRect clipRect(toPoint(m_paintOffset), clipSize); | 111     LayoutRect clipRect(toPoint(m_paintOffset), clipSize); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 125     // to be always invalidated in-time. | 128     // to be always invalidated in-time. | 
| 126     if (box.usesCompositedScrolling()) | 129     if (box.usesCompositedScrolling()) | 
| 127         ASSERT(!m_clipped); // The box should establish paint invalidation conta
     iner, so no m_clipped inherited. | 130         ASSERT(!m_clipped); // The box should establish paint invalidation conta
     iner, so no m_clipped inherited. | 
| 128     else | 131     else | 
| 129         addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size())); | 132         addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size())); | 
| 130 | 133 | 
| 131     m_paintOffset -= box.scrolledContentOffset(); | 134     m_paintOffset -= box.scrolledContentOffset(); | 
| 132 } | 135 } | 
| 133 | 136 | 
| 134 } // namespace blink | 137 } // namespace blink | 
| OLD | NEW | 
|---|