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> |
| 9 #include <vector> |
| 10 |
8 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
9 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
10 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
11 #include "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
12 #include "cc/base/hash_pair.h" | 15 #include "cc/base/hash_pair.h" |
13 #include "cc/base/region.h" | 16 #include "cc/base/region.h" |
14 #include "cc/base/tiling_data.h" | 17 #include "cc/base/tiling_data.h" |
15 #include "cc/resources/tile.h" | 18 #include "cc/resources/tile.h" |
16 #include "cc/resources/tile_priority.h" | 19 #include "cc/resources/tile_priority.h" |
17 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
18 | 21 |
19 namespace cc { | 22 namespace cc { |
20 | 23 |
21 class PictureLayerTiling; | 24 class PictureLayerTiling; |
22 | 25 |
23 class PictureLayerTilingClient { | 26 class PictureLayerTilingClient { |
24 public: | 27 public: |
25 // 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 |
26 // 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. |
27 virtual scoped_refptr<Tile> CreateTile( | 30 virtual scoped_refptr<Tile> CreateTile( |
28 PictureLayerTiling* tiling, | 31 PictureLayerTiling* tiling, |
29 gfx::Rect content_rect) = 0; | 32 gfx::Rect content_rect) = 0; |
30 virtual void UpdatePile(Tile* tile) = 0; | 33 virtual void UpdatePile(Tile* tile) = 0; |
31 virtual gfx::Size CalculateTileSize( | 34 virtual gfx::Size CalculateTileSize( |
32 gfx::Size current_tile_size, | 35 gfx::Size current_tile_size, |
33 gfx::Size content_bounds) = 0; | 36 gfx::Size content_bounds) = 0; |
| 37 |
| 38 protected: |
| 39 virtual ~PictureLayerTilingClient() {} |
34 }; | 40 }; |
35 | 41 |
36 class CC_EXPORT PictureLayerTiling { | 42 class CC_EXPORT PictureLayerTiling { |
37 public: | 43 public: |
38 ~PictureLayerTiling(); | 44 ~PictureLayerTiling(); |
39 | 45 |
40 // Create a tiling with no tiles. CreateTiles must be called to add some. | 46 // Create a tiling with no tiles. CreateTiles must be called to add some. |
41 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); | 47 static scoped_ptr<PictureLayerTiling> Create(float contents_scale); |
42 scoped_ptr<PictureLayerTiling> Clone() const; | 48 scoped_ptr<PictureLayerTiling> Clone() const; |
43 | 49 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // The src_tree priority is reset to the lowest priority possible. This | 144 // The src_tree priority is reset to the lowest priority possible. This |
139 // also updates the pile on each tile to be the current client's pile. | 145 // also updates the pile on each tile to be the current client's pile. |
140 void DidBecomeActive(); | 146 void DidBecomeActive(); |
141 | 147 |
142 scoped_ptr<base::Value> AsValue() const; | 148 scoped_ptr<base::Value> AsValue() const; |
143 | 149 |
144 protected: | 150 protected: |
145 typedef std::pair<int, int> TileMapKey; | 151 typedef std::pair<int, int> TileMapKey; |
146 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; | 152 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; |
147 | 153 |
148 PictureLayerTiling(float contents_scale); | 154 explicit PictureLayerTiling(float contents_scale); |
149 Tile* TileAt(int, int) const; | 155 Tile* TileAt(int, int) const; |
150 void CreateTilesFromContentRect(gfx::Rect layer_rect); | 156 void CreateTilesFromContentRect(gfx::Rect layer_rect); |
151 void CreateTile(int i, int j); | 157 void CreateTile(int i, int j); |
152 | 158 |
153 PictureLayerTilingClient* client_; | 159 PictureLayerTilingClient* client_; |
154 float contents_scale_; | 160 float contents_scale_; |
155 gfx::Size layer_bounds_; | 161 gfx::Size layer_bounds_; |
156 gfx::Rect last_prioritized_rect_; | 162 gfx::Rect last_prioritized_rect_; |
157 // It is not legal to have a NULL tile in the tiles_ map. | 163 // It is not legal to have a NULL tile in the tiles_ map. |
158 TileMap tiles_; | 164 TileMap tiles_; |
159 TilingData tiling_data_; | 165 TilingData tiling_data_; |
160 TileResolution resolution_; | 166 TileResolution resolution_; |
161 int last_source_frame_number_; | 167 int last_source_frame_number_; |
162 double last_impl_frame_time_; | 168 double last_impl_frame_time_; |
163 | 169 |
164 friend class Iterator; | 170 friend class Iterator; |
165 }; | 171 }; |
166 | 172 |
167 } // namespace cc | 173 } // namespace cc |
168 | 174 |
169 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 175 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |