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/compositing/CompositingReasonFinder.h" | 6 #include "core/rendering/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/page/Page.h" | 12 #include "core/page/Page.h" |
13 #include "core/rendering/RenderView.h" | 13 #include "core/rendering/RenderView.h" |
14 #include "core/rendering/compositing/RenderLayerCompositor.h" | 14 #include "core/rendering/compositing/RenderLayerCompositor.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(); |
23 } | 23 } |
24 | 24 |
25 void CompositingReasonFinder::updateTriggers() | 25 void CompositingReasonFinder::updateTriggers() |
26 { | 26 { |
27 m_compositingTriggers = 0; | 27 m_compositingTriggers = 0; |
28 | 28 |
29 Settings& settings = m_renderView.document().page()->settings(); | 29 Settings& settings = m_renderView.document().page()->settings(); |
30 if (settings.acceleratedCompositingForCanvasEnabled()) | |
31 m_compositingTriggers |= CanvasTrigger; | |
32 if (settings.compositedScrollingForFramesEnabled()) | 30 if (settings.compositedScrollingForFramesEnabled()) |
33 m_compositingTriggers |= ScrollableInnerFrameTrigger; | 31 m_compositingTriggers |= ScrollableInnerFrameTrigger; |
34 | 32 |
35 // We map both these settings to universal overlow scrolling. | 33 // We map both these settings to universal overlow scrolling. |
36 // FIXME: Replace these settings with a generic compositing setting for High
DPI. | 34 // FIXME: Replace these settings with a generic compositing setting for High
DPI. |
37 if (settings.acceleratedCompositingForOverflowScrollEnabled() || settings.co
mpositorDrivenAcceleratedScrollingEnabled()) | 35 if (settings.acceleratedCompositingForOverflowScrollEnabled() || settings.co
mpositorDrivenAcceleratedScrollingEnabled()) |
38 m_compositingTriggers |= OverflowScrollTrigger; | 36 m_compositingTriggers |= OverflowScrollTrigger; |
39 | 37 |
40 if (settings.acceleratedCompositingForFixedPositionEnabled()) | 38 if (settings.acceleratedCompositingForFixedPositionEnabled()) |
41 m_compositingTriggers |= ViewportConstrainedPositionedTrigger; | 39 m_compositingTriggers |= ViewportConstrainedPositionedTrigger; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 directReasons |= CompositingReasonOverflowScrollingParent; | 145 directReasons |= CompositingReasonOverflowScrollingParent; |
148 } | 146 } |
149 | 147 |
150 if (layer->needsCompositedScrolling()) | 148 if (layer->needsCompositedScrolling()) |
151 directReasons |= CompositingReasonOverflowScrollingTouch; | 149 directReasons |= CompositingReasonOverflowScrollingTouch; |
152 } | 150 } |
153 | 151 |
154 if (requiresCompositingForPositionFixed(renderer)) | 152 if (requiresCompositingForPositionFixed(renderer)) |
155 directReasons |= CompositingReasonPositionFixed; | 153 directReasons |= CompositingReasonPositionFixed; |
156 | 154 |
157 directReasons |= renderer->additionalCompositingReasons(m_compositingTrigger
s); | 155 directReasons |= renderer->additionalCompositingReasons(); |
158 | 156 |
159 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); | 157 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); |
160 return directReasons; | 158 return directReasons; |
161 } | 159 } |
162 | 160 |
163 bool CompositingReasonFinder::requiresCompositingForAnimation(RenderStyle* style
) const | 161 bool CompositingReasonFinder::requiresCompositingForAnimation(RenderStyle* style
) const |
164 { | 162 { |
165 if (style->subtreeWillChangeContents()) | 163 if (style->subtreeWillChangeContents()) |
166 return style->isRunningAnimationOnCompositor(); | 164 return style->isRunningAnimationOnCompositor(); |
167 | 165 |
168 return style->shouldCompositeForCurrentAnimations(); | 166 return style->shouldCompositeForCurrentAnimations(); |
169 } | 167 } |
170 | 168 |
171 bool CompositingReasonFinder::requiresCompositingForPositionFixed(RenderObject*
renderer) const | 169 bool CompositingReasonFinder::requiresCompositingForPositionFixed(RenderObject*
renderer) const |
172 { | 170 { |
173 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) | 171 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) |
174 return false; | 172 return false; |
175 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. | 173 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. |
176 // They will stay fixed wrt the container rather than the enclosing frame. | 174 // They will stay fixed wrt the container rather than the enclosing frame. |
177 return renderer->style()->position() == FixedPosition | 175 return renderer->style()->position() == FixedPosition |
178 && renderer->container() == &m_renderView | 176 && renderer->container() == &m_renderView |
179 && m_renderView.frameView()->isScrollable(); | 177 && m_renderView.frameView()->isScrollable(); |
180 } | 178 } |
181 | 179 |
182 } | 180 } |
OLD | NEW |