Add animationDidEnd callbacks on GraphicsLayer
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / mac / PlatformCALayerRemote.h
1 /*
2  * Copyright (C) 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 PlatformCALayerRemote_h
27 #define PlatformCALayerRemote_h
28
29 #include "RemoteLayerTreeTransaction.h"
30 #include <WebCore/PlatformCALayer.h>
31 #include <WebCore/PlatformLayer.h>
32 #include <WebCore/TileController.h>
33
34 namespace WebCore {
35 class LayerPool;
36 }
37
38 namespace WebKit {
39
40 class RemoteLayerTreeContext;
41
42 class PlatformCALayerRemote : public WebCore::PlatformCALayer {
43 public:
44     static PassRefPtr<PlatformCALayerRemote> create(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext&);
45     static PassRefPtr<PlatformCALayerRemote> create(PlatformLayer *, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext&);
46     static PassRefPtr<PlatformCALayerRemote> create(const PlatformCALayerRemote&, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext&);
47
48     virtual ~PlatformCALayerRemote();
49
50     virtual PlatformLayer* platformLayer() const override { return nullptr; }
51
52     void recursiveBuildTransaction(RemoteLayerTreeContext&, RemoteLayerTreeTransaction&);
53
54     virtual void setNeedsDisplayInRect(const WebCore::FloatRect& dirtyRect) override;
55     virtual void setNeedsDisplay() override;
56
57     virtual void copyContentsFromLayer(PlatformCALayer*) override;
58
59     virtual WebCore::PlatformCALayer* superlayer() const override;
60     virtual void removeFromSuperlayer() override;
61     virtual void setSublayers(const WebCore::PlatformCALayerList&) override;
62     virtual void removeAllSublayers() override;
63     virtual void appendSublayer(WebCore::PlatformCALayer*) override;
64     virtual void insertSublayer(WebCore::PlatformCALayer*, size_t index) override;
65     virtual void replaceSublayer(WebCore::PlatformCALayer* reference, WebCore::PlatformCALayer*) override;
66     virtual const WebCore::PlatformCALayerList* customSublayers() const override { return nullptr; }
67     virtual void adoptSublayers(WebCore::PlatformCALayer* source) override;
68
69     virtual void addAnimationForKey(const String& key, WebCore::PlatformCAAnimation*) override;
70     virtual void removeAnimationForKey(const String& key) override;
71     virtual PassRefPtr<WebCore::PlatformCAAnimation> animationForKey(const String& key) override;
72     virtual void animationStarted(const String& key, CFTimeInterval beginTime) override;
73     virtual void animationEnded(const String& key) override;
74
75     virtual void setMask(WebCore::PlatformCALayer*) override;
76
77     virtual bool isOpaque() const override;
78     virtual void setOpaque(bool) override;
79
80     virtual WebCore::FloatRect bounds() const override;
81     virtual void setBounds(const WebCore::FloatRect&) override;
82
83     virtual WebCore::FloatPoint3D position() const override;
84     virtual void setPosition(const WebCore::FloatPoint3D&) override;
85
86     virtual WebCore::FloatPoint3D anchorPoint() const override;
87     virtual void setAnchorPoint(const WebCore::FloatPoint3D&) override;
88
89     virtual WebCore::TransformationMatrix transform() const override;
90     virtual void setTransform(const WebCore::TransformationMatrix&) override;
91
92     virtual WebCore::TransformationMatrix sublayerTransform() const override;
93     virtual void setSublayerTransform(const WebCore::TransformationMatrix&) override;
94
95     virtual void setHidden(bool) override;
96
97     virtual void setGeometryFlipped(bool) override;
98
99     virtual bool isDoubleSided() const override;
100     virtual void setDoubleSided(bool) override;
101
102     virtual bool masksToBounds() const override;
103     virtual void setMasksToBounds(bool) override;
104
105     virtual bool acceleratesDrawing() const override;
106     virtual void setAcceleratesDrawing(bool) override;
107
108     virtual CFTypeRef contents() const override;
109     virtual void setContents(CFTypeRef) override;
110
111     virtual void setContentsRect(const WebCore::FloatRect&) override;
112
113     virtual void setMinificationFilter(WebCore::PlatformCALayer::FilterType) override;
114     virtual void setMagnificationFilter(WebCore::PlatformCALayer::FilterType) override;
115
116     virtual WebCore::Color backgroundColor() const override;
117     virtual void setBackgroundColor(const WebCore::Color&) override;
118
119     virtual void setBorderWidth(float) override;
120     virtual void setBorderColor(const WebCore::Color&) override;
121
122     virtual float opacity() const override;
123     virtual void setOpacity(float) override;
124
125 #if ENABLE(CSS_FILTERS)
126     virtual void setFilters(const WebCore::FilterOperations&) override;
127     static bool filtersCanBeComposited(const WebCore::FilterOperations&);
128     virtual void copyFiltersFrom(const WebCore::PlatformCALayer*) override;
129 #endif
130
131 #if ENABLE(CSS_COMPOSITING)
132     virtual void setBlendMode(WebCore::BlendMode) override;
133 #endif
134
135     virtual void setName(const String&) override;
136
137     virtual void setSpeed(float) override;
138
139     virtual void setTimeOffset(CFTimeInterval) override;
140
141     virtual float contentsScale() const override;
142     virtual void setContentsScale(float) override;
143
144     virtual void setEdgeAntialiasingMask(unsigned) override;
145
146     virtual WebCore::GraphicsLayer::CustomAppearance customAppearance() const override;
147     virtual void updateCustomAppearance(WebCore::GraphicsLayer::CustomAppearance) override;
148
149     virtual WebCore::GraphicsLayer::CustomBehavior customBehavior() const override;
150     virtual void updateCustomBehavior(WebCore::GraphicsLayer::CustomBehavior) override;
151
152     virtual WebCore::TiledBacking* tiledBacking() override { return nullptr; }
153
154     virtual PassRefPtr<WebCore::PlatformCALayer> clone(WebCore::PlatformCALayerClient* owner) const override;
155
156     virtual PassRefPtr<PlatformCALayer> createCompatibleLayer(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient*) const override;
157
158     virtual void enumerateRectsBeingDrawn(CGContextRef, void (^block)(CGRect)) override;
159
160     virtual uint32_t hostingContextID();
161
162     void setClonedLayer(const PlatformCALayer*);
163
164     RemoteLayerTreeTransaction::LayerProperties& properties() { return m_properties; }
165     const RemoteLayerTreeTransaction::LayerProperties& properties() const { return m_properties; }
166
167     void didCommit();
168
169     void clearContext() { m_context = nullptr; }
170     RemoteLayerTreeContext* context() const { return m_context; }
171
172 protected:
173     PlatformCALayerRemote(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext& context);
174     PlatformCALayerRemote(const PlatformCALayerRemote&, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext&);
175
176     void updateClonedLayerProperties(PlatformCALayerRemote& clone, bool copyContents = true) const;
177
178 private:
179     virtual bool isPlatformCALayerRemote() const override { return true; }
180     void ensureBackingStore();
181     void updateBackingStore();
182     void removeSublayer(PlatformCALayerRemote*);
183
184     bool requiresCustomAppearanceUpdateOnBoundsChange() const;
185
186     virtual WebCore::LayerPool& layerPool() override;
187
188     RemoteLayerTreeTransaction::LayerProperties m_properties;
189     WebCore::PlatformCALayerList m_children;
190     PlatformCALayerRemote* m_superlayer;
191     PlatformCALayerRemote* m_maskLayer;
192     HashMap<String, RefPtr<WebCore::PlatformCAAnimation>> m_animations;
193     bool m_acceleratesDrawing;
194
195     RemoteLayerTreeContext* m_context;
196 };
197
198 PLATFORM_CALAYER_TYPE_CASTS(PlatformCALayerRemote, isPlatformCALayerRemote())
199
200 } // namespace WebKit
201
202 #endif // PlatformCALayerRemote_h