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

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

Issue 311813005: Issue repaints for RenderLayers that get new composited backings after (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 27 matching lines...) Expand all
38 CompositingLayerAssigner::CompositingLayerAssigner(RenderLayerCompositor* compos itor) 38 CompositingLayerAssigner::CompositingLayerAssigner(RenderLayerCompositor* compos itor)
39 : m_compositor(compositor) 39 : m_compositor(compositor)
40 , m_layerSquashingEnabled(compositor->layerSquashingEnabled()) 40 , m_layerSquashingEnabled(compositor->layerSquashingEnabled())
41 { 41 {
42 } 42 }
43 43
44 CompositingLayerAssigner::~CompositingLayerAssigner() 44 CompositingLayerAssigner::~CompositingLayerAssigner()
45 { 45 {
46 } 46 }
47 47
48 void CompositingLayerAssigner::assign(RenderLayer* updateRoot, bool& layersChang ed) 48 void CompositingLayerAssigner::assign(RenderLayer* updateRoot, bool& layersChang ed, Vector<RenderLayer*>& layersNeedingRepaint)
49 { 49 {
50 SquashingState squashingState; 50 SquashingState squashingState;
51 assignLayersToBackingsInternal(updateRoot, squashingState, layersChanged); 51 assignLayersToBackingsInternal(updateRoot, squashingState, layersChanged, la yersNeedingRepaint);
52 if (squashingState.hasMostRecentMapping) 52 if (squashingState.hasMostRecentMapping)
53 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa shingState.nextSquashedLayerIndex); 53 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa shingState.nextSquashedLayerIndex);
54 } 54 }
55 55
56 void CompositingLayerAssigner::SquashingState::updateSquashingStateForNewMapping (CompositedLayerMappingPtr newCompositedLayerMapping, bool hasNewCompositedLayer Mapping) 56 void CompositingLayerAssigner::SquashingState::updateSquashingStateForNewMapping (CompositedLayerMappingPtr newCompositedLayerMapping, bool hasNewCompositedLayer Mapping)
57 { 57 {
58 // The most recent backing is done accumulating any more squashing layers. 58 // The most recent backing is done accumulating any more squashing layers.
59 if (hasMostRecentMapping) 59 if (hasMostRecentMapping)
60 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn dex); 60 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn dex);
61 61
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 if (ancestorDependentProperties.transformAncestor != squashingLayerAncestorD ependentProperties.transformAncestor) 155 if (ancestorDependentProperties.transformAncestor != squashingLayerAncestorD ependentProperties.transformAncestor)
156 return false; 156 return false;
157 157
158 if (ancestorDependentProperties.filterAncestor != squashingLayerAncestorDepe ndentProperties.filterAncestor) 158 if (ancestorDependentProperties.filterAncestor != squashingLayerAncestorDepe ndentProperties.filterAncestor)
159 return false; 159 return false;
160 160
161 return true; 161 return true;
162 } 162 }
163 163
164 bool CompositingLayerAssigner::updateSquashingAssignment(RenderLayer* layer, Squ ashingState& squashingState, const CompositingStateTransitionType compositedLaye rUpdate) 164 bool CompositingLayerAssigner::updateSquashingAssignment(RenderLayer* layer, Squ ashingState& squashingState, const CompositingStateTransitionType compositedLaye rUpdate,
165 Vector<RenderLayer*>& layersNeedingRepaint)
165 { 166 {
166 // NOTE: In the future as we generalize this, the background of this layer m ay need to be assigned to a different backing than 167 // NOTE: In the future as we generalize this, the background of this layer m ay need to be assigned to a different backing than
167 // the squashed RenderLayer's own primary contents. This would happen when w e have a composited negative z-index element that needs 168 // the squashed RenderLayer's own primary contents. This would happen when w e have a composited negative z-index element that needs
168 // to paint on top of the background, but below the layer's main contents. F or now, because we always composite layers 169 // to paint on top of the background, but below the layer's main contents. F or now, because we always composite layers
169 // when they have a composited negative z-index child, such layers will neve r need squashing so it is not yet an issue. 170 // when they have a composited negative z-index child, such layers will neve r need squashing so it is not yet an issue.
170 if (compositedLayerUpdate == PutInSquashingLayer) { 171 if (compositedLayerUpdate == PutInSquashingLayer) {
171 // A layer that is squashed with other layers cannot have its own Compos itedLayerMapping. 172 // A layer that is squashed with other layers cannot have its own Compos itedLayerMapping.
172 ASSERT(!layer->hasCompositedLayerMapping()); 173 ASSERT(!layer->hasCompositedLayerMapping());
173 ASSERT(squashingState.hasMostRecentMapping); 174 ASSERT(squashingState.hasMostRecentMapping);
174 175
175 bool changedSquashingLayer = 176 bool changedSquashingLayer =
176 squashingState.mostRecentMapping->updateSquashingLayerAssignment(lay er, squashingState.mostRecentMapping->owningLayer(), squashingState.nextSquashed LayerIndex); 177 squashingState.mostRecentMapping->updateSquashingLayerAssignment(lay er, squashingState.mostRecentMapping->owningLayer(), squashingState.nextSquashed LayerIndex);
177 if (!changedSquashingLayer) 178 if (!changedSquashingLayer)
178 return true; 179 return true;
179 180
180 // If we've modified the collection of squashed layers, we must update 181 // If we've modified the collection of squashed layers, we must update
181 // the graphics layer geometry. 182 // the graphics layer geometry.
182 squashingState.mostRecentMapping->setNeedsGraphicsLayerUpdate(); 183 squashingState.mostRecentMapping->setNeedsGraphicsLayerUpdate();
183 184
184 layer->clipper().clearClipRectsIncludingDescendants(); 185 layer->clipper().clearClipRectsIncludingDescendants();
185 186
186 // FIXME: it seems premature to compute this before all compositing stat e has been updated?
187 // This layer and all of its descendants have cached repaints rects that are relative to
188 // the repaint container, so change when compositing changes; we need to update them here.
189
190 // FIXME: what's up with parent()?
Ian Vollick 2014/06/04 04:40:35 Hmm. Perhaps the issue causing the layout test cra
chrishtr 2014/06/04 16:40:07 The pad-gesture-fling.html crash was unrelated. Se
191 if (layer->parent())
192 layer->repainter().computeRepaintRectsIncludingDescendants();
193
194 // Issue a repaint, since |layer| may have been added to an already-exis ting squashing layer. 187 // Issue a repaint, since |layer| may have been added to an already-exis ting squashing layer.
195 m_compositor->repaintOnCompositingChange(layer); 188 layersNeedingRepaint.append(layer);
196 189
197 return true; 190 return true;
198 } 191 }
199 if (compositedLayerUpdate == RemoveFromSquashingLayer) { 192 if (compositedLayerUpdate == RemoveFromSquashingLayer) {
200 if (layer->groupedMapping()) { 193 if (layer->groupedMapping()) {
201 // Before removing |layer| from an already-existing squashing layer that may have other content, issue a repaint. 194 // Before removing |layer| from an already-existing squashing layer that may have other content, issue a repaint.
202 m_compositor->repaintOnCompositingChange(layer); 195 m_compositor->repaintOnCompositingChange(layer);
203 layer->groupedMapping()->setNeedsGraphicsLayerUpdate(); 196 layer->groupedMapping()->setNeedsGraphicsLayerUpdate();
204 layer->setGroupedMapping(0); 197 layer->setGroupedMapping(0);
205 } 198 }
206 199
207 // This layer and all of its descendants have cached repaints rects that are relative to
208 // the repaint container, so change when compositing changes; we need to update them here.
209 layer->repainter().computeRepaintRectsIncludingDescendants();
210
211 // If we need to repaint, do so now that we've removed it from a squashe d layer. 200 // If we need to repaint, do so now that we've removed it from a squashe d layer.
212 m_compositor->repaintOnCompositingChange(layer); 201 layersNeedingRepaint.append(layer);
213 202
214 layer->setLostGroupedMapping(false); 203 layer->setLostGroupedMapping(false);
215 return true; 204 return true;
216 } 205 }
217 206
218 return false; 207 return false;
219 } 208 }
220 209
221 void CompositingLayerAssigner::assignLayersToBackingsForReflectionLayer(RenderLa yer* reflectionLayer, bool& layersChanged) 210 void CompositingLayerAssigner::assignLayersToBackingsForReflectionLayer(RenderLa yer* reflectionLayer, bool& layersChanged, Vector<RenderLayer*>& layersNeedingRe paint)
222 { 211 {
223 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye rUpdate(reflectionLayer); 212 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye rUpdate(reflectionLayer);
224 if (compositedLayerUpdate != NoCompositingStateChange) { 213 if (compositedLayerUpdate != NoCompositingStateChange) {
214 layersNeedingRepaint.append(reflectionLayer);
225 layersChanged = true; 215 layersChanged = true;
226 m_compositor->allocateOrClearCompositedLayerMapping(reflectionLayer, com positedLayerUpdate); 216 m_compositor->allocateOrClearCompositedLayerMapping(reflectionLayer, com positedLayerUpdate);
227 } 217 }
228 m_compositor->updateDirectCompositingReasons(reflectionLayer); 218 m_compositor->updateDirectCompositingReasons(reflectionLayer);
229 if (reflectionLayer->hasCompositedLayerMapping()) 219 if (reflectionLayer->hasCompositedLayerMapping())
230 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat ion(GraphicsLayerUpdater::ForceUpdate); 220 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat ion(GraphicsLayerUpdater::ForceUpdate);
231 } 221 }
232 222
233 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer , SquashingState& squashingState, bool& layersChanged) 223 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer , SquashingState& squashingState, bool& layersChanged, Vector<RenderLayer*>& lay ersNeedingRepaint)
234 { 224 {
235 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons() ) && !canSquashIntoCurrentSquashingOwner(layer, squashingState)) 225 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons() ) && !canSquashIntoCurrentSquashingOwner(layer, squashingState))
236 layer->setCompositingReasons(layer->compositingReasons() | CompositingRe asonNoSquashingTargetFound); 226 layer->setCompositingReasons(layer->compositingReasons() | CompositingRe asonNoSquashingTargetFound);
237 227
238 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye rUpdate(layer); 228 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye rUpdate(layer);
239 229
240 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay erUpdate)) 230 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay erUpdate)) {
231 layersNeedingRepaint.append(layer);
241 layersChanged = true; 232 layersChanged = true;
233 }
242 234
243 // FIXME: special-casing reflection layers here is not right. 235 // FIXME: special-casing reflection layers here is not right.
244 if (layer->reflectionInfo()) 236 if (layer->reflectionInfo())
245 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec tionLayer(), layersChanged); 237 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec tionLayer(), layersChanged, layersNeedingRepaint);
246 238
247 // Add this layer to a squashing backing if needed. 239 // Add this layer to a squashing backing if needed.
248 if (m_layerSquashingEnabled) { 240 if (m_layerSquashingEnabled) {
249 if (updateSquashingAssignment(layer, squashingState, compositedLayerUpda te)) 241 if (updateSquashingAssignment(layer, squashingState, compositedLayerUpda te, layersNeedingRepaint))
250 layersChanged = true; 242 layersChanged = true;
251 243
244
Ian Vollick 2014/06/04 02:45:43 Nit: extra ws.
chrishtr 2014/06/04 03:54:36 Done.
252 const bool layerIsSquashed = compositedLayerUpdate == PutInSquashingLaye r || (compositedLayerUpdate == NoCompositingStateChange && layer->groupedMapping ()); 245 const bool layerIsSquashed = compositedLayerUpdate == PutInSquashingLaye r || (compositedLayerUpdate == NoCompositingStateChange && layer->groupedMapping ());
253 if (layerIsSquashed) { 246 if (layerIsSquashed) {
254 squashingState.nextSquashedLayerIndex++; 247 squashingState.nextSquashedLayerIndex++;
255 IntRect layerBounds = layer->ancestorDependentProperties().clippedAb soluteBoundingBox; 248 IntRect layerBounds = layer->ancestorDependentProperties().clippedAb soluteBoundingBox;
256 squashingState.totalAreaOfSquashedRects += layerBounds.size().area() ; 249 squashingState.totalAreaOfSquashedRects += layerBounds.size().area() ;
257 squashingState.boundingRect.unite(layerBounds); 250 squashingState.boundingRect.unite(layerBounds);
258 } 251 }
259 } 252 }
260 253
261 if (layer->stackingNode()->isStackingContext()) { 254 if (layer->stackingNode()->isStackingContext()) {
262 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren); 255 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren);
263 while (RenderLayerStackingNode* curNode = iterator.next()) 256 while (RenderLayerStackingNode* curNode = iterator.next())
264 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay ersChanged); 257 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay ersChanged, layersNeedingRepaint);
265 } 258 }
266 259
267 if (m_layerSquashingEnabled) { 260 if (m_layerSquashingEnabled) {
268 // At this point, if the layer is to be "separately" composited, then it s backing becomes the most recent in paint-order. 261 // At this point, if the layer is to be "separately" composited, then it s backing becomes the most recent in paint-order.
269 if (layer->compositingState() == PaintsIntoOwnBacking || layer->composit ingState() == HasOwnBackingButPaintsIntoAncestor) { 262 if (layer->compositingState() == PaintsIntoOwnBacking || layer->composit ingState() == HasOwnBackingButPaintsIntoAncestor) {
270 ASSERT(!requiresSquashing(layer->compositingReasons())); 263 ASSERT(!requiresSquashing(layer->compositingReasons()));
271 squashingState.updateSquashingStateForNewMapping(layer->compositedLa yerMapping(), layer->hasCompositedLayerMapping()); 264 squashingState.updateSquashingStateForNewMapping(layer->compositedLa yerMapping(), layer->hasCompositedLayerMapping());
272 } 265 }
273 } 266 }
274 267
275 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren); 268 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren);
276 while (RenderLayerStackingNode* curNode = iterator.next()) 269 while (RenderLayerStackingNode* curNode = iterator.next())
277 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersC hanged); 270 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersC hanged, layersNeedingRepaint);
278 271
279 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping ->owningLayer() == layer) 272 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping ->owningLayer() == layer)
280 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; 273 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true;
281 } 274 }
282 275
283 } 276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698