Chromium Code Reviews| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 { | 82 { |
| 83 return m_compositingTriggers & LegacyOverflowScrollTrigger; | 83 return m_compositingTriggers & LegacyOverflowScrollTrigger; |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool CompositingReasonFinder::isMainFrame() const | 86 bool CompositingReasonFinder::isMainFrame() const |
| 87 { | 87 { |
| 88 // FIXME: LocalFrame::isMainFrame() is probably better. | 88 // FIXME: LocalFrame::isMainFrame() is probably better. |
| 89 return !m_renderView.document().ownerElement(); | 89 return !m_renderView.document().ownerElement(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 CompositingReasons CompositingReasonFinder::suppressStyleDeterminedReasonsIfPoss ible(const RenderLayer* layer, CompositingReasons styleReasons) const | |
|
abarth-chromium
2014/04/14 20:25:53
Can we give this function a more semantic name? S
ajuma
2014/04/15 19:11:34
Done.
| |
| 93 { | |
| 94 CompositingReasons adjustedReasons = styleReasons; | |
| 95 adjustedReasons &= ~(CompositingReasonWillChangeCompositingHint | Compositin gReasonWillChangeGpuRasterizationHint); | |
| 96 | |
| 97 // We can suppress layer creation for animations before animations start, bu t not | |
| 98 // once they're already running on the compositor. | |
| 99 if (!layer->renderer()->style()->isRunningAnimationOnCompositor()) | |
| 100 adjustedReasons &= ~CompositingReasonActiveAnimation; | |
| 101 | |
| 102 return adjustedReasons; | |
| 103 } | |
| 104 | |
| 105 | |
|
abarth-chromium
2014/04/14 20:25:53
Please remove this extra blank line.
ajuma
2014/04/15 19:11:34
Done.
| |
| 92 CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* lay er, bool* needToRecomputeCompositingRequirements) const | 106 CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* lay er, bool* needToRecomputeCompositingRequirements) const |
| 93 { | 107 { |
| 94 CompositingReasons styleReasons = layer->styleDeterminedCompositingReasons() ; | 108 CompositingReasons styleReasons = layer->styleDeterminedCompositingReasons() ; |
| 95 ASSERT(styleDeterminedReasons(layer->renderer()) == styleReasons); | 109 ASSERT(styleDeterminedReasons(layer) == styleReasons); |
| 96 return styleReasons | nonStyleDeterminedDirectReasons(layer, needToRecompute CompositingRequirements); | 110 return styleReasons | nonStyleDeterminedDirectReasons(layer, needToRecompute CompositingRequirements); |
| 97 } | 111 } |
| 98 | 112 |
| 99 // This information doesn't appear to be incorporated into CompositingReasons. | 113 // This information doesn't appear to be incorporated into CompositingReasons. |
| 100 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const | 114 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const |
| 101 { | 115 { |
| 102 // Need this done first to determine overflow. | 116 // Need this done first to determine overflow. |
| 103 ASSERT(!m_renderView.needsLayout()); | 117 ASSERT(!m_renderView.needsLayout()); |
| 104 if (isMainFrame()) | 118 if (isMainFrame()) |
| 105 return false; | 119 return false; |
| 106 | 120 |
| 107 if (!(m_compositingTriggers & ScrollableInnerFrameTrigger)) | 121 if (!(m_compositingTriggers & ScrollableInnerFrameTrigger)) |
| 108 return false; | 122 return false; |
| 109 | 123 |
| 110 FrameView* frameView = m_renderView.frameView(); | 124 FrameView* frameView = m_renderView.frameView(); |
| 111 return frameView->isScrollable(); | 125 return frameView->isScrollable(); |
| 112 } | 126 } |
| 113 | 127 |
| 114 CompositingReasons CompositingReasonFinder::styleDeterminedReasons(RenderObject* renderer) const | 128 CompositingReasons CompositingReasonFinder::styleDeterminedReasons(const RenderL ayer* layer) const |
| 115 { | 129 { |
| 116 CompositingReasons directReasons = CompositingReasonNone; | 130 CompositingReasons directReasons = CompositingReasonNone; |
| 131 RenderObject* renderer = layer->renderer(); | |
| 117 | 132 |
| 118 if (requiresCompositingForTransform(renderer)) | 133 if (requiresCompositingForTransform(renderer)) |
| 119 directReasons |= CompositingReason3DTransform; | 134 directReasons |= CompositingReason3DTransform; |
| 120 | 135 |
| 121 if (requiresCompositingForBackfaceVisibilityHidden(renderer)) | 136 if (requiresCompositingForBackfaceVisibilityHidden(renderer)) |
| 122 directReasons |= CompositingReasonBackfaceVisibilityHidden; | 137 directReasons |= CompositingReasonBackfaceVisibilityHidden; |
| 123 | 138 |
| 124 if (requiresCompositingForAnimation(renderer)) | 139 if (requiresCompositingForAnimation(renderer)) |
| 125 directReasons |= CompositingReasonActiveAnimation; | 140 directReasons |= CompositingReasonActiveAnimation; |
| 126 | 141 |
| 127 if (requiresCompositingForFilters(renderer)) | 142 if (requiresCompositingForFilters(renderer)) |
| 128 directReasons |= CompositingReasonFilters; | 143 directReasons |= CompositingReasonFilters; |
| 129 | 144 |
| 130 if (requiresCompositingForWillChange(renderer)) | 145 if (requiresCompositingForWillChangeCompositingHint(renderer)) |
| 131 directReasons |= CompositingReasonWillChange; | 146 directReasons |= CompositingReasonWillChangeCompositingHint; |
| 147 | |
| 148 if (requiresCompositingForWillChangeGpuRasterizationHint(renderer)) | |
| 149 directReasons |= CompositingReasonWillChangeGpuRasterizationHint; | |
| 150 | |
| 151 if (layer->suppressingCompositedLayerCreation()) | |
| 152 directReasons = suppressStyleDeterminedReasonsIfPossible(layer, directRe asons); | |
|
abarth-chromium
2014/04/14 20:29:53
Maybe it would be clearer to just inline this func
| |
| 132 | 153 |
| 133 ASSERT(!(directReasons & ~CompositingReasonComboAllStyleDeterminedReasons)); | 154 ASSERT(!(directReasons & ~CompositingReasonComboAllStyleDeterminedReasons)); |
| 134 return directReasons; | 155 return directReasons; |
| 135 } | 156 } |
| 136 | 157 |
| 137 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend erer) const | 158 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend erer) const |
| 138 { | 159 { |
| 139 if (!(m_compositingTriggers & ThreeDTransformTrigger)) | 160 if (!(m_compositingTriggers & ThreeDTransformTrigger)) |
| 140 return false; | 161 return false; |
| 141 | 162 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 153 } | 174 } |
| 154 | 175 |
| 155 bool CompositingReasonFinder::requiresCompositingForFilters(RenderObject* render er) const | 176 bool CompositingReasonFinder::requiresCompositingForFilters(RenderObject* render er) const |
| 156 { | 177 { |
| 157 if (!(m_compositingTriggers & FilterTrigger)) | 178 if (!(m_compositingTriggers & FilterTrigger)) |
| 158 return false; | 179 return false; |
| 159 | 180 |
| 160 return renderer->hasFilter(); | 181 return renderer->hasFilter(); |
| 161 } | 182 } |
| 162 | 183 |
| 163 bool CompositingReasonFinder::requiresCompositingForWillChange(const RenderObjec t* renderer) const | 184 bool CompositingReasonFinder::requiresCompositingForWillChangeCompositingHint(co nst RenderObject* renderer) const |
| 164 { | 185 { |
| 165 if (renderer->style()->hasWillChangeCompositingHint()) | 186 return renderer->style()->hasWillChangeCompositingHint(); |
| 166 return true; | 187 } |
| 167 | 188 |
| 189 bool CompositingReasonFinder::requiresCompositingForWillChangeGpuRasterizationHi nt(const RenderObject* renderer) const | |
| 190 { | |
| 168 if (!(m_compositingTriggers & GPURasterizationTrigger)) | 191 if (!(m_compositingTriggers & GPURasterizationTrigger)) |
| 169 return false; | 192 return false; |
| 170 | 193 |
| 171 return renderer->style()->hasWillChangeGpuRasterizationHint(); | 194 return renderer->style()->hasWillChangeGpuRasterizationHint(); |
| 172 } | 195 } |
| 173 | 196 |
| 174 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons t RenderLayer* layer, bool* needToRecomputeCompositingRequirements) const | 197 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons t RenderLayer* layer, bool* needToRecomputeCompositingRequirements) const |
| 175 { | 198 { |
| 176 CompositingReasons directReasons = CompositingReasonNone; | 199 CompositingReasons directReasons = CompositingReasonNone; |
| 177 RenderObject* renderer = layer->renderer(); | 200 RenderObject* renderer = layer->renderer(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 *needToRecomputeCompositingRequirements = true; | 359 *needToRecomputeCompositingRequirements = true; |
| 337 } | 360 } |
| 338 return false; | 361 return false; |
| 339 } | 362 } |
| 340 } | 363 } |
| 341 | 364 |
| 342 return true; | 365 return true; |
| 343 } | 366 } |
| 344 | 367 |
| 345 } | 368 } |
| OLD | NEW |