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

Side by Side Diff: Source/core/rendering/PaintInvalidationState.cpp

Issue 598623002: Initial PaintInvalidationState support for SVG (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
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
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 = svgRoot.localToBorderBoxTransform();
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 , m_svgTransform(next.m_svgTransform)
100 {
101 ASSERT(renderer != m_paintInvalidationContainer);
102
103 if (m_cachedOffsetsEnabled)
104 m_svgTransform *= renderer.localToParentTransform();
105 }
106
107 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize)
108 {
109 LayoutRect clipRect(toPoint(m_paintOffset), clipSize);
110 if (m_clipped) {
111 m_clipRect.intersect(clipRect);
112 } else {
113 m_clipRect = clipRect;
114 m_clipped = true;
115 }
116 }
117
84 void PaintInvalidationState::applyClipIfNeeded(const RenderObject& renderer) 118 void PaintInvalidationState::applyClipIfNeeded(const RenderObject& renderer)
85 { 119 {
86 if (!renderer.hasOverflowClip()) 120 if (!renderer.hasOverflowClip())
87 return; 121 return;
88 122
89 const RenderBox& box = toRenderBox(renderer); 123 const RenderBox& box = toRenderBox(renderer);
90 124
91 // Do not clip scroll layer contents because the compositor expects the whol e layer 125 // Do not clip scroll layer contents because the compositor expects the whol e layer
92 // to be always invalidated in-time. 126 // to be always invalidated in-time.
93 if (box.usesCompositedScrolling()) { 127 if (box.usesCompositedScrolling())
94 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited. 128 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited.
95 } else { 129 else
96 LayoutRect clipRect(toPoint(m_paintOffset), box.layer()->size()); 130 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 131
105 m_paintOffset -= box.scrolledContentOffset(); 132 m_paintOffset -= box.scrolledContentOffset();
106 } 133 }
107 134
108 } // namespace blink 135 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698