| OLD | NEW |
| (Empty) |
| 1 // Copyright 2011 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_LAYER_TILING_DATA_H_ | |
| 6 #define CC_LAYER_TILING_DATA_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "cc/base/cc_export.h" | |
| 11 #include "cc/base/hash_pair.h" | |
| 12 #include "cc/base/region.h" | |
| 13 #include "cc/base/scoped_ptr_hash_map.h" | |
| 14 #include "cc/base/tiling_data.h" | |
| 15 #include "ui/gfx/rect.h" | |
| 16 | |
| 17 namespace cc { | |
| 18 | |
| 19 class CC_EXPORT LayerTilingData { | |
| 20 public: | |
| 21 enum BorderTexelOption { | |
| 22 HAS_BORDER_TEXELS, | |
| 23 NO_BORDER_TEXELS | |
| 24 }; | |
| 25 | |
| 26 ~LayerTilingData(); | |
| 27 | |
| 28 static scoped_ptr<LayerTilingData> Create(gfx::Size tile_size, | |
| 29 BorderTexelOption option); | |
| 30 | |
| 31 bool has_empty_bounds() const { return tiling_data_.has_empty_bounds(); } | |
| 32 int num_tiles_x() const { return tiling_data_.num_tiles_x(); } | |
| 33 int num_tiles_y() const { return tiling_data_.num_tiles_y(); } | |
| 34 gfx::Rect tile_bounds(int i, int j) const { | |
| 35 return tiling_data_.TileBounds(i, j); | |
| 36 } | |
| 37 gfx::Vector2d texture_offset(int x_index, int y_index) const { | |
| 38 return tiling_data_.TextureOffset(x_index, y_index); | |
| 39 } | |
| 40 | |
| 41 // Change the tile size. This may invalidate all the existing tiles. | |
| 42 void SetTileSize(gfx::Size size); | |
| 43 gfx::Size tile_size() const; | |
| 44 // Change the border texel setting. This may invalidate all existing tiles. | |
| 45 void SetBorderTexelOption(BorderTexelOption option); | |
| 46 bool has_border_texels() const { return !!tiling_data_.border_texels(); } | |
| 47 | |
| 48 bool is_empty() const { return has_empty_bounds() || !tiles().size(); } | |
| 49 | |
| 50 const LayerTilingData& operator=(const LayerTilingData&); | |
| 51 | |
| 52 class Tile { | |
| 53 public: | |
| 54 Tile() : i_(-1), j_(-1) {} | |
| 55 virtual ~Tile() {} | |
| 56 | |
| 57 int i() const { return i_; } | |
| 58 int j() const { return j_; } | |
| 59 void move_to(int i, int j) { | |
| 60 i_ = i; | |
| 61 j_ = j; | |
| 62 } | |
| 63 | |
| 64 gfx::Rect opaque_rect() const { return opaque_rect_; } | |
| 65 void set_opaque_rect(gfx::Rect opaque_rect) { opaque_rect_ = opaque_rect; } | |
| 66 private: | |
| 67 int i_; | |
| 68 int j_; | |
| 69 gfx::Rect opaque_rect_; | |
| 70 DISALLOW_COPY_AND_ASSIGN(Tile); | |
| 71 }; | |
| 72 typedef std::pair<int, int> TileMapKey; | |
| 73 typedef ScopedPtrHashMap<TileMapKey, Tile> TileMap; | |
| 74 | |
| 75 void AddTile(scoped_ptr<Tile> tile, int i, int j); | |
| 76 scoped_ptr<Tile> TakeTile(int i, int j); | |
| 77 Tile* TileAt(int i, int j) const; | |
| 78 const TileMap& tiles() const { return tiles_; } | |
| 79 | |
| 80 void SetBounds(gfx::Size size); | |
| 81 gfx::Size bounds() const { return tiling_data_.total_size(); } | |
| 82 | |
| 83 void ContentRectToTileIndices(gfx::Rect rect, | |
| 84 int* left, | |
| 85 int* top, | |
| 86 int* right, | |
| 87 int* bottom) const; | |
| 88 gfx::Rect TileRect(const Tile* tile) const; | |
| 89 | |
| 90 Region OpaqueRegionInContentRect(gfx::Rect rect) const; | |
| 91 | |
| 92 void reset() { tiles_.clear(); } | |
| 93 | |
| 94 protected: | |
| 95 LayerTilingData(gfx::Size tile_size, BorderTexelOption option); | |
| 96 | |
| 97 TileMap tiles_; | |
| 98 TilingData tiling_data_; | |
| 99 | |
| 100 DISALLOW_COPY(LayerTilingData); | |
| 101 }; | |
| 102 | |
| 103 } // namespace cc | |
| 104 | |
| 105 #endif // CC_LAYER_TILING_DATA_H_ | |
| OLD | NEW |