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
31namespace WebCore {
32
33class FloatPoint;
34class FloatRect;
35class GraphicsContext;
36class GraphicsLayer;
37class IntPoint;
38class IntRect;
39class TransformationMatrix;
40
41enum GraphicsLayerPaintingPhaseFlags {
42 GraphicsLayerPaintBackground = 1 << 0,
43 GraphicsLayerPaintForeground = 1 << 1,
44 GraphicsLayerPaintMask = 1 << 2,
45 GraphicsLayerPaintClipPath = 1 << 3,
46 GraphicsLayerPaintOverflowContents = 1 << 4,
47 GraphicsLayerPaintCompositedScroll = 1 << 5,
48 GraphicsLayerPaintChildClippingMask = 1 << 6,
49 GraphicsLayerPaintAllWithOverflowClip = GraphicsLayerPaintBackground | GraphicsLayerPaintForeground
50};
51typedef uint8_t GraphicsLayerPaintingPhase;
52
53enum AnimatedPropertyID {
54 AnimatedPropertyInvalid,
55 AnimatedPropertyTransform,
56 AnimatedPropertyOpacity,
57 AnimatedPropertyBackgroundColor,
58 AnimatedPropertyFilter,
59#if ENABLE(FILTERS_LEVEL_2)
60 AnimatedPropertyWebkitBackdropFilter,
61#endif
62};
63
64enum LayerTreeAsTextBehaviorFlags {
65 LayerTreeAsTextBehaviorNormal = 0,
66 LayerTreeAsTextDebug = 1 << 0, // Dump extra debugging info like layer addresses.
67 LayerTreeAsTextIncludeVisibleRects = 1 << 1,
68 LayerTreeAsTextIncludeTileCaches = 1 << 2,
69 LayerTreeAsTextIncludeRepaintRects = 1 << 3,
70 LayerTreeAsTextIncludePaintingPhases = 1 << 4,
71 LayerTreeAsTextIncludeContentLayers = 1 << 5,
72 LayerTreeAsTextIncludePageOverlayLayers = 1 << 6,
73 LayerTreeAsTextIncludeAcceleratesDrawing = 1 << 7,
74 LayerTreeAsTextIncludeBackingStoreAttached = 1 << 8,
75 LayerTreeAsTextIncludeRootLayerProperties = 1 << 9,
76 LayerTreeAsTextIncludeEventRegion = 1 << 10,
77 LayerTreeAsTextShowAll = 0xFFFF
78};
79typedef unsigned LayerTreeAsTextBehavior;
80
81enum GraphicsLayerPaintFlags {
82 GraphicsLayerPaintNormal = 0,
83 GraphicsLayerPaintSnapshotting = 1 << 0,
84 GraphicsLayerPaintFirstTilePaint = 1 << 1,
85};
86typedef unsigned GraphicsLayerPaintBehavior;
87
88class GraphicsLayerClient {
89public:
90 virtual ~GraphicsLayerClient() = default;
91
92 virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) { }
93
94 // Callback for when hardware-accelerated animation started.
95 virtual void notifyAnimationStarted(const GraphicsLayer*, const String& /*animationKey*/, MonotonicTime /*time*/) { }
96 virtual void notifyAnimationEnded(const GraphicsLayer*, const String& /*animationKey*/) { }
97
98 // Notification that a layer property changed that requires a subsequent call to flushCompositingState()
99 // to appear on the screen.
100 virtual void notifyFlushRequired(const GraphicsLayer*) { }
101
102 // Notification that this layer requires a flush before the next display refresh.
103 virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) { }
104
105 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, 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