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) |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
| 199 TRACE_LAYER_INVALIDATION(layer, InspectorLayerInvalidationTrackingEvent:
:AddedToSquashingLayer); |
198 layersNeedingPaintInvalidation.append(layer); | 200 layersNeedingPaintInvalidation.append(layer); |
199 m_layersChanged = true; | 201 m_layersChanged = true; |
200 } else if (compositedLayerUpdate == RemoveFromSquashingLayer) { | 202 } else if (compositedLayerUpdate == RemoveFromSquashingLayer) { |
201 if (layer->groupedMapping()) { | 203 if (layer->groupedMapping()) { |
202 // Before removing |layer| from an already-existing squashing layer
that may have other content, issue a paint invalidation. | 204 // Before removing |layer| from an already-existing squashing layer
that may have other content, issue a paint invalidation. |
203 m_compositor->paintInvalidationOnCompositingChange(layer); | 205 m_compositor->paintInvalidationOnCompositingChange(layer); |
204 layer->groupedMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUp
dateSubtree); | 206 layer->groupedMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUp
dateSubtree); |
205 layer->setGroupedMapping(0); | 207 layer->setGroupedMapping(0); |
206 } | 208 } |
207 | 209 |
208 // If we need to issue paint invalidations, do so now that we've removed
it from a squashed layer. | 210 // If we need to issue paint invalidations, do so now that we've removed
it from a squashed layer. |
| 211 TRACE_LAYER_INVALIDATION(layer, InspectorLayerInvalidationTrackingEvent:
:RemovedFromSquashingLayer); |
209 layersNeedingPaintInvalidation.append(layer); | 212 layersNeedingPaintInvalidation.append(layer); |
210 m_layersChanged = true; | 213 m_layersChanged = true; |
211 | 214 |
212 layer->setLostGroupedMapping(false); | 215 layer->setLostGroupedMapping(false); |
213 } | 216 } |
214 } | 217 } |
215 | 218 |
216 void CompositingLayerAssigner::assignLayersToBackingsForReflectionLayer(RenderLa
yer* reflectionLayer, Vector<RenderLayer*>& layersNeedingPaintInvalidation) | 219 void CompositingLayerAssigner::assignLayersToBackingsForReflectionLayer(RenderLa
yer* reflectionLayer, Vector<RenderLayer*>& layersNeedingPaintInvalidation) |
217 { | 220 { |
218 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(reflectionLayer); | 221 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(reflectionLayer); |
219 if (compositedLayerUpdate != NoCompositingStateChange) { | 222 if (compositedLayerUpdate != NoCompositingStateChange) { |
| 223 TRACE_LAYER_INVALIDATION(reflectionLayer, InspectorLayerInvalidationTrac
kingEvent::ReflectionLayerChanged); |
220 layersNeedingPaintInvalidation.append(reflectionLayer); | 224 layersNeedingPaintInvalidation.append(reflectionLayer); |
221 m_layersChanged = true; | 225 m_layersChanged = true; |
222 m_compositor->allocateOrClearCompositedLayerMapping(reflectionLayer, com
positedLayerUpdate); | 226 m_compositor->allocateOrClearCompositedLayerMapping(reflectionLayer, com
positedLayerUpdate); |
223 } | 227 } |
224 m_compositor->updateDirectCompositingReasons(reflectionLayer); | 228 m_compositor->updateDirectCompositingReasons(reflectionLayer); |
225 | 229 |
226 // FIXME: Why do we updateGraphicsLayerConfiguration here instead of in the
GraphicsLayerUpdater? | 230 // FIXME: Why do we updateGraphicsLayerConfiguration here instead of in the
GraphicsLayerUpdater? |
227 if (reflectionLayer->hasCompositedLayerMapping()) | 231 if (reflectionLayer->hasCompositedLayerMapping()) |
228 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat
ion(); | 232 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat
ion(); |
229 } | 233 } |
230 | 234 |
231 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer
, SquashingState& squashingState, Vector<RenderLayer*>& layersNeedingPaintInvali
dation) | 235 void CompositingLayerAssigner::assignLayersToBackingsInternal(RenderLayer* layer
, SquashingState& squashingState, Vector<RenderLayer*>& layersNeedingPaintInvali
dation) |
232 { | 236 { |
233 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons()
)) { | 237 if (m_layerSquashingEnabled && requiresSquashing(layer->compositingReasons()
)) { |
234 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua
shing(layer, squashingState); | 238 CompositingReasons reasonsPreventingSquashing = getReasonsPreventingSqua
shing(layer, squashingState); |
235 if (reasonsPreventingSquashing) | 239 if (reasonsPreventingSquashing) |
236 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr
eventingSquashing); | 240 layer->setCompositingReasons(layer->compositingReasons() | reasonsPr
eventingSquashing); |
237 } | 241 } |
238 | 242 |
239 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(layer); | 243 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(layer); |
240 | 244 |
241 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay
erUpdate)) { | 245 if (m_compositor->allocateOrClearCompositedLayerMapping(layer, compositedLay
erUpdate)) { |
| 246 TRACE_LAYER_INVALIDATION(layer, InspectorLayerInvalidationTrackingEvent:
:NewCompositedLayer); |
242 layersNeedingPaintInvalidation.append(layer); | 247 layersNeedingPaintInvalidation.append(layer); |
243 m_layersChanged = true; | 248 m_layersChanged = true; |
244 } | 249 } |
245 | 250 |
246 // FIXME: special-casing reflection layers here is not right. | 251 // FIXME: special-casing reflection layers here is not right. |
247 if (layer->reflectionInfo()) | 252 if (layer->reflectionInfo()) |
248 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec
tionLayer(), layersNeedingPaintInvalidation); | 253 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec
tionLayer(), layersNeedingPaintInvalidation); |
249 | 254 |
250 // Add this layer to a squashing backing if needed. | 255 // Add this layer to a squashing backing if needed. |
251 if (m_layerSquashingEnabled) { | 256 if (m_layerSquashingEnabled) { |
(...skipping 30 matching lines...) Expand all Loading... |
282 | 287 |
283 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); | 288 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); |
284 while (RenderLayerStackingNode* curNode = iterator.next()) | 289 while (RenderLayerStackingNode* curNode = iterator.next()) |
285 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN
eedingPaintInvalidation); | 290 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersN
eedingPaintInvalidation); |
286 | 291 |
287 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping
->owningLayer() == layer) | 292 if (squashingState.hasMostRecentMapping && &squashingState.mostRecentMapping
->owningLayer() == layer) |
288 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; | 293 squashingState.haveAssignedBackingsToEntireSquashingLayerSubtree = true; |
289 } | 294 } |
290 | 295 |
291 } | 296 } |
OLD | NEW |