| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 24 */ | |
| 25 | |
| 26 #ifndef SKY_ENGINE_CORE_RENDERING_COMPOSITING_RENDERLAYERCOMPOSITOR_H_ | |
| 27 #define SKY_ENGINE_CORE_RENDERING_COMPOSITING_RENDERLAYERCOMPOSITOR_H_ | |
| 28 | |
| 29 #include "sky/engine/core/rendering/RenderLayer.h" | |
| 30 #include "sky/engine/core/rendering/compositing/CompositingReasonFinder.h" | |
| 31 #include "sky/engine/platform/graphics/GraphicsLayerClient.h" | |
| 32 #include "sky/engine/wtf/HashMap.h" | |
| 33 | |
| 34 namespace blink { | |
| 35 | |
| 36 class DocumentLifecycle; | |
| 37 class GraphicsLayer; | |
| 38 class GraphicsLayerFactory; | |
| 39 class Page; | |
| 40 | |
| 41 enum CompositingUpdateType { | |
| 42 CompositingUpdateNone, | |
| 43 CompositingUpdateAfterGeometryChange, | |
| 44 CompositingUpdateAfterCompositingInputChange, | |
| 45 CompositingUpdateRebuildTree, | |
| 46 }; | |
| 47 | |
| 48 enum CompositingStateTransitionType { | |
| 49 NoCompositingStateChange, | |
| 50 AllocateOwnCompositedLayerMapping, | |
| 51 RemoveOwnCompositedLayerMapping, | |
| 52 PutInSquashingLayer, | |
| 53 RemoveFromSquashingLayer | |
| 54 }; | |
| 55 | |
| 56 // RenderLayerCompositor manages the hierarchy of | |
| 57 // composited RenderLayers. It determines which RenderLayers | |
| 58 // become compositing, and creates and maintains a hierarchy of | |
| 59 // GraphicsLayers based on the RenderLayer painting order. | |
| 60 // | |
| 61 // There is one RenderLayerCompositor per RenderView. | |
| 62 | |
| 63 class RenderLayerCompositor final : public GraphicsLayerClient { | |
| 64 WTF_MAKE_FAST_ALLOCATED; | |
| 65 public: | |
| 66 explicit RenderLayerCompositor(RenderView&); | |
| 67 virtual ~RenderLayerCompositor(); | |
| 68 | |
| 69 void updateIfNeededRecursive(); | |
| 70 | |
| 71 // Return true if this RenderView is in "compositing mode" (i.e. has one or
more | |
| 72 // composited RenderLayers) | |
| 73 bool inCompositingMode() const; | |
| 74 // FIXME: Replace all callers with inCompositingMdoe and remove this functio
n. | |
| 75 bool staleInCompositingMode() const; | |
| 76 // This will make a compositing layer at the root automatically, and hook up
to | |
| 77 // the native view/window system. | |
| 78 void setCompositingModeEnabled(bool); | |
| 79 | |
| 80 // Returns true if the accelerated compositing is enabled | |
| 81 // FIXME(sky): Remove | |
| 82 bool hasAcceleratedCompositing() const; | |
| 83 bool layerSquashingEnabled() const; | |
| 84 | |
| 85 bool preferCompositingToLCDTextEnabled() const; | |
| 86 | |
| 87 bool rootShouldAlwaysComposite() const; | |
| 88 | |
| 89 // Copy the accelerated compositing related flags from Settings | |
| 90 void updateAcceleratedCompositingSettings(); | |
| 91 | |
| 92 // Used to indicate that a compositing update will be needed for the next fr
ame that gets drawn. | |
| 93 void setNeedsCompositingUpdate(CompositingUpdateType); | |
| 94 | |
| 95 void didLayout(); | |
| 96 | |
| 97 // Whether layer's compositedLayerMapping needs a GraphicsLayer to clip z-or
der children of the given RenderLayer. | |
| 98 bool clipsCompositingDescendants(const RenderLayer*) const; | |
| 99 | |
| 100 // Whether the given layer needs an extra 'contents' layer. | |
| 101 bool needsContentsCompositingLayer(const RenderLayer*) const; | |
| 102 | |
| 103 bool supportsFixedRootBackgroundCompositing() const; | |
| 104 bool needsFixedRootBackgroundLayer(const RenderLayer*) const; | |
| 105 GraphicsLayer* fixedRootBackgroundLayer() const; | |
| 106 void setNeedsUpdateFixedBackground() { m_needsUpdateFixedBackground = true;
} | |
| 107 | |
| 108 // Issue paint invalidations of the appropriate layers when the given Render
Layer starts or stops being composited. | |
| 109 void paintInvalidationOnCompositingChange(RenderLayer*); | |
| 110 | |
| 111 void fullyInvalidatePaint(); | |
| 112 | |
| 113 RenderLayer* rootRenderLayer() const; | |
| 114 GraphicsLayer* rootGraphicsLayer() const; | |
| 115 GraphicsLayer* scrollLayer() const; | |
| 116 GraphicsLayer* containerLayer() const; | |
| 117 | |
| 118 // We don't always have a root transform layer. This function lazily allocat
es one | |
| 119 // and returns it as required. | |
| 120 GraphicsLayer* ensureRootTransformLayer(); | |
| 121 | |
| 122 enum RootLayerAttachment { | |
| 123 RootLayerUnattached, | |
| 124 RootLayerAttachedViaChromeClient, | |
| 125 RootLayerAttachedViaEnclosingFrame | |
| 126 }; | |
| 127 | |
| 128 RootLayerAttachment rootLayerAttachment() const { return m_rootLayerAttachme
nt; } | |
| 129 void updateRootLayerAttachment(); | |
| 130 void updateRootLayerPosition(); | |
| 131 | |
| 132 void setIsInWindow(bool); | |
| 133 | |
| 134 // Update the geometry of the layers used for clipping and scrolling in fram
es. | |
| 135 void frameViewDidChangeLocation(const IntPoint& contentsOffset); | |
| 136 void frameViewDidChangeSize(); | |
| 137 void rootFixedBackgroundsChanged(); | |
| 138 | |
| 139 String layerTreeAsText(LayerTreeFlags); | |
| 140 | |
| 141 void resetTrackedPaintInvalidationRects(); | |
| 142 void setTracksPaintInvalidations(bool); | |
| 143 | |
| 144 virtual String debugName(const GraphicsLayer*) override; | |
| 145 DocumentLifecycle& lifecycle() const; | |
| 146 | |
| 147 void updatePotentialCompositingReasonsFromStyle(RenderLayer*); | |
| 148 | |
| 149 // Whether the layer could ever be composited. | |
| 150 bool canBeComposited(const RenderLayer*) const; | |
| 151 | |
| 152 // FIXME: Move allocateOrClearCompositedLayerMapping to CompositingLayerAssi
gner once we've fixed | |
| 153 // the compositing chicken/egg issues. | |
| 154 bool allocateOrClearCompositedLayerMapping(RenderLayer*, CompositingStateTra
nsitionType compositedLayerUpdate); | |
| 155 | |
| 156 void updateDirectCompositingReasons(RenderLayer*); | |
| 157 | |
| 158 void setOverlayLayer(GraphicsLayer*); | |
| 159 | |
| 160 private: | |
| 161 #if ENABLE(ASSERT) | |
| 162 void assertNoUnresolvedDirtyBits(); | |
| 163 #endif | |
| 164 | |
| 165 // GraphicsLayerClient implementation | |
| 166 virtual void notifyAnimationStarted(const GraphicsLayer*, double) override {
} | |
| 167 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL
ayerPaintingPhase, const IntRect&) override; | |
| 168 | |
| 169 virtual bool isTrackingPaintInvalidations() const override; | |
| 170 | |
| 171 void updateWithoutAcceleratedCompositing(CompositingUpdateType); | |
| 172 void updateIfNeeded(); | |
| 173 | |
| 174 void ensureRootLayer(); | |
| 175 void destroyRootLayer(); | |
| 176 | |
| 177 void attachRootLayer(RootLayerAttachment); | |
| 178 void detachRootLayer(); | |
| 179 | |
| 180 Page* page() const; | |
| 181 | |
| 182 GraphicsLayerFactory* graphicsLayerFactory() const; | |
| 183 | |
| 184 void enableCompositingModeIfNeeded(); | |
| 185 | |
| 186 RenderView& m_renderView; | |
| 187 OwnPtr<GraphicsLayer> m_rootContentLayer; | |
| 188 OwnPtr<GraphicsLayer> m_rootTransformLayer; | |
| 189 | |
| 190 CompositingReasonFinder m_compositingReasonFinder; | |
| 191 | |
| 192 CompositingUpdateType m_pendingUpdateType; | |
| 193 | |
| 194 bool m_compositing; | |
| 195 | |
| 196 // The root layer doesn't composite if it's a non-scrollable frame. | |
| 197 // So, after a layout we set this dirty bit to know that we need | |
| 198 // to recompute whether the root layer should composite even if | |
| 199 // none of its descendants composite. | |
| 200 // FIXME: Get rid of all the callers of setCompositingModeEnabled | |
| 201 // except the one in updateIfNeeded, then rename this to | |
| 202 // m_compositingDirty. | |
| 203 bool m_rootShouldAlwaysCompositeDirty; | |
| 204 bool m_needsUpdateFixedBackground; | |
| 205 bool m_isTrackingPaintInvalidations; // Used for testing. | |
| 206 | |
| 207 RootLayerAttachment m_rootLayerAttachment; | |
| 208 | |
| 209 // Enclosing container layer, which clips for iframe content | |
| 210 OwnPtr<GraphicsLayer> m_containerLayer; | |
| 211 OwnPtr<GraphicsLayer> m_scrollLayer; | |
| 212 | |
| 213 // Enclosing layer for overflow controls and the clipping layer | |
| 214 OwnPtr<GraphicsLayer> m_overflowControlsHostLayer; | |
| 215 }; | |
| 216 | |
| 217 } // namespace blink | |
| 218 | |
| 219 #endif // SKY_ENGINE_CORE_RENDERING_COMPOSITING_RENDERLAYERCOMPOSITOR_H_ | |
| OLD | NEW |