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

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

Issue 785333002: Delete the Layer Squashing runtime feature. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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 21 matching lines...) Expand all
32 #include "platform/TraceEvent.h" 32 #include "platform/TraceEvent.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 // We will only allow squashing if the bbox-area:squashed-area doesn't exceed 36 // We will only allow squashing if the bbox-area:squashed-area doesn't exceed
37 // the ratio |gSquashingSparsityTolerance|:1. 37 // the ratio |gSquashingSparsityTolerance|:1.
38 static uint64_t gSquashingSparsityTolerance = 6; 38 static uint64_t gSquashingSparsityTolerance = 6;
39 39
40 CompositingLayerAssigner::CompositingLayerAssigner(RenderLayerCompositor* compos itor) 40 CompositingLayerAssigner::CompositingLayerAssigner(RenderLayerCompositor* compos itor)
41 : m_compositor(compositor) 41 : m_compositor(compositor)
42 , m_layerSquashingEnabled(compositor->layerSquashingEnabled())
43 , m_layersChanged(false) 42 , m_layersChanged(false)
44 { 43 {
45 } 44 }
46 45
47 CompositingLayerAssigner::~CompositingLayerAssigner() 46 CompositingLayerAssigner::~CompositingLayerAssigner()
48 { 47 {
49 } 48 }
50 49
51 void CompositingLayerAssigner::assign(RenderLayer* updateRoot, Vector<RenderLaye r*>& layersNeedingPaintInvalidation) 50 void CompositingLayerAssigner::assign(RenderLayer* updateRoot, Vector<RenderLaye r*>& layersNeedingPaintInvalidation)
52 { 51 {
(...skipping 26 matching lines...) Expand all
79 const uint64_t newBoundingRectArea = newBoundingRect.size().area(); 78 const uint64_t newBoundingRectArea = newBoundingRect.size().area();
80 const uint64_t newSquashedArea = squashingState.totalAreaOfSquashedRects + b ounds.size().area(); 79 const uint64_t newSquashedArea = squashingState.totalAreaOfSquashedRects + b ounds.size().area();
81 return newBoundingRectArea > gSquashingSparsityTolerance * newSquashedArea; 80 return newBoundingRectArea > gSquashingSparsityTolerance * newSquashedArea;
82 } 81 }
83 82
84 bool CompositingLayerAssigner::needsOwnBacking(const RenderLayer* layer) const 83 bool CompositingLayerAssigner::needsOwnBacking(const RenderLayer* layer) const
85 { 84 {
86 if (!m_compositor->canBeComposited(layer)) 85 if (!m_compositor->canBeComposited(layer))
87 return false; 86 return false;
88 87
89 // If squashing is disabled, then layers that would have been squashed shoul d just be separately composited. 88 return requiresCompositing(layer->compositingReasons()) || (m_compositor->st aleInCompositingMode() && layer->isRootLayer());
90 bool needsOwnBackingForDisabledSquashing = !m_layerSquashingEnabled && requi resSquashing(layer->compositingReasons());
91
92 return requiresCompositing(layer->compositingReasons()) || needsOwnBackingFo rDisabledSquashing || (m_compositor->staleInCompositingMode() && layer->isRootLa yer());
93 } 89 }
94 90
95 CompositingStateTransitionType CompositingLayerAssigner::computeCompositedLayerU pdate(RenderLayer* layer) 91 CompositingStateTransitionType CompositingLayerAssigner::computeCompositedLayerU pdate(RenderLayer* layer)
96 { 92 {
97 CompositingStateTransitionType update = NoCompositingStateChange; 93 CompositingStateTransitionType update = NoCompositingStateChange;
98 if (needsOwnBacking(layer)) { 94 if (needsOwnBacking(layer)) {
99 if (!layer->hasCompositedLayerMapping()) { 95 if (!layer->hasCompositedLayerMapping()) {
100 update = AllocateOwnCompositedLayerMapping; 96 update = AllocateOwnCompositedLayerMapping;
101 } 97 }
102 } else { 98 } else {
103 if (layer->hasCompositedLayerMapping()) 99 if (layer->hasCompositedLayerMapping())
104 update = RemoveOwnCompositedLayerMapping; 100 update = RemoveOwnCompositedLayerMapping;
105 101
106 if (m_layerSquashingEnabled) { 102 if (!layer->subtreeIsInvisible() && requiresSquashing(layer->compositing Reasons())) {
107 if (!layer->subtreeIsInvisible() && requiresSquashing(layer->composi tingReasons())) { 103 // We can't compute at this time whether the squashing layer update is a no-op,
108 // We can't compute at this time whether the squashing layer upd ate is a no-op, 104 // since that requires walking the render layer tree.
109 // since that requires walking the render layer tree. 105 update = PutInSquashingLayer;
110 update = PutInSquashingLayer; 106 } else if (layer->groupedMapping() || layer->lostGroupedMapping()) {
111 } else if (layer->groupedMapping() || layer->lostGroupedMapping()) { 107 update = RemoveFromSquashingLayer;
112 update = RemoveFromSquashingLayer;
113 }
114 } 108 }
115 } 109 }
116 return update; 110 return update;
117 } 111 }
118 112
119 CompositingReasons CompositingLayerAssigner::getReasonsPreventingSquashing(const RenderLayer* layer, const CompositingLayerAssigner::SquashingState& squashingSt ate) 113 CompositingReasons CompositingLayerAssigner::getReasonsPreventingSquashing(const RenderLayer* layer, const CompositingLayerAssigner::SquashingState& squashingSt ate)
120 { 114 {
121 if (!squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree) 115 if (!squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree)
122 return CompositingReasonSquashingWouldBreakPaintOrder; 116 return CompositingReasonSquashingWouldBreakPaintOrder;
123 117
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 224 }
231 m_compositor->updateDirectCompositingReasons(reflectionLayer); 225 m_compositor->updateDirectCompositingReasons(reflectionLayer);
232 226
233 // FIXME: Why do we updateGraphicsLayerConfiguration here instead of in the GraphicsLayerUpdater? 227 // FIXME: Why do we updateGraphicsLayerConfiguration here instead of in the GraphicsLayerUpdater?
234 if (reflectionLayer->hasCompositedLayerMapping()) 228 if (reflectionLayer->hasCompositedLayerMapping())
235 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat ion(); 229 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat ion();
236 } 230 }
237 231
238 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer , SquashingState& squashingState, Vector<RenderLayer*>& layersNeedingPaintInvali dation) 232 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer , SquashingState& squashingState, Vector<RenderLayer*>& layersNeedingPaintInvali dation)
239 { 233 {
240 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons() )) { 234 if (requiresSquashing(layer->compositingReasons())) {
241 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua shing(layer, squashingState); 235 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua shing(layer, squashingState);
242 if (reasonsPreventingSquashing) 236 if (reasonsPreventingSquashing)
243 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr eventingSquashing); 237 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr eventingSquashing);
244 } 238 }
245 239
246 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye rUpdate(layer); 240 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye rUpdate(layer);
247 241
248 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay erUpdate)) { 242 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay erUpdate)) {
249 TRACE_LAYER_INVALIDATION(layer, InspectorLayerInvalidationTrackingEvent: :NewCompositedLayer); 243 TRACE_LAYER_INVALIDATION(layer, InspectorLayerInvalidationTrackingEvent: :NewCompositedLayer);
250 layersNeedingPaintInvalidation.append(layer); 244 layersNeedingPaintInvalidation.append(layer);
251 m_layersChanged = true; 245 m_layersChanged = true;
252 } 246 }
253 247
254 // FIXME: special-casing reflection layers here is not right. 248 // FIXME: special-casing reflection layers here is not right.
255 if (layer->reflectionInfo()) 249 if (layer->reflectionInfo())
256 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec tionLayer(), layersNeedingPaintInvalidation); 250 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec tionLayer(), layersNeedingPaintInvalidation);
257 251
258 // Add this layer to a squashing backing if needed. 252 // Add this layer to a squashing backing if needed.
259 if (m_layerSquashingEnabled) { 253 updateSquashingAssignment(layer, squashingState, compositedLayerUpdate, laye rsNeedingPaintInvalidation);
260 updateSquashingAssignment(layer, squashingState, compositedLayerUpdate, layersNeedingPaintInvalidation);
261 254
262 const bool layerIsSquashed = compositedLayerUpdate == PutInSquashingLaye r || (compositedLayerUpdate == NoCompositingStateChange && layer->groupedMapping ()); 255 const bool layerIsSquashed = compositedLayerUpdate == PutInSquashingLayer || (compositedLayerUpdate == NoCompositingStateChange && layer->groupedMapping());
263 if (layerIsSquashed) { 256 if (layerIsSquashed) {
264 squashingState.nextSquashedLayerIndex++; 257 squashingState.nextSquashedLayerIndex++;
265 IntRect layerBounds = layer->clippedAbsoluteBoundingBox(); 258 IntRect layerBounds = layer->clippedAbsoluteBoundingBox();
266 squashingState.totalAreaOfSquashedRects += layerBounds.size().area() ; 259 squashingState.totalAreaOfSquashedRects += layerBounds.size().area();
267 squashingState.boundingRect.unite(layerBounds); 260 squashingState.boundingRect.unite(layerBounds);
268 }
269 } 261 }
270 262
271 if (layer->stackingNode()->isStackingContext()) { 263 if (layer->stackingNode()->isStackingContext()) {
272 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren); 264 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren);
273 while (RenderLayerStackingNode* curNode = iterator.next()) 265 while (RenderLayerStackingNode* curNode = iterator.next())
274 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay ersNeedingPaintInvalidation); 266 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay ersNeedingPaintInvalidation);
275 } 267 }
276 268
277 if (m_layerSquashingEnabled) { 269 // At this point, if the layer is to be separately composited, then its back ing becomes the most recent in paint-order.
278 // At this point, if the layer is to be separately composited, then its backing becomes the most recent in paint-order. 270 if (layer->compositingState() == PaintsIntoOwnBacking) {
279 if (layer->compositingState() == PaintsIntoOwnBacking) { 271 ASSERT(!requiresSquashing(layer->compositingReasons()));
280 ASSERT(!requiresSquashing(layer->compositingReasons())); 272 squashingState.updateSquashingStateForNewMapping(layer->compositedLayerM apping(), layer->hasCompositedLayerMapping());
281 squashingState.updateSquashingStateForNewMapping(layer->compositedLa yerMapping(), layer->hasCompositedLayerMapping());
282 }
283 } 273 }
284 274
285 if (layer->scrollParent()) 275 if (layer->scrollParent())
286 layer->scrollParent()->scrollableArea()->setTopmostScrollChild(layer); 276 layer->scrollParent()->scrollableArea()->setTopmostScrollChild(layer);
287 277
288 if (layer->needsCompositedScrolling()) 278 if (layer->needsCompositedScrolling())
289 layer->scrollableArea()->setTopmostScrollChild(0); 279 layer->scrollableArea()->setTopmostScrollChild(0);
290 280
291 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren); 281 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren);
292 while (RenderLayerStackingNode* curNode = iterator.next()) 282 while (RenderLayerStackingNode* curNode = iterator.next())
293 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN eedingPaintInvalidation); 283 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN eedingPaintInvalidation);
294 284
295 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping ->owningLayer() == layer) 285 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping ->owningLayer() == layer)
296 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; 286 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true;
297 } 287 }
298 288
299 } 289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698