Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 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, | 35 gfx::Size current_tile_size, |
| 36 gfx::Size content_bounds) = 0; | 36 gfx::Size content_bounds) = 0; |
| 37 virtual const Region* GetInvalidation() = 0; | |
| 38 virtual const PictureLayerTiling* GetTwinTiling( | |
| 39 const PictureLayerTiling* tiling) = 0; | |
| 37 | 40 |
| 38 protected: | 41 protected: |
| 39 virtual ~PictureLayerTilingClient() {} | 42 virtual ~PictureLayerTilingClient() {} |
| 40 }; | 43 }; |
| 41 | 44 |
| 42 class CC_EXPORT PictureLayerTiling { | 45 class CC_EXPORT PictureLayerTiling { |
| 43 public: | 46 public: |
| 44 ~PictureLayerTiling(); | 47 ~PictureLayerTiling(); |
| 45 | 48 |
| 46 // Create a tiling with no tiles. CreateTiles must be called to add some. | 49 // Create a tiling with no tiles. CreateTiles must be called to add some. |
| 47 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); | 50 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); |
| 48 scoped_ptr<PictureLayerTiling> Clone() const; | 51 scoped_ptr<PictureLayerTiling> Clone() const; |
| 49 | 52 |
| 50 gfx::Size layer_bounds() const { return layer_bounds_; } | 53 gfx::Size layer_bounds() const { return layer_bounds_; } |
| 51 void SetLayerBounds(gfx::Size layer_bounds); | 54 void SetLayerBounds(gfx::Size layer_bounds); |
| 52 void Invalidate(const Region& layer_invalidation); | |
| 53 | 55 |
| 54 // Add any tiles that intersect with |layer_rect|. If any tiles already | 56 // Add any tiles that intersect with |layer_rect|. If any tiles already |
| 55 // exist, then this leaves them as-is. | 57 // exist, then this leaves them as-is. |
| 56 void CreateTilesFromLayerRect(gfx::Rect layer_rect); | |
| 57 | 58 |
| 58 void SetClient(PictureLayerTilingClient* client); | 59 void SetClient(PictureLayerTilingClient* client); |
| 59 void set_resolution(TileResolution resolution) { resolution_ = resolution; } | 60 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
| 60 TileResolution resolution() const { return resolution_; } | 61 TileResolution resolution() const { return resolution_; } |
| 61 | 62 |
| 62 gfx::Rect ContentRect() const; | 63 gfx::Rect ContentRect() const; |
| 63 gfx::SizeF ContentSizeF() const; | 64 gfx::SizeF ContentSizeF() const; |
| 64 float contents_scale() const { return contents_scale_; } | 65 float contents_scale() const { return contents_scale_; } |
| 65 | 66 |
| 66 std::vector<Tile*> AllTilesForTesting() const { | 67 std::vector<Tile*> AllTilesForTesting() const { |
| 67 std::vector<Tile*> all_tiles; | 68 std::vector<Tile*> all_tiles; |
| 68 for (TileMap::const_iterator it = tiles_.begin(); | 69 for (TileMap::const_iterator it = tiles_.begin(); |
| 69 it != tiles_.end(); ++it) | 70 it != tiles_.end(); ++it) |
| 70 all_tiles.push_back(it->second); | 71 all_tiles.push_back(it->second); |
| 71 return all_tiles; | 72 return all_tiles; |
| 72 } | 73 } |
| 73 | 74 |
| 74 static gfx::Rect ExpandRectEquallyToAreaBoundedBy( | |
| 75 gfx::Rect starting_rect, | |
| 76 int64 target_area, | |
| 77 gfx::Rect bounding_rect); | |
| 78 | |
| 79 // Iterate over all tiles to fill content_rect. Even if tiles are invalid | 75 // Iterate over all tiles to fill content_rect. Even if tiles are invalid |
| 80 // (i.e. no valid resource) this tiling should still iterate over them. | 76 // (i.e. no valid resource) this tiling should still iterate over them. |
| 81 // The union of all geometry_rect calls for each element iterated over should | 77 // The union of all geometry_rect calls for each element iterated over should |
| 82 // exactly equal content_rect and no two geometry_rects should intersect. | 78 // exactly equal content_rect and no two geometry_rects should intersect. |
| 83 class CC_EXPORT Iterator { | 79 class CC_EXPORT Iterator { |
| 84 public: | 80 public: |
| 85 Iterator(); | 81 Iterator(); |
| 86 Iterator(const PictureLayerTiling* tiling, | 82 Iterator(const PictureLayerTiling* tiling, |
| 87 float dest_scale, | 83 float dest_scale, |
| 88 gfx::Rect rect); | 84 gfx::Rect rect); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 void DidBecomeActive(); | 143 void DidBecomeActive(); |
| 148 | 144 |
| 149 scoped_ptr<base::Value> AsValue() const; | 145 scoped_ptr<base::Value> AsValue() const; |
| 150 | 146 |
| 151 protected: | 147 protected: |
| 152 typedef std::pair<int, int> TileMapKey; | 148 typedef std::pair<int, int> TileMapKey; |
| 153 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; | 149 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; |
| 154 | 150 |
| 155 explicit PictureLayerTiling(float contents_scale); | 151 explicit PictureLayerTiling(float contents_scale); |
| 156 Tile* TileAt(int, int) const; | 152 Tile* TileAt(int, int) const; |
| 157 void CreateTilesFromContentRect(gfx::Rect layer_rect); | |
| 158 void CreateTile(int i, int j); | 153 void CreateTile(int i, int j); |
| 159 | 154 |
| 160 PictureLayerTilingClient* client_; | 155 static gfx::Rect ExpandRectEquallyToAreaBoundedBy( |
| 156 gfx::Rect starting_rect, | |
| 157 int64 target_area, | |
| 158 gfx::Rect bounding_rect); | |
| 159 | |
| 160 // Given properties. | |
| 161 float contents_scale_; | 161 float contents_scale_; |
| 162 gfx::Size layer_bounds_; | 162 gfx::Size layer_bounds_; |
| 163 gfx::Rect last_prioritized_rect_; | 163 TileResolution resolution_; |
| 164 // It is not legal to have a NULL tile in the tiles_ map. | 164 PictureLayerTilingClient* client_; |
| 165 TileMap tiles_; | 165 |
| 166 // Internal data. | |
| 166 TilingData tiling_data_; | 167 TilingData tiling_data_; |
| 167 TileResolution resolution_; | 168 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
| 169 | |
| 170 // State saved for computing velocities based upon finite differences. | |
| 171 gfx::Rect interest_rect_; | |
|
enne (OOO)
2013/03/29 20:50:58
Can you call this last_interest_rect_ to match the
whunt
2013/03/29 21:52:04
I *can*, it doesn't quite follow the same semantic
enne (OOO)
2013/03/29 22:34:20
By "a variety of places" you mean "can be cleared
| |
| 168 int last_source_frame_number_; | 172 int last_source_frame_number_; |
| 169 double last_impl_frame_time_; | 173 double last_impl_frame_time_; |
| 170 | 174 |
| 171 friend class Iterator; | 175 friend class Iterator; |
| 172 | 176 |
| 173 private: | 177 private: |
| 174 DISALLOW_ASSIGN(PictureLayerTiling); | 178 DISALLOW_ASSIGN(PictureLayerTiling); |
|
enne (OOO)
2013/03/29 20:50:58
style nit: DISALLOW_etc goes last in a class decla
whunt
2013/03/29 21:52:04
Ahh, okay, this is where it merged in, I'll move i
| |
| 179 void ManageTiles(const gfx::Rect& old_interest_rect, | |
| 180 const gfx::Rect& new_interest_rect); | |
| 175 }; | 181 }; |
| 176 | 182 |
| 177 } // namespace cc | 183 } // namespace cc |
| 178 | 184 |
| 179 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 185 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
| OLD | NEW |