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