Chromium Code Reviews| Index: cc/resources/picture_layer_tiling.h | 
| diff --git a/cc/resources/picture_layer_tiling.h b/cc/resources/picture_layer_tiling.h | 
| index dae62723711ee741adfe368e43ecc700afe137d3..07eae03ab5e9e4cdc35a9de3245bfb321472cce8 100644 | 
| --- a/cc/resources/picture_layer_tiling.h | 
| +++ b/cc/resources/picture_layer_tiling.h | 
| @@ -15,6 +15,7 @@ | 
| #include "cc/base/region.h" | 
| #include "cc/base/tiling_data.h" | 
| #include "cc/resources/tile.h" | 
| +#include "cc/resources/tile_bundle.h" | 
| #include "cc/resources/tile_priority.h" | 
| #include "ui/gfx/rect.h" | 
| @@ -29,12 +30,18 @@ class CC_EXPORT PictureLayerTilingClient { | 
| virtual scoped_refptr<Tile> CreateTile( | 
| PictureLayerTiling* tiling, | 
| gfx::Rect content_rect) = 0; | 
| + virtual scoped_refptr<TileBundle> CreateTileBundle(int offset_x, | 
| + int offset_y, | 
| + int width, | 
| + int height) = 0; | 
| virtual void UpdatePile(Tile* tile) = 0; | 
| virtual gfx::Size CalculateTileSize( | 
| gfx::Size content_bounds) const = 0; | 
| virtual const Region* GetInvalidation() = 0; | 
| virtual const PictureLayerTiling* GetTwinTiling( | 
| const PictureLayerTiling* tiling) const = 0; | 
| + virtual bool IsActive() const = 0; | 
| + virtual bool IsPending() const = 0; | 
| protected: | 
| virtual ~PictureLayerTilingClient() {} | 
| @@ -66,19 +73,65 @@ class CC_EXPORT PictureLayerTiling { | 
| gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } | 
| float contents_scale() const { return contents_scale_; } | 
| + Tile* TileAt(WhichTree tree, int, int) const; | 
| + | 
| void CreateAllTilesForTesting() { | 
| - SetLiveTilesRect(gfx::Rect(tiling_data_.total_size())); | 
| + SetLiveTilesRect(ACTIVE_TREE, gfx::Rect(tiling_data_.total_size())); | 
| + live_tiles_rect_ = gfx::Rect(); | 
| + SetLiveTilesRect(PENDING_TREE, gfx::Rect(tiling_data_.total_size())); | 
| + } | 
| + | 
| + void CreateAllPendingTilesForTesting() { | 
| + SetLiveTilesRect(PENDING_TREE, gfx::Rect(tiling_data_.total_size())); | 
| + } | 
| + void CreateAllActiveTilesForTesting() { | 
| + SetLiveTilesRect(ACTIVE_TREE, gfx::Rect(tiling_data_.total_size())); | 
| } | 
| std::vector<Tile*> AllTilesForTesting() const { | 
| std::vector<Tile*> all_tiles; | 
| - for (TileMap::const_iterator it = tiles_.begin(); | 
| - it != tiles_.end(); ++it) | 
| - all_tiles.push_back(it->second.get()); | 
| + for (TileBundleMap::const_iterator it = tile_bundles_.begin(); | 
| + it != tile_bundles_.end(); ++it) { | 
| + for (TileBundle::Iterator tile_it(it->second.get()); tile_it; ++tile_it) | 
| + all_tiles.push_back(*tile_it); | 
| + } | 
| return all_tiles; | 
| } | 
| - Tile* TileAt(int i, int j) const; | 
| + std::vector<TileBundle*> AllTileBundlesForTesting() const { | 
| + std::vector<TileBundle*> all_bundles; | 
| + for (TileBundleMap::const_iterator it = tile_bundles_.begin(); | 
| + it != tile_bundles_.end(); ++it) { | 
| + all_bundles.push_back(it->second.get()); | 
| + } | 
| + return all_bundles; | 
| + } | 
| + | 
| + std::vector<Tile*> AllPendingTilesForTesting() const { | 
| + std::vector<Tile*> all_tiles; | 
| + for (TileBundleMap::const_iterator it = tile_bundles_.begin(); | 
| + it != tile_bundles_.end(); ++it) { | 
| + for (TileBundle::Iterator tile_it(it->second.get(), PENDING_TREE); | 
| + tile_it; | 
| + ++tile_it) { | 
| + all_tiles.push_back(*tile_it); | 
| + } | 
| + } | 
| + return all_tiles; | 
| + } | 
| + | 
| + std::vector<Tile*> AllActiveTilesForTesting() const { | 
| + std::vector<Tile*> all_tiles; | 
| + for (TileBundleMap::const_iterator it = tile_bundles_.begin(); | 
| + it != tile_bundles_.end(); ++it) { | 
| + for (TileBundle::Iterator tile_it(it->second.get(), ACTIVE_TREE); | 
| + tile_it; | 
| + ++tile_it) { | 
| + all_tiles.push_back(*tile_it); | 
| + } | 
| + } | 
| + return all_tiles; | 
| + } | 
| // Iterate over all tiles to fill content_rect. Even if tiles are invalid | 
| // (i.e. no valid resource) this tiling should still iterate over them. | 
| @@ -106,6 +159,9 @@ class CC_EXPORT PictureLayerTiling { | 
| Tile* operator->() const { return current_tile_; } | 
| Tile* operator*() const { return current_tile_; } | 
| + TilePriority priority(); | 
| + void SetPriorityForTesting(const TilePriority& priority); | 
| + | 
| CoverageIterator& operator++(); | 
| operator bool() const { return tile_j_ <= bottom_; } | 
| @@ -125,6 +181,7 @@ class CC_EXPORT PictureLayerTiling { | 
| int top_; | 
| int right_; | 
| int bottom_; | 
| + WhichTree tree_; | 
| friend class PictureLayerTiling; | 
| }; | 
| @@ -189,14 +246,27 @@ class CC_EXPORT PictureLayerTiling { | 
| } | 
| protected: | 
| - typedef std::pair<int, int> TileMapKey; | 
| - typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; | 
| + friend class TileBundle; | 
| + | 
| + typedef std::pair<int, int> TileBundleMapKey; | 
| + typedef base::hash_map<TileBundleMapKey, scoped_refptr<TileBundle> > | 
| + TileBundleMap; | 
| PictureLayerTiling(float contents_scale, | 
| gfx::Size layer_bounds, | 
| PictureLayerTilingClient* client); | 
| - void SetLiveTilesRect(gfx::Rect live_tiles_rect); | 
| - void CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); | 
| + void SetLiveTilesRect(WhichTree tree, gfx::Rect live_tiles_rect); | 
| + void CreateTile(WhichTree tree, | 
| + int i, | 
| + int j, | 
| + const PictureLayerTiling* twin_tiling); | 
| + bool RemoveTile(WhichTree tree, int i, int j); | 
| + void RemoveBundleIfEmptyContainingTileAt(int i, int j); | 
| + TileBundle* TileBundleContainingTileAt(int, int) const; | 
| + TileBundle* CreateBundleForTileAt(int, | 
| + int, | 
| + const PictureLayerTiling* twin_tiling); | 
| + TileBundle* TileBundleAt(int, int) const; | 
| // Given properties. | 
| float contents_scale_; | 
| @@ -206,7 +276,9 @@ class CC_EXPORT PictureLayerTiling { | 
| // Internal data. | 
| TilingData tiling_data_; | 
| - TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 
| + TilingData bundle_tiling_data_; | 
| + TileBundleMap tile_bundles_; // It is not legal to have a NULL tile in the | 
| 
 
enne (OOO)
2013/11/27 22:21:15
Comment is wrong.  Also, can you put this on its o
 
vmpstr
2013/11/27 23:31:57
Done.
 
 | 
| + // tiles_ map. | 
| gfx::Rect live_tiles_rect_; | 
| // State saved for computing velocities based upon finite differences. |