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

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

Issue 12865017: Makes tile-creation lazy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing last round of feedback Created 7 years, 8 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 | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/resources/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_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
(...skipping 14 matching lines...) Expand all
25 25
26 class PictureLayerTilingClient { 26 class PictureLayerTilingClient {
27 public: 27 public:
28 // 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
29 // 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.
30 virtual scoped_refptr<Tile> CreateTile( 30 virtual scoped_refptr<Tile> CreateTile(
31 PictureLayerTiling* tiling, 31 PictureLayerTiling* tiling,
32 gfx::Rect content_rect) = 0; 32 gfx::Rect content_rect) = 0;
33 virtual void UpdatePile(Tile* tile) = 0; 33 virtual void UpdatePile(Tile* tile) = 0;
34 virtual gfx::Size CalculateTileSize( 34 virtual gfx::Size CalculateTileSize(
35 gfx::Size current_tile_size,
36 gfx::Size content_bounds) = 0; 35 gfx::Size content_bounds) = 0;
36 virtual const Region* GetInvalidation() = 0;
37 virtual const PictureLayerTiling* GetTwinTiling(
38 const PictureLayerTiling* tiling) = 0;
37 39
38 protected: 40 protected:
39 virtual ~PictureLayerTilingClient() {} 41 virtual ~PictureLayerTilingClient() {}
40 }; 42 };
41 43
42 class CC_EXPORT PictureLayerTiling { 44 class CC_EXPORT PictureLayerTiling {
43 public: 45 public:
44 ~PictureLayerTiling(); 46 ~PictureLayerTiling();
45 47
46 // Create a tiling with no tiles. CreateTiles must be called to add some. 48 // Create a tiling with no tiles. CreateTiles must be called to add some.
47 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); 49 static scoped_ptr<PictureLayerTiling> Create(
48 scoped_ptr<PictureLayerTiling> Clone() const; 50 float contents_scale,
49 51 gfx::Size layer_bounds,
52 PictureLayerTilingClient* client);
53 scoped_ptr<PictureLayerTiling> Clone(gfx::Size layer_bounds,
54 PictureLayerTilingClient* client) const;
50 gfx::Size layer_bounds() const { return layer_bounds_; } 55 gfx::Size layer_bounds() const { return layer_bounds_; }
51 void SetLayerBounds(gfx::Size layer_bounds);
52 void Invalidate(const Region& layer_invalidation);
53 void InvalidateTilesWithText(); 56 void InvalidateTilesWithText();
54 57
55 // Add any tiles that intersect with |layer_rect|. If any tiles already 58 // Add any tiles that intersect with |layer_rect|. If any tiles already
56 // exist, then this leaves them as-is. 59 // exist, then this leaves them as-is.
57 void CreateTilesFromLayerRect(gfx::Rect layer_rect);
58 60
59 void SetClient(PictureLayerTilingClient* client); 61 void SetClient(PictureLayerTilingClient* client);
60 void set_resolution(TileResolution resolution) { resolution_ = resolution; } 62 void set_resolution(TileResolution resolution) { resolution_ = resolution; }
61 TileResolution resolution() const { return resolution_; } 63 TileResolution resolution() const { return resolution_; }
62 64
63 gfx::Rect ContentRect() const; 65 gfx::Rect ContentRect() const;
64 gfx::SizeF ContentSizeF() const; 66 gfx::SizeF ContentSizeF() const;
65 float contents_scale() const { return contents_scale_; } 67 float contents_scale() const { return contents_scale_; }
66 68
69 void CreateAllTilesForTesting() {
70 SetLiveTilesRect(gfx::Rect(tiling_data_.total_size()));
71 }
72
67 std::vector<Tile*> AllTilesForTesting() const { 73 std::vector<Tile*> AllTilesForTesting() const {
68 std::vector<Tile*> all_tiles; 74 std::vector<Tile*> all_tiles;
69 for (TileMap::const_iterator it = tiles_.begin(); 75 for (TileMap::const_iterator it = tiles_.begin();
70 it != tiles_.end(); ++it) 76 it != tiles_.end(); ++it)
71 all_tiles.push_back(it->second); 77 all_tiles.push_back(it->second);
72 return all_tiles; 78 return all_tiles;
73 } 79 }
74 80
75 static gfx::Rect ExpandRectEquallyToAreaBoundedBy(
76 gfx::Rect starting_rect,
77 int64 target_area,
78 gfx::Rect bounding_rect);
79
80 // Iterate over all tiles to fill content_rect. Even if tiles are invalid 81 // Iterate over all tiles to fill content_rect. Even if tiles are invalid
81 // (i.e. no valid resource) this tiling should still iterate over them. 82 // (i.e. no valid resource) this tiling should still iterate over them.
82 // The union of all geometry_rect calls for each element iterated over should 83 // The union of all geometry_rect calls for each element iterated over should
83 // exactly equal content_rect and no two geometry_rects should intersect. 84 // exactly equal content_rect and no two geometry_rects should intersect.
84 class CC_EXPORT CoverageIterator { 85 class CC_EXPORT CoverageIterator {
85 public: 86 public:
86 CoverageIterator(); 87 CoverageIterator();
87 CoverageIterator(const PictureLayerTiling* tiling, 88 CoverageIterator(const PictureLayerTiling* tiling,
88 float dest_scale, 89 float dest_scale,
89 gfx::Rect rect); 90 gfx::Rect rect);
(...skipping 28 matching lines...) Expand all
118 int left_; 119 int left_;
119 int top_; 120 int top_;
120 int right_; 121 int right_;
121 int bottom_; 122 int bottom_;
122 123
123 friend class PictureLayerTiling; 124 friend class PictureLayerTiling;
124 }; 125 };
125 126
126 Region OpaqueRegionInContentRect(const gfx::Rect&) const; 127 Region OpaqueRegionInContentRect(const gfx::Rect&) const;
127 128
128 void Reset() { return tiles_.clear(); } 129 void Reset();
129 130
130 void UpdateTilePriorities( 131 void UpdateTilePriorities(
131 WhichTree tree, 132 WhichTree tree,
132 gfx::Size device_viewport, 133 gfx::Size device_viewport,
133 const gfx::RectF& viewport_in_layer_space, 134 const gfx::RectF& viewport_in_layer_space,
134 gfx::Size last_layer_bounds, 135 gfx::Size last_layer_bounds,
135 gfx::Size current_layer_bounds, 136 gfx::Size current_layer_bounds,
136 float last_layer_contents_scale, 137 float last_layer_contents_scale,
137 float current_layer_contents_scale, 138 float current_layer_contents_scale,
138 const gfx::Transform& last_screen_transform, 139 const gfx::Transform& last_screen_transform,
139 const gfx::Transform& current_screen_transform, 140 const gfx::Transform& current_screen_transform,
140 int current_source_frame_number, 141 int current_source_frame_number,
141 double current_frame_time, 142 double current_frame_time,
142 bool store_screen_space_quads_on_tiles, 143 bool store_screen_space_quads_on_tiles,
143 size_t max_tiles_for_interest_area); 144 size_t max_tiles_for_interest_area);
144 145
145 // Copies the src_tree priority into the dst_tree priority for all tiles. 146 // Copies the src_tree priority into the dst_tree priority for all tiles.
146 // The src_tree priority is reset to the lowest priority possible. This 147 // The src_tree priority is reset to the lowest priority possible. This
147 // also updates the pile on each tile to be the current client's pile. 148 // also updates the pile on each tile to be the current client's pile.
148 void DidBecomeActive(); 149 void DidBecomeActive();
149 150
150 scoped_ptr<base::Value> AsValue() const; 151 scoped_ptr<base::Value> AsValue() const;
151 152
153 static gfx::Rect ExpandRectEquallyToAreaBoundedBy(
154 gfx::Rect starting_rect,
155 int64 target_area,
156 gfx::Rect bounding_rect);
157
152 protected: 158 protected:
153 typedef std::pair<int, int> TileMapKey; 159 typedef std::pair<int, int> TileMapKey;
154 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; 160 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap;
155 161
156 explicit PictureLayerTiling(float contents_scale); 162 PictureLayerTiling(float contents_scale,
163 gfx::Size layer_bounds,
164 PictureLayerTilingClient* client);
165 void SetLiveTilesRect(gfx::Rect live_tiles_rect);
166 void CreateTile(int i, int j);
157 Tile* TileAt(int, int) const; 167 Tile* TileAt(int, int) const;
158 void CreateTilesFromContentRect(gfx::Rect layer_rect);
159 void CreateTile(int i, int j);
160 168
161 PictureLayerTilingClient* client_; 169 // Given properties.
162 float contents_scale_; 170 float contents_scale_;
163 gfx::Size layer_bounds_; 171 gfx::Size layer_bounds_;
164 gfx::Rect last_prioritized_rect_; 172 TileResolution resolution_;
165 // It is not legal to have a NULL tile in the tiles_ map. 173 PictureLayerTilingClient* client_;
166 TileMap tiles_; 174
175 // Internal data.
167 TilingData tiling_data_; 176 TilingData tiling_data_;
168 TileResolution resolution_; 177 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map.
178 gfx::Rect live_tiles_rect_;
179
180 // State saved for computing velocities based upon finite differences.
169 int last_source_frame_number_; 181 int last_source_frame_number_;
170 double last_impl_frame_time_; 182 double last_impl_frame_time_;
171 183
172 friend class CoverageIterator; 184 friend class CoverageIterator;
173 185
174 private: 186 private:
175 DISALLOW_ASSIGN(PictureLayerTiling); 187 DISALLOW_ASSIGN(PictureLayerTiling);
176 }; 188 };
177 189
178 } // namespace cc 190 } // namespace cc
179 191
180 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 192 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/resources/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698