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/compositing/CompositingReasonFinder.h" | 6 #include "core/layout/compositing/CompositingReasonFinder.h" |
7 | 7 |
8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
11 #include "core/frame/Settings.h" | 11 #include "core/frame/Settings.h" |
12 #include "core/layout/compositing/RenderLayerCompositor.h" | 12 #include "core/layout/compositing/LayerCompositor.h" |
13 #include "core/page/Page.h" | 13 #include "core/page/Page.h" |
14 #include "core/rendering/RenderView.h" | 14 #include "core/rendering/RenderView.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 CompositingReasonFinder::CompositingReasonFinder(RenderView& renderView) | 18 CompositingReasonFinder::CompositingReasonFinder(RenderView& renderView) |
19 : m_renderView(renderView) | 19 : m_renderView(renderView) |
20 , m_compositingTriggers(static_cast<CompositingTriggerFlags>(AllCompositingT
riggers)) | 20 , m_compositingTriggers(static_cast<CompositingTriggerFlags>(AllCompositingT
riggers)) |
21 { | 21 { |
22 updateTriggers(); | 22 updateTriggers(); |
(...skipping 15 matching lines...) Expand all Loading... |
38 { | 38 { |
39 return m_compositingTriggers & OverflowScrollTrigger; | 39 return m_compositingTriggers & OverflowScrollTrigger; |
40 } | 40 } |
41 | 41 |
42 bool CompositingReasonFinder::isMainFrame() const | 42 bool CompositingReasonFinder::isMainFrame() const |
43 { | 43 { |
44 // FIXME: LocalFrame::isMainFrame() is probably better. | 44 // FIXME: LocalFrame::isMainFrame() is probably better. |
45 return !m_renderView.document().ownerElement(); | 45 return !m_renderView.document().ownerElement(); |
46 } | 46 } |
47 | 47 |
48 CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* lay
er) const | 48 CompositingReasons CompositingReasonFinder::directReasons(const Layer* layer) co
nst |
49 { | 49 { |
50 if (RuntimeEnabledFeatures::slimmingPaintCompositorLayerizationEnabled()) | 50 if (RuntimeEnabledFeatures::slimmingPaintCompositorLayerizationEnabled()) |
51 return CompositingReasonNone; | 51 return CompositingReasonNone; |
52 | 52 |
53 ASSERT(potentialCompositingReasonsFromStyle(layer->renderer()) == layer->pot
entialCompositingReasonsFromStyle()); | 53 ASSERT(potentialCompositingReasonsFromStyle(layer->renderer()) == layer->pot
entialCompositingReasonsFromStyle()); |
54 CompositingReasons styleDeterminedDirectCompositingReasons = layer->potentia
lCompositingReasonsFromStyle() & CompositingReasonComboAllDirectStyleDeterminedR
easons; | 54 CompositingReasons styleDeterminedDirectCompositingReasons = layer->potentia
lCompositingReasonsFromStyle() & CompositingReasonComboAllDirectStyleDeterminedR
easons; |
55 | 55 |
56 // Apply optimizations for scroll-blocks-on which require comparing style be
tween objects. | 56 // Apply optimizations for scroll-blocks-on which require comparing style be
tween objects. |
57 if ((styleDeterminedDirectCompositingReasons & CompositingReasonScrollBlocks
On) && !requiresCompositingForScrollBlocksOn(layer->renderer())) | 57 if ((styleDeterminedDirectCompositingReasons & CompositingReasonScrollBlocks
On) && !requiresCompositingForScrollBlocksOn(layer->renderer())) |
58 styleDeterminedDirectCompositingReasons &= ~CompositingReasonScrollBlock
sOn; | 58 styleDeterminedDirectCompositingReasons &= ~CompositingReasonScrollBlock
sOn; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 // If the implementation of createsGroup changes, we need to be aware of tha
t in this part of code. | 113 // If the implementation of createsGroup changes, we need to be aware of tha
t in this part of code. |
114 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->hasFil
ter() || style->hasBlendMode()) == renderer->createsGroup()); | 114 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->hasFil
ter() || style->hasBlendMode()) == renderer->createsGroup()); |
115 | 115 |
116 if (style->hasMask()) | 116 if (style->hasMask()) |
117 reasons |= CompositingReasonMaskWithCompositedDescendants; | 117 reasons |= CompositingReasonMaskWithCompositedDescendants; |
118 | 118 |
119 if (style->hasFilter()) | 119 if (style->hasFilter()) |
120 reasons |= CompositingReasonFilterWithCompositedDescendants; | 120 reasons |= CompositingReasonFilterWithCompositedDescendants; |
121 | 121 |
122 // See RenderLayer::updateTransform for an explanation of why we check both. | 122 // See Layer::updateTransform for an explanation of why we check both. |
123 if (renderer->hasTransformRelatedProperty() && style->hasTransform()) | 123 if (renderer->hasTransformRelatedProperty() && style->hasTransform()) |
124 reasons |= CompositingReasonTransformWithCompositedDescendants; | 124 reasons |= CompositingReasonTransformWithCompositedDescendants; |
125 | 125 |
126 if (renderer->isTransparent()) | 126 if (renderer->isTransparent()) |
127 reasons |= CompositingReasonOpacityWithCompositedDescendants; | 127 reasons |= CompositingReasonOpacityWithCompositedDescendants; |
128 | 128 |
129 if (style->hasBlendMode()) | 129 if (style->hasBlendMode()) |
130 reasons |= CompositingReasonBlendingWithCompositedDescendants; | 130 reasons |= CompositingReasonBlendingWithCompositedDescendants; |
131 | 131 |
132 if (renderer->hasReflection()) | 132 if (renderer->hasReflection()) |
133 reasons |= CompositingReasonReflectionWithCompositedDescendants; | 133 reasons |= CompositingReasonReflectionWithCompositedDescendants; |
134 | 134 |
135 ASSERT(!(reasons & ~CompositingReasonComboAllStyleDeterminedReasons)); | 135 ASSERT(!(reasons & ~CompositingReasonComboAllStyleDeterminedReasons)); |
136 return reasons; | 136 return reasons; |
137 } | 137 } |
138 | 138 |
139 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend
erer) const | 139 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend
erer) const |
140 { | 140 { |
141 // Note that we ask the renderer if it has a transform, because the style ma
y have transforms, | 141 // Note that we ask the renderer if it has a transform, because the style ma
y have transforms, |
142 // but the renderer may be an inline that doesn't support them. | 142 // but the renderer may be an inline that doesn't support them. |
143 return renderer->hasTransformRelatedProperty() && renderer->style()->transfo
rm().has3DOperation(); | 143 return renderer->hasTransformRelatedProperty() && renderer->style()->transfo
rm().has3DOperation(); |
144 } | 144 } |
145 | 145 |
146 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
t RenderLayer* layer) const | 146 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
t Layer* layer) const |
147 { | 147 { |
148 CompositingReasons directReasons = CompositingReasonNone; | 148 CompositingReasons directReasons = CompositingReasonNone; |
149 RenderObject* renderer = layer->renderer(); | 149 RenderObject* renderer = layer->renderer(); |
150 | 150 |
151 if (hasOverflowScrollTrigger()) { | 151 if (hasOverflowScrollTrigger()) { |
152 if (layer->clipParent()) | 152 if (layer->clipParent()) |
153 directReasons |= CompositingReasonOutOfFlowClipping; | 153 directReasons |= CompositingReasonOutOfFlowClipping; |
154 | 154 |
155 if (const RenderLayer* scrollingAncestor = layer->ancestorScrollingLayer
()) { | 155 if (const Layer* scrollingAncestor = layer->ancestorScrollingLayer()) { |
156 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollPa
rent()) | 156 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollPa
rent()) |
157 directReasons |= CompositingReasonOverflowScrollingParent; | 157 directReasons |= CompositingReasonOverflowScrollingParent; |
158 } | 158 } |
159 | 159 |
160 if (layer->needsCompositedScrolling()) | 160 if (layer->needsCompositedScrolling()) |
161 directReasons |= CompositingReasonOverflowScrollingTouch; | 161 directReasons |= CompositingReasonOverflowScrollingTouch; |
162 } | 162 } |
163 | 163 |
164 if (requiresCompositingForPositionFixed(layer)) | 164 if (requiresCompositingForPositionFixed(layer)) |
165 directReasons |= CompositingReasonPositionFixed; | 165 directReasons |= CompositingReasonPositionFixed; |
166 | 166 |
167 directReasons |= renderer->additionalCompositingReasons(); | 167 directReasons |= renderer->additionalCompositingReasons(); |
168 | 168 |
169 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); | 169 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); |
170 return directReasons; | 170 return directReasons; |
171 } | 171 } |
172 | 172 |
173 bool CompositingReasonFinder::requiresCompositingForAnimation(RenderStyle* style
) const | 173 bool CompositingReasonFinder::requiresCompositingForAnimation(RenderStyle* style
) const |
174 { | 174 { |
175 if (style->subtreeWillChangeContents()) | 175 if (style->subtreeWillChangeContents()) |
176 return style->isRunningAnimationOnCompositor(); | 176 return style->isRunningAnimationOnCompositor(); |
177 | 177 |
178 return style->shouldCompositeForCurrentAnimations(); | 178 return style->shouldCompositeForCurrentAnimations(); |
179 } | 179 } |
180 | 180 |
181 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const RenderLa
yer* layer) const | 181 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const Layer* l
ayer) const |
182 { | 182 { |
183 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) | 183 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) |
184 return false; | 184 return false; |
185 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. | 185 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. |
186 // They will stay fixed wrt the container rather than the enclosing frame. | 186 // They will stay fixed wrt the container rather than the enclosing frame. |
187 return layer->scrollsWithViewport() && m_renderView.frameView()->isScrollabl
e(); | 187 return layer->scrollsWithViewport() && m_renderView.frameView()->isScrollabl
e(); |
188 } | 188 } |
189 | 189 |
190 bool CompositingReasonFinder::requiresCompositingForScrollBlocksOn(const RenderO
bject* renderer) const | 190 bool CompositingReasonFinder::requiresCompositingForScrollBlocksOn(const RenderO
bject* renderer) const |
191 { | 191 { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // Either way, we don't need to require compositing for scroll block
s on. This avoids | 224 // Either way, we don't need to require compositing for scroll block
s on. This avoids |
225 // enabling compositing by default, and avoids cluttering the root l
ayers compositing reasons. | 225 // enabling compositing by default, and avoids cluttering the root l
ayers compositing reasons. |
226 return false; | 226 return false; |
227 } | 227 } |
228 } | 228 } |
229 | 229 |
230 return true; | 230 return true; |
231 } | 231 } |
232 | 232 |
233 } | 233 } |
OLD | NEW |