2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "WebAnimation.h"
31 #include "WebCommon.h"
33 #include "WebPrivatePtr.h"
35 #include "WebString.h"
36 #include "WebVector.h"
41 class WebAnimationDelegate;
42 class WebFilterOperations;
43 class WebTransformationMatrix;
52 #define WEBLAYER_IS_PURE_VIRTUAL
53 WEBKIT_EXPORT static WebLayer* create();
55 virtual ~WebLayer() { }
57 // Returns a positive ID that will be unique across all WebLayers allocated in this process.
58 virtual int id() const = 0;
60 // Sets a region of the layer as invalid, i.e. needs to update its content.
61 virtual void invalidateRect(const WebFloatRect&) = 0;
63 // Sets the entire layer as invalid, i.e. needs to update its content.
64 virtual void invalidate() = 0;
66 // These functions do not take ownership of the WebLayer* parameter.
67 virtual void addChild(WebLayer*) = 0;
68 virtual void insertChild(WebLayer*, size_t index) = 0;
69 virtual void replaceChild(WebLayer* reference, WebLayer* newLayer) = 0;
70 virtual void setChildren(const WebVector<WebLayer*>&) = 0;
71 virtual void removeFromParent() = 0;
72 virtual void removeAllChildren() = 0;
74 virtual void setAnchorPoint(const WebFloatPoint&) = 0;
75 virtual WebFloatPoint anchorPoint() const = 0;
77 virtual void setAnchorPointZ(float) = 0;
78 virtual float anchorPointZ() const = 0;
80 virtual void setBounds(const WebSize&) = 0;
81 virtual WebSize bounds() const = 0;
83 virtual void setMasksToBounds(bool) = 0;
84 virtual bool masksToBounds() const = 0;
86 virtual void setMaskLayer(WebLayer*) = 0;
87 virtual void setReplicaLayer(WebLayer*) = 0;
89 virtual void setOpacity(float) = 0;
90 virtual float opacity() const = 0;
92 virtual void setOpaque(bool) = 0;
93 virtual bool opaque() const = 0;
95 virtual void setPosition(const WebFloatPoint&) = 0;
96 virtual WebFloatPoint position() const = 0;
98 virtual void setSublayerTransform(const SkMatrix44&) = 0;
99 virtual void setSublayerTransform(const WebTransformationMatrix&) = 0;
100 virtual SkMatrix44 sublayerTransform() const = 0;
102 virtual void setTransform(const SkMatrix44&) = 0;
103 virtual void setTransform(const WebTransformationMatrix&) = 0;
104 virtual SkMatrix44 transform() const = 0;
106 // Sets whether the layer draws its content when compositing.
107 virtual void setDrawsContent(bool) = 0;
108 virtual bool drawsContent() const = 0;
110 virtual void setPreserves3D(bool) = 0;
112 // Mark that this layer should use its parent's transform and double-sided
113 // properties in determining this layer's backface visibility instead of
114 // using its own properties. If this property is set, this layer must
115 // have a parent, and the parent may not have this property set.
116 // Note: This API is to work around issues with visibility the handling of
117 // WebKit layers that have a contents layer (canvas, plugin, WebGL, video,
119 virtual void setUseParentBackfaceVisibility(bool) = 0;
121 virtual void setBackgroundColor(WebColor) = 0;
123 // Clear the filters in use by passing in a newly instantiated
124 // WebFilterOperations object.
125 virtual void setFilters(const WebFilterOperations&) = 0;
127 // Apply filters to pixels that show through the background of this layer.
128 // Note: These filters are only possible on layers that are drawn directly
129 // to a root render surface with an opaque background. This means if an
130 // ancestor of the background-filtered layer sets certain properties
131 // (opacity, transforms), it may conflict and hide the background filters.
132 virtual void setBackgroundFilters(const WebFilterOperations&) = 0;
134 virtual void setDebugBorderColor(const WebColor&) = 0;
135 virtual void setDebugBorderWidth(float) = 0;
136 virtual void setDebugName(WebString) = 0;
138 // An animation delegate is notified when animations are started and
139 // stopped. The WebLayer does not take ownership of the delegate, and it is
140 // the responsibility of the client to reset the layer's delegate before
141 // deleting the delegate.
142 virtual void setAnimationDelegate(WebAnimationDelegate*) = 0;
144 // Returns false if the animation cannot be added.
145 virtual bool addAnimation(WebAnimation*) = 0;
147 // Removes all animations with the given id.
148 virtual void removeAnimation(int animationId) = 0;
150 // Removes all animations with the given id targeting the given property.
151 virtual void removeAnimation(int animationId, WebAnimation::TargetProperty) = 0;
153 // Pauses all animations with the given id.
154 virtual void pauseAnimation(int animationId, double timeOffset) = 0;
156 // The following functions suspend and resume all animations. The given time
157 // is assumed to use the same time base as monotonicallyIncreasingTime().
158 virtual void suspendAnimations(double monotonicTime) = 0;
159 virtual void resumeAnimations(double monotonicTime) = 0;
161 // Returns true if this layer has any active animations - useful for tests.
162 virtual bool hasActiveAnimation() = 0;
164 // Transfers all animations running on the current layer.
165 virtual void transferAnimationsTo(WebLayer*) = 0;
168 virtual void setScrollPosition(WebPoint) = 0;
169 virtual void setScrollable(bool) = 0;
170 virtual void setHaveWheelEventHandlers(bool) = 0;
171 virtual void setShouldScrollOnMainThread(bool) = 0;
172 virtual void setNonFastScrollableRegion(const WebVector<WebRect>&) = 0;
173 virtual void setIsContainerForFixedPositionLayers(bool) = 0;
174 virtual void setFixedToContainerLayer(bool) = 0;
176 // Forces this layer to use a render surface. There is no benefit in doing
177 // so, but this is to facilitate benchmarks and tests.
178 virtual void setForceRenderSurface(bool) = 0;
181 } // namespace WebKit