OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef RenderLayerCompositor_h | 26 #ifndef LayerCompositor_h |
27 #define RenderLayerCompositor_h | 27 #define LayerCompositor_h |
28 | 28 |
| 29 #include "core/layout/Layer.h" |
29 #include "core/layout/compositing/CompositingReasonFinder.h" | 30 #include "core/layout/compositing/CompositingReasonFinder.h" |
30 #include "core/rendering/RenderLayer.h" | |
31 #include "platform/graphics/GraphicsLayerClient.h" | 31 #include "platform/graphics/GraphicsLayerClient.h" |
32 #include "wtf/HashMap.h" | 32 #include "wtf/HashMap.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 class DocumentLifecycle; | 36 class DocumentLifecycle; |
37 class GraphicsLayer; | 37 class GraphicsLayer; |
38 class GraphicsLayerFactory; | 38 class GraphicsLayerFactory; |
39 class Page; | 39 class Page; |
40 class RenderPart; | 40 class RenderPart; |
41 class ScrollingCoordinator; | 41 class ScrollingCoordinator; |
42 | 42 |
43 enum CompositingUpdateType { | 43 enum CompositingUpdateType { |
44 CompositingUpdateNone, | 44 CompositingUpdateNone, |
45 CompositingUpdateAfterGeometryChange, | 45 CompositingUpdateAfterGeometryChange, |
46 CompositingUpdateAfterCompositingInputChange, | 46 CompositingUpdateAfterCompositingInputChange, |
47 CompositingUpdateRebuildTree, | 47 CompositingUpdateRebuildTree, |
48 }; | 48 }; |
49 | 49 |
50 enum CompositingStateTransitionType { | 50 enum CompositingStateTransitionType { |
51 NoCompositingStateChange, | 51 NoCompositingStateChange, |
52 AllocateOwnCompositedLayerMapping, | 52 AllocateOwnCompositedLayerMapping, |
53 RemoveOwnCompositedLayerMapping, | 53 RemoveOwnCompositedLayerMapping, |
54 PutInSquashingLayer, | 54 PutInSquashingLayer, |
55 RemoveFromSquashingLayer | 55 RemoveFromSquashingLayer |
56 }; | 56 }; |
57 | 57 |
58 // RenderLayerCompositor manages the hierarchy of | 58 // LayerCompositor manages the hierarchy of |
59 // composited RenderLayers. It determines which RenderLayers | 59 // composited Layers. It determines which Layers |
60 // become compositing, and creates and maintains a hierarchy of | 60 // become compositing, and creates and maintains a hierarchy of |
61 // GraphicsLayers based on the RenderLayer painting order. | 61 // GraphicsLayers based on the Layer painting order. |
62 // | 62 // |
63 // There is one RenderLayerCompositor per RenderView. | 63 // There is one LayerCompositor per RenderView. |
64 | 64 |
65 class RenderLayerCompositor final : public GraphicsLayerClient { | 65 class LayerCompositor final : public GraphicsLayerClient { |
66 WTF_MAKE_FAST_ALLOCATED; | 66 WTF_MAKE_FAST_ALLOCATED; |
67 public: | 67 public: |
68 explicit RenderLayerCompositor(RenderView&); | 68 explicit LayerCompositor(RenderView&); |
69 virtual ~RenderLayerCompositor(); | 69 virtual ~LayerCompositor(); |
70 | 70 |
71 void updateIfNeededRecursive(); | 71 void updateIfNeededRecursive(); |
72 | 72 |
73 // Return true if this RenderView is in "compositing mode" (i.e. has one or
more | 73 // Return true if this RenderView is in "compositing mode" (i.e. has one or
more |
74 // composited RenderLayers) | 74 // composited Layers) |
75 bool inCompositingMode() const; | 75 bool inCompositingMode() const; |
76 // FIXME: Replace all callers with inCompositingMode and remove this functio
n. | 76 // FIXME: Replace all callers with inCompositingMode and remove this functio
n. |
77 bool staleInCompositingMode() const; | 77 bool staleInCompositingMode() const; |
78 // This will make a compositing layer at the root automatically, and hook up
to | 78 // This will make a compositing layer at the root automatically, and hook up
to |
79 // the native view/window system. | 79 // the native view/window system. |
80 void setCompositingModeEnabled(bool); | 80 void setCompositingModeEnabled(bool); |
81 | 81 |
82 // Returns true if the accelerated compositing is enabled | 82 // Returns true if the accelerated compositing is enabled |
83 bool hasAcceleratedCompositing() const { return m_hasAcceleratedCompositing;
} | 83 bool hasAcceleratedCompositing() const { return m_hasAcceleratedCompositing;
} |
84 | 84 |
85 bool preferCompositingToLCDTextEnabled() const; | 85 bool preferCompositingToLCDTextEnabled() const; |
86 | 86 |
87 bool rootShouldAlwaysComposite() const; | 87 bool rootShouldAlwaysComposite() const; |
88 | 88 |
89 // Copy the accelerated compositing related flags from Settings | 89 // Copy the accelerated compositing related flags from Settings |
90 void updateAcceleratedCompositingSettings(); | 90 void updateAcceleratedCompositingSettings(); |
91 | 91 |
92 // Used to indicate that a compositing update will be needed for the next fr
ame that gets drawn. | 92 // Used to indicate that a compositing update will be needed for the next fr
ame that gets drawn. |
93 void setNeedsCompositingUpdate(CompositingUpdateType); | 93 void setNeedsCompositingUpdate(CompositingUpdateType); |
94 | 94 |
95 void didLayout(); | 95 void didLayout(); |
96 | 96 |
97 // Whether layer's compositedLayerMapping needs a GraphicsLayer to clip z-or
der children of the given RenderLayer. | 97 // Whether layer's compositedLayerMapping needs a GraphicsLayer to clip z-or
der children of the given Layer. |
98 bool clipsCompositingDescendants(const RenderLayer*) const; | 98 bool clipsCompositingDescendants(const Layer*) const; |
99 | 99 |
100 // Whether the given layer needs an extra 'contents' layer. | 100 // Whether the given layer needs an extra 'contents' layer. |
101 bool needsContentsCompositingLayer(const RenderLayer*) const; | 101 bool needsContentsCompositingLayer(const Layer*) const; |
102 | 102 |
103 bool supportsFixedRootBackgroundCompositing() const; | 103 bool supportsFixedRootBackgroundCompositing() const; |
104 bool needsFixedRootBackgroundLayer(const RenderLayer*) const; | 104 bool needsFixedRootBackgroundLayer(const Layer*) const; |
105 GraphicsLayer* fixedRootBackgroundLayer() const; | 105 GraphicsLayer* fixedRootBackgroundLayer() const; |
106 void setNeedsUpdateFixedBackground() { m_needsUpdateFixedBackground = true;
} | 106 void setNeedsUpdateFixedBackground() { m_needsUpdateFixedBackground = true;
} |
107 | 107 |
108 // Issue paint invalidations of the appropriate layers when the given Render
Layer starts or stops being composited. | 108 // Issue paint invalidations of the appropriate layers when the given Layer
starts or stops being composited. |
109 void paintInvalidationOnCompositingChange(RenderLayer*); | 109 void paintInvalidationOnCompositingChange(Layer*); |
110 | 110 |
111 void fullyInvalidatePaint(); | 111 void fullyInvalidatePaint(); |
112 | 112 |
113 RenderLayer* rootRenderLayer() const; | 113 Layer* rootLayer() const; |
114 GraphicsLayer* rootGraphicsLayer() const; | 114 GraphicsLayer* rootGraphicsLayer() const; |
115 GraphicsLayer* frameScrollLayer() const; | 115 GraphicsLayer* frameScrollLayer() const; |
116 GraphicsLayer* scrollLayer() const; | 116 GraphicsLayer* scrollLayer() const; |
117 GraphicsLayer* containerLayer() const; | 117 GraphicsLayer* containerLayer() const; |
118 | 118 |
119 // We don't always have a root transform layer. This function lazily allocat
es one | 119 // We don't always have a root transform layer. This function lazily allocat
es one |
120 // and returns it as required. | 120 // and returns it as required. |
121 GraphicsLayer* ensureRootTransformLayer(); | 121 GraphicsLayer* ensureRootTransformLayer(); |
122 | 122 |
123 enum RootLayerAttachment { | 123 enum RootLayerAttachment { |
124 RootLayerUnattached, | 124 RootLayerUnattached, |
125 RootLayerAttachedViaChromeClient, | 125 RootLayerAttachedViaChromeClient, |
126 RootLayerAttachedViaEnclosingFrame | 126 RootLayerAttachedViaEnclosingFrame |
127 }; | 127 }; |
128 | 128 |
129 RootLayerAttachment rootLayerAttachment() const { return m_rootLayerAttachme
nt; } | 129 RootLayerAttachment rootLayerAttachment() const { return m_rootLayerAttachme
nt; } |
130 void updateRootLayerAttachment(); | 130 void updateRootLayerAttachment(); |
131 void updateRootLayerPosition(); | 131 void updateRootLayerPosition(); |
132 | 132 |
133 void setIsInWindow(bool); | 133 void setIsInWindow(bool); |
134 | 134 |
135 static RenderLayerCompositor* frameContentsCompositor(RenderPart*); | 135 static LayerCompositor* frameContentsCompositor(RenderPart*); |
136 // Return true if the layers changed. | 136 // Return true if the layers changed. |
137 static bool parentFrameContentLayers(RenderPart*); | 137 static bool parentFrameContentLayers(RenderPart*); |
138 | 138 |
139 // Update the geometry of the layers used for clipping and scrolling in fram
es. | 139 // Update the geometry of the layers used for clipping and scrolling in fram
es. |
140 void frameViewDidChangeLocation(const IntPoint& contentsOffset); | 140 void frameViewDidChangeLocation(const IntPoint& contentsOffset); |
141 void frameViewDidChangeSize(); | 141 void frameViewDidChangeSize(); |
142 void frameViewDidScroll(); | 142 void frameViewDidScroll(); |
143 void frameViewScrollbarsExistenceDidChange(); | 143 void frameViewScrollbarsExistenceDidChange(); |
144 void rootFixedBackgroundsChanged(); | 144 void rootFixedBackgroundsChanged(); |
145 | 145 |
146 bool scrollingLayerDidChange(RenderLayer*); | 146 bool scrollingLayerDidChange(Layer*); |
147 | 147 |
148 String layerTreeAsText(LayerTreeFlags); | 148 String layerTreeAsText(LayerTreeFlags); |
149 | 149 |
150 GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizo
ntalScrollbar.get(); } | 150 GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizo
ntalScrollbar.get(); } |
151 GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVertical
Scrollbar.get(); } | 151 GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVertical
Scrollbar.get(); } |
152 GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.
get(); } | 152 GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.
get(); } |
153 | 153 |
154 void resetTrackedPaintInvalidationRects(); | 154 void resetTrackedPaintInvalidationRects(); |
155 void setTracksPaintInvalidations(bool); | 155 void setTracksPaintInvalidations(bool); |
156 | 156 |
157 virtual String debugName(const GraphicsLayer*) override; | 157 virtual String debugName(const GraphicsLayer*) override; |
158 DocumentLifecycle& lifecycle() const; | 158 DocumentLifecycle& lifecycle() const; |
159 | 159 |
160 void updatePotentialCompositingReasonsFromStyle(RenderLayer*); | 160 void updatePotentialCompositingReasonsFromStyle(Layer*); |
161 | 161 |
162 // Whether the layer could ever be composited. | 162 // Whether the layer could ever be composited. |
163 bool canBeComposited(const RenderLayer*) const; | 163 bool canBeComposited(const Layer*) const; |
164 | 164 |
165 // FIXME: Move allocateOrClearCompositedLayerMapping to CompositingLayerAssi
gner once we've fixed | 165 // FIXME: Move allocateOrClearCompositedLayerMapping to CompositingLayerAssi
gner once we've fixed |
166 // the compositing chicken/egg issues. | 166 // the compositing chicken/egg issues. |
167 bool allocateOrClearCompositedLayerMapping(RenderLayer*, CompositingStateTra
nsitionType compositedLayerUpdate); | 167 bool allocateOrClearCompositedLayerMapping(Layer*, CompositingStateTransitio
nType compositedLayerUpdate); |
168 | 168 |
169 void updateDirectCompositingReasons(RenderLayer*); | 169 void updateDirectCompositingReasons(Layer*); |
170 | 170 |
171 void setOverlayLayer(GraphicsLayer*); | 171 void setOverlayLayer(GraphicsLayer*); |
172 | 172 |
173 bool inOverlayFullscreenVideo() const { return m_inOverlayFullscreenVideo; } | 173 bool inOverlayFullscreenVideo() const { return m_inOverlayFullscreenVideo; } |
174 | 174 |
175 private: | 175 private: |
176 #if ENABLE(ASSERT) | 176 #if ENABLE(ASSERT) |
177 void assertNoUnresolvedDirtyBits(); | 177 void assertNoUnresolvedDirtyBits(); |
178 #endif | 178 #endif |
179 | 179 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // Layers for overflow controls | 240 // Layers for overflow controls |
241 OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar; | 241 OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar; |
242 OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar; | 242 OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar; |
243 OwnPtr<GraphicsLayer> m_layerForScrollCorner; | 243 OwnPtr<GraphicsLayer> m_layerForScrollCorner; |
244 | 244 |
245 bool m_inOverlayFullscreenVideo; | 245 bool m_inOverlayFullscreenVideo; |
246 }; | 246 }; |
247 | 247 |
248 } // namespace blink | 248 } // namespace blink |
249 | 249 |
250 #endif // RenderLayerCompositor_h | 250 #endif // LayerCompositor_h |
OLD | NEW |