OLD | NEW |
| (Empty) |
1 /* | |
2 Copyright (C) 2010-2012 Nokia Corporation and/or its subsidiary(-ies) | |
3 | |
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. | |
8 | |
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. | |
13 | |
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. | |
18 */ | |
19 | |
20 #ifndef TiledBackingStore_h | |
21 #define TiledBackingStore_h | |
22 | |
23 #if USE(TILED_BACKING_STORE) | |
24 | |
25 #include "FloatPoint.h" | |
26 #include "IntPoint.h" | |
27 #include "IntRect.h" | |
28 #include "Tile.h" | |
29 #include "TiledBackingStoreBackend.h" | |
30 #include "Timer.h" | |
31 #include <wtf/Assertions.h> | |
32 #include <wtf/HashMap.h> | |
33 #include <wtf/RefPtr.h> | |
34 | |
35 namespace WebCore { | |
36 | |
37 class GraphicsContext; | |
38 class TiledBackingStore; | |
39 class TiledBackingStoreClient; | |
40 | |
41 class TiledBackingStore { | |
42 WTF_MAKE_NONCOPYABLE(TiledBackingStore); WTF_MAKE_FAST_ALLOCATED; | |
43 public: | |
44 TiledBackingStore(TiledBackingStoreClient*, PassOwnPtr<TiledBackingStoreBack
end> = TiledBackingStoreBackend::create()); | |
45 ~TiledBackingStore(); | |
46 | |
47 TiledBackingStoreClient* client() { return m_client; } | |
48 | |
49 // Used when class methods cannot be called asynchronously by client. | |
50 // Updates of tiles are committed as soon as all the events in event queue h
ave been processed. | |
51 void setCommitTileUpdatesOnIdleEventLoop(bool enable) { m_commitTileUpdatesO
nIdleEventLoop = enable; } | |
52 | |
53 void setTrajectoryVector(const FloatPoint&); | |
54 void coverWithTilesIfNeeded(); | |
55 | |
56 float contentsScale() { return m_contentsScale; } | |
57 void setContentsScale(float); | |
58 | |
59 bool contentsFrozen() const { return m_contentsFrozen; } | |
60 void setContentsFrozen(bool); | |
61 | |
62 void updateTileBuffers(); | |
63 | |
64 void invalidate(const IntRect& dirtyRect); | |
65 void paint(GraphicsContext*, const IntRect&); | |
66 | |
67 IntSize tileSize() { return m_tileSize; } | |
68 void setTileSize(const IntSize&); | |
69 | |
70 IntRect mapToContents(const IntRect&) const; | |
71 IntRect mapFromContents(const IntRect&) const; | |
72 | |
73 IntRect tileRectForCoordinate(const Tile::Coordinate&) const; | |
74 Tile::Coordinate tileCoordinateForPoint(const IntPoint&) const; | |
75 double tileDistance(const IntRect& viewport, const Tile::Coordinate&) const; | |
76 | |
77 IntRect coverRect() const { return m_coverRect; } | |
78 bool visibleAreaIsCovered() const; | |
79 void removeAllNonVisibleTiles(); | |
80 | |
81 void setSupportsAlpha(bool); | |
82 | |
83 private: | |
84 void startTileBufferUpdateTimer(); | |
85 void startBackingStoreUpdateTimer(double = 0); | |
86 | |
87 void tileBufferUpdateTimerFired(Timer<TiledBackingStore>*); | |
88 void backingStoreUpdateTimerFired(Timer<TiledBackingStore>*); | |
89 | |
90 void createTiles(); | |
91 void computeCoverAndKeepRect(const IntRect& visibleRect, IntRect& coverRect,
IntRect& keepRect) const; | |
92 | |
93 bool isBackingStoreUpdatesSuspended() const; | |
94 bool isTileBufferUpdatesSuspended() const; | |
95 | |
96 void commitScaleChange(); | |
97 | |
98 bool resizeEdgeTiles(); | |
99 void setCoverRect(const IntRect& rect) { m_coverRect = rect; } | |
100 void setKeepRect(const IntRect&); | |
101 | |
102 PassRefPtr<Tile> tileAt(const Tile::Coordinate&) const; | |
103 void setTile(const Tile::Coordinate& coordinate, PassRefPtr<Tile> tile); | |
104 void removeTile(const Tile::Coordinate& coordinate); | |
105 | |
106 IntRect visibleRect() const; | |
107 | |
108 float coverageRatio(const IntRect&) const; | |
109 void adjustForContentsRect(IntRect&) const; | |
110 | |
111 void paintCheckerPattern(GraphicsContext*, const IntRect&, const Tile::Coord
inate&); | |
112 | |
113 private: | |
114 TiledBackingStoreClient* m_client; | |
115 OwnPtr<TiledBackingStoreBackend> m_backend; | |
116 | |
117 typedef HashMap<Tile::Coordinate, RefPtr<Tile> > TileMap; | |
118 TileMap m_tiles; | |
119 | |
120 Timer<TiledBackingStore> m_tileBufferUpdateTimer; | |
121 Timer<TiledBackingStore> m_backingStoreUpdateTimer; | |
122 | |
123 IntSize m_tileSize; | |
124 float m_coverAreaMultiplier; | |
125 | |
126 FloatPoint m_trajectoryVector; | |
127 FloatPoint m_pendingTrajectoryVector; | |
128 IntRect m_visibleRect; | |
129 | |
130 IntRect m_coverRect; | |
131 IntRect m_keepRect; | |
132 IntRect m_rect; | |
133 | |
134 float m_contentsScale; | |
135 float m_pendingScale; | |
136 | |
137 bool m_commitTileUpdatesOnIdleEventLoop; | |
138 bool m_contentsFrozen; | |
139 bool m_supportsAlpha; | |
140 bool m_pendingTileCreation; | |
141 | |
142 friend class Tile; | |
143 }; | |
144 | |
145 } | |
146 | |
147 #endif | |
148 #endif | |
OLD | NEW |