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/GraphicsLayerUpdater.h" | 28 #include "core/rendering/compositing/GraphicsLayerTreeBuilder.h" |
29 | 29 |
30 #include "core/html/HTMLMediaElement.h" | 30 #include "core/html/HTMLMediaElement.h" |
31 #include "core/rendering/RenderLayer.h" | 31 #include "core/rendering/RenderLayer.h" |
32 #include "core/rendering/RenderLayerReflectionInfo.h" | 32 #include "core/rendering/RenderLayerReflectionInfo.h" |
33 #include "core/rendering/RenderPart.h" | 33 #include "core/rendering/RenderPart.h" |
| 34 #include "core/rendering/RenderView.h" |
34 #include "core/rendering/compositing/CompositedLayerMapping.h" | 35 #include "core/rendering/compositing/CompositedLayerMapping.h" |
35 #include "core/rendering/compositing/RenderLayerCompositor.h" | 36 #include "core/rendering/compositing/RenderLayerCompositor.h" |
36 | 37 |
37 namespace WebCore { | 38 namespace WebCore { |
38 | 39 |
| 40 GraphicsLayerTreeBuilder::GraphicsLayerTreeBuilder() |
| 41 { |
| 42 } |
| 43 |
| 44 GraphicsLayerTreeBuilder::~GraphicsLayerTreeBuilder() |
| 45 { |
| 46 } |
| 47 |
39 static bool shouldAppendLayer(const RenderLayer& layer) | 48 static bool shouldAppendLayer(const RenderLayer& layer) |
40 { | 49 { |
41 if (!RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) | 50 if (!RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) |
42 return true; | 51 return true; |
43 Node* node = layer.renderer()->node(); | 52 Node* node = layer.renderer()->node(); |
44 if (node && isHTMLMediaElement(*node) && toHTMLMediaElement(node)->isFullscr
een()) | 53 if (node && isHTMLMediaElement(*node) && toHTMLMediaElement(node)->isFullscr
een()) |
45 return false; | 54 return false; |
46 return true; | 55 return true; |
47 } | 56 } |
48 | 57 |
49 GraphicsLayerUpdater::UpdateContext::UpdateContext(const UpdateContext& other, c
onst RenderLayer& layer) | 58 void GraphicsLayerTreeBuilder::rebuild(RenderLayer& layer, GraphicsLayerVector&
childLayersOfEnclosingLayer) |
50 : m_compositingStackingContext(other.m_compositingStackingContext) | |
51 , m_compositingAncestor(other.compositingContainer(layer)) | |
52 { | |
53 CompositingState compositingState = layer.compositingState(); | |
54 if (compositingState != NotComposited && compositingState != PaintsIntoGroup
edBacking) { | |
55 m_compositingAncestor = &layer; | |
56 if (layer.stackingNode()->isStackingContext()) | |
57 m_compositingStackingContext = &layer; | |
58 } | |
59 } | |
60 | |
61 const RenderLayer* GraphicsLayerUpdater::UpdateContext::compositingContainer(con
st RenderLayer& layer) const | |
62 { | |
63 return layer.stackingNode()->isNormalFlowOnly() ? m_compositingAncestor : m_
compositingStackingContext; | |
64 } | |
65 | |
66 GraphicsLayerUpdater::GraphicsLayerUpdater() | |
67 : m_needsRebuildTree(false) | |
68 { | |
69 } | |
70 | |
71 GraphicsLayerUpdater::~GraphicsLayerUpdater() | |
72 { | |
73 } | |
74 | |
75 void GraphicsLayerUpdater::rebuildTree(RenderLayer& layer, GraphicsLayerVector&
childLayersOfEnclosingLayer) | |
76 { | 59 { |
77 // Make the layer compositing if necessary, and set up clipping and content
layers. | 60 // Make the layer compositing if necessary, and set up clipping and content
layers. |
78 // Note that we can only do work here that is independent of whether the des
cendant layers | 61 // Note that we can only do work here that is independent of whether the des
cendant layers |
79 // have been processed. computeCompositingRequirements() will already have d
one the repaint if necessary. | 62 // have been processed. computeCompositingRequirements() will already have d
one the repaint if necessary. |
80 | 63 |
81 layer.stackingNode()->updateLayerListsIfNeeded(); | 64 layer.stackingNode()->updateLayerListsIfNeeded(); |
82 | 65 |
83 const bool hasCompositedLayerMapping = layer.hasCompositedLayerMapping(); | 66 const bool hasCompositedLayerMapping = layer.hasCompositedLayerMapping(); |
84 CompositedLayerMappingPtr currentCompositedLayerMapping = layer.compositedLa
yerMapping(); | 67 CompositedLayerMappingPtr currentCompositedLayerMapping = layer.compositedLa
yerMapping(); |
85 | 68 |
86 // If this layer has a compositedLayerMapping, then that is where we place s
ubsequent children GraphicsLayers. | 69 // If this layer has a compositedLayerMapping, then that is where we place s
ubsequent children GraphicsLayers. |
87 // Otherwise children continue to append to the child list of the enclosing
layer. | 70 // Otherwise children continue to append to the child list of the enclosing
layer. |
88 GraphicsLayerVector layerChildren; | 71 GraphicsLayerVector layerChildren; |
89 GraphicsLayerVector& childList = hasCompositedLayerMapping ? layerChildren :
childLayersOfEnclosingLayer; | 72 GraphicsLayerVector& childList = hasCompositedLayerMapping ? layerChildren :
childLayersOfEnclosingLayer; |
90 | 73 |
91 #if !ASSERT_DISABLED | 74 #if !ASSERT_DISABLED |
92 LayerListMutationDetector mutationChecker(layer.stackingNode()); | 75 LayerListMutationDetector mutationChecker(layer.stackingNode()); |
93 #endif | 76 #endif |
94 | 77 |
95 if (layer.stackingNode()->isStackingContext()) { | 78 if (layer.stackingNode()->isStackingContext()) { |
96 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), Negative
ZOrderChildren); | 79 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), Negative
ZOrderChildren); |
97 while (RenderLayerStackingNode* curNode = iterator.next()) | 80 while (RenderLayerStackingNode* curNode = iterator.next()) |
98 rebuildTree(*curNode->layer(), childList); | 81 rebuild(*curNode->layer(), childList); |
99 | 82 |
100 // If a negative z-order child is compositing, we get a foreground layer
which needs to get parented. | 83 // If a negative z-order child is compositing, we get a foreground layer
which needs to get parented. |
101 if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregrou
ndLayer()) | 84 if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregrou
ndLayer()) |
102 childList.append(currentCompositedLayerMapping->foregroundLayer()); | 85 childList.append(currentCompositedLayerMapping->foregroundLayer()); |
103 } | 86 } |
104 | 87 |
105 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NormalFlowCh
ildren | PositiveZOrderChildren); | 88 RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NormalFlowCh
ildren | PositiveZOrderChildren); |
106 while (RenderLayerStackingNode* curNode = iterator.next()) | 89 while (RenderLayerStackingNode* curNode = iterator.next()) |
107 rebuildTree(*curNode->layer(), childList); | 90 rebuild(*curNode->layer(), childList); |
108 | 91 |
109 if (hasCompositedLayerMapping) { | 92 if (hasCompositedLayerMapping) { |
110 bool parented = false; | 93 bool parented = false; |
111 if (layer.renderer()->isRenderPart()) | 94 if (layer.renderer()->isRenderPart()) |
112 parented = RenderLayerCompositor::parentFrameContentLayers(toRenderP
art(layer.renderer())); | 95 parented = RenderLayerCompositor::parentFrameContentLayers(toRenderP
art(layer.renderer())); |
113 | 96 |
114 if (!parented) | 97 if (!parented) |
115 currentCompositedLayerMapping->parentForSublayers()->setChildren(lay
erChildren); | 98 currentCompositedLayerMapping->parentForSublayers()->setChildren(lay
erChildren); |
116 | 99 |
117 // If the layer has a clipping layer the overflow controls layers will b
e siblings of the clipping layer. | 100 // If the layer has a clipping layer the overflow controls layers will b
e siblings of the clipping layer. |
(...skipping 13 matching lines...) Expand all Loading... |
131 overflowControlLayer->removeFromParent(); | 114 overflowControlLayer->removeFromParent(); |
132 currentCompositedLayerMapping->parentForSublayers()->addChild(ov
erflowControlLayer); | 115 currentCompositedLayerMapping->parentForSublayers()->addChild(ov
erflowControlLayer); |
133 } | 116 } |
134 } | 117 } |
135 | 118 |
136 if (shouldAppendLayer(layer)) | 119 if (shouldAppendLayer(layer)) |
137 childLayersOfEnclosingLayer.append(currentCompositedLayerMapping->ch
ildForSuperlayers()); | 120 childLayersOfEnclosingLayer.append(currentCompositedLayerMapping->ch
ildForSuperlayers()); |
138 } | 121 } |
139 } | 122 } |
140 | 123 |
141 void GraphicsLayerUpdater::update(RenderLayer& layer, UpdateType updateType, con
st UpdateContext& context) | |
142 { | |
143 if (layer.hasCompositedLayerMapping()) { | |
144 CompositedLayerMappingPtr mapping = layer.compositedLayerMapping(); | |
145 | |
146 const RenderLayer* compositingContainer = context.compositingContainer(l
ayer); | |
147 ASSERT(compositingContainer == layer.ancestorCompositingLayer()); | |
148 if (mapping->updateRequiresOwnBackingStoreForAncestorReasons(compositing
Container)) | |
149 updateType = ForceUpdate; | |
150 | |
151 // Note carefully: here we assume that the compositing state of all desc
endants have been updated already, | |
152 // so it is legitimate to compute and cache the composited bounds for th
is layer. | |
153 mapping->updateCompositedBounds(updateType); | |
154 | |
155 if (RenderLayerReflectionInfo* reflection = layer.reflectionInfo()) { | |
156 if (reflection->reflectionLayer()->hasCompositedLayerMapping()) | |
157 reflection->reflectionLayer()->compositedLayerMapping()->updateC
ompositedBounds(ForceUpdate); | |
158 } | |
159 | |
160 if (mapping->updateGraphicsLayerConfiguration(updateType)) | |
161 m_needsRebuildTree = true; | |
162 | |
163 mapping->updateGraphicsLayerGeometry(updateType, compositingContainer); | |
164 | |
165 updateType = mapping->updateTypeForChildren(updateType); | |
166 mapping->clearNeedsGraphicsLayerUpdate(); | |
167 | |
168 if (!layer.parent()) | |
169 layer.compositor()->updateRootLayerPosition(); | |
170 | |
171 if (mapping->hasUnpositionedOverflowControlsLayers()) | |
172 layer.scrollableArea()->positionOverflowControls(); | |
173 } | |
174 | |
175 UpdateContext childContext(context, layer); | |
176 for (RenderLayer* child = layer.firstChild(); child; child = child->nextSibl
ing()) | |
177 update(*child, updateType, childContext); | |
178 } | 124 } |
179 | |
180 #if !ASSERT_DISABLED | |
181 | |
182 void GraphicsLayerUpdater::assertNeedsToUpdateGraphicsLayerBitsCleared(RenderLay
er& layer) | |
183 { | |
184 if (layer.hasCompositedLayerMapping()) | |
185 layer.compositedLayerMapping()->assertNeedsToUpdateGraphicsLayerBitsClea
red(); | |
186 | |
187 for (RenderLayer* child = layer.firstChild(); child; child = child->nextSibl
ing()) | |
188 assertNeedsToUpdateGraphicsLayerBitsCleared(*child); | |
189 } | |
190 | |
191 #endif | |
192 | |
193 } // namespace WebCore | |
OLD | NEW |