Prepare for debug CMake builds on Windows.
[WebKit-https.git] / Source / WebCore / rendering / RenderLayerCompositor.h
1 /*
2  * Copyright (C) 2009, 2013 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 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
29 #include "ChromeClient.h"
30 #include "GraphicsLayerClient.h"
31 #include "GraphicsLayerUpdater.h"
32 #include "RenderLayer.h"
33 #include <wtf/HashMap.h>
34
35 namespace WebCore {
36
37 class FixedPositionViewportConstraints;
38 class GraphicsLayer;
39 class GraphicsLayerUpdater;
40 class RenderEmbeddedObject;
41 class RenderNamedFlowFragment;
42 class RenderVideo;
43 class RenderWidget;
44 class ScrollingCoordinator;
45 class StickyPositionViewportConstraints;
46 class TiledBacking;
47
48 typedef unsigned LayerTreeFlags;
49
50 enum CompositingUpdateType {
51     CompositingUpdateAfterStyleChange,
52     CompositingUpdateAfterLayout,
53     CompositingUpdateOnHitTest,
54     CompositingUpdateOnScroll,
55     CompositingUpdateOnCompositedScroll
56 };
57
58 enum {
59     CompositingReasonNone                                   = 0,
60     CompositingReason3DTransform                            = 1 << 0,
61     CompositingReasonVideo                                  = 1 << 1,
62     CompositingReasonCanvas                                 = 1 << 2,
63     CompositingReasonPlugin                                 = 1 << 3,
64     CompositingReasonIFrame                                 = 1 << 4,
65     CompositingReasonBackfaceVisibilityHidden               = 1 << 5,
66     CompositingReasonClipsCompositingDescendants            = 1 << 6,
67     CompositingReasonAnimation                              = 1 << 7,
68     CompositingReasonFilters                                = 1 << 8,
69     CompositingReasonPositionFixed                          = 1 << 9,
70     CompositingReasonPositionSticky                         = 1 << 10,
71     CompositingReasonOverflowScrollingTouch                 = 1 << 11,
72     CompositingReasonStacking                               = 1 << 12,
73     CompositingReasonOverlap                                = 1 << 13,
74     CompositingReasonNegativeZIndexChildren                 = 1 << 14,
75     CompositingReasonTransformWithCompositedDescendants     = 1 << 15,
76     CompositingReasonOpacityWithCompositedDescendants       = 1 << 16,
77     CompositingReasonMaskWithCompositedDescendants          = 1 << 17,
78     CompositingReasonReflectionWithCompositedDescendants    = 1 << 18,
79     CompositingReasonFilterWithCompositedDescendants        = 1 << 19,
80     CompositingReasonBlendingWithCompositedDescendants      = 1 << 20,
81     CompositingReasonPerspective                            = 1 << 21,
82     CompositingReasonPreserve3D                             = 1 << 22,
83     CompositingReasonRoot                                   = 1 << 23,
84     CompositingReasonIsolatesCompositedBlendingDescendants  = 1 << 24,
85 };
86 typedef unsigned CompositingReasons;
87
88 // RenderLayerCompositor manages the hierarchy of
89 // composited RenderLayers. It determines which RenderLayers
90 // become compositing, and creates and maintains a hierarchy of
91 // GraphicsLayers based on the RenderLayer painting order.
92 // 
93 // There is one RenderLayerCompositor per RenderView.
94
95 class RenderLayerCompositor final : public GraphicsLayerClient, public GraphicsLayerUpdaterClient {
96     WTF_MAKE_FAST_ALLOCATED;
97 public:
98     explicit RenderLayerCompositor(RenderView&);
99     virtual ~RenderLayerCompositor();
100
101     // Return true if this RenderView is in "compositing mode" (i.e. has one or more
102     // composited RenderLayers)
103     bool inCompositingMode() const { return m_compositing; }
104     // This will make a compositing layer at the root automatically, and hook up to
105     // the native view/window system.
106     void enableCompositingMode(bool enable = true);
107
108     bool inForcedCompositingMode() const { return m_forceCompositingMode; }
109
110     // Returns true if the accelerated compositing is enabled
111     bool hasAcceleratedCompositing() const { return m_hasAcceleratedCompositing; }
112
113     bool canRender3DTransforms() const;
114
115     // Copy the accelerated compositing related flags from Settings
116     void cacheAcceleratedCompositingFlags();
117
118     // Called when the layer hierarchy needs to be updated (compositing layers have been
119     // created, destroyed or re-parented).
120     void setCompositingLayersNeedRebuild(bool needRebuild = true);
121     bool compositingLayersNeedRebuild() const { return m_compositingLayersNeedRebuild; }
122     
123     void willRecalcStyle();
124
125     // Returns true if the composited layers were actually updated.
126     bool didRecalcStyleWithNoPendingLayout();
127
128     // GraphicsLayers buffer state, which gets pushed to the underlying platform layers
129     // at specific times.
130     void scheduleLayerFlush(bool canThrottle);
131     void flushPendingLayerChanges(bool isFlushRoot = true);
132     
133     // flushPendingLayerChanges() flushes the entire GraphicsLayer tree, which can cross frame boundaries.
134     // This call returns the rootmost compositor that is being flushed (including self).
135     RenderLayerCompositor* enclosingCompositorFlushingLayers() const;
136
137     // Called when the GraphicsLayer for the given RenderLayer has flushed changes inside of flushPendingLayerChanges().
138     void didFlushChangesForLayer(RenderLayer&, const GraphicsLayer*);
139
140     // Called when something outside WebKit affects the visible rect (e.g. delegated scrolling). Might schedule a layer flush.
141     void didChangeVisibleRect();
142     
143     // Rebuild the tree of compositing layers
144     bool updateCompositingLayers(CompositingUpdateType, RenderLayer* updateRoot = nullptr);
145     // This is only used when state changes and we do not exepect a style update or layout to happen soon (e.g. when
146     // we discover that an iframe is overlapped during painting).
147     void scheduleCompositingLayerUpdate();
148     // This is used to cancel any pending update timers when the document goes into page cache.
149     void cancelCompositingLayerUpdate();
150
151     // Update the compositing state of the given layer. Returns true if that state changed.
152     enum CompositingChangeRepaint { CompositingChangeRepaintNow, CompositingChangeWillRepaintLater };
153     bool updateLayerCompositingState(RenderLayer&, CompositingChangeRepaint = CompositingChangeRepaintNow);
154
155     // Update the geometry for compositing children of compositingAncestor.
156     void updateCompositingDescendantGeometry(RenderLayer& compositingAncestor, RenderLayer&, bool compositedChildrenOnly);
157     
158     // Whether layer's backing needs a graphics layer to do clipping by an ancestor (non-stacking-context parent with overflow).
159     bool clippedByAncestor(RenderLayer&) const;
160     // Whether layer's backing needs a graphics layer to clip z-order children of the given layer.
161     bool clipsCompositingDescendants(const RenderLayer&) const;
162
163     // Whether the given layer needs an extra 'contents' layer.
164     bool needsContentsCompositingLayer(const RenderLayer&) const;
165
166     bool supportsFixedRootBackgroundCompositing() const;
167     bool needsFixedRootBackgroundLayer(const RenderLayer&) const;
168     GraphicsLayer* fixedRootBackgroundLayer() const;
169
170     void rootOrBodyStyleChanged(RenderElement&, const RenderStyle* oldStyle);
171
172     // Called after the view transparency, or the document or base background color change.
173     void rootBackgroundTransparencyChanged();
174     
175     // Repaint the appropriate layers when the given RenderLayer starts or stops being composited.
176     void repaintOnCompositingChange(RenderLayer&);
177     
178     void repaintInCompositedAncestor(RenderLayer&, const LayoutRect&);
179     
180     // Notify us that a layer has been added or removed
181     void layerWasAdded(RenderLayer& parent, RenderLayer& child);
182     void layerWillBeRemoved(RenderLayer& parent, RenderLayer& child);
183
184     void layerStyleChanged(StyleDifference, RenderLayer&, const RenderStyle* oldStyle);
185
186     static bool canCompositeClipPath(const RenderLayer&);
187
188     // Get the nearest ancestor layer that has overflow or clip, but is not a stacking context
189     RenderLayer* enclosingNonStackingClippingLayer(const RenderLayer&) const;
190
191     // Repaint all composited layers.
192     void repaintCompositedLayers();
193
194     // Returns true if the given layer needs it own backing store.
195     bool requiresOwnBackingStore(const RenderLayer&, const RenderLayer* compositingAncestorLayer, const LayoutRect& layerCompositedBoundsInAncestor, const LayoutRect& ancestorCompositedBounds) const;
196
197     WEBCORE_EXPORT RenderLayer& rootRenderLayer() const;
198     GraphicsLayer* rootGraphicsLayer() const;
199     WEBCORE_EXPORT GraphicsLayer* scrollLayer() const;
200     GraphicsLayer* clipLayer() const;
201     GraphicsLayer* rootContentLayer() const;
202
203 #if ENABLE(RUBBER_BANDING)
204     GraphicsLayer* headerLayer() const;
205     GraphicsLayer* footerLayer() const;
206 #endif
207
208     enum RootLayerAttachment {
209         RootLayerUnattached,
210         RootLayerAttachedViaChromeClient,
211         RootLayerAttachedViaEnclosingFrame
212     };
213
214     RootLayerAttachment rootLayerAttachment() const { return m_rootLayerAttachment; }
215     void updateRootLayerAttachment();
216     void updateRootLayerPosition();
217     
218     void setIsInWindow(bool);
219
220     void clearBackingForAllLayers();
221     
222     void layerBecameComposited(const RenderLayer&) { ++m_compositedLayerCount; }
223     void layerBecameNonComposited(const RenderLayer&);
224     
225 #if ENABLE(VIDEO)
226     // Use by RenderVideo to ask if it should try to use accelerated compositing.
227     bool canAccelerateVideoRendering(RenderVideo&) const;
228 #endif
229
230     // Walk the tree looking for layers with 3d transforms. Useful in case you need
231     // to know if there is non-affine content, e.g. for drawing into an image.
232     bool has3DContent() const;
233     
234     static RenderLayerCompositor* frameContentsCompositor(RenderWidget*);
235     // Return true if the layers changed.
236     static bool parentFrameContentLayers(RenderWidget*);
237
238     // Update the geometry of the layers used for clipping and scrolling in frames.
239     void frameViewDidChangeLocation(const IntPoint& contentsOffset);
240     void frameViewDidChangeSize();
241     void frameViewDidScroll();
242     void frameViewDidAddOrRemoveScrollbars();
243     void frameViewDidLayout();
244     void rootFixedBackgroundsChanged();
245
246     void scrollingLayerDidChange(RenderLayer&);
247     void fixedRootBackgroundLayerChanged();
248
249     String layerTreeAsText(LayerTreeFlags);
250
251     virtual float deviceScaleFactor() const override;
252     virtual float contentsScaleMultiplierForNewTiles(const GraphicsLayer*) const override;
253     virtual float pageScaleFactor() const override;
254     virtual float zoomedOutPageScaleFactor() const override;
255
256     virtual void didCommitChangesForLayer(const GraphicsLayer*) const override;
257     virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) override;
258
259     void layerTiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/);
260     
261     bool acceleratedDrawingEnabled() const { return m_acceleratedDrawingEnabled; }
262
263     void deviceOrPageScaleFactorChanged();
264
265     void windowScreenDidChange(PlatformDisplayID);
266
267     GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); }
268     GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); }
269     GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.get(); }
270 #if ENABLE(RUBBER_BANDING)
271     GraphicsLayer* layerForOverhangAreas() const { return m_layerForOverhangAreas.get(); }
272     GraphicsLayer* layerForContentShadow() const { return m_contentShadowLayer.get(); }
273
274     GraphicsLayer* updateLayerForTopOverhangArea(bool wantsLayer);
275     GraphicsLayer* updateLayerForBottomOverhangArea(bool wantsLayer);
276     GraphicsLayer* updateLayerForHeader(bool wantsLayer);
277     GraphicsLayer* updateLayerForFooter(bool wantsLayer);
278 #endif
279
280     ScrollableArea* scrollableAreaForScrollLayerID(ScrollingNodeID) const;
281
282     void updateScrollCoordinatedStatus(RenderLayer&);
283     void removeFromScrollCoordinatedLayers(RenderLayer&);
284
285     void willRemoveScrollingLayerWithBacking(RenderLayer&, RenderLayerBacking&);
286     void didAddScrollingLayer(RenderLayer&);
287
288 #if PLATFORM(IOS)
289     void registerAllViewportConstrainedLayers();
290     void unregisterAllViewportConstrainedLayers();
291
292     void registerAllScrollingLayers();
293     void unregisterAllScrollingLayers();
294 #endif
295
296     void resetTrackedRepaintRects();
297     void setTracksRepaints(bool);
298
299     void setShouldReevaluateCompositingAfterLayout() { m_reevaluateCompositingAfterLayout = true; }
300
301     bool viewHasTransparentBackground(Color* backgroundColor = nullptr) const;
302
303     bool hasNonMainLayersWithTiledBacking() const { return m_layersWithTiledBackingCount; }
304
305     CompositingReasons reasonsForCompositing(const RenderLayer&) const;
306
307     void setLayerFlushThrottlingEnabled(bool);
308     void disableLayerFlushThrottlingTemporarilyForInteraction();
309     
310     void didPaintBacking(RenderLayerBacking*);
311
312     void setRootExtendedBackgroundColor(const Color&);
313     Color rootExtendedBackgroundColor() const { return m_rootExtendedBackgroundColor; }
314
315     // For testing.
316     WEBCORE_EXPORT void startTrackingLayerFlushes();
317     WEBCORE_EXPORT unsigned layerFlushCount() const;
318
319     WEBCORE_EXPORT void startTrackingCompositingUpdates();
320     WEBCORE_EXPORT unsigned compositingUpdateCount() const;
321
322 private:
323     class OverlapMap;
324     struct CompositingState;
325     struct OverlapExtent;
326
327     // GraphicsLayerClient implementation
328     virtual void notifyFlushRequired(const GraphicsLayer*) override;
329     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect&) override;
330     virtual void customPositionForVisibleRectComputation(const GraphicsLayer*, FloatPoint&) const override;
331     virtual bool isTrackingRepaints() const override;
332     
333     // GraphicsLayerUpdaterClient implementation
334     virtual void flushLayersSoon(GraphicsLayerUpdater&) override;
335
336     // Whether the given RL needs a compositing layer.
337     bool needsToBeComposited(const RenderLayer&, RenderLayer::ViewportConstrainedNotCompositedReason* = nullptr) const;
338     // Whether the layer has an intrinsic need for compositing layer.
339     bool requiresCompositingLayer(const RenderLayer&, RenderLayer::ViewportConstrainedNotCompositedReason* = nullptr) const;
340     // Whether the layer could ever be composited.
341     bool canBeComposited(const RenderLayer&) const;
342
343     // Make or destroy the backing for this layer; returns true if backing changed.
344     enum class BackingRequired { No, Yes, Unknown };
345     bool updateBacking(RenderLayer&, CompositingChangeRepaint shouldRepaint, BackingRequired = BackingRequired::Unknown);
346
347     void clearBackingForLayerIncludingDescendants(RenderLayer&);
348     void setIsInWindowForLayerIncludingDescendants(RenderLayer&, bool isInWindow);
349
350     // Repaint this and its child layers.
351     void recursiveRepaintLayer(RenderLayer&);
352
353     void computeExtent(const OverlapMap&, const RenderLayer&, OverlapExtent&) const;
354     void addToOverlapMap(OverlapMap&, const RenderLayer&, OverlapExtent&);
355     void addToOverlapMapRecursive(OverlapMap&, const RenderLayer&, const RenderLayer* ancestorLayer = nullptr);
356
357     void updateCompositingLayersTimerFired();
358
359     // Returns true if any layer's compositing changed
360     void computeCompositingRequirements(RenderLayer* ancestorLayer, RenderLayer&, OverlapMap&, CompositingState&, bool& layersChanged, bool& descendantHas3DTransform);
361
362     void computeRegionCompositingRequirements(RenderNamedFlowFragment*, OverlapMap&, CompositingState&, bool& layersChanged, bool& anyDescendantHas3DTransform);
363
364     void computeCompositingRequirementsForNamedFlowFixed(RenderLayer&, OverlapMap&, CompositingState&, bool& layersChanged, bool& anyDescendantHas3DTransform);
365
366     // Recurses down the tree, parenting descendant compositing layers and collecting an array of child layers for the current compositing layer.
367     void rebuildCompositingLayerTree(RenderLayer&, Vector<GraphicsLayer*>& childGraphicsLayersOfEnclosingLayer, int depth);
368
369     // Recurses down the RenderFlowThread tree, parenting descendant compositing layers and collecting an array of child 
370     // layers for the current compositing layer corresponding to the anonymous region (that belongs to the region's parent).
371     void rebuildRegionCompositingLayerTree(RenderNamedFlowFragment*, Vector<GraphicsLayer*>& childList, int depth);
372
373     void rebuildCompositingLayerTreeForNamedFlowFixed(RenderLayer&, Vector<GraphicsLayer*>& childList, int depth);
374
375     // Recurses down the tree, updating layer geometry only.
376     void updateLayerTreeGeometry(RenderLayer&, int depth);
377     
378     // Hook compositing layers together
379     void setCompositingParent(RenderLayer& childLayer, RenderLayer* parentLayer);
380     void removeCompositedChildren(RenderLayer&);
381
382     bool layerHas3DContent(const RenderLayer&) const;
383     bool isRunningTransformAnimation(RenderLayerModelObject&) const;
384
385     void appendDocumentOverlayLayers(Vector<GraphicsLayer*>&);
386     bool hasAnyAdditionalCompositedLayers(const RenderLayer& rootLayer) const;
387
388     void ensureRootLayer();
389     void destroyRootLayer();
390
391     void attachRootLayer(RootLayerAttachment);
392     void detachRootLayer();
393     
394     void rootLayerAttachmentChanged();
395
396     void updateOverflowControlsLayers();
397
398     void updateScrollLayerPosition();
399
400     FloatPoint positionForClipLayer() const;
401
402     void notifyIFramesOfCompositingChange();
403
404     bool isFlushingLayers() const { return m_flushingLayers; }
405     void updateScrollCoordinatedLayersAfterFlushIncludingSubframes();
406     void updateScrollCoordinatedLayersAfterFlush();
407     
408     Page* page() const;
409     
410     GraphicsLayerFactory* graphicsLayerFactory() const;
411     ScrollingCoordinator* scrollingCoordinator() const;
412
413 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
414     RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override;
415 #endif
416
417     bool requiresCompositingForAnimation(RenderLayerModelObject&) const;
418     bool requiresCompositingForTransform(RenderLayerModelObject&) const;
419     bool requiresCompositingForBackfaceVisibility(RenderLayerModelObject&) const;
420     bool requiresCompositingForVideo(RenderLayerModelObject&) const;
421     bool requiresCompositingForCanvas(RenderLayerModelObject&) const;
422     bool requiresCompositingForPlugin(RenderLayerModelObject&) const;
423     bool requiresCompositingForFrame(RenderLayerModelObject&) const;
424     bool requiresCompositingForFilters(RenderLayerModelObject&) const;
425     bool requiresCompositingForScrollableFrame() const;
426     bool requiresCompositingForPosition(RenderLayerModelObject&, const RenderLayer&, RenderLayer::ViewportConstrainedNotCompositedReason* = nullptr) const;
427     bool requiresCompositingForOverflowScrolling(const RenderLayer&) const;
428     bool requiresCompositingForIndirectReason(RenderLayerModelObject&, bool hasCompositedDescendants, bool has3DTransformedDescendants, RenderLayer::IndirectCompositingReason&) const;
429
430 #if PLATFORM(IOS)
431     bool requiresCompositingForScrolling(const RenderLayer&) const;
432
433     void updateCustomLayersAfterFlush();
434
435     ChromeClient* chromeClient() const;
436
437 #endif
438
439     void updateScrollCoordinationForThisFrame(ScrollingNodeID);
440     ScrollingNodeID attachScrollingNode(RenderLayer&, ScrollingNodeType, ScrollingNodeID parentNodeID);
441     void updateScrollCoordinatedLayer(RenderLayer&, LayerScrollCoordinationRoles);
442     void detachScrollCoordinatedLayer(RenderLayer&, LayerScrollCoordinationRoles);
443     void reattachSubframeScrollLayers();
444     
445     FixedPositionViewportConstraints computeFixedViewportConstraints(RenderLayer&) const;
446     StickyPositionViewportConstraints computeStickyViewportConstraints(RenderLayer&) const;
447
448     bool requiresScrollLayer(RootLayerAttachment) const;
449     bool requiresHorizontalScrollbarLayer() const;
450     bool requiresVerticalScrollbarLayer() const;
451     bool requiresScrollCornerLayer() const;
452 #if ENABLE(RUBBER_BANDING)
453     bool requiresOverhangAreasLayer() const;
454     bool requiresContentShadowLayer() const;
455 #endif
456
457     // True if the FrameView uses a ScrollingCoordinator.
458     bool hasCoordinatedScrolling() const;
459
460     bool isAsyncScrollableStickyLayer(const RenderLayer&, const RenderLayer** enclosingAcceleratedOverflowLayer = nullptr) const;
461     bool isViewportConstrainedFixedOrStickyLayer(const RenderLayer&) const;
462     
463     bool shouldCompositeOverflowControls() const;
464
465     void scheduleLayerFlushNow();
466     bool isThrottlingLayerFlushes() const;
467     void startInitialLayerFlushTimerIfNeeded();
468     void startLayerFlushTimerIfNeeded();
469     void layerFlushTimerFired();
470
471     void paintRelatedMilestonesTimerFired();
472
473 #if !LOG_DISABLED
474     const char* logReasonsForCompositing(const RenderLayer&);
475     void logLayerInfo(const RenderLayer&, int depth);
476 #endif
477
478     bool documentUsesTiledBacking() const;
479     bool isMainFrameCompositor() const;
480
481 private:
482     RenderView& m_renderView;
483     std::unique_ptr<GraphicsLayer> m_rootContentLayer;
484     Timer m_updateCompositingLayersTimer;
485
486     bool m_hasAcceleratedCompositing;
487     ChromeClient::CompositingTriggerFlags m_compositingTriggers;
488
489     bool m_showDebugBorders;
490     bool m_showRepaintCounter;
491     bool m_acceleratedDrawingEnabled;
492
493     // When true, we have to wait until layout has happened before we can decide whether to enter compositing mode,
494     // because only then do we know the final size of plugins and iframes.
495     mutable bool m_reevaluateCompositingAfterLayout;
496
497     bool m_compositing;
498     bool m_compositingLayersNeedRebuild;
499     bool m_flushingLayers;
500     bool m_shouldFlushOnReattach;
501     bool m_forceCompositingMode;
502     bool m_inPostLayoutUpdate; // true when it's OK to trust layout information (e.g. layer sizes and positions)
503     bool m_subframeScrollLayersNeedReattach;
504
505     bool m_isTrackingRepaints; // Used for testing.
506
507     int m_compositedLayerCount { 0 };
508     unsigned m_layersWithTiledBackingCount { 0 };
509     unsigned m_layerFlushCount { 0 };
510     unsigned m_compositingUpdateCount { 0 };
511
512     RootLayerAttachment m_rootLayerAttachment;
513
514     // Enclosing clipping layer for iframe content
515     std::unique_ptr<GraphicsLayer> m_clipLayer;
516     std::unique_ptr<GraphicsLayer> m_scrollLayer;
517
518 #if PLATFORM(IOS)
519     HashSet<RenderLayer*> m_scrollingLayers;
520     HashSet<RenderLayer*> m_scrollingLayersNeedingUpdate;
521 #endif
522     HashSet<RenderLayer*> m_scrollCoordinatedLayers;
523     HashSet<RenderLayer*> m_scrollCoordinatedLayersNeedingUpdate;
524
525     // Enclosing layer for overflow controls and the clipping layer
526     std::unique_ptr<GraphicsLayer> m_overflowControlsHostLayer;
527
528     // Layers for overflow controls
529     std::unique_ptr<GraphicsLayer> m_layerForHorizontalScrollbar;
530     std::unique_ptr<GraphicsLayer> m_layerForVerticalScrollbar;
531     std::unique_ptr<GraphicsLayer> m_layerForScrollCorner;
532 #if ENABLE(RUBBER_BANDING)
533     std::unique_ptr<GraphicsLayer> m_layerForOverhangAreas;
534     std::unique_ptr<GraphicsLayer> m_contentShadowLayer;
535     std::unique_ptr<GraphicsLayer> m_layerForTopOverhangArea;
536     std::unique_ptr<GraphicsLayer> m_layerForBottomOverhangArea;
537     std::unique_ptr<GraphicsLayer> m_layerForHeader;
538     std::unique_ptr<GraphicsLayer> m_layerForFooter;
539 #endif
540
541     std::unique_ptr<GraphicsLayerUpdater> m_layerUpdater; // Updates tiled layer visible area periodically while animations are running.
542
543     Timer m_layerFlushTimer;
544     bool m_layerFlushThrottlingEnabled;
545     bool m_layerFlushThrottlingTemporarilyDisabledForInteraction;
546     bool m_hasPendingLayerFlush;
547     bool m_layerNeedsCompositingUpdate { false };
548     bool m_viewBackgroundIsTransparent { false };
549
550     Timer m_paintRelatedMilestonesTimer;
551
552 #if !LOG_DISABLED
553     int m_rootLayerUpdateCount { 0 };
554     int m_obligateCompositedLayerCount { 0 }; // count of layer that have to be composited.
555     int m_secondaryCompositedLayerCount { 0 }; // count of layers that have to be composited because of stacking or overlap.
556     double m_obligatoryBackingStoreBytes { 0 };
557     double m_secondaryBackingStoreBytes { 0 };
558 #endif
559
560     Color m_rootExtendedBackgroundColor;
561
562     HashMap<ScrollingNodeID, RenderLayer*> m_scrollingNodeToLayerMap;
563 };
564
565 void paintScrollbar(Scrollbar*, GraphicsContext&, const IntRect& clip);
566
567 } // namespace WebCore
568
569 #endif // RenderLayerCompositor_h