| 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/tiling_data.h" | 16 #include "cc/tiling_data.h" |
| 16 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 17 | 18 |
| 18 namespace cc { | 19 namespace cc { |
| 19 | 20 |
| 20 class PictureLayerTiling; | 21 class PictureLayerTiling; |
| 21 | 22 |
| 22 class PictureLayerTilingClient { | 23 class PictureLayerTilingClient { |
| 23 public: | 24 public: |
| 24 virtual scoped_refptr<Tile> CreateTile(PictureLayerTiling*, gfx::Rect) = 0; | 25 virtual scoped_refptr<Tile> CreateTile(PictureLayerTiling*, gfx::Rect) = 0; |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 class CC_EXPORT PictureLayerTiling { | 28 class CC_EXPORT PictureLayerTiling { |
| 28 public: | 29 public: |
| 29 ~PictureLayerTiling(); | 30 ~PictureLayerTiling(); |
| 30 | 31 |
| 31 static scoped_ptr<PictureLayerTiling> Create(float contents_scale, | 32 static scoped_ptr<PictureLayerTiling> Create(float contents_scale, |
| 32 gfx::Size tile_size); | 33 gfx::Size tile_size); |
| 33 scoped_ptr<PictureLayerTiling> Clone() const; | 34 scoped_ptr<PictureLayerTiling> Clone() const; |
| 34 | 35 |
| 35 const PictureLayerTiling& operator=(const PictureLayerTiling&); | 36 const PictureLayerTiling& operator=(const PictureLayerTiling&); |
| 36 | 37 |
| 37 void SetLayerBounds(gfx::Size layer_bounds); | 38 void SetLayerBounds(gfx::Size layer_bounds); |
| 38 void Invalidate(const Region& layer_invalidation); | 39 void Invalidate(const Region& layer_invalidation); |
| 39 | 40 |
| 40 void SetClient(PictureLayerTilingClient* client); | 41 void SetClient(PictureLayerTilingClient* client); |
| 42 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
| 41 | 43 |
| 42 gfx::Rect ContentRect() const; | 44 gfx::Rect ContentRect() const; |
| 43 float contents_scale() const { return contents_scale_; } | 45 float contents_scale() const { return contents_scale_; } |
| 44 | 46 |
| 45 // Iterate over all tiles to fill content_rect. Even if tiles are invalid | 47 // Iterate over all tiles to fill content_rect. Even if tiles are invalid |
| 46 // (i.e. no valid resource) this tiling should still iterate over them. | 48 // (i.e. no valid resource) this tiling should still iterate over them. |
| 47 // The union of all geometry_rect calls for each element iterated over should | 49 // The union of all geometry_rect calls for each element iterated over should |
| 48 // exactly equal content_rect and no two geometry_rects should intersect. | 50 // exactly equal content_rect and no two geometry_rects should intersect. |
| 49 class CC_EXPORT Iterator { | 51 class CC_EXPORT Iterator { |
| 50 public: | 52 public: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 friend class PictureLayerTiling; | 84 friend class PictureLayerTiling; |
| 83 }; | 85 }; |
| 84 | 86 |
| 85 Region OpaqueRegionInContentRect(const gfx::Rect&) const; | 87 Region OpaqueRegionInContentRect(const gfx::Rect&) const; |
| 86 | 88 |
| 87 void Reset() { return tiles_.clear(); } | 89 void Reset() { return tiles_.clear(); } |
| 88 | 90 |
| 89 void UpdateTilePriorities( | 91 void UpdateTilePriorities( |
| 90 WhichTree tree, | 92 WhichTree tree, |
| 91 const gfx::Size& device_viewport, | 93 const gfx::Size& device_viewport, |
| 92 float layer_content_scale_x, | 94 float last_contents_scale, |
| 93 float layer_content_scale_y, | 95 float current_contents_scale, |
| 94 const gfx::Transform& last_screen_transform, | 96 const gfx::Transform& last_screen_transform, |
| 95 const gfx::Transform& current_screen_transform, | 97 const gfx::Transform& current_screen_transform, |
| 96 double time_delta); | 98 double time_delta); |
| 97 | 99 |
| 98 protected: | 100 protected: |
| 99 typedef std::pair<int, int> TileMapKey; | 101 typedef std::pair<int, int> TileMapKey; |
| 100 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; | 102 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; |
| 101 | 103 |
| 102 PictureLayerTiling(float contents_scale, gfx::Size tileSize); | 104 PictureLayerTiling(float contents_scale, gfx::Size tileSize); |
| 103 Tile* TileAt(int, int) const; | 105 Tile* TileAt(int, int) const; |
| 104 void CreateTile(int i, int j); | 106 void CreateTile(int i, int j); |
| 105 | 107 |
| 106 PictureLayerTilingClient* client_; | 108 PictureLayerTilingClient* client_; |
| 107 float contents_scale_; | 109 float contents_scale_; |
| 108 gfx::Size layer_bounds_; | 110 gfx::Size layer_bounds_; |
| 109 TileMap tiles_; | 111 TileMap tiles_; |
| 110 TilingData tiling_data_; | 112 TilingData tiling_data_; |
| 113 TileResolution resolution_; |
| 111 | 114 |
| 112 friend class Iterator; | 115 friend class Iterator; |
| 113 }; | 116 }; |
| 114 | 117 |
| 115 } // namespace cc | 118 } // namespace cc |
| 116 | 119 |
| 117 #endif // CC_PICTURE_LAYER_TILING_H_ | 120 #endif // CC_PICTURE_LAYER_TILING_H_ |
| OLD | NEW |