2 Copyright (C) 2010 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 ENABLE(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 void adjustVisibleRect();
49 TiledBackingStoreClient* client() { return m_client; }
50 float contentsScale() { return m_contentsScale; }
51 void setContentsScale(float);
53 bool contentsFrozen() const { return m_contentsFrozen; }
54 void setContentsFrozen(bool);
55 void updateTileBuffers();
57 void invalidate(const IntRect& dirtyRect);
58 void paint(GraphicsContext*, const IntRect&);
60 IntSize tileSize() { return m_tileSize; }
61 void setTileSize(const IntSize&);
63 double tileCreationDelay() const { return m_tileCreationDelay; }
64 void setTileCreationDelay(double delay);
66 // Tiled are dropped outside the keep area, and created for cover area. The values a relative to the viewport size.
67 void getKeepAndCoverAreaMultipliers(float& keepMultiplier, float& coverMultiplier)
69 keepMultiplier = m_keepAreaMultiplier;
70 coverMultiplier = m_coverAreaMultiplier;
72 void setKeepAndCoverAreaMultipliers(float keepMultiplier, float coverMultiplier);
73 void setVisibleRectTrajectoryVector(const FloatPoint&);
75 IntRect mapToContents(const IntRect&) const;
76 IntRect mapFromContents(const IntRect&) const;
78 IntRect tileRectForCoordinate(const Tile::Coordinate&) const;
79 Tile::Coordinate tileCoordinateForPoint(const IntPoint&) const;
80 double tileDistance(const IntRect& viewport, const Tile::Coordinate&) const;
81 float coverageRatio(const WebCore::IntRect& contentsRect);
84 void startTileBufferUpdateTimer();
85 void startTileCreationTimer();
87 typedef Timer<TiledBackingStore> TileTimer;
89 void tileBufferUpdateTimerFired(TileTimer*);
90 void tileCreationTimerFired(TileTimer*);
93 IntRect computeKeepRect(const IntRect& visibleRect) const;
94 IntRect computeCoverRect(const IntRect& visibleRect) const;
96 void commitScaleChange();
98 bool resizeEdgeTiles();
99 void dropTilesOutsideRect(const IntRect&);
101 PassRefPtr<Tile> tileAt(const Tile::Coordinate&) const;
102 void setTile(const Tile::Coordinate& coordinate, PassRefPtr<Tile> tile);
103 void removeTile(const Tile::Coordinate& coordinate);
105 IntRect contentsRect() const;
107 void paintCheckerPattern(GraphicsContext*, const IntRect&, const Tile::Coordinate&);
110 TiledBackingStoreClient* m_client;
111 OwnPtr<TiledBackingStoreBackend> m_backend;
113 typedef HashMap<Tile::Coordinate, RefPtr<Tile> > TileMap;
116 TileTimer* m_tileBufferUpdateTimer;
117 TileTimer* m_tileCreationTimer;
120 double m_tileCreationDelay;
121 float m_keepAreaMultiplier;
122 float m_coverAreaMultiplier;
123 FloatPoint m_visibleRectTrajectoryVector;
125 IntRect m_previousVisibleRect;
126 float m_contentsScale;
127 float m_pendingScale;
129 bool m_contentsFrozen;