2 * Copyright (C) 2009 Apple 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
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.
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 COMPUTER, 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.
26 #ifndef GraphicsLayerCA_h
27 #define GraphicsLayerCA_h
29 #if USE(ACCELERATED_COMPOSITING)
31 #include "GraphicsLayer.h"
32 #include <wtf/RetainPtr.h>
34 @
class WebAnimationDelegate
;
39 class GraphicsLayerCA
: public GraphicsLayer
{
42 GraphicsLayerCA(GraphicsLayerClient
*);
43 virtual ~GraphicsLayerCA();
45 virtual void setName(const String
&);
47 // for hosting this GraphicsLayer in a native layer hierarchy
48 virtual NativeLayer
nativeLayer() const;
50 virtual void addChild(GraphicsLayer
*);
51 virtual void addChildAtIndex(GraphicsLayer
*, int index
);
52 virtual void addChildAbove(GraphicsLayer
* layer
, GraphicsLayer
* sibling
);
53 virtual void addChildBelow(GraphicsLayer
* layer
, GraphicsLayer
* sibling
);
54 virtual bool replaceChild(GraphicsLayer
* oldChild
, GraphicsLayer
* newChild
);
56 virtual void removeFromParent();
58 virtual void setPosition(const FloatPoint
&);
59 virtual void setAnchorPoint(const FloatPoint3D
&);
60 virtual void setSize(const FloatSize
&);
62 virtual void setTransform(const TransformationMatrix
&);
64 virtual void setChildrenTransform(const TransformationMatrix
&);
66 virtual void setPreserves3D(bool);
67 virtual void setMasksToBounds(bool);
68 virtual void setDrawsContent(bool);
70 virtual void setBackgroundColor(const Color
&, const Animation
* anim
= 0, double beginTime
= 0);
71 virtual void clearBackgroundColor();
73 virtual void setContentsOpaque(bool);
74 virtual void setBackfaceVisibility(bool);
76 // return true if we started an animation
77 virtual bool setOpacity(float, const Animation
* anim
= 0, double beginTime
= 0);
79 virtual void setNeedsDisplay();
80 virtual void setNeedsDisplayInRect(const FloatRect
&);
82 virtual void suspendAnimations();
83 virtual void resumeAnimations();
85 virtual bool animateTransform(const TransformValueList
&, const IntSize
&, const Animation
*, double beginTime
, bool isTransition
);
86 virtual bool animateFloat(AnimatedPropertyID
, const FloatValueList
&, const Animation
*, double beginTime
);
88 virtual void setContentsToImage(Image
*);
89 virtual void setContentsToVideo(PlatformLayer
*);
90 virtual void clearContents();
92 virtual void updateContentsRect();
94 virtual PlatformLayer
* platformLayer() const;
96 virtual void setContentsScale(float);
98 virtual void setDebugBackgroundColor(const Color
&);
99 virtual void setDebugBorder(const Color
&, float borderWidth
);
100 virtual void setZPosition(float);
103 WebLayer
* primaryLayer() const { return m_transformLayer
.get() ? m_transformLayer
.get() : m_layer
.get(); }
104 WebLayer
* hostLayerForSublayers() const;
105 WebLayer
* layerForSuperlayer() const;
107 WebLayer
* animatedLayer(AnimatedPropertyID property
) const
109 return (property
== AnimatedPropertyBackgroundColor
) ? m_contentsLayer
.get() : primaryLayer();
112 void setBasicAnimation(AnimatedPropertyID
, TransformOperation::OperationType
, short index
, void* fromVal
, void* toVal
, bool isTransition
, const Animation
*, double time
);
113 void setKeyframeAnimation(AnimatedPropertyID
, TransformOperation::OperationType
, short index
, void* keys
, void* values
, void* timingFunctions
, bool isTransition
, const Animation
*, double time
);
115 virtual void removeAnimation(int index
, bool reset
);
117 bool requiresTiledLayer(const FloatSize
&) const;
118 void swapFromOrToTiledLayer(bool useTiledLayer
);
120 void setHasContentsLayer(bool);
121 void setContentsLayer(WebLayer
*);
122 void setContentsLayerFlipped(bool);
124 RetainPtr
<WebLayer
> m_layer
;
125 RetainPtr
<WebLayer
> m_transformLayer
;
126 RetainPtr
<WebLayer
> m_contentsLayer
;
128 RetainPtr
<WebAnimationDelegate
> m_animationDelegate
;
130 bool m_contentLayerForImageOrVideo
;
133 } // namespace WebCore
136 #endif // USE(ACCELERATED_COMPOSITING)
138 #endif // GraphicsLayerCA_h