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 "CSSPropertyNames.h" | 8 #include "CSSPropertyNames.h" |
9 #include "HTMLNames.h" | 9 #include "HTMLNames.h" |
10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 Settings& settings = m_renderView.document().page()->settings(); | 45 Settings& settings = m_renderView.document().page()->settings(); |
46 if (settings.acceleratedCompositingForVideoEnabled()) | 46 if (settings.acceleratedCompositingForVideoEnabled()) |
47 m_compositingTriggers |= VideoTrigger; | 47 m_compositingTriggers |= VideoTrigger; |
48 if (settings.acceleratedCompositingForCanvasEnabled()) | 48 if (settings.acceleratedCompositingForCanvasEnabled()) |
49 m_compositingTriggers |= CanvasTrigger; | 49 m_compositingTriggers |= CanvasTrigger; |
50 if (settings.compositedScrollingForFramesEnabled()) | 50 if (settings.compositedScrollingForFramesEnabled()) |
51 m_compositingTriggers |= ScrollableInnerFrameTrigger; | 51 m_compositingTriggers |= ScrollableInnerFrameTrigger; |
52 if (settings.acceleratedCompositingForFiltersEnabled()) | 52 if (settings.acceleratedCompositingForFiltersEnabled()) |
53 m_compositingTriggers |= FilterTrigger; | 53 m_compositingTriggers |= FilterTrigger; |
54 if (settings.acceleratedCompositingForGpuRasterizationHintEnabled()) | |
55 m_compositingTriggers |= GPURasterizationTrigger; | |
56 | 54 |
57 // We map both these settings to universal overlow scrolling. | 55 // We map both these settings to universal overlow scrolling. |
58 // FIXME: Replace these settings with a generic compositing setting for High
DPI. | 56 // FIXME: Replace these settings with a generic compositing setting for High
DPI. |
59 if (settings.acceleratedCompositingForOverflowScrollEnabled() || settings.co
mpositorDrivenAcceleratedScrollingEnabled()) | 57 if (settings.acceleratedCompositingForOverflowScrollEnabled() || settings.co
mpositorDrivenAcceleratedScrollingEnabled()) |
60 m_compositingTriggers |= OverflowScrollTrigger; | 58 m_compositingTriggers |= OverflowScrollTrigger; |
61 | 59 |
62 // FIXME: acceleratedCompositingForFixedPositionEnabled should be renamed ac
celeratedCompositingForViewportConstrainedPositionEnabled(). | 60 // FIXME: acceleratedCompositingForFixedPositionEnabled should be renamed ac
celeratedCompositingForViewportConstrainedPositionEnabled(). |
63 // Or the sticky and fixed position elements should be behind different flag
s. | 61 // Or the sticky and fixed position elements should be behind different flag
s. |
64 if (settings.acceleratedCompositingForFixedPositionEnabled()) | 62 if (settings.acceleratedCompositingForFixedPositionEnabled()) |
65 m_compositingTriggers |= ViewportConstrainedPositionedTrigger; | 63 m_compositingTriggers |= ViewportConstrainedPositionedTrigger; |
(...skipping 11 matching lines...) Expand all Loading... |
77 { | 75 { |
78 return m_compositingTriggers & LegacyOverflowScrollTrigger; | 76 return m_compositingTriggers & LegacyOverflowScrollTrigger; |
79 } | 77 } |
80 | 78 |
81 bool CompositingReasonFinder::isMainFrame() const | 79 bool CompositingReasonFinder::isMainFrame() const |
82 { | 80 { |
83 // FIXME: LocalFrame::isMainFrame() is probably better. | 81 // FIXME: LocalFrame::isMainFrame() is probably better. |
84 return !m_renderView.document().ownerElement(); | 82 return !m_renderView.document().ownerElement(); |
85 } | 83 } |
86 | 84 |
87 CompositingReasons CompositingReasonFinder::suppressWillChangeAndAnimationForGpu
Rasterization(const RenderLayer* layer, CompositingReasons styleReasons) const | |
88 { | |
89 CompositingReasons adjustedReasons = styleReasons; | |
90 adjustedReasons &= ~(CompositingReasonWillChangeCompositingHint | Compositin
gReasonWillChangeGpuRasterizationHint); | |
91 | |
92 // We can suppress layer creation for animations before animations start, bu
t not | |
93 // once they're already running on the compositor. | |
94 if (!layer->renderer()->style()->isRunningAnimationOnCompositor()) | |
95 adjustedReasons &= ~CompositingReasonActiveAnimation; | |
96 | |
97 return adjustedReasons; | |
98 } | |
99 | |
100 CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* lay
er, bool* needToRecomputeCompositingRequirements) const | 85 CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* lay
er, bool* needToRecomputeCompositingRequirements) const |
101 { | 86 { |
102 CompositingReasons styleReasons = layer->styleDeterminedCompositingReasons()
; | 87 CompositingReasons styleReasons = layer->styleDeterminedCompositingReasons()
; |
103 ASSERT(styleDeterminedReasons(layer->renderer()) == styleReasons); | 88 ASSERT(styleDeterminedReasons(layer->renderer()) == styleReasons); |
104 return styleReasons | nonStyleDeterminedDirectReasons(layer, needToRecompute
CompositingRequirements); | 89 return styleReasons | nonStyleDeterminedDirectReasons(layer, needToRecompute
CompositingRequirements); |
105 } | 90 } |
106 | 91 |
107 // This information doesn't appear to be incorporated into CompositingReasons. | 92 // This information doesn't appear to be incorporated into CompositingReasons. |
108 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const | 93 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const |
109 { | 94 { |
(...skipping 21 matching lines...) Expand all Loading... |
131 | 116 |
132 if (requiresCompositingForAnimation(renderer)) | 117 if (requiresCompositingForAnimation(renderer)) |
133 directReasons |= CompositingReasonActiveAnimation; | 118 directReasons |= CompositingReasonActiveAnimation; |
134 | 119 |
135 if (requiresCompositingForFilters(renderer)) | 120 if (requiresCompositingForFilters(renderer)) |
136 directReasons |= CompositingReasonFilters; | 121 directReasons |= CompositingReasonFilters; |
137 | 122 |
138 if (requiresCompositingForWillChangeCompositingHint(renderer)) | 123 if (requiresCompositingForWillChangeCompositingHint(renderer)) |
139 directReasons |= CompositingReasonWillChangeCompositingHint; | 124 directReasons |= CompositingReasonWillChangeCompositingHint; |
140 | 125 |
141 if (requiresCompositingForWillChangeGpuRasterizationHint(renderer)) | |
142 directReasons |= CompositingReasonWillChangeGpuRasterizationHint; | |
143 | |
144 ASSERT(!(directReasons & ~CompositingReasonComboAllStyleDeterminedReasons)); | 126 ASSERT(!(directReasons & ~CompositingReasonComboAllStyleDeterminedReasons)); |
145 return directReasons; | 127 return directReasons; |
146 } | 128 } |
147 | 129 |
148 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend
erer) const | 130 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend
erer) const |
149 { | 131 { |
150 // Note that we ask the renderer if it has a transform, because the style ma
y have transforms, | 132 // Note that we ask the renderer if it has a transform, because the style ma
y have transforms, |
151 // but the renderer may be an inline that doesn't suppport them. | 133 // but the renderer may be an inline that doesn't suppport them. |
152 return renderer->hasTransform() && renderer->style()->transform().has3DOpera
tion(); | 134 return renderer->hasTransform() && renderer->style()->transform().has3DOpera
tion(); |
153 } | 135 } |
154 | 136 |
155 bool CompositingReasonFinder::requiresCompositingForBackfaceVisibilityHidden(Ren
derObject* renderer) const | 137 bool CompositingReasonFinder::requiresCompositingForBackfaceVisibilityHidden(Ren
derObject* renderer) const |
156 { | 138 { |
157 return renderer->style()->backfaceVisibility() == BackfaceVisibilityHidden; | 139 return renderer->style()->backfaceVisibility() == BackfaceVisibilityHidden; |
158 } | 140 } |
159 | 141 |
160 bool CompositingReasonFinder::requiresCompositingForFilters(RenderObject* render
er) const | 142 bool CompositingReasonFinder::requiresCompositingForFilters(RenderObject* render
er) const |
161 { | 143 { |
162 if (!(m_compositingTriggers & FilterTrigger)) | 144 if (!(m_compositingTriggers & FilterTrigger)) |
163 return false; | 145 return false; |
164 | 146 |
165 return renderer->hasFilter(); | 147 return renderer->hasFilter(); |
166 } | 148 } |
167 | 149 |
168 bool CompositingReasonFinder::requiresCompositingForWillChangeCompositingHint(co
nst RenderObject* renderer) const | 150 bool CompositingReasonFinder::requiresCompositingForWillChangeCompositingHint(co
nst RenderObject* renderer) const |
169 { | 151 { |
170 return renderer->style()->hasWillChangeCompositingHint(); | 152 return renderer->style()->hasWillChangeCompositingHint(); |
171 } | 153 } |
172 | 154 |
173 bool CompositingReasonFinder::requiresCompositingForWillChangeGpuRasterizationHi
nt(const RenderObject* renderer) const | |
174 { | |
175 if (!(m_compositingTriggers & GPURasterizationTrigger)) | |
176 return false; | |
177 | |
178 return renderer->style()->hasWillChangeGpuRasterizationHint(); | |
179 } | |
180 | |
181 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
t RenderLayer* layer, bool* needToRecomputeCompositingRequirements) const | 155 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
t RenderLayer* layer, bool* needToRecomputeCompositingRequirements) const |
182 { | 156 { |
183 CompositingReasons directReasons = CompositingReasonNone; | 157 CompositingReasons directReasons = CompositingReasonNone; |
184 RenderObject* renderer = layer->renderer(); | 158 RenderObject* renderer = layer->renderer(); |
185 | 159 |
186 if (hasOverflowScrollTrigger()) { | 160 if (hasOverflowScrollTrigger()) { |
187 if (requiresCompositingForOutOfFlowClipping(layer)) | 161 if (requiresCompositingForOutOfFlowClipping(layer)) |
188 directReasons |= CompositingReasonOutOfFlowClipping; | 162 directReasons |= CompositingReasonOutOfFlowClipping; |
189 | 163 |
190 if (requiresCompositingForOverflowScrollingParent(layer)) | 164 if (requiresCompositingForOverflowScrollingParent(layer)) |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 *needToRecomputeCompositingRequirements = true; | 314 *needToRecomputeCompositingRequirements = true; |
341 } | 315 } |
342 return false; | 316 return false; |
343 } | 317 } |
344 } | 318 } |
345 | 319 |
346 return true; | 320 return true; |
347 } | 321 } |
348 | 322 |
349 } | 323 } |
OLD | NEW |