OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_PICTURE_LAYER_TILING_H_ |
| 6 #define CC_PICTURE_LAYER_TILING_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/hash_tables.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/cc_export.h" |
| 12 #include "cc/hash_pair.h" |
| 13 #include "cc/region.h" |
| 14 #include "cc/tile.h" |
| 15 #include "cc/tiling_data.h" |
| 16 #include "ui/gfx/rect.h" |
| 17 |
| 18 namespace cc { |
| 19 |
| 20 class PictureLayerTiling; |
| 21 |
| 22 class PictureLayerTilingClient { |
| 23 public: |
| 24 virtual scoped_refptr<Tile> CreateTile(PictureLayerTiling*, gfx::Rect) = 0; |
| 25 }; |
| 26 |
| 27 class CC_EXPORT PictureLayerTiling { |
| 28 public: |
| 29 ~PictureLayerTiling(); |
| 30 |
| 31 static scoped_ptr<PictureLayerTiling> Create(gfx::Size tile_size); |
| 32 scoped_ptr<PictureLayerTiling> Clone() const; |
| 33 |
| 34 const PictureLayerTiling& operator=(const PictureLayerTiling&); |
| 35 |
| 36 void SetBounds(gfx::Size); |
| 37 gfx::Size bounds() const { return tiling_data_.total_size(); } |
| 38 |
| 39 void create_tiles(gfx::Rect); |
| 40 void set_client(PictureLayerTilingClient* client); |
| 41 |
| 42 class Iterator { |
| 43 public: |
| 44 Iterator(PictureLayerTiling* tiling, gfx::Rect content_rect); |
| 45 ~Iterator(); |
| 46 |
| 47 // Visible rect (no borders) |
| 48 gfx::Rect geometry_rect() const; |
| 49 // Full tile rect (not clipped, with borders) |
| 50 gfx::Rect full_tile_rect() const; |
| 51 // Texture rect (in texels) for geometry_rect |
| 52 gfx::Rect texture_rect() const; |
| 53 gfx::Rect opaque_rect() const; |
| 54 gfx::Size texture_size() const; |
| 55 |
| 56 Tile* operator->() const { return current_tile_; } |
| 57 Tile* operator*() const { return current_tile_; } |
| 58 |
| 59 Iterator& operator++(); |
| 60 bool operator==(const Iterator& other) const; |
| 61 bool operator!=(const Iterator& other) const; |
| 62 operator bool() const { return current_tile_; } |
| 63 |
| 64 private: |
| 65 PictureLayerTiling* tiling_; |
| 66 Tile* current_tile_; |
| 67 gfx::Rect content_rect_; |
| 68 int tile_i_; |
| 69 int tile_j_; |
| 70 int left_; |
| 71 int top_; |
| 72 int right_; |
| 73 int bottom_; |
| 74 |
| 75 friend class PictureLayerTiling; |
| 76 }; |
| 77 |
| 78 Region OpaqueRegionInContentRect(const gfx::Rect&) const; |
| 79 |
| 80 void Reset() { return tiles_.clear(); } |
| 81 |
| 82 protected: |
| 83 typedef std::pair<int, int> TileMapKey; |
| 84 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; |
| 85 |
| 86 PictureLayerTiling(gfx::Size tileSize); |
| 87 Tile* TileAt(int, int) const; |
| 88 |
| 89 PictureLayerTilingClient* client_; |
| 90 TileMap tiles_; |
| 91 TilingData tiling_data_; |
| 92 |
| 93 friend class Iterator; |
| 94 }; |
| 95 |
| 96 } // namespace cc |
| 97 |
| 98 #endif // CC_PICTURE_LAYER_TILING_H_ |
OLD | NEW |