1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
|
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PlatformCALayer_h
#define PlatformCALayer_h
#if USE(ACCELERATED_COMPOSITING)
#include "GraphicsContext.h"
#include "PlatformCAAnimation.h"
#include "PlatformCALayerClient.h"
#include <QuartzCore/CABase.h>
#include <wtf/CurrentTime.h>
#include <wtf/HashMap.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
OBJC_CLASS AVPlayerLayer;
namespace WebCore {
class PlatformCALayer;
typedef Vector<RefPtr<PlatformCALayer> > PlatformCALayerList;
class PlatformCALayer : public RefCounted<PlatformCALayer> {
public:
static CFTimeInterval currentTimeToMediaTime(double t) { return CACurrentMediaTime() + t - WTF::currentTime(); }
// LayerTypeRootLayer is used on some platforms. It has no backing store, so setNeedsDisplay
// should not call CACFLayerSetNeedsDisplay, but rather just notify the renderer that it
// has changed and should be re-rendered.
enum LayerType {
LayerTypeLayer,
LayerTypeWebLayer,
LayerTypeTransformLayer,
LayerTypeWebTiledLayer,
LayerTypeTiledBackingLayer,
LayerTypePageTiledBackingLayer,
LayerTypeRootLayer,
LayerTypeAVPlayerLayer,
LayerTypeCustom
};
enum FilterType { Linear, Nearest, Trilinear };
static PassRefPtr<PlatformCALayer> create(LayerType, PlatformCALayerClient*);
// This function passes the layer as a void* rather than a PlatformLayer because PlatformLayer
// is defined differently for Obj C and C++. This allows callers from both languages.
static PassRefPtr<PlatformCALayer> create(void* platformLayer, PlatformCALayerClient*);
PassRefPtr<PlatformCALayer> clone(PlatformCALayerClient*) const;
~PlatformCALayer();
// This function passes the layer as a void* rather than a PlatformLayer because PlatformLayer
// is defined differently for Obj C and C++. This allows callers from both languages.
static PlatformCALayer* platformCALayer(void* platformLayer);
PlatformLayer* platformLayer() const;
#if PLATFORM(WIN)
bool usesTiledBackingLayer() const { return false; }
#else
bool usesTiledBackingLayer() const { return m_layerType == LayerTypePageTiledBackingLayer || m_layerType == LayerTypeTiledBackingLayer; }
#endif
PlatformCALayer* rootLayer() const;
// A list of sublayers that GraphicsLayerCA should maintain as the first sublayers.
const PlatformCALayerList* customSublayers() const { return m_customSublayers.get(); }
static bool isValueFunctionSupported();
PlatformCALayerClient* owner() const { return m_owner; }
void setOwner(PlatformCALayerClient*);
void animationStarted(CFTimeInterval beginTime);
void ensureAnimationsSubmitted();
// Layout support
void setNeedsLayout();
void setNeedsDisplay(const FloatRect* dirtyRect = 0);
// This tells the layer tree to commit changes and perform a render, without do a setNeedsDisplay on any layer.
void setNeedsCommit();
void setContentsChanged();
LayerType layerType() const { return m_layerType; }
PlatformCALayer* superlayer() const;
void removeFromSuperlayer();
void setSublayers(const PlatformCALayerList&);
void removeAllSublayers();
void appendSublayer(PlatformCALayer*);
void insertSublayer(PlatformCALayer*, size_t index);
void replaceSublayer(PlatformCALayer* reference, PlatformCALayer*);
size_t sublayerCount() const;
// This method removes the sublayers from the source and reparents them to the current layer.
// Any sublayers previously in the current layer are removed.
void adoptSublayers(PlatformCALayer* source);
void addAnimationForKey(const String& key, PlatformCAAnimation* animation);
void removeAnimationForKey(const String& key);
PassRefPtr<PlatformCAAnimation> animationForKey(const String& key);
PlatformCALayer* mask() const;
void setMask(PlatformCALayer*);
bool isOpaque() const;
void setOpaque(bool);
FloatRect bounds() const;
void setBounds(const FloatRect&);
FloatPoint3D position() const;
void setPosition(const FloatPoint3D&);
void setPosition(const FloatPoint& pos) { setPosition(FloatPoint3D(pos.x(), pos.y(), 0)); }
FloatPoint3D anchorPoint() const;
void setAnchorPoint(const FloatPoint3D&);
TransformationMatrix transform() const;
void setTransform(const TransformationMatrix&);
TransformationMatrix sublayerTransform() const;
void setSublayerTransform(const TransformationMatrix&);
TransformationMatrix contentsTransform() const;
void setContentsTransform(const TransformationMatrix&);
bool isHidden() const;
void setHidden(bool);
bool isGeometryFlipped() const;
void setGeometryFlipped(bool);
bool isDoubleSided() const;
void setDoubleSided(bool);
bool masksToBounds() const;
void setMasksToBounds(bool);
bool acceleratesDrawing() const;
void setAcceleratesDrawing(bool);
CFTypeRef contents() const;
void setContents(CFTypeRef);
FloatRect contentsRect() const;
void setContentsRect(const FloatRect&);
void setMinificationFilter(FilterType);
void setMagnificationFilter(FilterType);
Color backgroundColor() const;
void setBackgroundColor(const Color&);
float borderWidth() const;
void setBorderWidth(float);
Color borderColor() const;
void setBorderColor(const Color&);
float opacity() const;
void setOpacity(float);
#if ENABLE(CSS_FILTERS)
void setFilters(const FilterOperations&);
static bool filtersCanBeComposited(const FilterOperations&);
void copyFiltersFrom(const PlatformCALayer*);
#endif
String name() const;
void setName(const String&);
FloatRect frame() const;
void setFrame(const FloatRect&);
float speed() const;
void setSpeed(float);
CFTimeInterval timeOffset() const;
void setTimeOffset(CFTimeInterval);
float contentsScale() const;
void setContentsScale(float);
TiledBacking* tiledBacking();
#if PLATFORM(WIN)
HashMap<String, RefPtr<PlatformCAAnimation> >& animations() { return m_animations; }
#endif
#if PLATFORM(WIN) && !defined(NDEBUG)
void printTree() const;
#endif
#if PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
void synchronouslyDisplayTilesInRect(const FloatRect&);
#endif
protected:
PlatformCALayer(LayerType, PlatformLayer*, PlatformCALayerClient*);
private:
AVPlayerLayer* playerLayer() const;
PlatformCALayerClient* m_owner;
LayerType m_layerType;
OwnPtr<PlatformCALayerList> m_customSublayers;
#if PLATFORM(MAC) || PLATFORM(WIN)
RetainPtr<PlatformLayer> m_layer;
#endif
#if PLATFORM(WIN)
HashMap<String, RefPtr<PlatformCAAnimation> > m_animations;
#endif
#if PLATFORM(MAC)
#ifdef __OBJC__
RetainPtr<NSObject> m_delegate;
#else
RetainPtr<void> m_delegate;
#endif
#endif
};
}
#endif // USE(ACCELERATED_COMPOSITING)
#endif // PlatformCALayer_h
|