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
|
/*
Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CoordinatedGraphicsLayer_h
#define CoordinatedGraphicsLayer_h
#include "CoordinatedImageBacking.h"
#include "CoordinatedTile.h"
#include "FloatPoint3D.h"
#include "GraphicsLayer.h"
#include "GraphicsLayerAnimation.h"
#include "GraphicsLayerTransform.h"
#include "Image.h"
#include "IntSize.h"
#include "ShareableBitmap.h"
#include "TiledBackingStore.h"
#include "TiledBackingStoreClient.h"
#include "TransformationMatrix.h"
#include "UpdateInfo.h"
#include "WebLayerTreeInfo.h"
#include "WebProcess.h"
#if USE(GRAPHICS_SURFACE)
#include <WebCore/GraphicsSurfaceToken.h>
#endif
#include <WebCore/RunLoop.h>
#include <wtf/text/StringHash.h>
#if USE(COORDINATED_GRAPHICS)
namespace WebCore {
class CoordinatedGraphicsLayer;
class GraphicsLayerAnimations;
}
namespace WebKit {
class CoordinatedGraphicsLayerClient {
public:
// CoordinatedTileClient
virtual void createTile(WebLayerID, int tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&) = 0;
virtual void updateTile(WebLayerID, int tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&) = 0;
virtual void removeTile(WebLayerID, int tileID) = 0;
virtual WebCore::IntRect visibleContentsRect() const = 0;
virtual bool layerTreeTileUpdatesAllowed() const = 0;
virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) = 0;
virtual void syncLayerState(WebLayerID, const WebLayerInfo&) = 0;
virtual void syncLayerChildren(WebLayerID, const Vector<WebLayerID>&) = 0;
#if ENABLE(CSS_FILTERS)
virtual void syncLayerFilters(WebLayerID, const WebCore::FilterOperations&) = 0;
#endif
#if USE(GRAPHICS_SURFACE)
virtual void createCanvas(WebLayerID, WebCore::PlatformLayer*) = 0;
virtual void syncCanvas(WebLayerID, WebCore::PlatformLayer*) = 0;
virtual void destroyCanvas(WebLayerID) = 0;
#endif
virtual void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&) = 0;
virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*) = 0;
virtual void syncFixedLayers() = 0;
virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, int& atlasID, WebCore::IntPoint&) = 0;
};
}
namespace WebCore {
class CoordinatedGraphicsLayer : public GraphicsLayer
, public TiledBackingStoreClient
, public WebKit::CoordinatedImageBacking::Host
, public WebKit::CoordinatedTileClient {
public:
explicit CoordinatedGraphicsLayer(GraphicsLayerClient*);
virtual ~CoordinatedGraphicsLayer();
// Reimplementations from GraphicsLayer.h.
virtual bool setChildren(const Vector<GraphicsLayer*>&) OVERRIDE;
virtual void addChild(GraphicsLayer*) OVERRIDE;
virtual void addChildAtIndex(GraphicsLayer*, int) OVERRIDE;
virtual void addChildAbove(GraphicsLayer*, GraphicsLayer*) OVERRIDE;
virtual void addChildBelow(GraphicsLayer*, GraphicsLayer*) OVERRIDE;
virtual bool replaceChild(GraphicsLayer*, GraphicsLayer*) OVERRIDE;
virtual void removeFromParent() OVERRIDE;
virtual void setPosition(const FloatPoint&) OVERRIDE;
virtual void setAnchorPoint(const FloatPoint3D&) OVERRIDE;
virtual void setSize(const FloatSize&) OVERRIDE;
virtual void setTransform(const TransformationMatrix&) OVERRIDE;
virtual void setChildrenTransform(const TransformationMatrix&) OVERRIDE;
virtual void setPreserves3D(bool) OVERRIDE;
virtual void setMasksToBounds(bool) OVERRIDE;
virtual void setDrawsContent(bool) OVERRIDE;
virtual void setContentsVisible(bool) OVERRIDE;
virtual void setContentsOpaque(bool) OVERRIDE;
virtual void setBackfaceVisibility(bool) OVERRIDE;
virtual void setOpacity(float) OVERRIDE;
virtual void setContentsRect(const IntRect&) OVERRIDE;
virtual void setContentsToImage(Image*) OVERRIDE;
virtual bool shouldDirectlyCompositeImage(Image*) const OVERRIDE;
virtual void setContentsToCanvas(PlatformLayer*) OVERRIDE;
virtual void setMaskLayer(GraphicsLayer*) OVERRIDE;
virtual void setReplicatedByLayer(GraphicsLayer*) OVERRIDE;
virtual void setNeedsDisplay() OVERRIDE;
virtual void setNeedsDisplayInRect(const FloatRect&) OVERRIDE;
virtual void setContentsNeedsDisplay() OVERRIDE;
virtual void flushCompositingState(const FloatRect&) OVERRIDE;
virtual void flushCompositingStateForThisLayerOnly() OVERRIDE;
#if ENABLE(CSS_FILTERS)
virtual bool setFilters(const FilterOperations&) OVERRIDE;
#endif
virtual bool addAnimation(const KeyframeValueList&, const IntSize&, const Animation*, const String&, double) OVERRIDE;
virtual void pauseAnimation(const String&, double) OVERRIDE;
virtual void removeAnimation(const String&) OVERRIDE;
virtual void suspendAnimations(double time) OVERRIDE;
virtual void resumeAnimations() OVERRIDE;
void setContentsScale(float);
void setVisibleContentRectTrajectoryVector(const FloatPoint&);
void setRootLayer(bool);
WebKit::WebLayerID id() const;
void setFixedToViewport(bool isFixed) { m_fixedToViewport = isFixed; }
IntRect coverRect() const { return m_mainBackingStore ? m_mainBackingStore->mapToContents(m_mainBackingStore->coverRect()) : IntRect(); }
static void initFactory();
// TiledBackingStoreClient
virtual void tiledBackingStorePaintBegin() OVERRIDE;
virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&) OVERRIDE;
virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea) OVERRIDE;
virtual bool tiledBackingStoreUpdatesAllowed() const OVERRIDE;
virtual IntRect tiledBackingStoreContentsRect() OVERRIDE;
virtual IntRect tiledBackingStoreVisibleRect() OVERRIDE;
virtual Color tiledBackingStoreBackgroundColor() const OVERRIDE;
// CoordinatedTileClient
virtual void createTile(int tileID, const WebKit::SurfaceUpdateInfo&, const IntRect&) OVERRIDE;
virtual void updateTile(int tileID, const WebKit::SurfaceUpdateInfo&, const IntRect&) OVERRIDE;
virtual void removeTile(int tileID) OVERRIDE;
virtual PassOwnPtr<GraphicsContext> beginContentUpdate(const IntSize&, int& atlasID, IntPoint&) OVERRIDE;
void setCoordinator(WebKit::CoordinatedGraphicsLayerClient*);
void adjustVisibleRect();
void purgeBackingStores();
bool hasPendingVisibleChanges();
private:
bool fixedToViewport() const { return m_fixedToViewport; }
void didChangeLayerState();
void didChangeAnimations();
void didChangeGeometry();
void didChangeChildren();
#if ENABLE(CSS_FILTERS)
void didChangeFilters();
#endif
void didChangeImageBacking();
void syncLayerState();
void syncAnimations();
void syncChildren();
#if ENABLE(CSS_FILTERS)
void syncFilters();
#endif
void syncImageBacking();
void syncCanvas();
void computeTransformedVisibleRect();
void updateContentBuffers();
void createBackingStore();
void releaseImageBackingIfNeeded();
// CoordinatedImageBacking::Host
virtual bool imageBackingVisible() OVERRIDE;
void destroyCanvasIfNeeded();
void createCanvasIfNeeded();
bool selfOrAncestorHasActiveTransformAnimation() const;
bool selfOrAncestorHaveNonAffineTransforms();
void adjustContentsScale();
void setShouldUpdateVisibleRect();
float effectiveContentsScale();
void animationStartedTimerFired(Timer<CoordinatedGraphicsLayer>*);
WebKit::WebLayerID m_id;
WebKit::WebLayerInfo m_layerInfo;
GraphicsLayerTransform m_layerTransform;
TransformationMatrix m_cachedInverseTransform;
bool m_inUpdateMode : 1;
bool m_shouldUpdateVisibleRect: 1;
bool m_shouldSyncLayerState: 1;
bool m_shouldSyncChildren: 1;
bool m_shouldSyncFilters: 1;
bool m_shouldSyncImageBacking: 1;
bool m_shouldSyncAnimations: 1;
bool m_fixedToViewport : 1;
bool m_canvasNeedsDisplay : 1;
bool m_canvasNeedsCreate : 1;
bool m_canvasNeedsDestroy : 1;
WebKit::CoordinatedGraphicsLayerClient* m_coordinator;
OwnPtr<TiledBackingStore> m_mainBackingStore;
OwnPtr<TiledBackingStore> m_previousBackingStore;
float m_contentsScale;
RefPtr<Image> m_compositedImage;
NativeImagePtr m_compositedNativeImagePtr;
RefPtr<WebKit::CoordinatedImageBacking> m_coordinatedImageBacking;
PlatformLayer* m_canvasPlatformLayer;
#if USE(GRAPHICS_SURFACE)
GraphicsSurfaceToken m_canvasToken;
#endif
Timer<CoordinatedGraphicsLayer> m_animationStartedTimer;
GraphicsLayerAnimations m_animations;
double m_lastAnimationStartTime;
};
CoordinatedGraphicsLayer* toCoordinatedGraphicsLayer(GraphicsLayer*);
}
#endif
#endif // CoordinatedGraphicsLayer_H
|