tagging audio streams and changing audio sink to pulseaudio
[profile/ivi/webkit-efl.git] / Source / WebCore / platform / graphics / TiledBackingStore.h
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<TiledBackingStoreBackend> = TiledBackingStoreBackend::create());
45     ~TiledBackingStore();
46
47     TiledBackingStoreClient* client() { return m_client; }
48
49     void coverWithTilesIfNeeded(const FloatPoint& panningTrajectoryVector = FloatPoint());
50
51     float contentsScale() { return m_contentsScale; }
52     void setContentsScale(float);
53
54     bool contentsFrozen() const { return m_contentsFrozen; }
55     void setContentsFrozen(bool);
56
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; }
62 #endif
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     double tileCreationDelay() const { return m_tileCreationDelay; }
71     void setTileCreationDelay(double delay);
72
73     IntRect mapToContents(const IntRect&) const;
74     IntRect mapFromContents(const IntRect&) const;
75
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);
83 #endif
84
85     bool visibleAreaIsCovered() const;
86     void removeAllNonVisibleTiles();
87
88     void setSupportsAlpha(bool);
89     bool supportsAlpha() const { return m_supportsAlpha; }
90
91 #if ENABLE(TIZEN_DONT_PURGE_PLATFORM_SURFACE_BACKINGSTORE_ON_NODE_DETACH_FROM_WEBLAYER_TREE)
92     void reviewTiles();
93 #endif
94 private:
95 #if !ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
96     void startTileBufferUpdateTimer();
97 #endif
98     void startBackingStoreUpdateTimer();
99
100     void tileBufferUpdateTimerFired(Timer<TiledBackingStore>*);
101     void backingStoreUpdateTimerFired(Timer<TiledBackingStore>*);
102
103     void createTiles();
104     void computeCoverAndKeepRect(const IntRect& visibleRect, IntRect& coverRect, IntRect& keepRect) const;
105
106     bool isBackingStoreUpdatesSuspended() const;
107     bool isTileBufferUpdatesSuspended() const;
108
109     void commitScaleChange();
110
111     bool resizeEdgeTiles();
112     void setCoverRect(const IntRect& rect) { m_coverRect = rect; }
113     void setKeepRect(const IntRect&);
114
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);
118
119     IntRect visibleRect() const;
120
121     float coverageRatio(const IntRect&) const;
122     void adjustForContentsRect(IntRect&) const;
123
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&);
127 #endif
128
129 private:
130     TiledBackingStoreClient* m_client;
131     OwnPtr<TiledBackingStoreBackend> m_backend;
132
133     typedef HashMap<Tile::Coordinate, RefPtr<Tile> > TileMap;
134     TileMap m_tiles;
135
136     Timer<TiledBackingStore> m_tileBufferUpdateTimer;
137     Timer<TiledBackingStore> m_backingStoreUpdateTimer;
138
139     IntSize m_tileSize;
140     double m_tileCreationDelay;
141     float m_coverAreaMultiplier;
142
143 #if ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
144     Vector<RefPtr<Tile> > m_dirtyTiles;
145     bool m_contentsInvalid;
146 #endif
147
148 #if ENABLE(TIZEN_WEBKIT2_PRE_RENDERING_WITH_DIRECTIVITY)
149     float m_trajectoryVectorScalar;
150 #endif
151     FloatPoint m_trajectoryVector;
152     IntRect m_visibleRect;
153
154     IntRect m_coverRect;
155     IntRect m_keepRect;
156     IntRect m_rect;
157
158     float m_contentsScale;
159     float m_pendingScale;
160
161     bool m_contentsFrozen;
162     bool m_supportsAlpha;
163
164 #if ENABLE(TIZEN_CUTOFF_TILES_OVER_MEMORY_LIMIT)
165     double m_cutOffTileDistance;
166     Vector<TileCutOffInfo> m_cutOffInfoList;
167 #endif
168
169     friend class Tile;
170 };
171
172 }
173
174 #endif
175 #endif