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 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#pragma once
27
28#include "TiledBacking.h"
29#include <wtf/Forward.h>
30#include <wtf/OptionSet.h>
31
32namespace WebCore {
33
34class FloatPoint;
35class FloatRect;
36class GraphicsContext;
37class GraphicsLayer;
38class IntPoint;
39class IntRect;
40class TransformationMatrix;
41
42enum class GraphicsLayerPaintingPhase {
43 Background = 1 << 0,
44 Foreground = 1 << 1,
45 Mask = 1 << 2,
46 ClipPath = 1 << 3,
47 OverflowContents = 1 << 4,
48 CompositedScroll = 1 << 5,
49 ChildClippingMask = 1 << 6,
50};
51
52enum AnimatedPropertyID {
53 AnimatedPropertyInvalid,
54 AnimatedPropertyTransform,
55 AnimatedPropertyOpacity,
56 AnimatedPropertyBackgroundColor,
57 AnimatedPropertyFilter,
58#if ENABLE(FILTERS_LEVEL_2)
59 AnimatedPropertyWebkitBackdropFilter,
60#endif
61};
62
63enum LayerTreeAsTextBehaviorFlags {
64 LayerTreeAsTextBehaviorNormal = 0,
65 LayerTreeAsTextDebug = 1 << 0, // Dump extra debugging info like layer addresses.
66 LayerTreeAsTextIncludeVisibleRects = 1 << 1,
67 LayerTreeAsTextIncludeTileCaches = 1 << 2,
68 LayerTreeAsTextIncludeRepaintRects = 1 << 3,
69 LayerTreeAsTextIncludePaintingPhases = 1 << 4,
70 LayerTreeAsTextIncludeContentLayers = 1 << 5,
71 LayerTreeAsTextIncludePageOverlayLayers = 1 << 6,
72 LayerTreeAsTextIncludeAcceleratesDrawing = 1 << 7,
73 LayerTreeAsTextIncludeBackingStoreAttached = 1 << 8,
74 LayerTreeAsTextIncludeRootLayerProperties = 1 << 9,
75 LayerTreeAsTextIncludeEventRegion = 1 << 10,
76 LayerTreeAsTextShowAll = 0xFFFF
77};
78typedef unsigned LayerTreeAsTextBehavior;
79
80enum GraphicsLayerPaintFlags {
81 GraphicsLayerPaintNormal = 0,
82 GraphicsLayerPaintSnapshotting = 1 << 0,
83 GraphicsLayerPaintFirstTilePaint = 1 << 1,
84};
85typedef unsigned GraphicsLayerPaintBehavior;
86
87class GraphicsLayerClient {
88public:
89 virtual ~GraphicsLayerClient() = default;
90
91 virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) { }
92
93 // Callback for when hardware-accelerated animation started.
94 virtual void notifyAnimationStarted(const GraphicsLayer*, const String& /*animationKey*/, MonotonicTime /*time*/) { }
95 virtual void notifyAnimationEnded(const GraphicsLayer*, const String& /*animationKey*/) { }
96
97 // Notification that a layer property changed that requires a subsequent call to flushCompositingState()
98 // to appear on the screen.
99 virtual void notifyFlushRequired(const GraphicsLayer*) { }
100
101 // Notification that this layer requires a flush before the next display refresh.
102 virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) { }
103
104 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, OptionSet<GraphicsLayerPaintingPhase>,
105 const FloatRect& /* inClip */, GraphicsLayerPaintBehavior) { }
106 virtual void didChangePlatformLayerForLayer(const GraphicsLayer*) { }
107
108 // Provides current transform (taking transform-origin and animations into account). Input matrix has been
109 // initialized to identity already. Returns false if the layer has no transform.
110 virtual bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const { return false; }
111
112 // Allows the client to modify a layer position used during the visibleRect calculation, for example to ignore
113 // scroll overhang.
114 virtual void customPositionForVisibleRectComputation(const GraphicsLayer*, FloatPoint&) const { }
115
116 // Multiplier for backing store size, related to high DPI.
117 virtual float deviceScaleFactor() const { return 1; }
118 // Page scale factor.
119 virtual float pageScaleFactor() const { return 1; }
120 virtual float zoomedOutPageScaleFactor() const { return 0; }
121
122 virtual float contentsScaleMultiplierForNewTiles(const GraphicsLayer*) const { return 1; }
123 virtual bool paintsOpaquelyAtNonIntegralScales(const GraphicsLayer*) const { return false; }
124
125 virtual bool isTrackingRepaints() const { return false; }
126
127 virtual bool shouldSkipLayerInDump(const GraphicsLayer*, LayerTreeAsTextBehavior) const { return false; }
128 virtual bool shouldDumpPropertyForLayer(const GraphicsLayer*, const char*, LayerTreeAsTextBehavior) const { return true; }
129
130 virtual bool shouldAggressivelyRetainTiles(const GraphicsLayer*) const { return false; }
131 virtual bool shouldTemporarilyRetainTileCohorts(const GraphicsLayer*) const { return true; }
132
133 virtual bool useGiantTiles() const { return false; }
134
135 virtual bool needsPixelAligment() const { return false; }
136
137 virtual bool needsIOSDumpRenderTreeMainFrameRenderViewLayerIsAlwaysOpaqueHack(const GraphicsLayer&) const { return false; }
138
139 virtual void logFilledVisibleFreshTile(unsigned) { };
140
141#ifndef NDEBUG
142 // RenderLayerBacking overrides this to verify that it is not
143 // currently painting contents. An ASSERT fails, if it is.
144 // This is executed in GraphicsLayer construction and destruction
145 // to verify that we don't create or destroy GraphicsLayers
146 // while painting.
147 virtual void verifyNotPainting() { }
148#endif
149};
150
151} // namespace WebCore
152
153