Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: Source/core/rendering/compositing/CompositingRequirementsUpdater.cpp

Issue 233063004: Suppress layer creation for descendants of GPU-rasterized layers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2014 Google Inc. All rights reserved. 3 * Copyright (C) 2014 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 }; 156 };
157 157
158 class CompositingRequirementsUpdater::RecursionData { 158 class CompositingRequirementsUpdater::RecursionData {
159 public: 159 public:
160 RecursionData(RenderLayer* compAncestor, RenderLayer* mostRecentCompositedLa yer, bool testOverlap) 160 RecursionData(RenderLayer* compAncestor, RenderLayer* mostRecentCompositedLa yer, bool testOverlap)
161 : m_compositingAncestor(compAncestor) 161 : m_compositingAncestor(compAncestor)
162 , m_mostRecentCompositedLayer(mostRecentCompositedLayer) 162 , m_mostRecentCompositedLayer(mostRecentCompositedLayer)
163 , m_subtreeIsCompositing(false) 163 , m_subtreeIsCompositing(false)
164 , m_hasUnisolatedCompositedBlendingDescendant(false) 164 , m_hasUnisolatedCompositedBlendingDescendant(false)
165 , m_testingOverlap(testOverlap) 165 , m_testingOverlap(testOverlap)
166 , m_suppressLayerCreation(false)
166 #ifndef NDEBUG 167 #ifndef NDEBUG
167 , m_depth(0) 168 , m_depth(0)
168 #endif 169 #endif
169 { 170 {
170 } 171 }
171 172
172 RecursionData(const RecursionData& other) 173 RecursionData(const RecursionData& other)
173 : m_compositingAncestor(other.m_compositingAncestor) 174 : m_compositingAncestor(other.m_compositingAncestor)
174 , m_mostRecentCompositedLayer(other.m_mostRecentCompositedLayer) 175 , m_mostRecentCompositedLayer(other.m_mostRecentCompositedLayer)
175 , m_subtreeIsCompositing(other.m_subtreeIsCompositing) 176 , m_subtreeIsCompositing(other.m_subtreeIsCompositing)
176 , m_hasUnisolatedCompositedBlendingDescendant(other.m_hasUnisolatedCompo sitedBlendingDescendant) 177 , m_hasUnisolatedCompositedBlendingDescendant(other.m_hasUnisolatedCompo sitedBlendingDescendant)
177 , m_testingOverlap(other.m_testingOverlap) 178 , m_testingOverlap(other.m_testingOverlap)
179 , m_suppressLayerCreation(other.m_suppressLayerCreation)
178 #ifndef NDEBUG 180 #ifndef NDEBUG
179 , m_depth(other.m_depth + 1) 181 , m_depth(other.m_depth + 1)
180 #endif 182 #endif
181 { 183 {
182 } 184 }
183 185
184 RenderLayer* m_compositingAncestor; 186 RenderLayer* m_compositingAncestor;
185 RenderLayer* m_mostRecentCompositedLayer; // in paint order regardless of hi erarchy. 187 RenderLayer* m_mostRecentCompositedLayer; // in paint order regardless of hi erarchy.
186 bool m_subtreeIsCompositing; 188 bool m_subtreeIsCompositing;
187 bool m_hasUnisolatedCompositedBlendingDescendant; 189 bool m_hasUnisolatedCompositedBlendingDescendant;
188 bool m_testingOverlap; 190 bool m_testingOverlap;
191 bool m_suppressLayerCreation;
189 #ifndef NDEBUG 192 #ifndef NDEBUG
190 int m_depth; 193 int m_depth;
191 #endif 194 #endif
192 }; 195 };
193 196
194 static bool requiresCompositingOrSquashing(CompositingReasons reasons) 197 static bool requiresCompositingOrSquashing(CompositingReasons reasons)
195 { 198 {
196 #ifndef NDEBUG 199 #ifndef NDEBUG
197 bool fastAnswer = reasons != CompositingReasonNone; 200 bool fastAnswer = reasons != CompositingReasonNone;
198 bool slowAnswer = requiresCompositing(reasons) || requiresSquashing(reasons) ; 201 bool slowAnswer = requiresCompositing(reasons) || requiresSquashing(reasons) ;
199 ASSERT(fastAnswer == slowAnswer); 202 ASSERT(fastAnswer == slowAnswer);
200 #endif 203 #endif
201 return reasons != CompositingReasonNone; 204 return reasons != CompositingReasonNone;
202 } 205 }
203 206
207 static bool shouldMakeDescendantsSuppressCompositedLayerCreation(CompositingReas ons reasons)
208 {
209 return reasons & CompositingReasonWillChangeGpuRasterizationHint;
210 }
211
204 static CompositingReasons subtreeReasonsForCompositing(RenderObject* renderer, b ool hasCompositedDescendants, bool has3DTransformedDescendants) 212 static CompositingReasons subtreeReasonsForCompositing(RenderObject* renderer, b ool hasCompositedDescendants, bool has3DTransformedDescendants)
205 { 213 {
206 CompositingReasons subtreeReasons = CompositingReasonNone; 214 CompositingReasons subtreeReasons = CompositingReasonNone;
207 215
208 // FIXME: this seems to be a potentially different layer than the layer for which this was called. May not be an error, but is very confusing. 216 // FIXME: this seems to be a potentially different layer than the layer for which this was called. May not be an error, but is very confusing.
209 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); 217 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
210 218
211 // When a layer has composited descendants, some effects, like 2d transforms , filters, masks etc must be implemented 219 // When a layer has composited descendants, some effects, like 2d transforms , filters, masks etc must be implemented
212 // via compositing so that they also apply to those composited descdendants. 220 // via compositing so that they also apply to those composited descdendants.
213 if (hasCompositedDescendants) { 221 if (hasCompositedDescendants) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 IntRect absoluteDecendantBoundingBox; 287 IntRect absoluteDecendantBoundingBox;
280 updateRecursive(0, root, overlapTestRequestMap, recursionData, saw3DTransfor m, unclippedDescendants, absoluteDecendantBoundingBox); 288 updateRecursive(0, root, overlapTestRequestMap, recursionData, saw3DTransfor m, unclippedDescendants, absoluteDecendantBoundingBox);
281 } 289 }
282 290
283 void CompositingRequirementsUpdater::updateRecursive(RenderLayer* ancestorLayer, RenderLayer* layer, OverlapMap& overlapMap, RecursionData& currentRecursionData , bool& descendantHas3DTransform, Vector<RenderLayer*>& unclippedDescendants, In tRect& absoluteDecendantBoundingBox) 291 void CompositingRequirementsUpdater::updateRecursive(RenderLayer* ancestorLayer, RenderLayer* layer, OverlapMap& overlapMap, RecursionData& currentRecursionData , bool& descendantHas3DTransform, Vector<RenderLayer*>& unclippedDescendants, In tRect& absoluteDecendantBoundingBox)
284 { 292 {
285 RenderLayerCompositor* compositor = m_renderView.compositor(); 293 RenderLayerCompositor* compositor = m_renderView.compositor();
286 294
287 layer->stackingNode()->updateLayerListsIfNeeded(); 295 layer->stackingNode()->updateLayerListsIfNeeded();
288 296
297 bool needToRecomputeStyleReasons = layer->suppressingCompositedLayerCreation () != currentRecursionData.m_suppressLayerCreation;
298 layer->setSuppressingCompositedLayerCreation(currentRecursionData.m_suppress LayerCreation);
abarth-chromium 2014/04/14 20:29:53 Why is this a property of the RenderLayer? It see
ajuma 2014/04/15 19:11:34 As long as we continue to have incremental composi
299
289 // Clear the flag 300 // Clear the flag
290 layer->setHasCompositingDescendant(false); 301 layer->setHasCompositingDescendant(false);
291 302
292 // Start by assuming this layer will not need to composite. 303 // Start by assuming this layer will not need to composite.
293 CompositingReasons reasonsToComposite = CompositingReasonNone; 304 CompositingReasons reasonsToComposite = CompositingReasonNone;
294 305
306 if (needToRecomputeStyleReasons)
abarth-chromium 2014/04/14 20:29:53 There's no such thing as a need to recompute style
ajuma 2014/04/15 19:11:34 Fixed. Instead of mutating style-determined reason
307 compositor->updateStyleDeterminedCompositingReasons(layer);
308
295 // First accumulate the straightforward compositing reasons. 309 // First accumulate the straightforward compositing reasons.
296 CompositingReasons directReasons = m_compositingReasonFinder.directReasons(l ayer, m_needsToRecomputeCompositingRequirements); 310 CompositingReasons directReasons = m_compositingReasonFinder.directReasons(l ayer, m_needsToRecomputeCompositingRequirements);
297 311
298 // Video is special. It's the only RenderLayer type that can both have 312 // Video is special. It's the only RenderLayer type that can both have
299 // RenderLayer children and whose children can't use its backing to render 313 // RenderLayer children and whose children can't use its backing to render
300 // into. These children (the controls) always need to be promoted into their 314 // into. These children (the controls) always need to be promoted into their
301 // own layers to draw on top of the accelerated video. 315 // own layers to draw on top of the accelerated video.
302 if (currentRecursionData.m_compositingAncestor && currentRecursionData.m_com positingAncestor->renderer()->isVideo()) 316 if (currentRecursionData.m_compositingAncestor && currentRecursionData.m_com positingAncestor->renderer()->isVideo())
303 directReasons |= CompositingReasonVideoOverlay; 317 directReasons |= CompositingReasonVideoOverlay;
304 318
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 if (currentRecursionData.m_testingOverlap && !requiresCompositingOrSquashing (directReasons)) 355 if (currentRecursionData.m_testingOverlap && !requiresCompositingOrSquashing (directReasons))
342 overlapCompositingReason = overlapMap.overlapsLayers(absBounds) ? Compos itingReasonOverlap : CompositingReasonNone; 356 overlapCompositingReason = overlapMap.overlapsLayers(absBounds) ? Compos itingReasonOverlap : CompositingReasonNone;
343 357
344 reasonsToComposite |= overlapCompositingReason; 358 reasonsToComposite |= overlapCompositingReason;
345 359
346 // The children of this layer don't need to composite, unless there is 360 // The children of this layer don't need to composite, unless there is
347 // a compositing layer among them, so start by inheriting the compositing 361 // a compositing layer among them, so start by inheriting the compositing
348 // ancestor with m_subtreeIsCompositing set to false. 362 // ancestor with m_subtreeIsCompositing set to false.
349 RecursionData childRecursionData(currentRecursionData); 363 RecursionData childRecursionData(currentRecursionData);
350 childRecursionData.m_subtreeIsCompositing = false; 364 childRecursionData.m_subtreeIsCompositing = false;
365 childRecursionData.m_suppressLayerCreation = layer->suppressingCompositedLay erCreation() || shouldMakeDescendantsSuppressCompositedLayerCreation(directReaso ns);
351 366
352 bool willBeCompositedOrSquashed = compositor->canBeComposited(layer) && requ iresCompositingOrSquashing(reasonsToComposite); 367 bool willBeCompositedOrSquashed = compositor->canBeComposited(layer) && requ iresCompositingOrSquashing(reasonsToComposite);
353 if (willBeCompositedOrSquashed) { 368 if (willBeCompositedOrSquashed) {
354 // Tell the parent it has compositing descendants. 369 // Tell the parent it has compositing descendants.
355 currentRecursionData.m_subtreeIsCompositing = true; 370 currentRecursionData.m_subtreeIsCompositing = true;
356 // This layer now acts as the ancestor for kids. 371 // This layer now acts as the ancestor for kids.
357 childRecursionData.m_compositingAncestor = layer; 372 childRecursionData.m_compositingAncestor = layer;
358 373
359 // Here we know that all children and the layer's own contents can blind ly paint into 374 // Here we know that all children and the layer's own contents can blind ly paint into
360 // this layer's backing, until a descendant is composited. So, we don't need to check 375 // this layer's backing, until a descendant is composited. So, we don't need to check
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 530 }
516 531
517 bool CompositingRequirementsUpdater::isRunningAcceleratedTransformAnimation(Rend erObject* renderer) const 532 bool CompositingRequirementsUpdater::isRunningAcceleratedTransformAnimation(Rend erObject* renderer) const
518 { 533 {
519 if (!m_compositingReasonFinder.hasAnimationTrigger()) 534 if (!m_compositingReasonFinder.hasAnimationTrigger())
520 return false; 535 return false;
521 return renderer->style()->hasCurrentTransformAnimation(); 536 return renderer->style()->hasCurrentTransformAnimation();
522 } 537 }
523 538
524 } // namespace WebCore 539 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698