OLD | NEW |
---|---|
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 Loading... | |
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 |
67 std::vector<Tile*> AllTilesForTesting() const { | 69 std::vector<Tile*> AllTilesForTesting() { |
70 SetLiveTilesRect(gfx::Rect(tiling_data_.total_size())); | |
71 | |
68 std::vector<Tile*> all_tiles; | 72 std::vector<Tile*> all_tiles; |
69 for (TileMap::const_iterator it = tiles_.begin(); | 73 for (TileMap::const_iterator it = tiles_.begin(); |
70 it != tiles_.end(); ++it) | 74 it != tiles_.end(); ++it) |
71 all_tiles.push_back(it->second); | 75 all_tiles.push_back(it->second); |
72 return all_tiles; | 76 return all_tiles; |
73 } | 77 } |
74 | 78 |
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 | 79 // 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. | 80 // (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 | 81 // 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. | 82 // exactly equal content_rect and no two geometry_rects should intersect. |
84 class CC_EXPORT CoverageIterator { | 83 class CC_EXPORT CoverageIterator { |
85 public: | 84 public: |
86 CoverageIterator(); | 85 CoverageIterator(); |
87 CoverageIterator(const PictureLayerTiling* tiling, | 86 CoverageIterator(const PictureLayerTiling* tiling, |
88 float dest_scale, | 87 float dest_scale, |
89 gfx::Rect rect); | 88 gfx::Rect rect); |
(...skipping 28 matching lines...) Expand all Loading... | |
118 int left_; | 117 int left_; |
119 int top_; | 118 int top_; |
120 int right_; | 119 int right_; |
121 int bottom_; | 120 int bottom_; |
122 | 121 |
123 friend class PictureLayerTiling; | 122 friend class PictureLayerTiling; |
124 }; | 123 }; |
125 | 124 |
126 Region OpaqueRegionInContentRect(const gfx::Rect&) const; | 125 Region OpaqueRegionInContentRect(const gfx::Rect&) const; |
127 | 126 |
128 void Reset() { return tiles_.clear(); } | 127 void Reset(); |
129 | 128 |
130 void UpdateTilePriorities( | 129 void UpdateTilePriorities( |
131 WhichTree tree, | 130 WhichTree tree, |
132 gfx::Size device_viewport, | 131 gfx::Size device_viewport, |
133 const gfx::RectF& viewport_in_layer_space, | 132 const gfx::RectF& viewport_in_layer_space, |
134 gfx::Size last_layer_bounds, | 133 gfx::Size last_layer_bounds, |
135 gfx::Size current_layer_bounds, | 134 gfx::Size current_layer_bounds, |
136 float last_layer_contents_scale, | 135 float last_layer_contents_scale, |
137 float current_layer_contents_scale, | 136 float current_layer_contents_scale, |
138 const gfx::Transform& last_screen_transform, | 137 const gfx::Transform& last_screen_transform, |
139 const gfx::Transform& current_screen_transform, | 138 const gfx::Transform& current_screen_transform, |
140 int current_source_frame_number, | 139 int current_source_frame_number, |
141 double current_frame_time, | 140 double current_frame_time, |
142 bool store_screen_space_quads_on_tiles, | 141 bool store_screen_space_quads_on_tiles, |
143 size_t max_tiles_for_interest_area); | 142 size_t max_tiles_for_interest_area); |
144 | 143 |
145 // Copies the src_tree priority into the dst_tree priority for all tiles. | 144 // 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 | 145 // 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. | 146 // also updates the pile on each tile to be the current client's pile. |
148 void DidBecomeActive(); | 147 void DidBecomeActive(); |
149 | 148 |
150 scoped_ptr<base::Value> AsValue() const; | 149 scoped_ptr<base::Value> AsValue() const; |
151 | 150 |
151 static gfx::Rect ExpandRectEquallyToAreaBoundedBy( | |
152 gfx::Rect starting_rect, | |
153 int64 target_area, | |
154 gfx::Rect bounding_rect); | |
155 | |
156 gfx::Size tile_bounds() const { | |
157 return tiling_data_.max_texture_size(); | |
158 } | |
159 | |
160 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); | |
enne (OOO)
2013/04/10 20:25:30
I don't like making all of these functions public
whunt
2013/04/10 20:52:30
It's not unreasonable to add SetLiveTilesRect to t
| |
161 void CreateTile(int i, int j); | |
enne (OOO)
2013/04/10 20:25:30
This doesn't look like it needs to be exposed.
| |
162 const TilingData& tiling_data() const { return tiling_data_; } | |
163 Tile* TileAt(int, int) const; | |
164 | |
152 protected: | 165 protected: |
153 typedef std::pair<int, int> TileMapKey; | 166 typedef std::pair<int, int> TileMapKey; |
154 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; | 167 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; |
155 | 168 |
156 explicit PictureLayerTiling(float contents_scale); | 169 PictureLayerTiling(float contents_scale, |
157 Tile* TileAt(int, int) const; | 170 gfx::Size layer_bounds, |
158 void CreateTilesFromContentRect(gfx::Rect layer_rect); | 171 PictureLayerTilingClient* client); |
159 void CreateTile(int i, int j); | |
160 | 172 |
161 PictureLayerTilingClient* client_; | 173 // Given properties. |
162 float contents_scale_; | 174 float contents_scale_; |
163 gfx::Size layer_bounds_; | 175 gfx::Size layer_bounds_; |
164 gfx::Rect last_prioritized_rect_; | 176 TileResolution resolution_; |
165 // It is not legal to have a NULL tile in the tiles_ map. | 177 PictureLayerTilingClient* client_; |
166 TileMap tiles_; | 178 |
179 // Internal data. | |
167 TilingData tiling_data_; | 180 TilingData tiling_data_; |
168 TileResolution resolution_; | 181 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
182 gfx::Rect live_tiles_rect_; | |
183 | |
184 // State saved for computing velocities based upon finite differences. | |
169 int last_source_frame_number_; | 185 int last_source_frame_number_; |
170 double last_impl_frame_time_; | 186 double last_impl_frame_time_; |
171 | 187 |
172 friend class CoverageIterator; | 188 friend class CoverageIterator; |
173 | 189 |
174 private: | 190 private: |
175 DISALLOW_ASSIGN(PictureLayerTiling); | 191 DISALLOW_ASSIGN(PictureLayerTiling); |
176 }; | 192 }; |
177 | 193 |
178 } // namespace cc | 194 } // namespace cc |
179 | 195 |
180 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 196 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |