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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "cc/base/hash_pair.h" | 12 #include "cc/base/hash_pair.h" |
| 13 #include "cc/base/region.h" | 13 #include "cc/base/region.h" |
| 14 #include "cc/base/tiling_data.h" | 14 #include "cc/base/tiling_data.h" |
| 15 #include "cc/resources/tile.h" | 15 #include "cc/resources/tile.h" |
| 16 #include "cc/resources/tile_priority.h" | 16 #include "cc/resources/tile_priority.h" |
| 17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 | 20 |
| 21 class PictureLayerTiling; | 21 class PictureLayerTiling; |
| 22 | 22 |
| 23 class PictureLayerTilingClient { | 23 class PictureLayerTilingClient { |
| 24 public: | 24 public: |
| 25 // Create a tile at the given content_rect (in the contents scale of the | 25 // Create a tile at the given content_rect (in the contents scale of the |
| 26 // tiling) This might return null if the client cannot create such a tile. | 26 // tiling) This might return null if the client cannot create such a tile. |
| 27 virtual scoped_refptr<Tile> CreateTile( | 27 virtual scoped_refptr<Tile> CreateTile( |
| 28 PictureLayerTiling* tiling, | 28 PictureLayerTiling* tiling, |
| 29 gfx::Rect content_rect) = 0; | 29 const gfx::Rect& content_rect, |
| 30 const gfx::Rect& paint_rect) = 0; | |
| 30 virtual void UpdatePile(Tile* tile) = 0; | 31 virtual void UpdatePile(Tile* tile) = 0; |
| 31 virtual gfx::Size CalculateTileSize( | 32 virtual gfx::Size CalculateTileSize( |
| 32 gfx::Size current_tile_size, | 33 gfx::Size current_tile_size, |
| 33 gfx::Size content_bounds) = 0; | 34 gfx::Size content_bounds) = 0; |
| 35 virtual const Region* GetInvalidation() = 0; | |
| 36 virtual const PictureLayerTiling* GetSibling(const PictureLayerTiling* tiling) = 0; | |
| 34 }; | 37 }; |
| 35 | 38 |
| 36 class CC_EXPORT PictureLayerTiling { | 39 class CC_EXPORT PictureLayerTiling { |
| 37 public: | 40 public: |
| 38 ~PictureLayerTiling(); | 41 ~PictureLayerTiling(); |
| 39 | 42 |
| 40 // Create a tiling with no tiles. CreateTiles must be called to add some. | 43 // Create a tiling with no tiles. CreateTiles must be called to add some. |
| 41 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); | 44 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); |
| 42 scoped_ptr<PictureLayerTiling> Clone() const; | 45 scoped_ptr<PictureLayerTiling> Clone() const; |
| 43 | 46 |
| 44 gfx::Size layer_bounds() const { return layer_bounds_; } | 47 gfx::Size layer_bounds() const { return layer_bounds_; } |
| 45 void SetLayerBounds(gfx::Size layer_bounds); | 48 void SetLayerBounds(gfx::Size layer_bounds); |
| 46 void Invalidate(const Region& layer_invalidation); | |
| 47 | 49 |
| 48 // Add any tiles that intersect with |layer_rect|. If any tiles already | 50 // Add any tiles that intersect with |layer_rect|. If any tiles already |
| 49 // exist, then this leaves them as-is. | 51 // exist, then this leaves them as-is. |
| 50 void CreateTilesFromLayerRect(gfx::Rect layer_rect); | 52 void CreateTilesFromLayerRect(gfx::Rect layer_rect); |
| 51 | 53 |
| 52 void SetClient(PictureLayerTilingClient* client); | 54 void SetClient(PictureLayerTilingClient* client); |
| 53 void set_resolution(TileResolution resolution) { resolution_ = resolution; } | 55 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
| 54 TileResolution resolution() const { return resolution_; } | 56 TileResolution resolution() const { return resolution_; } |
| 55 | 57 |
| 56 gfx::Rect ContentRect() const; | 58 gfx::Rect ContentRect() const; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 // also updates the pile on each tile to be the current client's pile. | 141 // also updates the pile on each tile to be the current client's pile. |
| 140 void DidBecomeActive(); | 142 void DidBecomeActive(); |
| 141 | 143 |
| 142 scoped_ptr<base::Value> AsValue() const; | 144 scoped_ptr<base::Value> AsValue() const; |
| 143 | 145 |
| 144 protected: | 146 protected: |
| 145 typedef std::pair<int, int> TileMapKey; | 147 typedef std::pair<int, int> TileMapKey; |
| 146 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; | 148 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; |
| 147 | 149 |
| 148 PictureLayerTiling(float contents_scale); | 150 PictureLayerTiling(float contents_scale); |
| 151 PictureLayerTiling(const PictureLayerTiling& other, int); | |
| 149 Tile* TileAt(int, int) const; | 152 Tile* TileAt(int, int) const; |
| 150 void CreateTilesFromContentRect(gfx::Rect layer_rect); | 153 void CreateTilesFromContentRect(gfx::Rect layer_rect); |
| 151 void CreateTile(int i, int j); | 154 void CreateTile(int i, int j); |
| 152 | 155 |
| 153 PictureLayerTilingClient* client_; | 156 // Given properties. |
| 154 float contents_scale_; | 157 float contents_scale_; |
| 155 gfx::Size layer_bounds_; | 158 gfx::Size layer_bounds_; |
| 156 gfx::Rect last_prioritized_rect_; | 159 TileResolution resolution_; |
| 157 // It is not legal to have a NULL tile in the tiles_ map. | 160 PictureLayerTilingClient* client_; |
| 158 TileMap tiles_; | 161 |
| 162 // Internal data. | |
| 159 TilingData tiling_data_; | 163 TilingData tiling_data_; |
| 160 TileResolution resolution_; | 164 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
| 165 | |
| 166 // State saved for computing velocities based upon finite differences. | |
| 167 gfx::Rect interest_rect_; | |
| 168 gfx::Rect last_interest_rect_; | |
| 161 int last_source_frame_number_; | 169 int last_source_frame_number_; |
| 162 double last_impl_frame_time_; | 170 double last_impl_frame_time_; |
| 163 | 171 |
| 164 friend class Iterator; | 172 // An iterator that iterates over the TileMapKeys within a gfx::Rect. |
|
enne (OOO)
2013/03/27 16:16:27
Do you need a new iterator class here? Why not jus
| |
| 173 class CC_EXPORT SimpleIterator { | |
| 174 public: | |
| 175 SimpleIterator(const PictureLayerTiling* tiling, | |
| 176 const gfx::Rect& rect); // we assume rect is contained | |
|
enne (OOO)
2013/03/27 16:16:27
Please don't make multi-line comments at the end o
| |
| 177 // within tiling's content | |
| 178 | |
| 179 TileMapKey operator->() const { return key_; } | |
| 180 TileMapKey operator*() const { return key_; } | |
| 181 | |
| 182 SimpleIterator& operator++(); | |
| 183 operator bool() const { return key_.second < bottom_; } | |
| 184 | |
| 185 private: | |
| 186 TileMapKey key_; | |
| 187 int left_; | |
| 188 int right_; // left_ <= key_.first < right_ | |
| 189 int bottom_; // key_.second < bottom_ | |
| 190 }; | |
| 191 | |
| 192 void ManageTiles(const gfx::Rect& old_interest_rect, | |
| 193 const gfx::Rect& new_interest_rect); | |
| 165 }; | 194 }; |
| 166 | 195 |
| 167 } // namespace cc | 196 } // namespace cc |
| 168 | 197 |
| 169 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 198 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
| OLD | NEW |