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

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: Move assert disabler in ~CompositedLayerMapping 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 layer->stackingNode()->updateLayerListsIfNeeded(); 295 layer->stackingNode()->updateLayerListsIfNeeded();
288 296
289 // Clear the flag 297 // Clear the flag
290 layer->setHasCompositingDescendant(false); 298 layer->setHasCompositingDescendant(false);
291 299
292 // Start by assuming this layer will not need to composite. 300 // Start by assuming this layer will not need to composite.
293 CompositingReasons reasonsToComposite = CompositingReasonNone; 301 CompositingReasons reasonsToComposite = CompositingReasonNone;
294 302
295 // First accumulate the straightforward compositing reasons. 303 // First accumulate the straightforward compositing reasons.
296 CompositingReasons directReasons = m_compositingReasonFinder.directReasons(l ayer, m_needsToRecomputeCompositingRequirements); 304 CompositingReasons directReasons = m_compositingReasonFinder.directReasons(l ayer, m_needsToRecomputeCompositingRequirements);
305 layer->setSuppressingCompositedLayerCreation(currentRecursionData.m_suppress LayerCreation);
306 if (layer->suppressingCompositedLayerCreation())
307 directReasons = m_compositingReasonFinder.suppressWillChangeAndAnimation ForGpuRasterization(layer, directReasons);
297 308
298 // Video is special. It's the only RenderLayer type that can both have 309 // 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 310 // 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 311 // into. These children (the controls) always need to be promoted into their
301 // own layers to draw on top of the accelerated video. 312 // own layers to draw on top of the accelerated video.
302 if (currentRecursionData.m_compositingAncestor && currentRecursionData.m_com positingAncestor->renderer()->isVideo()) 313 if (currentRecursionData.m_compositingAncestor && currentRecursionData.m_com positingAncestor->renderer()->isVideo())
303 directReasons |= CompositingReasonVideoOverlay; 314 directReasons |= CompositingReasonVideoOverlay;
304 315
305 if (compositor->canBeComposited(layer)) 316 if (compositor->canBeComposited(layer))
306 reasonsToComposite |= directReasons; 317 reasonsToComposite |= directReasons;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 if (currentRecursionData.m_testingOverlap && !requiresCompositingOrSquashing (directReasons)) 352 if (currentRecursionData.m_testingOverlap && !requiresCompositingOrSquashing (directReasons))
342 overlapCompositingReason = overlapMap.overlapsLayers(absBounds) ? Compos itingReasonOverlap : CompositingReasonNone; 353 overlapCompositingReason = overlapMap.overlapsLayers(absBounds) ? Compos itingReasonOverlap : CompositingReasonNone;
343 354
344 reasonsToComposite |= overlapCompositingReason; 355 reasonsToComposite |= overlapCompositingReason;
345 356
346 // The children of this layer don't need to composite, unless there is 357 // 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 358 // a compositing layer among them, so start by inheriting the compositing
348 // ancestor with m_subtreeIsCompositing set to false. 359 // ancestor with m_subtreeIsCompositing set to false.
349 RecursionData childRecursionData(currentRecursionData); 360 RecursionData childRecursionData(currentRecursionData);
350 childRecursionData.m_subtreeIsCompositing = false; 361 childRecursionData.m_subtreeIsCompositing = false;
362 childRecursionData.m_suppressLayerCreation = layer->suppressingCompositedLay erCreation() || shouldMakeDescendantsSuppressCompositedLayerCreation(directReaso ns);
351 363
352 bool willBeCompositedOrSquashed = compositor->canBeComposited(layer) && requ iresCompositingOrSquashing(reasonsToComposite); 364 bool willBeCompositedOrSquashed = compositor->canBeComposited(layer) && requ iresCompositingOrSquashing(reasonsToComposite);
353 if (willBeCompositedOrSquashed) { 365 if (willBeCompositedOrSquashed) {
354 // Tell the parent it has compositing descendants. 366 // Tell the parent it has compositing descendants.
355 currentRecursionData.m_subtreeIsCompositing = true; 367 currentRecursionData.m_subtreeIsCompositing = true;
356 // This layer now acts as the ancestor for kids. 368 // This layer now acts as the ancestor for kids.
357 childRecursionData.m_compositingAncestor = layer; 369 childRecursionData.m_compositingAncestor = layer;
358 370
359 // Here we know that all children and the layer's own contents can blind ly paint into 371 // 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 372 // 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 } 527 }
516 528
517 bool CompositingRequirementsUpdater::isRunningAcceleratedTransformAnimation(Rend erObject* renderer) const 529 bool CompositingRequirementsUpdater::isRunningAcceleratedTransformAnimation(Rend erObject* renderer) const
518 { 530 {
519 if (!m_compositingReasonFinder.hasAnimationTrigger()) 531 if (!m_compositingReasonFinder.hasAnimationTrigger())
520 return false; 532 return false;
521 return renderer->style()->hasCurrentTransformAnimation(); 533 return renderer->style()->hasCurrentTransformAnimation();
522 } 534 }
523 535
524 } // namespace WebCore 536 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698