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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 virtual void UpdatePile(Tile* tile) = 0; | 31 virtual void UpdatePile(Tile* tile) = 0; |
32 virtual gfx::Size CalculateTileSize( | 32 virtual gfx::Size CalculateTileSize( |
33 gfx::Size current_tile_size, | 33 gfx::Size current_tile_size, |
34 gfx::Size content_bounds) = 0; | 34 gfx::Size content_bounds) = 0; |
35 }; | 35 }; |
36 | 36 |
37 class TileHandle { | 37 class TileHandle { |
38 public: | 38 public: |
39 TileHandle(scoped_refptr<Tile> tile); | 39 TileHandle(scoped_refptr<Tile> tile); |
40 Tile* tile() const { return tile_.get(); } | 40 Tile* tile() const { return tile_.get(); } |
| 41 void RegisterWithTileManager(); |
| 42 void UnregisterFromTileManager(); |
41 private: | 43 private: |
42 scoped_refptr<Tile> tile_; | 44 scoped_refptr<Tile> tile_; |
43 scoped_refptr<ManagedTileState> managed_tile_state_; | 45 scoped_refptr<ManagedTileState> managed_tile_state_; |
44 }; | 46 }; |
45 | 47 |
46 class CC_EXPORT PictureLayerTiling { | 48 class CC_EXPORT PictureLayerTiling { |
47 public: | 49 public: |
48 ~PictureLayerTiling(); | 50 ~PictureLayerTiling(); |
49 | 51 |
50 // Create a tiling with no tiles. CreateTiles must be called to add some. | 52 // Create a tiling with no tiles. CreateTiles must be called to add some. |
51 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); | 53 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); |
52 scoped_ptr<PictureLayerTiling> Clone() const; | 54 scoped_ptr<PictureLayerTiling> Clone() const; |
53 | 55 |
54 gfx::Size layer_bounds() const { return layer_bounds_; } | 56 gfx::Size layer_bounds() const { return layer_bounds_; } |
55 void SetLayerBounds(gfx::Size layer_bounds); | 57 void SetLayerBounds(gfx::Size layer_bounds); |
56 void Invalidate(const Region& layer_invalidation); | 58 void Invalidate(const Region& layer_invalidation); |
57 | 59 |
58 // Add any tiles that intersect with |layer_rect|. If any tiles already | 60 // Add any tiles that intersect with |layer_rect|. If any tiles already |
59 // exist, then this leaves them as-is. | 61 // exist, then this leaves them as-is. |
60 void CreateTilesFromLayerRect(gfx::Rect layer_rect); | 62 void CreateTilesFromLayerRect(gfx::Rect layer_rect); |
61 | 63 |
62 void SetClient(PictureLayerTilingClient* client); | 64 void SetClient(PictureLayerTilingClient* client); |
63 void set_resolution(TileResolution resolution) { resolution_ = resolution; } | 65 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
64 TileResolution resolution() const { return resolution_; } | 66 TileResolution resolution() const { return resolution_; } |
65 | 67 |
66 gfx::Rect ContentRect() const; | 68 gfx::Rect ContentRect() const; |
67 gfx::SizeF ContentSizeF() const; | 69 gfx::SizeF ContentSizeF() const; |
68 float contents_scale() const { return contents_scale_; } | 70 float contents_scale() const { return contents_scale_; } |
69 | 71 |
| 72 void RegisterAllTilesManagedForTesting() { |
| 73 for (TileMap::iterator it = tiles_.begin(); |
| 74 it != tiles_.end(); ++it) |
| 75 it->second.RegisterWithTileManager(); |
| 76 } |
| 77 |
70 std::vector<Tile*> AllTilesForTesting() const { | 78 std::vector<Tile*> AllTilesForTesting() const { |
71 std::vector<Tile*> all_tiles; | 79 std::vector<Tile*> all_tiles; |
72 for (TileMap::const_iterator it = tiles_.begin(); | 80 for (TileMap::const_iterator it = tiles_.begin(); |
73 it != tiles_.end(); ++it) | 81 it != tiles_.end(); ++it) |
74 all_tiles.push_back(it->second.tile()); | 82 all_tiles.push_back(it->second.tile()); |
75 return all_tiles; | 83 return all_tiles; |
76 } | 84 } |
77 | 85 |
78 enum LayerDeviceAlignment { | 86 enum LayerDeviceAlignment { |
79 LayerDeviceAlignmentUnknown, | 87 LayerDeviceAlignmentUnknown, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 TileResolution resolution_; | 183 TileResolution resolution_; |
176 int last_source_frame_number_; | 184 int last_source_frame_number_; |
177 double last_impl_frame_time_; | 185 double last_impl_frame_time_; |
178 | 186 |
179 friend class Iterator; | 187 friend class Iterator; |
180 }; | 188 }; |
181 | 189 |
182 } // namespace cc | 190 } // namespace cc |
183 | 191 |
184 #endif // CC_PICTURE_LAYER_TILING_H_ | 192 #endif // CC_PICTURE_LAYER_TILING_H_ |
OLD | NEW |