Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: cc/picture_layer_tiling.h

Issue 12280021: cc: Don't discard tiles unless memory is low (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/picture_layer_tiling.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_PICTURE_LAYER_TILING_H_ 5 #ifndef CC_PICTURE_LAYER_TILING_H_
6 #define CC_PICTURE_LAYER_TILING_H_ 6 #define CC_PICTURE_LAYER_TILING_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/hash_tables.h" 9 #include "base/hash_tables.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 18 matching lines...) Expand all
29 PictureLayerTiling* tiling, 29 PictureLayerTiling* tiling,
30 gfx::Rect content_rect) = 0; 30 gfx::Rect content_rect) = 0;
31 virtual void UpdatePile(Tile* tile) = 0; 31 virtual void UpdatePile(Tile* tile) = 0;
32 virtual gfx::Size CalculateTileSize( 32 virtual gfx::Size CalculateTileSize(
33 gfx::Size current_tile_size, 33 gfx::Size current_tile_size,
34 gfx::Size content_bounds) = 0; 34 gfx::Size content_bounds) = 0;
35 }; 35 };
36 36
37 class TileHandle { 37 class TileHandle {
38 public: 38 public:
39 TileHandle(scoped_refptr<Tile> tile); 39 TileHandle(std::pair<int, int> key, scoped_refptr<Tile> tile);
40 Tile* tile() const { return tile_.get(); } 40 TileHandle(const TileHandle& tile_handle);
41 ~TileHandle();
42
41 void RegisterWithTileManager(); 43 void RegisterWithTileManager();
42 void UnregisterFromTileManager(); 44 void UnregisterFromTileManager();
45
46 void AddToLiveTileList(PictureLayerTiling* tiling);
47 void RemoveFromLiveTileList();
48
49 std::pair<int, int> key() const { return key_; }
50 Tile* tile() const { return tile_.get(); }
51 bool should_be_live() const { return should_be_live_; }
52 void set_should_be_live(bool should_be_live) {
53 should_be_live_ = should_be_live;
54 }
55
43 private: 56 private:
57 std::pair<int, int> key_;
44 scoped_refptr<Tile> tile_; 58 scoped_refptr<Tile> tile_;
45 scoped_refptr<ManagedTileState> managed_tile_state_; 59 scoped_refptr<ManagedTileState> managed_tile_state_;
60
61 // Transiently set in UpdateTilePriorities to track tiles that
62 // are actively desired to be painted.
63 bool should_be_live_;
64
65 // tiling_ is non-NULL only if this is in a tiling's live_tile_list_, in
66 // which case tiling_live_tile_list_iterator_ valid.
67 PictureLayerTiling* tiling_;
68 std::list<TileHandle*>::iterator tiling_live_tile_list_iterator_;
46 }; 69 };
47 70
48 class CC_EXPORT PictureLayerTiling { 71 class CC_EXPORT PictureLayerTiling {
49 public: 72 public:
50 ~PictureLayerTiling(); 73 ~PictureLayerTiling();
51 74
52 // Create a tiling with no tiles. CreateTiles must be called to add some. 75 // Create a tiling with no tiles. CreateTiles must be called to add some.
53 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); 76 static scoped_ptr<PictureLayerTiling> Create(float contents_scale);
54 scoped_ptr<PictureLayerTiling> Clone() const; 77 scoped_ptr<PictureLayerTiling> Clone() const;
55 78
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // Copies the src_tree priority into the dst_tree priority for all tiles. 183 // Copies the src_tree priority into the dst_tree priority for all tiles.
161 // The src_tree priority is reset to the lowest priority possible. This 184 // The src_tree priority is reset to the lowest priority possible. This
162 // also updates the pile on each tile to be the current client's pile. 185 // also updates the pile on each tile to be the current client's pile.
163 void DidBecomeActive(); 186 void DidBecomeActive();
164 187
165 scoped_ptr<base::Value> AsValue() const; 188 scoped_ptr<base::Value> AsValue() const;
166 189
167 protected: 190 protected:
168 typedef std::pair<int, int> TileMapKey; 191 typedef std::pair<int, int> TileMapKey;
169 typedef base::hash_map<TileMapKey, TileHandle> TileMap; 192 typedef base::hash_map<TileMapKey, TileHandle> TileMap;
193 typedef std::list<TileHandle*> TileList;
170 194
171 PictureLayerTiling(float contents_scale); 195 PictureLayerTiling(float contents_scale);
172 Tile* TileAt(int, int) const; 196 Tile* TileAt(int, int) const;
173 void CreateTilesFromContentRect(gfx::Rect layer_rect); 197 void CreateTilesFromContentRect(gfx::Rect layer_rect);
174 void CreateTile(int i, int j); 198 void CreateTile(int i, int j);
175 199
176 PictureLayerTilingClient* client_; 200 PictureLayerTilingClient* client_;
177 float contents_scale_; 201 float contents_scale_;
178 gfx::Size layer_bounds_; 202 gfx::Size layer_bounds_;
179 gfx::Rect last_prioritized_rect_; 203 gfx::Rect last_prioritized_rect_;
180 // It is not legal to have a NULL tile in the tiles_ map. 204 // It is not legal to have a NULL tile in the tiles_ map.
181 TileMap tiles_; 205 TileMap tiles_;
206 TileList live_tiles_;
182 TilingData tiling_data_; 207 TilingData tiling_data_;
183 TileResolution resolution_; 208 TileResolution resolution_;
184 int last_source_frame_number_; 209 int last_source_frame_number_;
185 double last_impl_frame_time_; 210 double last_impl_frame_time_;
186 211
212 friend class TileHandle;
187 friend class Iterator; 213 friend class Iterator;
188 }; 214 };
189 215
190 } // namespace cc 216 } // namespace cc
191 217
192 #endif // CC_PICTURE_LAYER_TILING_H_ 218 #endif // CC_PICTURE_LAYER_TILING_H_
OLDNEW
« no previous file with comments | « no previous file | cc/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698