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 10 matching lines...) Expand all Loading... |
21 namespace cc { | 21 namespace cc { |
22 | 22 |
23 class PictureLayerTiling; | 23 class PictureLayerTiling; |
24 | 24 |
25 class CC_EXPORT PictureLayerTilingClient { | 25 class CC_EXPORT PictureLayerTilingClient { |
26 public: | 26 public: |
27 // Create a tile at the given content_rect (in the contents scale of the | 27 // 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. | 28 // tiling) This might return null if the client cannot create such a tile. |
29 virtual scoped_refptr<Tile> CreateTile( | 29 virtual scoped_refptr<Tile> CreateTile( |
30 PictureLayerTiling* tiling, | 30 PictureLayerTiling* tiling, |
31 gfx::Rect content_rect) = 0; | 31 const gfx::Rect& content_rect) = 0; |
32 virtual void UpdatePile(Tile* tile) = 0; | 32 virtual void UpdatePile(Tile* tile) = 0; |
33 virtual gfx::Size CalculateTileSize( | 33 virtual gfx::Size CalculateTileSize( |
34 gfx::Size content_bounds) const = 0; | 34 gfx::Size content_bounds) const = 0; |
35 virtual const Region* GetInvalidation() = 0; | 35 virtual const Region* GetInvalidation() = 0; |
36 virtual const PictureLayerTiling* GetTwinTiling( | 36 virtual const PictureLayerTiling* GetTwinTiling( |
37 const PictureLayerTiling* tiling) const = 0; | 37 const PictureLayerTiling* tiling) const = 0; |
38 | 38 |
39 protected: | 39 protected: |
40 virtual ~PictureLayerTilingClient() {} | 40 virtual ~PictureLayerTilingClient() {} |
41 }; | 41 }; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 // Iterate over all tiles to fill content_rect. Even if tiles are invalid | 83 // Iterate over all tiles to fill content_rect. Even if tiles are invalid |
84 // (i.e. no valid resource) this tiling should still iterate over them. | 84 // (i.e. no valid resource) this tiling should still iterate over them. |
85 // The union of all geometry_rect calls for each element iterated over should | 85 // The union of all geometry_rect calls for each element iterated over should |
86 // exactly equal content_rect and no two geometry_rects should intersect. | 86 // exactly equal content_rect and no two geometry_rects should intersect. |
87 class CC_EXPORT CoverageIterator { | 87 class CC_EXPORT CoverageIterator { |
88 public: | 88 public: |
89 CoverageIterator(); | 89 CoverageIterator(); |
90 CoverageIterator(const PictureLayerTiling* tiling, | 90 CoverageIterator(const PictureLayerTiling* tiling, |
91 float dest_scale, | 91 float dest_scale, |
92 gfx::Rect rect); | 92 const gfx::Rect& rect); |
93 ~CoverageIterator(); | 93 ~CoverageIterator(); |
94 | 94 |
95 // Visible rect (no borders), always in the space of content_rect, | 95 // Visible rect (no borders), always in the space of content_rect, |
96 // regardless of the contents scale of the tiling. | 96 // regardless of the contents scale of the tiling. |
97 gfx::Rect geometry_rect() const; | 97 gfx::Rect geometry_rect() const; |
98 // Texture rect (in texels) for geometry_rect | 98 // Texture rect (in texels) for geometry_rect |
99 gfx::RectF texture_rect() const; | 99 gfx::RectF texture_rect() const; |
100 gfx::Size texture_size() const; | 100 gfx::Size texture_size() const; |
101 | 101 |
102 // Full rect (including borders) of the current tile, always in the space | 102 // Full rect (including borders) of the current tile, always in the space |
(...skipping 19 matching lines...) Expand all Loading... |
122 int tile_i_; | 122 int tile_i_; |
123 int tile_j_; | 123 int tile_j_; |
124 int left_; | 124 int left_; |
125 int top_; | 125 int top_; |
126 int right_; | 126 int right_; |
127 int bottom_; | 127 int bottom_; |
128 | 128 |
129 friend class PictureLayerTiling; | 129 friend class PictureLayerTiling; |
130 }; | 130 }; |
131 | 131 |
132 Region OpaqueRegionInContentRect(gfx::Rect content_rect) const; | 132 Region OpaqueRegionInContentRect(const gfx::Rect& content_rect) const; |
133 | 133 |
134 void Reset(); | 134 void Reset(); |
135 | 135 |
136 void UpdateTilePriorities( | 136 void UpdateTilePriorities( |
137 WhichTree tree, | 137 WhichTree tree, |
138 gfx::Size device_viewport, | 138 gfx::Size device_viewport, |
139 gfx::Rect viewport_in_layer_space, | 139 const gfx::Rect& viewport_in_layer_space, |
140 gfx::Rect visible_layer_rect, | 140 const gfx::Rect& visible_layer_rect, |
141 gfx::Size last_layer_bounds, | 141 gfx::Size last_layer_bounds, |
142 gfx::Size current_layer_bounds, | 142 gfx::Size current_layer_bounds, |
143 float last_layer_contents_scale, | 143 float last_layer_contents_scale, |
144 float current_layer_contents_scale, | 144 float current_layer_contents_scale, |
145 const gfx::Transform& last_screen_transform, | 145 const gfx::Transform& last_screen_transform, |
146 const gfx::Transform& current_screen_transform, | 146 const gfx::Transform& current_screen_transform, |
147 double current_frame_time_in_seconds, | 147 double current_frame_time_in_seconds, |
148 size_t max_tiles_for_interest_area); | 148 size_t max_tiles_for_interest_area); |
149 | 149 |
150 // Copies the src_tree priority into the dst_tree priority for all tiles. | 150 // Copies the src_tree priority into the dst_tree priority for all tiles. |
(...skipping 21 matching lines...) Expand all Loading... |
172 RectExpansionCache(); | 172 RectExpansionCache(); |
173 | 173 |
174 gfx::Rect previous_start; | 174 gfx::Rect previous_start; |
175 gfx::Rect previous_bounds; | 175 gfx::Rect previous_bounds; |
176 gfx::Rect previous_result; | 176 gfx::Rect previous_result; |
177 int64 previous_target; | 177 int64 previous_target; |
178 }; | 178 }; |
179 | 179 |
180 static | 180 static |
181 gfx::Rect ExpandRectEquallyToAreaBoundedBy( | 181 gfx::Rect ExpandRectEquallyToAreaBoundedBy( |
182 gfx::Rect starting_rect, | 182 const gfx::Rect& starting_rect, |
183 int64 target_area, | 183 int64 target_area, |
184 gfx::Rect bounding_rect, | 184 const gfx::Rect& bounding_rect, |
185 RectExpansionCache* cache); | 185 RectExpansionCache* cache); |
186 | 186 |
187 bool has_ever_been_updated() const { | 187 bool has_ever_been_updated() const { |
188 return last_impl_frame_time_in_seconds_ != 0.0; | 188 return last_impl_frame_time_in_seconds_ != 0.0; |
189 } | 189 } |
190 | 190 |
191 protected: | 191 protected: |
192 typedef std::pair<int, int> TileMapKey; | 192 typedef std::pair<int, int> TileMapKey; |
193 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; | 193 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; |
194 | 194 |
195 PictureLayerTiling(float contents_scale, | 195 PictureLayerTiling(float contents_scale, |
196 gfx::Size layer_bounds, | 196 gfx::Size layer_bounds, |
197 PictureLayerTilingClient* client); | 197 PictureLayerTilingClient* client); |
198 void SetLiveTilesRect(gfx::Rect live_tiles_rect); | 198 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); |
199 void CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); | 199 void CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); |
200 | 200 |
201 // Given properties. | 201 // Given properties. |
202 float contents_scale_; | 202 float contents_scale_; |
203 gfx::Size layer_bounds_; | 203 gfx::Size layer_bounds_; |
204 TileResolution resolution_; | 204 TileResolution resolution_; |
205 PictureLayerTilingClient* client_; | 205 PictureLayerTilingClient* client_; |
206 | 206 |
207 // Internal data. | 207 // Internal data. |
208 TilingData tiling_data_; | 208 TilingData tiling_data_; |
209 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 209 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
210 gfx::Rect live_tiles_rect_; | 210 gfx::Rect live_tiles_rect_; |
211 | 211 |
212 // State saved for computing velocities based upon finite differences. | 212 // State saved for computing velocities based upon finite differences. |
213 double last_impl_frame_time_in_seconds_; | 213 double last_impl_frame_time_in_seconds_; |
214 | 214 |
215 friend class CoverageIterator; | 215 friend class CoverageIterator; |
216 | 216 |
217 private: | 217 private: |
218 DISALLOW_ASSIGN(PictureLayerTiling); | 218 DISALLOW_ASSIGN(PictureLayerTiling); |
219 | 219 |
220 RectExpansionCache expansion_cache_; | 220 RectExpansionCache expansion_cache_; |
221 }; | 221 }; |
222 | 222 |
223 } // namespace cc | 223 } // namespace cc |
224 | 224 |
225 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 225 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |