| 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_PICTURE_LAYER_TILING_H_ | 5 #ifndef CC_PICTURE_LAYER_TILING_H_ |
| 6 #define CC_PICTURE_LAYER_TILING_H_ | 6 #define CC_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/cc_export.h" | 11 #include "cc/cc_export.h" |
| 12 #include "cc/hash_pair.h" | 12 #include "cc/hash_pair.h" |
| 13 #include "cc/region.h" | 13 #include "cc/region.h" |
| 14 #include "cc/tile.h" | 14 #include "cc/tile.h" |
| 15 #include "cc/tile_priority.h" | 15 #include "cc/tile_priority.h" |
| 16 #include "cc/tiling_data.h" | 16 #include "cc/tiling_data.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 class ManagedTileState; |
| 22 | 23 |
| 23 class PictureLayerTilingClient { | 24 class PictureLayerTilingClient { |
| 24 public: | 25 public: |
| 25 // Create a tile at the given content_rect (in the contents scale of the | 26 // 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. | 27 // tiling) This might return null if the client cannot create such a tile. |
| 27 virtual scoped_refptr<Tile> CreateTile( | 28 virtual scoped_refptr<Tile> CreateTile( |
| 28 PictureLayerTiling* tiling, | 29 PictureLayerTiling* tiling, |
| 29 gfx::Rect content_rect) = 0; | 30 gfx::Rect content_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; |
| 34 }; | 35 }; |
| 35 | 36 |
| 37 class TileHandle { |
| 38 public: |
| 39 TileHandle(scoped_refptr<Tile> tile); |
| 40 ~TileHandle(); |
| 41 Tile* tile() const { return tile_.get(); } |
| 42 private: |
| 43 scoped_refptr<Tile> tile_; |
| 44 scoped_refptr<ManagedTileState> managed_tile_state_; |
| 45 }; |
| 46 |
| 36 class CC_EXPORT PictureLayerTiling { | 47 class CC_EXPORT PictureLayerTiling { |
| 37 public: | 48 public: |
| 38 ~PictureLayerTiling(); | 49 ~PictureLayerTiling(); |
| 39 | 50 |
| 40 // Create a tiling with no tiles. CreateTiles must be called to add some. | 51 // Create a tiling with no tiles. CreateTiles must be called to add some. |
| 41 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); | 52 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); |
| 42 scoped_ptr<PictureLayerTiling> Clone() const; | 53 scoped_ptr<PictureLayerTiling> Clone() const; |
| 43 | 54 |
| 44 gfx::Size layer_bounds() const { return layer_bounds_; } | 55 gfx::Size layer_bounds() const { return layer_bounds_; } |
| 45 void SetLayerBounds(gfx::Size layer_bounds); | 56 void SetLayerBounds(gfx::Size layer_bounds); |
| 46 void Invalidate(const Region& layer_invalidation); | 57 void Invalidate(const Region& layer_invalidation); |
| 47 | 58 |
| 48 // Add any tiles that intersect with |layer_rect|. If any tiles already | 59 // Add any tiles that intersect with |layer_rect|. If any tiles already |
| 49 // exist, then this leaves them as-is. | 60 // exist, then this leaves them as-is. |
| 50 void CreateTilesFromLayerRect(gfx::Rect layer_rect); | 61 void CreateTilesFromLayerRect(gfx::Rect layer_rect); |
| 51 | 62 |
| 52 void SetClient(PictureLayerTilingClient* client); | 63 void SetClient(PictureLayerTilingClient* client); |
| 53 void set_resolution(TileResolution resolution) { resolution_ = resolution; } | 64 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
| 54 TileResolution resolution() const { return resolution_; } | 65 TileResolution resolution() const { return resolution_; } |
| 55 | 66 |
| 56 gfx::Rect ContentRect() const; | 67 gfx::Rect ContentRect() const; |
| 57 gfx::SizeF ContentSizeF() const; | 68 gfx::SizeF ContentSizeF() const; |
| 58 float contents_scale() const { return contents_scale_; } | 69 float contents_scale() const { return contents_scale_; } |
| 59 | 70 |
| 60 std::vector<Tile*> AllTilesForTesting() const { | 71 std::vector<Tile*> AllTilesForTesting() const { |
| 61 std::vector<Tile*> all_tiles; | 72 std::vector<Tile*> all_tiles; |
| 62 for (TileMap::const_iterator it = tiles_.begin(); | 73 for (TileMap::const_iterator it = tiles_.begin(); |
| 63 it != tiles_.end(); ++it) | 74 it != tiles_.end(); ++it) |
| 64 all_tiles.push_back(it->second); | 75 all_tiles.push_back(it->second.tile()); |
| 65 return all_tiles; | 76 return all_tiles; |
| 66 } | 77 } |
| 67 | 78 |
| 68 enum LayerDeviceAlignment { | 79 enum LayerDeviceAlignment { |
| 69 LayerDeviceAlignmentUnknown, | 80 LayerDeviceAlignmentUnknown, |
| 70 LayerAlignedToDevice, | 81 LayerAlignedToDevice, |
| 71 LayerNotAlignedToDevice, | 82 LayerNotAlignedToDevice, |
| 72 }; | 83 }; |
| 73 | 84 |
| 74 // Iterate over all tiles to fill content_rect. Even if tiles are invalid | 85 // Iterate over all tiles to fill content_rect. Even if tiles are invalid |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 152 |
| 142 // Copies the src_tree priority into the dst_tree priority for all tiles. | 153 // Copies the src_tree priority into the dst_tree priority for all tiles. |
| 143 // The src_tree priority is reset to the lowest priority possible. This | 154 // The src_tree priority is reset to the lowest priority possible. This |
| 144 // also updates the pile on each tile to be the current client's pile. | 155 // also updates the pile on each tile to be the current client's pile. |
| 145 void DidBecomeActive(); | 156 void DidBecomeActive(); |
| 146 | 157 |
| 147 scoped_ptr<base::Value> AsValue() const; | 158 scoped_ptr<base::Value> AsValue() const; |
| 148 | 159 |
| 149 protected: | 160 protected: |
| 150 typedef std::pair<int, int> TileMapKey; | 161 typedef std::pair<int, int> TileMapKey; |
| 151 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; | 162 typedef base::hash_map<TileMapKey, TileHandle> TileMap; |
| 152 | 163 |
| 153 PictureLayerTiling(float contents_scale); | 164 PictureLayerTiling(float contents_scale); |
| 154 Tile* TileAt(int, int) const; | 165 Tile* TileAt(int, int) const; |
| 155 void CreateTilesFromContentRect(gfx::Rect layer_rect); | 166 void CreateTilesFromContentRect(gfx::Rect layer_rect); |
| 156 void CreateTile(int i, int j); | 167 void CreateTile(int i, int j); |
| 157 | 168 |
| 158 PictureLayerTilingClient* client_; | 169 PictureLayerTilingClient* client_; |
| 159 float contents_scale_; | 170 float contents_scale_; |
| 160 gfx::Size layer_bounds_; | 171 gfx::Size layer_bounds_; |
| 161 gfx::Rect last_prioritized_rect_; | 172 gfx::Rect last_prioritized_rect_; |
| 162 // It is not legal to have a NULL tile in the tiles_ map. | 173 // It is not legal to have a NULL tile in the tiles_ map. |
| 163 TileMap tiles_; | 174 TileMap tiles_; |
| 164 TilingData tiling_data_; | 175 TilingData tiling_data_; |
| 165 TileResolution resolution_; | 176 TileResolution resolution_; |
| 166 int last_source_frame_number_; | 177 int last_source_frame_number_; |
| 167 double last_impl_frame_time_; | 178 double last_impl_frame_time_; |
| 168 | 179 |
| 169 friend class Iterator; | 180 friend class Iterator; |
| 170 }; | 181 }; |
| 171 | 182 |
| 172 } // namespace cc | 183 } // namespace cc |
| 173 | 184 |
| 174 #endif // CC_PICTURE_LAYER_TILING_H_ | 185 #endif // CC_PICTURE_LAYER_TILING_H_ |
| OLD | NEW |