OLD | NEW |
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 |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
13 * | 13 * |
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/rendering/compositing/CompositingLayerAssigner.h" | 28 #include "core/rendering/compositing/CompositingLayerAssigner.h" |
29 | 29 |
| 30 #include "core/inspector/InspectorTraceEvents.h" |
30 #include "core/rendering/compositing/CompositedLayerMapping.h" | 31 #include "core/rendering/compositing/CompositedLayerMapping.h" |
31 #include "platform/TraceEvent.h" | 32 #include "platform/TraceEvent.h" |
32 | 33 |
33 namespace blink { | 34 namespace blink { |
34 | 35 |
35 // 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 |
36 // the ratio |gSquashingSparsityTolerance|:1. | 37 // the ratio |gSquashingSparsityTolerance|:1. |
37 static uint64_t gSquashingSparsityTolerance = 6; | 38 static uint64_t gSquashingSparsityTolerance = 6; |
38 | 39 |
39 CompositingLayerAssigner::CompositingLayerAssigner(RenderLayerCompositor* compos
itor) | 40 CompositingLayerAssigner::CompositingLayerAssigner(RenderLayerCompositor* compos
itor) |
40 : m_compositor(compositor) | 41 : m_compositor(compositor) |
41 , m_layerSquashingEnabled(compositor->layerSquashingEnabled()) | 42 , m_layerSquashingEnabled(compositor->layerSquashingEnabled()) |
42 , m_layersChanged(false) | 43 , m_layersChanged(false) |
43 { | 44 { |
44 } | 45 } |
45 | 46 |
46 CompositingLayerAssigner::~CompositingLayerAssigner() | 47 CompositingLayerAssigner::~CompositingLayerAssigner() |
47 { | 48 { |
48 } | 49 } |
49 | 50 |
50 void CompositingLayerAssigner::assign(RenderLayer* updateRoot, Vector<RenderLaye
r*>& layersNeedingPaintInvalidation) | 51 void CompositingLayerAssigner::assign(RenderLayer* updateRoot, LayersNeedingPain
tInvalidation& layersNeedingPaintInvalidation) |
51 { | 52 { |
52 TRACE_EVENT0("blink", "CompositingLayerAssigner::assign"); | 53 TRACE_EVENT0("blink", "CompositingLayerAssigner::assign"); |
53 | 54 |
54 SquashingState squashingState; | 55 SquashingState squashingState; |
55 assignLayersToBackingsInternal(updateRoot, squashingState, layersNeedingPain
tInvalidation); | 56 assignLayersToBackingsInternal(updateRoot, squashingState, layersNeedingPain
tInvalidation); |
56 if (squashingState.hasMostRecentMapping) | 57 if (squashingState.hasMostRecentMapping) |
57 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa
shingState.nextSquashedLayerIndex); | 58 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa
shingState.nextSquashedLayerIndex); |
58 } | 59 } |
59 | 60 |
60 void CompositingLayerAssigner::SquashingState::updateSquashingStateForNewMapping
(CompositedLayerMapping* newCompositedLayerMapping, bool hasNewCompositedLayerMa
pping) | 61 void CompositingLayerAssigner::SquashingState::updateSquashingStateForNewMapping
(CompositedLayerMapping* newCompositedLayerMapping, bool hasNewCompositedLayerMa
pping) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if (compositingInputs.transformAncestor != squashingLayerCompositingInputs.t
ransformAncestor) | 166 if (compositingInputs.transformAncestor != squashingLayerCompositingInputs.t
ransformAncestor) |
166 return CompositingReasonSquashingTransformAncestorMismatch; | 167 return CompositingReasonSquashingTransformAncestorMismatch; |
167 | 168 |
168 if (layer->hasFilter() || compositingInputs.filterAncestor != squashingLayer
CompositingInputs.filterAncestor) | 169 if (layer->hasFilter() || compositingInputs.filterAncestor != squashingLayer
CompositingInputs.filterAncestor) |
169 return CompositingReasonSquashingFilterMismatch; | 170 return CompositingReasonSquashingFilterMismatch; |
170 | 171 |
171 return CompositingReasonNone; | 172 return CompositingReasonNone; |
172 } | 173 } |
173 | 174 |
174 void CompositingLayerAssigner::updateSquashingAssignment(RenderLayer* layer, Squ
ashingState& squashingState, const CompositingStateTransitionType compositedLaye
rUpdate, | 175 void CompositingLayerAssigner::updateSquashingAssignment(RenderLayer* layer, Squ
ashingState& squashingState, const CompositingStateTransitionType compositedLaye
rUpdate, |
175 Vector<RenderLayer*>& layersNeedingPaintInvalidation) | 176 LayersNeedingPaintInvalidation& layersNeedingPaintInvalidation) |
176 { | 177 { |
177 // NOTE: In the future as we generalize this, the background of this layer m
ay need to be assigned to a different backing than | 178 // NOTE: In the future as we generalize this, the background of this layer m
ay need to be assigned to a different backing than |
178 // the squashed RenderLayer's own primary contents. This would happen when w
e have a composited negative z-index element that needs | 179 // the squashed RenderLayer's own primary contents. This would happen when w
e have a composited negative z-index element that needs |
179 // to paint on top of the background, but below the layer's main contents. F
or now, because we always composite layers | 180 // to paint on top of the background, but below the layer's main contents. F
or now, because we always composite layers |
180 // when they have a composited negative z-index child, such layers will neve
r need squashing so it is not yet an issue. | 181 // when they have a composited negative z-index child, such layers will neve
r need squashing so it is not yet an issue. |
181 if (compositedLayerUpdate == PutInSquashingLayer) { | 182 if (compositedLayerUpdate == PutInSquashingLayer) { |
182 // A layer that is squashed with other layers cannot have its own Compos
itedLayerMapping. | 183 // A layer that is squashed with other layers cannot have its own Compos
itedLayerMapping. |
183 ASSERT(!layer->hasCompositedLayerMapping()); | 184 ASSERT(!layer->hasCompositedLayerMapping()); |
184 ASSERT(squashingState.hasMostRecentMapping); | 185 ASSERT(squashingState.hasMostRecentMapping); |
185 | 186 |
186 bool changedSquashingLayer = | 187 bool changedSquashingLayer = |
187 squashingState.mostRecentMapping->updateSquashingLayerAssignment(lay
er, squashingState.mostRecentMapping->owningLayer(), squashingState.nextSquashed
LayerIndex); | 188 squashingState.mostRecentMapping->updateSquashingLayerAssignment(lay
er, squashingState.mostRecentMapping->owningLayer(), squashingState.nextSquashed
LayerIndex); |
188 if (!changedSquashingLayer) | 189 if (!changedSquashingLayer) |
189 return; | 190 return; |
190 | 191 |
191 // If we've modified the collection of squashed layers, we must update | 192 // If we've modified the collection of squashed layers, we must update |
192 // the graphics layer geometry. | 193 // the graphics layer geometry. |
193 squashingState.mostRecentMapping->setNeedsGraphicsLayerUpdate(GraphicsLa
yerUpdateSubtree); | 194 squashingState.mostRecentMapping->setNeedsGraphicsLayerUpdate(GraphicsLa
yerUpdateSubtree); |
194 | 195 |
195 layer->clipper().clearClipRectsIncludingDescendants(); | 196 layer->clipper().clearClipRectsIncludingDescendants(); |
196 | 197 |
197 // Issue a paint invalidation, since |layer| may have been added to an a
lready-existing squashing layer. | 198 // Issue a paint invalidation, since |layer| may have been added to an a
lready-existing squashing layer. |
198 layersNeedingPaintInvalidation.append(layer); | 199 layersNeedingPaintInvalidation.append(std::make_pair(layer, InspectorLay
erInvalidationTrackingEvent::AddedToSquashingLayer)); |
199 m_layersChanged = true; | 200 m_layersChanged = true; |
200 } else if (compositedLayerUpdate == RemoveFromSquashingLayer) { | 201 } else if (compositedLayerUpdate == RemoveFromSquashingLayer) { |
201 if (layer->groupedMapping()) { | 202 if (layer->groupedMapping()) { |
202 // Before removing |layer| from an already-existing squashing layer
that may have other content, issue a paint invalidation. | 203 // Before removing |layer| from an already-existing squashing layer
that may have other content, issue a paint invalidation. |
203 m_compositor->paintInvalidationOnCompositingChange(layer); | 204 m_compositor->paintInvalidationOnCompositingChange(layer); |
204 layer->groupedMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUp
dateSubtree); | 205 layer->groupedMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUp
dateSubtree); |
205 layer->setGroupedMapping(0); | 206 layer->setGroupedMapping(0); |
206 } | 207 } |
207 | 208 |
208 // If we need to issue paint invalidations, do so now that we've removed
it from a squashed layer. | 209 // If we need to issue paint invalidations, do so now that we've removed
it from a squashed layer. |
209 layersNeedingPaintInvalidation.append(layer); | 210 layersNeedingPaintInvalidation.append(std::make_pair(layer, InspectorLay
erInvalidationTrackingEvent::RemovedFromSquashingLayer)); |
210 m_layersChanged = true; | 211 m_layersChanged = true; |
211 | 212 |
212 layer->setLostGroupedMapping(false); | 213 layer->setLostGroupedMapping(false); |
213 } | 214 } |
214 } | 215 } |
215 | 216 |
216 void CompositingLayerAssigner::assignLayersToBackingsForReflectionLayer(RenderLa
yer* reflectionLayer, Vector<RenderLayer*>& layersNeedingPaintInvalidation) | 217 void CompositingLayerAssigner::assignLayersToBackingsForReflectionLayer(RenderLa
yer* reflectionLayer, LayersNeedingPaintInvalidation& layersNeedingPaintInvalida
tion) |
217 { | 218 { |
218 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(reflectionLayer); | 219 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(reflectionLayer); |
219 if (compositedLayerUpdate != NoCompositingStateChange) { | 220 if (compositedLayerUpdate != NoCompositingStateChange) { |
220 layersNeedingPaintInvalidation.append(reflectionLayer); | 221 layersNeedingPaintInvalidation.append(std::make_pair(reflectionLayer, In
spectorLayerInvalidationTrackingEvent::ReflectionLayerChanged)); |
221 m_layersChanged = true; | 222 m_layersChanged = true; |
222 m_compositor->allocateOrClearCompositedLayerMapping(reflectionLayer, com
positedLayerUpdate); | 223 m_compositor->allocateOrClearCompositedLayerMapping(reflectionLayer, com
positedLayerUpdate); |
223 } | 224 } |
224 m_compositor->updateDirectCompositingReasons(reflectionLayer); | 225 m_compositor->updateDirectCompositingReasons(reflectionLayer); |
225 | 226 |
226 // FIXME: Why do we updateGraphicsLayerConfiguration here instead of in the
GraphicsLayerUpdater? | 227 // FIXME: Why do we updateGraphicsLayerConfiguration here instead of in the
GraphicsLayerUpdater? |
227 if (reflectionLayer->hasCompositedLayerMapping()) | 228 if (reflectionLayer->hasCompositedLayerMapping()) |
228 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat
ion(); | 229 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat
ion(); |
229 } | 230 } |
230 | 231 |
231 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer
, SquashingState& squashingState, Vector<RenderLayer*>& layersNeedingPaintInvali
dation) | 232 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer
, SquashingState& squashingState, LayersNeedingPaintInvalidation& layersNeedingP
aintInvalidation) |
232 { | 233 { |
233 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons()
)) { | 234 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons()
)) { |
234 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua
shing(layer, squashingState); | 235 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua
shing(layer, squashingState); |
235 if (reasonsPreventingSquashing) | 236 if (reasonsPreventingSquashing) |
236 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr
eventingSquashing); | 237 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr
eventingSquashing); |
237 } | 238 } |
238 | 239 |
239 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(layer); | 240 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(layer); |
240 | 241 |
241 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay
erUpdate)) { | 242 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay
erUpdate)) { |
242 layersNeedingPaintInvalidation.append(layer); | 243 layersNeedingPaintInvalidation.append(std::make_pair(layer, InspectorLay
erInvalidationTrackingEvent::NewCompositedLayer)); |
243 m_layersChanged = true; | 244 m_layersChanged = true; |
244 } | 245 } |
245 | 246 |
246 // FIXME: special-casing reflection layers here is not right. | 247 // FIXME: special-casing reflection layers here is not right. |
247 if (layer->reflectionInfo()) | 248 if (layer->reflectionInfo()) |
248 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec
tionLayer(), layersNeedingPaintInvalidation); | 249 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec
tionLayer(), layersNeedingPaintInvalidation); |
249 | 250 |
250 // Add this layer to a squashing backing if needed. | 251 // Add this layer to a squashing backing if needed. |
251 if (m_layerSquashingEnabled) { | 252 if (m_layerSquashingEnabled) { |
252 updateSquashingAssignment(layer, squashingState, compositedLayerUpdate,
layersNeedingPaintInvalidation); | 253 updateSquashingAssignment(layer, squashingState, compositedLayerUpdate,
layersNeedingPaintInvalidation); |
(...skipping 29 matching lines...) Expand all Loading... |
282 | 283 |
283 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); | 284 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); |
284 while (RenderLayerStackingNode* curNode = iterator.next()) | 285 while (RenderLayerStackingNode* curNode = iterator.next()) |
285 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN
eedingPaintInvalidation); | 286 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN
eedingPaintInvalidation); |
286 | 287 |
287 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping
->owningLayer() == layer) | 288 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping
->owningLayer() == layer) |
288 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; | 289 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; |
289 } | 290 } |
290 | 291 |
291 } | 292 } |
OLD | NEW |