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/rendering/PaintInvalidationState.h" | 6 #include "core/rendering/PaintInvalidationState.h" |
7 | 7 |
8 #include "core/rendering/RenderInline.h" | 8 #include "core/rendering/RenderInline.h" |
9 #include "core/rendering/RenderLayer.h" | 9 #include "core/rendering/RenderLayer.h" |
10 #include "core/rendering/RenderView.h" | 10 #include "core/rendering/RenderView.h" |
11 #include "core/rendering/svg/RenderSVGModelObject.h" | 11 #include "core/rendering/svg/RenderSVGModelObject.h" |
| 12 #include "core/rendering/svg/RenderSVGRoot.h" |
12 #include "platform/Partitions.h" | 13 #include "platform/Partitions.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 PaintInvalidationState::PaintInvalidationState(const RenderView& renderView) | 17 PaintInvalidationState::PaintInvalidationState(const RenderView& renderView) |
17 : m_clipped(false) | 18 : m_clipped(false) |
18 , m_cachedOffsetsEnabled(true) | 19 , m_cachedOffsetsEnabled(true) |
19 , m_forceCheckForPaintInvalidation(false) | 20 , m_forceCheckForPaintInvalidation(false) |
20 , m_paintInvalidationContainer(*renderView.containerForPaintInvalidation()) | 21 , m_paintInvalidationContainer(*renderView.containerForPaintInvalidation()) |
21 { | 22 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 70 |
70 if (renderer.style()->hasInFlowPosition() && renderer.hasLayer()) | 71 if (renderer.style()->hasInFlowPosition() && renderer.hasLayer()) |
71 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); | 72 m_paintOffset += renderer.layer()->offsetForInFlowPosition(); |
72 } | 73 } |
73 | 74 |
74 m_clipped = !fixed && next.m_clipped; | 75 m_clipped = !fixed && next.m_clipped; |
75 if (m_clipped) | 76 if (m_clipped) |
76 m_clipRect = next.m_clipRect; | 77 m_clipRect = next.m_clipRect; |
77 } | 78 } |
78 | 79 |
| 80 if (m_cachedOffsetsEnabled && renderer.isSVGRoot()) { |
| 81 const RenderSVGRoot& svgRoot = toRenderSVGRoot(renderer); |
| 82 m_svgTransform = adoptPtr(new AffineTransform(svgRoot.localToBorderBoxTr
ansform())); |
| 83 if (svgRoot.shouldApplyViewportClip()) |
| 84 addClipRectRelativeToPaintOffset(svgRoot.pixelSnappedSize()); |
| 85 } |
| 86 |
79 applyClipIfNeeded(renderer); | 87 applyClipIfNeeded(renderer); |
80 | 88 |
81 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip
if present. | 89 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip
if present. |
82 } | 90 } |
83 | 91 |
| 92 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& nex
t, const RenderSVGModelObject& renderer) |
| 93 : m_clipped(next.m_clipped) |
| 94 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) |
| 95 , m_forceCheckForPaintInvalidation(next.m_forceCheckForPaintInvalidation) |
| 96 , m_clipRect(next.m_clipRect) |
| 97 , m_paintOffset(next.m_paintOffset) |
| 98 , m_paintInvalidationContainer(next.m_paintInvalidationContainer) |
| 99 { |
| 100 ASSERT(renderer != m_paintInvalidationContainer); |
| 101 |
| 102 if (m_cachedOffsetsEnabled) |
| 103 m_svgTransform = adoptPtr(new AffineTransform(next.svgTransform() * rend
erer.localToParentTransform())); |
| 104 } |
| 105 |
| 106 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize&
clipSize) |
| 107 { |
| 108 LayoutRect clipRect(toPoint(m_paintOffset), clipSize); |
| 109 if (m_clipped) { |
| 110 m_clipRect.intersect(clipRect); |
| 111 } else { |
| 112 m_clipRect = clipRect; |
| 113 m_clipped = true; |
| 114 } |
| 115 } |
| 116 |
84 void PaintInvalidationState::applyClipIfNeeded(const RenderObject& renderer) | 117 void PaintInvalidationState::applyClipIfNeeded(const RenderObject& renderer) |
85 { | 118 { |
86 if (!renderer.hasOverflowClip()) | 119 if (!renderer.hasOverflowClip()) |
87 return; | 120 return; |
88 | 121 |
89 const RenderBox& box = toRenderBox(renderer); | 122 const RenderBox& box = toRenderBox(renderer); |
90 | 123 |
91 // Do not clip scroll layer contents because the compositor expects the whol
e layer | 124 // Do not clip scroll layer contents because the compositor expects the whol
e layer |
92 // to be always invalidated in-time. | 125 // to be always invalidated in-time. |
93 if (box.usesCompositedScrolling()) { | 126 if (box.usesCompositedScrolling()) |
94 ASSERT(!m_clipped); // The box should establish paint invalidation conta
iner, so no m_clipped inherited. | 127 ASSERT(!m_clipped); // The box should establish paint invalidation conta
iner, so no m_clipped inherited. |
95 } else { | 128 else |
96 LayoutRect clipRect(toPoint(m_paintOffset), box.layer()->size()); | 129 addClipRectRelativeToPaintOffset(box.layer()->size()); |
97 if (m_clipped) { | |
98 m_clipRect.intersect(clipRect); | |
99 } else { | |
100 m_clipRect = clipRect; | |
101 m_clipped = true; | |
102 } | |
103 } | |
104 | 130 |
105 m_paintOffset -= box.scrolledContentOffset(); | 131 m_paintOffset -= box.scrolledContentOffset(); |
106 } | 132 } |
107 | 133 |
108 } // namespace blink | 134 } // namespace blink |
OLD | NEW |