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