| 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/animation/ActiveAnimations.h" | 10 #include "core/animation/ActiveAnimations.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "core/rendering/RenderLayerStackingNodeIterator.h" | 27 #include "core/rendering/RenderLayerStackingNodeIterator.h" |
| 28 #include "core/rendering/RenderReplica.h" | 28 #include "core/rendering/RenderReplica.h" |
| 29 #include "core/rendering/RenderVideo.h" | 29 #include "core/rendering/RenderVideo.h" |
| 30 #include "core/rendering/RenderView.h" | 30 #include "core/rendering/RenderView.h" |
| 31 #include "core/rendering/compositing/RenderLayerCompositor.h" | 31 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 32 | 32 |
| 33 namespace WebCore { | 33 namespace WebCore { |
| 34 | 34 |
| 35 CompositingReasonFinder::CompositingReasonFinder(RenderView& renderView) | 35 CompositingReasonFinder::CompositingReasonFinder(RenderView& renderView) |
| 36 : m_renderView(renderView) | 36 : m_renderView(renderView) |
| 37 , m_compositingTriggers(static_cast<ChromeClient::CompositingTriggerFlags>(C
hromeClient::AllTriggers)) | 37 , m_compositingTriggers(static_cast<CompositingTriggerFlags>(AllCompositingT
riggers)) |
| 38 { | 38 { |
| 39 } | 39 } |
| 40 | 40 |
| 41 void CompositingReasonFinder::updateTriggers() | 41 void CompositingReasonFinder::updateTriggers() |
| 42 { | 42 { |
| 43 m_compositingTriggers = m_renderView.document().page()->chrome().client().al
lowedCompositingTriggers(); | 43 m_compositingTriggers = m_renderView.document().page()->chrome().client().al
lowedCompositingTriggers(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool CompositingReasonFinder::has3DTransformTrigger() const | 46 bool CompositingReasonFinder::has3DTransformTrigger() const |
| 47 { | 47 { |
| 48 return m_compositingTriggers & ChromeClient::ThreeDTransformTrigger; | 48 return m_compositingTriggers & ThreeDTransformTrigger; |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool CompositingReasonFinder::hasAnimationTrigger() const | 51 bool CompositingReasonFinder::hasAnimationTrigger() const |
| 52 { | 52 { |
| 53 return m_compositingTriggers & ChromeClient::AnimationTrigger; | 53 return m_compositingTriggers & AnimationTrigger; |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool CompositingReasonFinder::isMainFrame() const | 56 bool CompositingReasonFinder::isMainFrame() const |
| 57 { | 57 { |
| 58 // FIXME: LocalFrame::isMainFrame() is probably better. | 58 // FIXME: LocalFrame::isMainFrame() is probably better. |
| 59 return !m_renderView.document().ownerElement(); | 59 return !m_renderView.document().ownerElement(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* lay
er, bool* needToRecomputeCompositingRequirements) const | 62 CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* lay
er, bool* needToRecomputeCompositingRequirements) const |
| 63 { | 63 { |
| 64 RenderObject* renderer = layer->renderer(); | 64 RenderObject* renderer = layer->renderer(); |
| 65 CompositingReasons directReasons = CompositingReasonNone; | 65 CompositingReasons directReasons = CompositingReasonNone; |
| 66 | 66 |
| 67 if (requiresCompositingForTransform(renderer)) | 67 if (requiresCompositingForTransform(renderer)) |
| 68 directReasons |= CompositingReason3DTransform; | 68 directReasons |= CompositingReason3DTransform; |
| 69 | 69 |
| 70 // Only zero or one of the following conditions will be true for a given Ren
derLayer. | 70 // Only zero or one of the following conditions will be true for a given Ren
derLayer. |
| 71 if (requiresCompositingForVideo(renderer)) | 71 // FIXME: These should be handled by overrides of RenderObject::additionalCo
mpositingReasons. |
| 72 directReasons |= CompositingReasonVideo; | 72 if (requiresCompositingForPlugin(renderer, needToRecomputeCompositingRequire
ments)) |
| 73 else if (requiresCompositingForCanvas(renderer)) | |
| 74 directReasons |= CompositingReasonCanvas; | |
| 75 else if (requiresCompositingForPlugin(renderer, needToRecomputeCompositingRe
quirements)) | |
| 76 directReasons |= CompositingReasonPlugin; | 73 directReasons |= CompositingReasonPlugin; |
| 77 else if (requiresCompositingForFrame(renderer, needToRecomputeCompositingReq
uirements)) | 74 else if (requiresCompositingForFrame(renderer, needToRecomputeCompositingReq
uirements)) |
| 78 directReasons |= CompositingReasonIFrame; | 75 directReasons |= CompositingReasonIFrame; |
| 79 | 76 |
| 80 if (requiresCompositingForBackfaceVisibilityHidden(renderer)) | 77 if (requiresCompositingForBackfaceVisibilityHidden(renderer)) |
| 81 directReasons |= CompositingReasonBackfaceVisibilityHidden; | 78 directReasons |= CompositingReasonBackfaceVisibilityHidden; |
| 82 | 79 |
| 83 if (requiresCompositingForAnimation(renderer)) | 80 if (requiresCompositingForAnimation(renderer)) |
| 84 directReasons |= CompositingReasonActiveAnimation; | 81 directReasons |= CompositingReasonActiveAnimation; |
| 85 | 82 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 97 | 94 |
| 98 if (requiresCompositingForOverflowScrollingParent(layer)) | 95 if (requiresCompositingForOverflowScrollingParent(layer)) |
| 99 directReasons |= CompositingReasonOverflowScrollingParent; | 96 directReasons |= CompositingReasonOverflowScrollingParent; |
| 100 | 97 |
| 101 if (requiresCompositingForOutOfFlowClipping(layer)) | 98 if (requiresCompositingForOutOfFlowClipping(layer)) |
| 102 directReasons |= CompositingReasonOutOfFlowClipping; | 99 directReasons |= CompositingReasonOutOfFlowClipping; |
| 103 | 100 |
| 104 if (requiresCompositingForWillChange(renderer)) | 101 if (requiresCompositingForWillChange(renderer)) |
| 105 directReasons |= CompositingReasonWillChange; | 102 directReasons |= CompositingReasonWillChange; |
| 106 | 103 |
| 104 directReasons |= renderer->additionalCompositingReasons(m_compositingTrigger
s); |
| 105 |
| 107 return directReasons; | 106 return directReasons; |
| 108 } | 107 } |
| 109 | 108 |
| 110 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const | 109 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const |
| 111 { | 110 { |
| 112 // Need this done first to determine overflow. | 111 // Need this done first to determine overflow. |
| 113 ASSERT(!m_renderView.needsLayout()); | 112 ASSERT(!m_renderView.needsLayout()); |
| 114 if (isMainFrame()) | 113 if (isMainFrame()) |
| 115 return false; | 114 return false; |
| 116 | 115 |
| 117 if (!(m_compositingTriggers & ChromeClient::ScrollableInnerFrameTrigger)) | 116 if (!(m_compositingTriggers & ScrollableInnerFrameTrigger)) |
| 118 return false; | 117 return false; |
| 119 | 118 |
| 120 FrameView* frameView = m_renderView.frameView(); | 119 FrameView* frameView = m_renderView.frameView(); |
| 121 return frameView->isScrollable(); | 120 return frameView->isScrollable(); |
| 122 } | 121 } |
| 123 | 122 |
| 124 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend
erer) const | 123 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend
erer) const |
| 125 { | 124 { |
| 126 if (!(m_compositingTriggers & ChromeClient::ThreeDTransformTrigger)) | 125 if (!(m_compositingTriggers & ThreeDTransformTrigger)) |
| 127 return false; | 126 return false; |
| 128 | 127 |
| 129 RenderStyle* style = renderer->style(); | 128 RenderStyle* style = renderer->style(); |
| 130 // Note that we ask the renderer if it has a transform, because the style ma
y have transforms, | 129 // Note that we ask the renderer if it has a transform, because the style ma
y have transforms, |
| 131 // but the renderer may be an inline that doesn't suppport them. | 130 // but the renderer may be an inline that doesn't suppport them. |
| 132 return renderer->hasTransform() && style->transform().has3DOperation(); | 131 return renderer->hasTransform() && style->transform().has3DOperation(); |
| 133 } | 132 } |
| 134 | 133 |
| 135 bool CompositingReasonFinder::requiresCompositingForVideo(RenderObject* renderer
) const | |
| 136 { | |
| 137 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && renderer->isV
ideo()) { | |
| 138 HTMLMediaElement* media = toHTMLMediaElement(renderer->node()); | |
| 139 if (media->isFullscreen()) | |
| 140 return true; | |
| 141 } | |
| 142 | |
| 143 if (!(m_compositingTriggers & ChromeClient::VideoTrigger)) | |
| 144 return false; | |
| 145 | |
| 146 if (renderer->isVideo()) { | |
| 147 RenderVideo* video = toRenderVideo(renderer); | |
| 148 return video->shouldDisplayVideo() && video->supportsAcceleratedRenderin
g(); | |
| 149 } | |
| 150 return false; | |
| 151 } | |
| 152 | |
| 153 bool CompositingReasonFinder::requiresCompositingForCanvas(RenderObject* rendere
r) const | |
| 154 { | |
| 155 if (!(m_compositingTriggers & ChromeClient::CanvasTrigger)) | |
| 156 return false; | |
| 157 | |
| 158 if (renderer->isCanvas()) { | |
| 159 HTMLCanvasElement* canvas = toHTMLCanvasElement(renderer->node()); | |
| 160 return canvas->renderingContext() && canvas->renderingContext()->isAccel
erated(); | |
| 161 } | |
| 162 return false; | |
| 163 } | |
| 164 | |
| 165 bool CompositingReasonFinder::requiresCompositingForPlugin(RenderObject* rendere
r, bool* needToRecomputeCompositingRequirements) const | 134 bool CompositingReasonFinder::requiresCompositingForPlugin(RenderObject* rendere
r, bool* needToRecomputeCompositingRequirements) const |
| 166 { | 135 { |
| 167 if (!(m_compositingTriggers & ChromeClient::PluginTrigger)) | 136 if (!(m_compositingTriggers & PluginTrigger)) |
| 168 return false; | 137 return false; |
| 169 | 138 |
| 170 if (!renderer->isEmbeddedObject() || !toRenderEmbeddedObject(renderer)->allo
wsAcceleratedCompositing()) | 139 if (!renderer->isEmbeddedObject() || !toRenderEmbeddedObject(renderer)->allo
wsAcceleratedCompositing()) |
| 171 return false; | 140 return false; |
| 172 | 141 |
| 173 // FIXME: this seems bogus. If we don't know the layout position/size of the
plugin yet, would't that be handled elsewhere? | 142 // FIXME: this seems bogus. If we don't know the layout position/size of the
plugin yet, would't that be handled elsewhere? |
| 174 *needToRecomputeCompositingRequirements = true; | 143 *needToRecomputeCompositingRequirements = true; |
| 175 | 144 |
| 176 RenderWidget* pluginRenderer = toRenderWidget(renderer); | 145 RenderWidget* pluginRenderer = toRenderWidget(renderer); |
| 177 // If we can't reliably know the size of the plugin yet, don't change compos
iting state. | 146 // If we can't reliably know the size of the plugin yet, don't change compos
iting state. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 207 if (renderer->needsLayout()) | 176 if (renderer->needsLayout()) |
| 208 return frameRenderer->hasLayer() && frameRenderer->layer()->hasComposite
dLayerMapping(); | 177 return frameRenderer->hasLayer() && frameRenderer->layer()->hasComposite
dLayerMapping(); |
| 209 | 178 |
| 210 // Don't go into compositing mode if height or width are zero. | 179 // Don't go into compositing mode if height or width are zero. |
| 211 IntRect contentBox = pixelSnappedIntRect(frameRenderer->contentBoxRect()); | 180 IntRect contentBox = pixelSnappedIntRect(frameRenderer->contentBoxRect()); |
| 212 return contentBox.height() * contentBox.width() > 0; | 181 return contentBox.height() * contentBox.width() > 0; |
| 213 } | 182 } |
| 214 | 183 |
| 215 bool CompositingReasonFinder::requiresCompositingForBackfaceVisibilityHidden(Ren
derObject* renderer) const | 184 bool CompositingReasonFinder::requiresCompositingForBackfaceVisibilityHidden(Ren
derObject* renderer) const |
| 216 { | 185 { |
| 217 if (!(m_compositingTriggers & ChromeClient::ThreeDTransformTrigger)) | 186 if (!(m_compositingTriggers & ThreeDTransformTrigger)) |
| 218 return false; | 187 return false; |
| 219 | 188 |
| 220 return renderer->style()->backfaceVisibility() == BackfaceVisibilityHidden; | 189 return renderer->style()->backfaceVisibility() == BackfaceVisibilityHidden; |
| 221 } | 190 } |
| 222 | 191 |
| 223 bool CompositingReasonFinder::requiresCompositingForAnimation(RenderObject* rend
erer) const | 192 bool CompositingReasonFinder::requiresCompositingForAnimation(RenderObject* rend
erer) const |
| 224 { | 193 { |
| 225 if (!(m_compositingTriggers & ChromeClient::AnimationTrigger)) | 194 if (!(m_compositingTriggers & AnimationTrigger)) |
| 226 return false; | 195 return false; |
| 227 | 196 |
| 228 return shouldCompositeForActiveAnimations(*renderer); | 197 return shouldCompositeForActiveAnimations(*renderer); |
| 229 } | 198 } |
| 230 | 199 |
| 231 bool CompositingReasonFinder::requiresCompositingForTransition(RenderObject* ren
derer) const | 200 bool CompositingReasonFinder::requiresCompositingForTransition(RenderObject* ren
derer) const |
| 232 { | 201 { |
| 233 if (!(m_compositingTriggers & ChromeClient::AnimationTrigger)) | 202 if (!(m_compositingTriggers & AnimationTrigger)) |
| 234 return false; | 203 return false; |
| 235 | 204 |
| 236 if (Settings* settings = m_renderView.document().settings()) { | 205 if (Settings* settings = m_renderView.document().settings()) { |
| 237 if (!settings->acceleratedCompositingForTransitionEnabled()) | 206 if (!settings->acceleratedCompositingForTransitionEnabled()) |
| 238 return false; | 207 return false; |
| 239 } | 208 } |
| 240 | 209 |
| 241 return renderer->style()->transitionForProperty(CSSPropertyOpacity) | 210 return renderer->style()->transitionForProperty(CSSPropertyOpacity) |
| 242 || renderer->style()->transitionForProperty(CSSPropertyWebkitFilter) | 211 || renderer->style()->transitionForProperty(CSSPropertyWebkitFilter) |
| 243 || renderer->style()->transitionForProperty(CSSPropertyWebkitTransform); | 212 || renderer->style()->transitionForProperty(CSSPropertyWebkitTransform); |
| 244 } | 213 } |
| 245 | 214 |
| 246 bool CompositingReasonFinder::requiresCompositingForFilters(RenderObject* render
er) const | 215 bool CompositingReasonFinder::requiresCompositingForFilters(RenderObject* render
er) const |
| 247 { | 216 { |
| 248 if (!(m_compositingTriggers & ChromeClient::FilterTrigger)) | 217 if (!(m_compositingTriggers & FilterTrigger)) |
| 249 return false; | 218 return false; |
| 250 | 219 |
| 251 return renderer->hasFilter(); | 220 return renderer->hasFilter(); |
| 252 } | 221 } |
| 253 | 222 |
| 254 bool CompositingReasonFinder::requiresCompositingForOverflowScrollingParent(cons
t RenderLayer* layer) const | 223 bool CompositingReasonFinder::requiresCompositingForOverflowScrollingParent(cons
t RenderLayer* layer) const |
| 255 { | 224 { |
| 256 return !!layer->scrollParent(); | 225 return !!layer->scrollParent(); |
| 257 } | 226 } |
| 258 | 227 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 361 |
| 393 return true; | 362 return true; |
| 394 } | 363 } |
| 395 | 364 |
| 396 bool CompositingReasonFinder::requiresCompositingForOverflowScrolling(const Rend
erLayer* layer) const | 365 bool CompositingReasonFinder::requiresCompositingForOverflowScrolling(const Rend
erLayer* layer) const |
| 397 { | 366 { |
| 398 return layer->needsCompositedScrolling(); | 367 return layer->needsCompositedScrolling(); |
| 399 } | 368 } |
| 400 | 369 |
| 401 } | 370 } |
| OLD | NEW |