simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 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 RenderLayerCompositor_h |
| 27 | #define RenderLayerCompositor_h |
| 28 | |
vangelis@chromium.org | 1bbe613 | 2010-11-30 20:41:59 +0000 | [diff] [blame] | 29 | #include "ChromeClient.h" |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 30 | #include "RenderLayer.h" |
simon.fraser@apple.com | 994de4f | 2009-06-30 19:53:41 +0000 | [diff] [blame] | 31 | #include "RenderLayerBacking.h" |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 32 | |
| 33 | namespace WebCore { |
| 34 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 35 | class GraphicsLayer; |
simon.fraser@apple.com | bda4184 | 2010-07-13 00:40:47 +0000 | [diff] [blame] | 36 | class RenderEmbeddedObject; |
cmarrin@apple.com | 8f4e044 | 2011-04-11 22:21:11 +0000 | [diff] [blame] | 37 | class RenderPart; |
jamesr@google.com | 0abe006 | 2012-02-18 00:23:16 +0000 | [diff] [blame] | 38 | class ScrollingCoordinator; |
simon.fraser@apple.com | 98df11b | 2009-06-18 18:52:09 +0000 | [diff] [blame] | 39 | #if ENABLE(VIDEO) |
| 40 | class RenderVideo; |
| 41 | #endif |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 42 | |
simon.fraser@apple.com | 762661b | 2010-01-28 18:07:14 +0000 | [diff] [blame] | 43 | enum CompositingUpdateType { |
simon.fraser@apple.com | 06a2bbb | 2012-04-20 21:54:45 +0000 | [diff] [blame] | 44 | CompositingUpdateAfterStyleChange, |
| 45 | CompositingUpdateAfterLayout, |
jamesr@google.com | ef5cfe2 | 2011-09-23 21:51:58 +0000 | [diff] [blame] | 46 | CompositingUpdateOnHitTest, |
simon.fraser@apple.com | 762661b | 2010-01-28 18:07:14 +0000 | [diff] [blame] | 47 | CompositingUpdateOnScroll |
| 48 | }; |
| 49 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 50 | // RenderLayerCompositor manages the hierarchy of |
| 51 | // composited RenderLayers. It determines which RenderLayers |
| 52 | // become compositing, and creates and maintains a hierarchy of |
| 53 | // GraphicsLayers based on the RenderLayer painting order. |
| 54 | // |
| 55 | // There is one RenderLayerCompositor per RenderView. |
| 56 | |
cmarrin@apple.com | 14a3dcf | 2011-01-07 20:00:22 +0000 | [diff] [blame] | 57 | class RenderLayerCompositor : public GraphicsLayerClient { |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 58 | public: |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 59 | RenderLayerCompositor(RenderView*); |
| 60 | ~RenderLayerCompositor(); |
cmarrin@apple.com | 14a3dcf | 2011-01-07 20:00:22 +0000 | [diff] [blame] | 61 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 62 | // Return true if this RenderView is in "compositing mode" (i.e. has one or more |
| 63 | // composited RenderLayers) |
| 64 | bool inCompositingMode() const { return m_compositing; } |
| 65 | // This will make a compositing layer at the root automatically, and hook up to |
| 66 | // the native view/window system. |
| 67 | void enableCompositingMode(bool enable = true); |
commit-queue@webkit.org | 3c453c4 | 2012-04-05 16:10:40 +0000 | [diff] [blame] | 68 | |
| 69 | bool inForcedCompositingMode() const { return m_forceCompositingMode; } |
| 70 | |
cmarrin@apple.com | 89072a0 | 2009-06-25 22:03:59 +0000 | [diff] [blame] | 71 | // Returns true if the accelerated compositing is enabled |
cmarrin@apple.com | d285182 | 2009-06-25 22:35:21 +0000 | [diff] [blame] | 72 | bool hasAcceleratedCompositing() const { return m_hasAcceleratedCompositing; } |
vangelis@chromium.org | 1bbe613 | 2010-11-30 20:41:59 +0000 | [diff] [blame] | 73 | |
| 74 | bool canRender3DTransforms() const; |
| 75 | |
cmarrin@apple.com | f2dff33 | 2009-11-18 19:23:44 +0000 | [diff] [blame] | 76 | // Copy the accelerated compositing related flags from Settings |
| 77 | void cacheAcceleratedCompositingFlags(); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 78 | |
simon.fraser@apple.com | 8717fee | 2009-07-31 23:03:25 +0000 | [diff] [blame] | 79 | // Called when the layer hierarchy needs to be updated (compositing layers have been |
simon.fraser@apple.com | 02f4049 | 2009-07-07 17:15:16 +0000 | [diff] [blame] | 80 | // created, destroyed or re-parented). |
| 81 | void setCompositingLayersNeedRebuild(bool needRebuild = true); |
| 82 | bool compositingLayersNeedRebuild() const { return m_compositingLayersNeedRebuild; } |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 83 | |
simon.fraser@apple.com | 02f4049 | 2009-07-07 17:15:16 +0000 | [diff] [blame] | 84 | // Controls whether or not to consult geometry when deciding which layers need |
| 85 | // to be composited. Defaults to true. |
| 86 | void setCompositingConsultsOverlap(bool b) { m_compositingConsultsOverlap = b; } |
| 87 | bool compositingConsultsOverlap() const { return m_compositingConsultsOverlap; } |
| 88 | |
simon.fraser@apple.com | 73e897b | 2011-01-14 23:45:17 +0000 | [diff] [blame] | 89 | // GraphicsLayers buffer state, which gets pushed to the underlying platform layers |
| 90 | // at specific times. |
| 91 | void scheduleLayerFlush(); |
simon.fraser@apple.com | d73911e | 2011-07-22 01:02:35 +0000 | [diff] [blame] | 92 | void flushPendingLayerChanges(bool isFlushRoot = true); |
simon.fraser@apple.com | c961f41 | 2011-01-20 03:20:47 +0000 | [diff] [blame] | 93 | |
| 94 | // flushPendingLayerChanges() flushes the entire GraphicsLayer tree, which can cross frame boundaries. |
| 95 | // This call returns the rootmost compositor that is being flushed (including self). |
| 96 | RenderLayerCompositor* enclosingCompositorFlushingLayers() const; |
simon.fraser@apple.com | 53dd08d | 2011-07-16 01:30:13 +0000 | [diff] [blame] | 97 | |
| 98 | // Called when the GraphicsLayer for the given RenderLayer has flushed changes inside of flushPendingLayerChanges(). |
| 99 | void didFlushChangesForLayer(RenderLayer*); |
cmarrin@apple.com | 20dc489 | 2009-04-03 19:29:22 +0000 | [diff] [blame] | 100 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 101 | // Rebuild the tree of compositing layers |
simon.fraser@apple.com | 06a2bbb | 2012-04-20 21:54:45 +0000 | [diff] [blame] | 102 | void updateCompositingLayers(CompositingUpdateType, RenderLayer* updateRoot = 0); |
simon.fraser@apple.com | bd17434 | 2010-08-25 18:24:17 +0000 | [diff] [blame] | 103 | // This is only used when state changes and we do not exepect a style update or layout to happen soon (e.g. when |
| 104 | // we discover that an iframe is overlapped during painting). |
| 105 | void scheduleCompositingLayerUpdate(); |
simon.fraser@apple.com | bd17434 | 2010-08-25 18:24:17 +0000 | [diff] [blame] | 106 | |
simon.fraser@apple.com | 3bc08f1 | 2009-04-07 22:06:19 +0000 | [diff] [blame] | 107 | // Update the compositing state of the given layer. Returns true if that state changed. |
| 108 | enum CompositingChangeRepaint { CompositingChangeRepaintNow, CompositingChangeWillRepaintLater }; |
| 109 | bool updateLayerCompositingState(RenderLayer*, CompositingChangeRepaint = CompositingChangeRepaintNow); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 110 | |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 111 | // Update the geometry for compositing children of compositingAncestor. |
simon.fraser@apple.com | 994de4f | 2009-06-30 19:53:41 +0000 | [diff] [blame] | 112 | void updateCompositingDescendantGeometry(RenderLayer* compositingAncestor, RenderLayer* layer, RenderLayerBacking::UpdateDepth); |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 113 | |
simon.fraser@apple.com | 699dc0b | 2009-04-07 17:45:00 +0000 | [diff] [blame] | 114 | // Whether layer's backing needs a graphics layer to do clipping by an ancestor (non-stacking-context parent with overflow). |
| 115 | bool clippedByAncestor(RenderLayer*) const; |
| 116 | // Whether layer's backing needs a graphics layer to clip z-order children of the given layer. |
| 117 | bool clipsCompositingDescendants(const RenderLayer*) const; |
| 118 | |
commit-queue@webkit.org | b07824e | 2012-06-14 17:45:05 +0000 | [diff] [blame] | 119 | // Whether the layer is fixed positioned to the view by an ancestor layer. |
| 120 | bool fixedPositionedByAncestor(const RenderLayer*) const; |
| 121 | |
simon.fraser@apple.com | 699dc0b | 2009-04-07 17:45:00 +0000 | [diff] [blame] | 122 | // Whether the given layer needs an extra 'contents' layer. |
| 123 | bool needsContentsCompositingLayer(const RenderLayer*) const; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 124 | // Return the bounding box required for compositing layer and its childern, relative to ancestorLayer. |
| 125 | // If layerBoundingBox is not 0, on return it contains the bounding box of this layer only. |
leviw@chromium.org | dac251e | 2012-02-15 01:20:32 +0000 | [diff] [blame] | 126 | IntRect calculateCompositedBounds(const RenderLayer*, const RenderLayer* ancestorLayer); |
simon.fraser@apple.com | 3bc08f1 | 2009-04-07 22:06:19 +0000 | [diff] [blame] | 127 | |
| 128 | // Repaint the appropriate layers when the given RenderLayer starts or stops being composited. |
| 129 | void repaintOnCompositingChange(RenderLayer*); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 130 | |
simon.fraser@apple.com | 9d12790 | 2012-05-29 20:49:15 +0000 | [diff] [blame] | 131 | void repaintInCompositedAncestor(RenderLayer*, const LayoutRect&); |
| 132 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 133 | // Notify us that a layer has been added or removed |
| 134 | void layerWasAdded(RenderLayer* parent, RenderLayer* child); |
| 135 | void layerWillBeRemoved(RenderLayer* parent, RenderLayer* child); |
| 136 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 137 | // Get the nearest ancestor layer that has overflow or clip, but is not a stacking context |
| 138 | RenderLayer* enclosingNonStackingClippingLayer(const RenderLayer* layer) const; |
| 139 | |
| 140 | // Repaint parts of all composited layers that intersect the given absolute rectangle. |
leviw@chromium.org | dac251e | 2012-02-15 01:20:32 +0000 | [diff] [blame] | 141 | void repaintCompositedLayersAbsoluteRect(const IntRect&); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 142 | |
simon.fraser@apple.com | b7cec68 | 2012-04-16 18:32:13 +0000 | [diff] [blame] | 143 | // Returns true if the given layer needs it own backing store. |
| 144 | bool requiresOwnBackingStore(const RenderLayer*, const RenderLayer* compositingAncestorLayer) const; |
| 145 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 146 | RenderLayer* rootRenderLayer() const; |
simon.fraser@apple.com | 2d3dba2 | 2011-07-12 22:21:29 +0000 | [diff] [blame] | 147 | GraphicsLayer* rootGraphicsLayer() const; |
enne@google.com | e5eee18 | 2011-11-04 16:41:19 +0000 | [diff] [blame] | 148 | GraphicsLayer* scrollLayer() const; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 149 | |
simon.fraser@apple.com | 509623e | 2010-05-11 05:33:23 +0000 | [diff] [blame] | 150 | enum RootLayerAttachment { |
| 151 | RootLayerUnattached, |
| 152 | RootLayerAttachedViaChromeClient, |
cmarrin@apple.com | 8f4e044 | 2011-04-11 22:21:11 +0000 | [diff] [blame] | 153 | RootLayerAttachedViaEnclosingFrame |
simon.fraser@apple.com | 509623e | 2010-05-11 05:33:23 +0000 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | RootLayerAttachment rootLayerAttachment() const { return m_rootLayerAttachment; } |
simon.fraser@apple.com | c0c558c | 2010-05-11 05:44:06 +0000 | [diff] [blame] | 157 | void updateRootLayerAttachment(); |
| 158 | void updateRootLayerPosition(); |
| 159 | |
simon.fraser@apple.com | c152ae6 | 2009-02-03 20:14:37 +0000 | [diff] [blame] | 160 | void didMoveOnscreen(); |
| 161 | void willMoveOffscreen(); |
simon.fraser@apple.com | 7ec0184 | 2011-07-06 20:15:07 +0000 | [diff] [blame] | 162 | |
| 163 | void clearBackingForAllLayers(); |
simon.fraser@apple.com | 98df11b | 2009-06-18 18:52:09 +0000 | [diff] [blame] | 164 | |
simon.fraser@apple.com | 47560da | 2011-10-21 03:02:05 +0000 | [diff] [blame] | 165 | void layerBecameComposited(const RenderLayer*) { ++m_compositedLayerCount; } |
| 166 | void layerBecameNonComposited(const RenderLayer*) |
| 167 | { |
| 168 | ASSERT(m_compositedLayerCount > 0); |
| 169 | --m_compositedLayerCount; |
| 170 | } |
| 171 | |
simon.fraser@apple.com | 98df11b | 2009-06-18 18:52:09 +0000 | [diff] [blame] | 172 | #if ENABLE(VIDEO) |
| 173 | // Use by RenderVideo to ask if it should try to use accelerated compositing. |
| 174 | bool canAccelerateVideoRendering(RenderVideo*) const; |
| 175 | #endif |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 176 | |
simon.fraser@apple.com | 61cf5eb | 2009-02-13 05:10:12 +0000 | [diff] [blame] | 177 | // Walk the tree looking for layers with 3d transforms. Useful in case you need |
| 178 | // to know if there is non-affine content, e.g. for drawing into an image. |
| 179 | bool has3DContent() const; |
simon.fraser@apple.com | ad796c5 | 2010-04-27 19:26:38 +0000 | [diff] [blame] | 180 | |
simon.fraser@apple.com | 8a7f801 | 2010-11-08 19:47:51 +0000 | [diff] [blame] | 181 | // Most platforms connect compositing layer trees between iframes and their parent document. |
| 182 | // Some (currently just Mac) allow iframes to do their own compositing. |
cmarrin@apple.com | 8f4e044 | 2011-04-11 22:21:11 +0000 | [diff] [blame] | 183 | static bool allowsIndependentlyCompositedFrames(const FrameView*); |
| 184 | bool shouldPropagateCompositingToEnclosingFrame() const; |
simon.fraser@apple.com | 61cf5eb | 2009-02-13 05:10:12 +0000 | [diff] [blame] | 185 | |
cmarrin@apple.com | 8f4e044 | 2011-04-11 22:21:11 +0000 | [diff] [blame] | 186 | static RenderLayerCompositor* frameContentsCompositor(RenderPart*); |
simon.fraser@apple.com | c0c558c | 2010-05-11 05:44:06 +0000 | [diff] [blame] | 187 | // Return true if the layers changed. |
cmarrin@apple.com | 8f4e044 | 2011-04-11 22:21:11 +0000 | [diff] [blame] | 188 | static bool parentFrameContentLayers(RenderPart*); |
simon.fraser@apple.com | be8126e | 2010-05-11 05:08:18 +0000 | [diff] [blame] | 189 | |
simon.fraser@apple.com | e38ba06 | 2010-05-13 23:14:46 +0000 | [diff] [blame] | 190 | // Update the geometry of the layers used for clipping and scrolling in frames. |
leviw@chromium.org | dac251e | 2012-02-15 01:20:32 +0000 | [diff] [blame] | 191 | void frameViewDidChangeLocation(const IntPoint& contentsOffset); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 192 | void frameViewDidChangeSize(); |
andersca@apple.com | 99039b2 | 2012-01-31 02:58:27 +0000 | [diff] [blame] | 193 | void frameViewDidScroll(); |
cmarrin@apple.com | 10c77cf | 2010-05-05 01:50:03 +0000 | [diff] [blame] | 194 | |
commit-queue@webkit.org | 4eab00b | 2011-03-21 20:01:57 +0000 | [diff] [blame] | 195 | String layerTreeAsText(bool showDebugInfo = false); |
simon.fraser@apple.com | 0a00f37 | 2010-09-17 19:00:03 +0000 | [diff] [blame] | 196 | |
cmarrin@apple.com | 14a3dcf | 2011-01-07 20:00:22 +0000 | [diff] [blame] | 197 | // These are named to avoid conflicts with the functions in GraphicsLayerClient |
| 198 | // These return the actual internal variables. |
| 199 | bool compositorShowDebugBorders() const { return m_showDebugBorders; } |
| 200 | bool compositorShowRepaintCounter() const { return m_showRepaintCounter; } |
| 201 | |
aroben@apple.com | 631cb90 | 2011-08-15 13:43:29 +0000 | [diff] [blame] | 202 | virtual float deviceScaleFactor() const; |
simon.fraser@apple.com | 53dd08d | 2011-07-16 01:30:13 +0000 | [diff] [blame] | 203 | virtual float pageScaleFactor() const; |
| 204 | virtual void didCommitChangesForLayer(const GraphicsLayer*) const; |
| 205 | |
simon.fraser@apple.com | 1eae7d2 | 2011-07-17 02:34:10 +0000 | [diff] [blame] | 206 | bool keepLayersPixelAligned() const; |
simon.fraser@apple.com | 5cce05c | 2012-03-23 21:40:21 +0000 | [diff] [blame] | 207 | bool acceleratedDrawingEnabled() const { return m_acceleratedDrawingEnabled; } |
simon.fraser@apple.com | 1eae7d2 | 2011-07-17 02:34:10 +0000 | [diff] [blame] | 208 | |
aroben@apple.com | 631cb90 | 2011-08-15 13:43:29 +0000 | [diff] [blame] | 209 | void deviceOrPageScaleFactorChanged(); |
cmarrin@apple.com | 09f22bf | 2011-01-12 22:27:27 +0000 | [diff] [blame] | 210 | |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 211 | GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); } |
| 212 | GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); } |
| 213 | GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.get(); } |
andersca@apple.com | 134cfff | 2012-01-13 00:30:55 +0000 | [diff] [blame] | 214 | #if ENABLE(RUBBER_BANDING) |
commit-queue@webkit.org | 0a4465d | 2011-09-15 04:06:49 +0000 | [diff] [blame] | 215 | GraphicsLayer* layerForOverhangAreas() const { return m_layerForOverhangAreas.get(); } |
| 216 | #endif |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 217 | |
andersca@apple.com | 4a0973b | 2012-02-14 02:36:00 +0000 | [diff] [blame] | 218 | void documentBackgroundColorDidChange(); |
| 219 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 220 | private: |
enne@google.com | d77b433 | 2012-03-06 05:13:00 +0000 | [diff] [blame] | 221 | class OverlapMap; |
| 222 | |
cmarrin@apple.com | 14a3dcf | 2011-01-07 20:00:22 +0000 | [diff] [blame] | 223 | // GraphicsLayerClient Implementation |
| 224 | virtual void notifyAnimationStarted(const GraphicsLayer*, double) { } |
simon.fraser@apple.com | 73e897b | 2011-01-14 23:45:17 +0000 | [diff] [blame] | 225 | virtual void notifySyncRequired(const GraphicsLayer*) { scheduleLayerFlush(); } |
leviw@chromium.org | dac251e | 2012-02-15 01:20:32 +0000 | [diff] [blame] | 226 | virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect&); |
cmarrin@apple.com | 14a3dcf | 2011-01-07 20:00:22 +0000 | [diff] [blame] | 227 | |
simon.fraser@apple.com | cc7fbbc | 2012-01-24 18:54:43 +0000 | [diff] [blame] | 228 | virtual bool showDebugBorders(const GraphicsLayer*) const; |
| 229 | virtual bool showRepaintCounter(const GraphicsLayer*) const; |
cmarrin@apple.com | 14a3dcf | 2011-01-07 20:00:22 +0000 | [diff] [blame] | 230 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 231 | // Whether the given RL needs a compositing layer. |
| 232 | bool needsToBeComposited(const RenderLayer*) const; |
| 233 | // Whether the layer has an intrinsic need for compositing layer. |
| 234 | bool requiresCompositingLayer(const RenderLayer*) const; |
simon.fraser@apple.com | d6bec43 | 2010-04-01 23:42:04 +0000 | [diff] [blame] | 235 | // Whether the layer could ever be composited. |
| 236 | bool canBeComposited(const RenderLayer*) const; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 237 | |
simon.fraser@apple.com | b2fc99c | 2009-06-22 22:45:24 +0000 | [diff] [blame] | 238 | // Make or destroy the backing for this layer; returns true if backing changed. |
| 239 | bool updateBacking(RenderLayer*, CompositingChangeRepaint shouldRepaint); |
| 240 | |
simon.fraser@apple.com | 7ec0184 | 2011-07-06 20:15:07 +0000 | [diff] [blame] | 241 | void clearBackingForLayerIncludingDescendants(RenderLayer*); |
| 242 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 243 | // Repaint the given rect (which is layer's coords), and regions of child layers that intersect that rect. |
leviw@chromium.org | dac251e | 2012-02-15 01:20:32 +0000 | [diff] [blame] | 244 | void recursiveRepaintLayerRect(RenderLayer*, const IntRect&); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 245 | |
simon.fraser@apple.com | c7744c2 | 2012-05-31 23:25:05 +0000 | [diff] [blame] | 246 | void addToOverlapMap(OverlapMap&, RenderLayer*, IntRect& layerBounds, bool& boundsComputed); |
| 247 | void addToOverlapMapRecursive(OverlapMap&, RenderLayer*, RenderLayer* ancestorLayer = 0); |
simon.fraser@apple.com | 02f4049 | 2009-07-07 17:15:16 +0000 | [diff] [blame] | 248 | |
simon.fraser@apple.com | bd17434 | 2010-08-25 18:24:17 +0000 | [diff] [blame] | 249 | void updateCompositingLayersTimerFired(Timer<RenderLayerCompositor>*); |
| 250 | |
simon.fraser@apple.com | 02f4049 | 2009-07-07 17:15:16 +0000 | [diff] [blame] | 251 | // Returns true if any layer's compositing changed |
simon.fraser@apple.com | f57fac5 | 2012-06-05 22:18:31 +0000 | [diff] [blame] | 252 | void computeCompositingRequirements(RenderLayer* ancestorLayer, RenderLayer*, OverlapMap*, struct CompositingState&, bool& layersChanged, bool& descendantHas3DTransform); |
simon.fraser@apple.com | 90c94a1 | 2009-11-30 03:21:55 +0000 | [diff] [blame] | 253 | |
| 254 | // Recurses down the tree, parenting descendant compositing layers and collecting an array of child layers for the current compositing layer. |
simon.fraser@apple.com | d6c5602 | 2012-04-27 01:40:10 +0000 | [diff] [blame] | 255 | void rebuildCompositingLayerTree(RenderLayer*, Vector<GraphicsLayer*>& childGraphicsLayersOfEnclosingLayer, int depth); |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 256 | |
simon.fraser@apple.com | 90c94a1 | 2009-11-30 03:21:55 +0000 | [diff] [blame] | 257 | // Recurses down the tree, updating layer geometry only. |
simon.fraser@apple.com | d6c5602 | 2012-04-27 01:40:10 +0000 | [diff] [blame] | 258 | void updateLayerTreeGeometry(RenderLayer*, int depth); |
simon.fraser@apple.com | 90c94a1 | 2009-11-30 03:21:55 +0000 | [diff] [blame] | 259 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 260 | // Hook compositing layers together |
| 261 | void setCompositingParent(RenderLayer* childLayer, RenderLayer* parentLayer); |
| 262 | void removeCompositedChildren(RenderLayer*); |
| 263 | |
simon.fraser@apple.com | 61cf5eb | 2009-02-13 05:10:12 +0000 | [diff] [blame] | 264 | bool layerHas3DContent(const RenderLayer*) const; |
simon.fraser@apple.com | ce9b3f0 | 2012-05-03 17:50:03 +0000 | [diff] [blame] | 265 | bool isRunningAcceleratedTransformAnimation(RenderObject*) const; |
| 266 | |
simon.fraser@apple.com | 47560da | 2011-10-21 03:02:05 +0000 | [diff] [blame] | 267 | bool hasAnyAdditionalCompositedLayers(const RenderLayer* rootLayer) const; |
simon.fraser@apple.com | 61cf5eb | 2009-02-13 05:10:12 +0000 | [diff] [blame] | 268 | |
simon.fraser@apple.com | 2d3dba2 | 2011-07-12 22:21:29 +0000 | [diff] [blame] | 269 | void ensureRootLayer(); |
| 270 | void destroyRootLayer(); |
simon.fraser@apple.com | 509623e | 2010-05-11 05:33:23 +0000 | [diff] [blame] | 271 | |
simon.fraser@apple.com | 2d3dba2 | 2011-07-12 22:21:29 +0000 | [diff] [blame] | 272 | void attachRootLayer(RootLayerAttachment); |
| 273 | void detachRootLayer(); |
cmarrin@apple.com | 89072a0 | 2009-06-25 22:03:59 +0000 | [diff] [blame] | 274 | |
simon.fraser@apple.com | c0c558c | 2010-05-11 05:44:06 +0000 | [diff] [blame] | 275 | void rootLayerAttachmentChanged(); |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 276 | |
| 277 | void updateOverflowControlsLayers(); |
| 278 | |
simon.fraser@apple.com | fb20cde | 2010-05-13 03:27:47 +0000 | [diff] [blame] | 279 | void notifyIFramesOfCompositingChange(); |
simon.fraser@apple.com | c0c558c | 2010-05-11 05:44:06 +0000 | [diff] [blame] | 280 | |
simon.fraser@apple.com | d73911e | 2011-07-22 01:02:35 +0000 | [diff] [blame] | 281 | bool isFlushingLayers() const { return m_flushingLayers; } |
| 282 | |
jamesr@google.com | 0abe006 | 2012-02-18 00:23:16 +0000 | [diff] [blame] | 283 | ScrollingCoordinator* scrollingCoordinator() const; |
| 284 | |
simon.fraser@apple.com | 6b59a90 | 2009-03-17 20:01:31 +0000 | [diff] [blame] | 285 | // Whether a running transition or animation enforces the need for a compositing layer. |
simon.fraser@apple.com | 0ac1f06 | 2009-06-27 06:22:30 +0000 | [diff] [blame] | 286 | bool requiresCompositingForAnimation(RenderObject*) const; |
| 287 | bool requiresCompositingForTransform(RenderObject*) const; |
simon.fraser@apple.com | 98df11b | 2009-06-18 18:52:09 +0000 | [diff] [blame] | 288 | bool requiresCompositingForVideo(RenderObject*) const; |
cmarrin@apple.com | 4e7728f | 2009-08-27 23:55:44 +0000 | [diff] [blame] | 289 | bool requiresCompositingForCanvas(RenderObject*) const; |
simon.fraser@apple.com | d6aff5e | 2010-01-12 00:15:06 +0000 | [diff] [blame] | 290 | bool requiresCompositingForPlugin(RenderObject*) const; |
cmarrin@apple.com | 8f4e044 | 2011-04-11 22:21:11 +0000 | [diff] [blame] | 291 | bool requiresCompositingForFrame(RenderObject*) const; |
noam.rosenthal@nokia.com | e7d126c | 2012-01-06 23:13:02 +0000 | [diff] [blame] | 292 | bool requiresCompositingForFilters(RenderObject*) const; |
enne@google.com | 1077863 | 2011-08-11 19:44:45 +0000 | [diff] [blame] | 293 | bool requiresCompositingForScrollableFrame() const; |
vangelis@chromium.org | e910d23 | 2011-10-27 20:28:40 +0000 | [diff] [blame] | 294 | bool requiresCompositingForPosition(RenderObject*, const RenderLayer*) const; |
simon.fraser@apple.com | f57fac5 | 2012-06-05 22:18:31 +0000 | [diff] [blame] | 295 | bool requiresCompositingForIndirectReason(RenderObject*, bool hasCompositedDescendants, bool has3DTransformedDescendants, RenderLayer::IndirectCompositingReason&) const; |
simon.fraser@apple.com | 6b59a90 | 2009-03-17 20:01:31 +0000 | [diff] [blame] | 296 | |
simon.fraser@apple.com | 31b329f | 2010-07-26 17:48:13 +0000 | [diff] [blame] | 297 | bool requiresScrollLayer(RootLayerAttachment) const; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 298 | bool requiresHorizontalScrollbarLayer() const; |
| 299 | bool requiresVerticalScrollbarLayer() const; |
| 300 | bool requiresScrollCornerLayer() const; |
andersca@apple.com | 134cfff | 2012-01-13 00:30:55 +0000 | [diff] [blame] | 301 | #if ENABLE(RUBBER_BANDING) |
commit-queue@webkit.org | 0a4465d | 2011-09-15 04:06:49 +0000 | [diff] [blame] | 302 | bool requiresOverhangAreasLayer() const; |
andersca@apple.com | b2abfa6 | 2012-02-08 20:24:57 +0000 | [diff] [blame] | 303 | bool requiresContentShadowLayer() const; |
commit-queue@webkit.org | 0a4465d | 2011-09-15 04:06:49 +0000 | [diff] [blame] | 304 | #endif |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 305 | |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 306 | #if !LOG_DISABLED |
| 307 | const char* reasonForCompositing(const RenderLayer*); |
simon.fraser@apple.com | d6c5602 | 2012-04-27 01:40:10 +0000 | [diff] [blame] | 308 | void logLayerInfo(const RenderLayer*, int depth); |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 309 | #endif |
| 310 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 311 | private: |
| 312 | RenderView* m_renderView; |
simon.fraser@apple.com | 2d3dba2 | 2011-07-12 22:21:29 +0000 | [diff] [blame] | 313 | OwnPtr<GraphicsLayer> m_rootContentLayer; |
simon.fraser@apple.com | bd17434 | 2010-08-25 18:24:17 +0000 | [diff] [blame] | 314 | Timer<RenderLayerCompositor> m_updateCompositingLayersTimer; |
| 315 | |
simon.fraser@apple.com | 02f4049 | 2009-07-07 17:15:16 +0000 | [diff] [blame] | 316 | bool m_hasAcceleratedCompositing; |
vangelis@chromium.org | 1bbe613 | 2010-11-30 20:41:59 +0000 | [diff] [blame] | 317 | ChromeClient::CompositingTriggerFlags m_compositingTriggers; |
| 318 | |
simon.fraser@apple.com | 47560da | 2011-10-21 03:02:05 +0000 | [diff] [blame] | 319 | int m_compositedLayerCount; |
cmarrin@apple.com | f2dff33 | 2009-11-18 19:23:44 +0000 | [diff] [blame] | 320 | bool m_showDebugBorders; |
| 321 | bool m_showRepaintCounter; |
simon.fraser@apple.com | 5cce05c | 2012-03-23 21:40:21 +0000 | [diff] [blame] | 322 | bool m_acceleratedDrawingEnabled; |
simon.fraser@apple.com | 02f4049 | 2009-07-07 17:15:16 +0000 | [diff] [blame] | 323 | bool m_compositingConsultsOverlap; |
simon.fraser@apple.com | bda4184 | 2010-07-13 00:40:47 +0000 | [diff] [blame] | 324 | |
| 325 | // When true, we have to wait until layout has happened before we can decide whether to enter compositing mode, |
| 326 | // because only then do we know the final size of plugins and iframes. |
simon.fraser@apple.com | 06a2bbb | 2012-04-20 21:54:45 +0000 | [diff] [blame] | 327 | mutable bool m_reevaluateCompositingAfterLayout; |
vangelis@chromium.org | e910d23 | 2011-10-27 20:28:40 +0000 | [diff] [blame] | 328 | |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 329 | bool m_compositing; |
simon.fraser@apple.com | 02f4049 | 2009-07-07 17:15:16 +0000 | [diff] [blame] | 330 | bool m_compositingLayersNeedRebuild; |
simon.fraser@apple.com | c961f41 | 2011-01-20 03:20:47 +0000 | [diff] [blame] | 331 | bool m_flushingLayers; |
commit-queue@webkit.org | a8f8e9e | 2011-03-16 23:37:48 +0000 | [diff] [blame] | 332 | bool m_forceCompositingMode; |
simon.fraser@apple.com | bda4184 | 2010-07-13 00:40:47 +0000 | [diff] [blame] | 333 | |
simon.fraser@apple.com | 509623e | 2010-05-11 05:33:23 +0000 | [diff] [blame] | 334 | RootLayerAttachment m_rootLayerAttachment; |
cmarrin@apple.com | 10c77cf | 2010-05-05 01:50:03 +0000 | [diff] [blame] | 335 | |
| 336 | // Enclosing clipping layer for iframe content |
simon.fraser@apple.com | e38ba06 | 2010-05-13 23:14:46 +0000 | [diff] [blame] | 337 | OwnPtr<GraphicsLayer> m_clipLayer; |
| 338 | OwnPtr<GraphicsLayer> m_scrollLayer; |
jamesr@google.com | e53ce64 | 2011-04-14 06:51:50 +0000 | [diff] [blame] | 339 | |
| 340 | // Enclosing layer for overflow controls and the clipping layer |
| 341 | OwnPtr<GraphicsLayer> m_overflowControlsHostLayer; |
| 342 | |
| 343 | // Layers for overflow controls |
| 344 | OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar; |
| 345 | OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar; |
| 346 | OwnPtr<GraphicsLayer> m_layerForScrollCorner; |
andersca@apple.com | 134cfff | 2012-01-13 00:30:55 +0000 | [diff] [blame] | 347 | #if ENABLE(RUBBER_BANDING) |
commit-queue@webkit.org | 0a4465d | 2011-09-15 04:06:49 +0000 | [diff] [blame] | 348 | OwnPtr<GraphicsLayer> m_layerForOverhangAreas; |
andersca@apple.com | b2abfa6 | 2012-02-08 20:24:57 +0000 | [diff] [blame] | 349 | OwnPtr<GraphicsLayer> m_contentShadowLayer; |
commit-queue@webkit.org | 0a4465d | 2011-09-15 04:06:49 +0000 | [diff] [blame] | 350 | #endif |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 351 | |
| 352 | #if !LOG_DISABLED |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 353 | int m_rootLayerUpdateCount; |
simon.fraser@apple.com | a7f01bd | 2012-04-25 04:30:13 +0000 | [diff] [blame] | 354 | int m_obligateCompositedLayerCount; // count of layer that have to be composited. |
| 355 | int m_secondaryCompositedLayerCount; // count of layers that have to be composited because of stacking or overlap. |
simon.fraser@apple.com | a46313b | 2012-06-28 20:28:42 +0000 | [diff] [blame] | 356 | double m_obligatoryBackingStoreBytes; |
| 357 | double m_secondaryBackingStoreBytes; |
simon.fraser@apple.com | 6d640a0 | 2009-01-31 01:47:49 +0000 | [diff] [blame] | 358 | #endif |
| 359 | }; |
| 360 | |
| 361 | |
| 362 | } // namespace WebCore |
| 363 | |
| 364 | #endif // RenderLayerCompositor_h |