2 Copyright (C) 2010-2012 Nokia Corporation and/or its subsidiary(-ies)
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef TiledBackingStore_h
21 #define TiledBackingStore_h
23 #if USE(TILED_BACKING_STORE)
25 #include "FloatPoint.h"
29 #include "TiledBackingStoreBackend.h"
31 #include <wtf/Assertions.h>
32 #include <wtf/HashMap.h>
33 #include <wtf/RefPtr.h>
37 class GraphicsContext;
38 class TiledBackingStore;
39 class TiledBackingStoreClient;
41 class TiledBackingStore {
42 WTF_MAKE_NONCOPYABLE(TiledBackingStore); WTF_MAKE_FAST_ALLOCATED;
44 TiledBackingStore(TiledBackingStoreClient*, PassOwnPtr<TiledBackingStoreBackend> = TiledBackingStoreBackend::create());
47 TiledBackingStoreClient* client() { return m_client; }
49 void coverWithTilesIfNeeded(const FloatPoint& panningTrajectoryVector = FloatPoint());
51 float contentsScale() { return m_contentsScale; }
52 void setContentsScale(float);
54 bool contentsFrozen() const { return m_contentsFrozen; }
55 void setContentsFrozen(bool);
57 void updateTileBuffers();
58 #if ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
59 void startTileBufferUpdateTimer();
60 void updateTileBuffersBegin();
61 void setContentsInvalid(bool invalid) { m_contentsInvalid = invalid; }
64 void invalidate(const IntRect& dirtyRect);
65 void paint(GraphicsContext*, const IntRect&);
67 IntSize tileSize() { return m_tileSize; }
68 void setTileSize(const IntSize&);
70 double tileCreationDelay() const { return m_tileCreationDelay; }
71 void setTileCreationDelay(double delay);
73 IntRect mapToContents(const IntRect&) const;
74 IntRect mapFromContents(const IntRect&) const;
76 IntRect tileRectForCoordinate(const Tile::Coordinate&) const;
77 Tile::Coordinate tileCoordinateForPoint(const IntPoint&) const;
78 double tileDistance(const IntRect& viewport, const Tile::Coordinate&) const;
79 #if ENABLE(TIZEN_CUTOFF_TILES_OVER_MEMORY_LIMIT)
80 double tileManhattanDistance(const IntRect& viewport, const Tile::Coordinate&) const;
81 Vector<TileCutOffInfo> getCutOffInfoList();
82 void setCutOffDistance(double distance);
85 bool visibleAreaIsCovered() const;
86 void removeAllNonVisibleTiles();
88 void setSupportsAlpha(bool);
89 bool supportsAlpha() const { return m_supportsAlpha; }
91 #if ENABLE(TIZEN_DONT_PURGE_PLATFORM_SURFACE_BACKINGSTORE_ON_NODE_DETACH_FROM_WEBLAYER_TREE)
95 #if !ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
96 void startTileBufferUpdateTimer();
98 void startBackingStoreUpdateTimer();
100 void tileBufferUpdateTimerFired(Timer<TiledBackingStore>*);
101 void backingStoreUpdateTimerFired(Timer<TiledBackingStore>*);
104 void computeCoverAndKeepRect(const IntRect& visibleRect, IntRect& coverRect, IntRect& keepRect) const;
106 bool isBackingStoreUpdatesSuspended() const;
107 bool isTileBufferUpdatesSuspended() const;
109 void commitScaleChange();
111 bool resizeEdgeTiles();
112 void setCoverRect(const IntRect& rect) { m_coverRect = rect; }
113 void setKeepRect(const IntRect&);
115 PassRefPtr<Tile> tileAt(const Tile::Coordinate&) const;
116 void setTile(const Tile::Coordinate& coordinate, PassRefPtr<Tile> tile);
117 void removeTile(const Tile::Coordinate& coordinate);
119 IntRect visibleRect() const;
121 float coverageRatio(const IntRect&) const;
122 void adjustForContentsRect(IntRect&) const;
124 void paintCheckerPattern(GraphicsContext*, const IntRect&, const Tile::Coordinate&);
125 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
126 IntSize computeAppropriateTileSize(const IntRect&, const IntRect&);
130 TiledBackingStoreClient* m_client;
131 OwnPtr<TiledBackingStoreBackend> m_backend;
133 typedef HashMap<Tile::Coordinate, RefPtr<Tile> > TileMap;
136 Timer<TiledBackingStore> m_tileBufferUpdateTimer;
137 Timer<TiledBackingStore> m_backingStoreUpdateTimer;
140 double m_tileCreationDelay;
141 float m_coverAreaMultiplier;
143 #if ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
144 Vector<RefPtr<Tile> > m_dirtyTiles;
145 bool m_contentsInvalid;
148 #if ENABLE(TIZEN_WEBKIT2_PRE_RENDERING_WITH_DIRECTIVITY)
149 float m_trajectoryVectorScalar;
151 FloatPoint m_trajectoryVector;
152 IntRect m_visibleRect;
158 float m_contentsScale;
159 float m_pendingScale;
161 bool m_contentsFrozen;
162 bool m_supportsAlpha;
164 #if ENABLE(TIZEN_CUTOFF_TILES_OVER_MEMORY_LIMIT)
165 double m_cutOffTileDistance;
166 Vector<TileCutOffInfo> m_cutOffInfoList;