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

Side by Side Diff: cc/resources/picture_layer_tiling.h

Issue 62283012: cc: Added tile bundles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
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_RESOURCES_PICTURE_LAYER_TILING_H_ 5 #ifndef CC_RESOURCES_PICTURE_LAYER_TILING_H_
6 #define CC_RESOURCES_PICTURE_LAYER_TILING_H_ 6 #define CC_RESOURCES_PICTURE_LAYER_TILING_H_
7 7
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "cc/base/cc_export.h" 14 #include "cc/base/cc_export.h"
15 #include "cc/base/region.h" 15 #include "cc/base/region.h"
16 #include "cc/base/tiling_data.h" 16 #include "cc/base/tiling_data.h"
17 #include "cc/resources/tile.h" 17 #include "cc/resources/tile.h"
18 #include "cc/resources/tile_bundle.h"
18 #include "cc/resources/tile_priority.h" 19 #include "cc/resources/tile_priority.h"
19 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
20 21
21 namespace cc { 22 namespace cc {
22 23
23 class PictureLayerTiling; 24 class PictureLayerTiling;
24 25
25 class CC_EXPORT PictureLayerTilingClient { 26 class CC_EXPORT PictureLayerTilingClient {
26 public: 27 public:
27 // Create a tile at the given content_rect (in the contents scale of the 28 // Create a tile at the given content_rect (in the contents scale of the
28 // tiling) This might return null if the client cannot create such a tile. 29 // tiling) This might return null if the client cannot create such a tile.
29 virtual scoped_refptr<Tile> CreateTile( 30 virtual scoped_refptr<Tile> CreateTile(
30 PictureLayerTiling* tiling, 31 PictureLayerTiling* tiling,
31 gfx::Rect content_rect) = 0; 32 gfx::Rect content_rect) = 0;
33 virtual scoped_refptr<TileBundle> CreateTileBundle(int width,
34 int height,
35 int offset_x,
36 int offset_y) = 0;
32 virtual void UpdatePile(Tile* tile) = 0; 37 virtual void UpdatePile(Tile* tile) = 0;
33 virtual gfx::Size CalculateTileSize( 38 virtual gfx::Size CalculateTileSize(
34 gfx::Size content_bounds) const = 0; 39 gfx::Size content_bounds) const = 0;
35 virtual const Region* GetInvalidation() = 0; 40 virtual const Region* GetInvalidation() = 0;
36 virtual const PictureLayerTiling* GetTwinTiling( 41 virtual const PictureLayerTiling* GetTwinTiling(
37 const PictureLayerTiling* tiling) = 0; 42 const PictureLayerTiling* tiling) = 0;
43 virtual bool IsActive() const = 0;
44 virtual bool IsPending() const = 0;
45 virtual bool IsRecycled() const = 0;
38 46
39 protected: 47 protected:
40 virtual ~PictureLayerTilingClient() {} 48 virtual ~PictureLayerTilingClient() {}
41 }; 49 };
42 50
43 class CC_EXPORT PictureLayerTiling { 51 class CC_EXPORT PictureLayerTiling {
44 public: 52 public:
45 ~PictureLayerTiling(); 53 ~PictureLayerTiling();
46 54
47 // Create a tiling with no tiles. CreateTiles must be called to add some. 55 // Create a tiling with no tiles. CreateTiles must be called to add some.
(...skipping 17 matching lines...) Expand all
65 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } 73 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; }
66 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } 74 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); }
67 float contents_scale() const { return contents_scale_; } 75 float contents_scale() const { return contents_scale_; }
68 76
69 void CreateAllTilesForTesting() { 77 void CreateAllTilesForTesting() {
70 SetLiveTilesRect(gfx::Rect(tiling_data_.total_size())); 78 SetLiveTilesRect(gfx::Rect(tiling_data_.total_size()));
71 } 79 }
72 80
73 std::vector<Tile*> AllTilesForTesting() const { 81 std::vector<Tile*> AllTilesForTesting() const {
74 std::vector<Tile*> all_tiles; 82 std::vector<Tile*> all_tiles;
75 for (TileMap::const_iterator it = tiles_.begin(); 83 for (TileBundleMap::const_iterator it = tile_bundles_.begin();
76 it != tiles_.end(); ++it) 84 it != tile_bundles_.end(); ++it) {
77 all_tiles.push_back(it->second.get()); 85 for (TileBundle::Iterator tile_it(it->second.get()); tile_it; ++tile_it)
86 all_tiles.push_back(*tile_it);
87 }
78 return all_tiles; 88 return all_tiles;
79 } 89 }
80 90
81 // Iterate over all tiles to fill content_rect. Even if tiles are invalid 91 // Iterate over all tiles to fill content_rect. Even if tiles are invalid
82 // (i.e. no valid resource) this tiling should still iterate over them. 92 // (i.e. no valid resource) this tiling should still iterate over them.
83 // The union of all geometry_rect calls for each element iterated over should 93 // The union of all geometry_rect calls for each element iterated over should
84 // exactly equal content_rect and no two geometry_rects should intersect. 94 // exactly equal content_rect and no two geometry_rects should intersect.
85 class CC_EXPORT CoverageIterator { 95 class CC_EXPORT CoverageIterator {
86 public: 96 public:
87 CoverageIterator(); 97 CoverageIterator();
88 CoverageIterator(const PictureLayerTiling* tiling, 98 CoverageIterator(const PictureLayerTiling* tiling,
89 float dest_scale, 99 float dest_scale,
90 gfx::Rect rect); 100 gfx::Rect rect);
91 ~CoverageIterator(); 101 ~CoverageIterator();
92 102
93 // Visible rect (no borders), always in the space of content_rect, 103 // Visible rect (no borders), always in the space of content_rect,
94 // regardless of the contents scale of the tiling. 104 // regardless of the contents scale of the tiling.
95 gfx::Rect geometry_rect() const; 105 gfx::Rect geometry_rect() const;
96 // Texture rect (in texels) for geometry_rect 106 // Texture rect (in texels) for geometry_rect
97 gfx::RectF texture_rect() const; 107 gfx::RectF texture_rect() const;
98 gfx::Size texture_size() const; 108 gfx::Size texture_size() const;
99 109
100 // Full rect (including borders) of the current tile, always in the space 110 // Full rect (including borders) of the current tile, always in the space
101 // of content_rect, regardless of the contents scale of the tiling. 111 // of content_rect, regardless of the contents scale of the tiling.
102 gfx::Rect full_tile_geometry_rect() const; 112 gfx::Rect full_tile_geometry_rect() const;
103 113
104 Tile* operator->() const { return current_tile_; } 114 Tile* operator->() const { return current_tile_; }
105 Tile* operator*() const { return current_tile_; } 115 Tile* operator*() const { return current_tile_; }
106 116
117 TilePriority priority();
118 void SetPriorityForTesting(const TilePriority& priority);
119
107 CoverageIterator& operator++(); 120 CoverageIterator& operator++();
108 operator bool() const { return tile_j_ <= bottom_; } 121 operator bool() const { return tile_j_ <= bottom_; }
109 122
110 private: 123 private:
111 const PictureLayerTiling* tiling_; 124 const PictureLayerTiling* tiling_;
112 gfx::Rect dest_rect_; 125 gfx::Rect dest_rect_;
113 float dest_to_content_scale_; 126 float dest_to_content_scale_;
114 127
115 Tile* current_tile_; 128 Tile* current_tile_;
116 gfx::Rect current_geometry_rect_; 129 gfx::Rect current_geometry_rect_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 gfx::Rect starting_rect, 190 gfx::Rect starting_rect,
178 int64 target_area, 191 int64 target_area,
179 gfx::Rect bounding_rect, 192 gfx::Rect bounding_rect,
180 RectExpansionCache* cache); 193 RectExpansionCache* cache);
181 194
182 bool has_ever_been_updated() const { 195 bool has_ever_been_updated() const {
183 return last_impl_frame_time_in_seconds_ != 0.0; 196 return last_impl_frame_time_in_seconds_ != 0.0;
184 } 197 }
185 198
186 protected: 199 protected:
187 typedef std::pair<int, int> TileMapKey; 200 friend class TileBundle;
188 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; 201
202 typedef std::pair<int, int> TileBundleMapKey;
203 typedef base::hash_map<TileBundleMapKey, scoped_refptr<TileBundle> >
204 TileBundleMap;
189 205
190 PictureLayerTiling(float contents_scale, 206 PictureLayerTiling(float contents_scale,
191 gfx::Size layer_bounds, 207 gfx::Size layer_bounds,
192 PictureLayerTilingClient* client); 208 PictureLayerTilingClient* client);
193 void SetLiveTilesRect(gfx::Rect live_tiles_rect); 209 void SetLiveTilesRect(gfx::Rect live_tiles_rect);
194 void CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); 210 void CreateTile(int i, int j, const PictureLayerTiling* twin_tiling);
211 bool RemoveTile(int i, int j);
195 Tile* TileAt(int, int) const; 212 Tile* TileAt(int, int) const;
213 TileBundle* TileBundleContainingTileAt(int, int) const;
214 TileBundle* CreateBundleForTileAt(int, int);
215 TileBundle* TileBundleAt(int, int) const;
196 216
197 // Given properties. 217 // Given properties.
198 float contents_scale_; 218 float contents_scale_;
199 gfx::Size layer_bounds_; 219 gfx::Size layer_bounds_;
200 TileResolution resolution_; 220 TileResolution resolution_;
201 PictureLayerTilingClient* client_; 221 PictureLayerTilingClient* client_;
202 222
203 // Internal data. 223 // Internal data.
204 TilingData tiling_data_; 224 TilingData tiling_data_;
205 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. 225 TilingData bundle_tiling_data_;
226 TileBundleMap tile_bundles_; // It is not legal to have a NULL tile in the
227 // tiles_ map.
206 gfx::Rect live_tiles_rect_; 228 gfx::Rect live_tiles_rect_;
207 229
208 // State saved for computing velocities based upon finite differences. 230 // State saved for computing velocities based upon finite differences.
209 double last_impl_frame_time_in_seconds_; 231 double last_impl_frame_time_in_seconds_;
210 232
211 friend class CoverageIterator; 233 friend class CoverageIterator;
212 234
213 private: 235 private:
214 DISALLOW_ASSIGN(PictureLayerTiling); 236 DISALLOW_ASSIGN(PictureLayerTiling);
215 237
216 RectExpansionCache expansion_cache_; 238 RectExpansionCache expansion_cache_;
217 }; 239 };
218 240
219 } // namespace cc 241 } // namespace cc
220 242
221 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 243 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698