| 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_TILE_H_ | |
| 6 #define CC_TILE_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/scoped_vector.h" | |
| 11 #include "cc/managed_tile_state.h" | |
| 12 #include "cc/picture_pile_impl.h" | |
| 13 #include "cc/tile_priority.h" | |
| 14 #include "cc/trees/layer_tree_host_impl.h" | |
| 15 #include "ui/gfx/rect.h" | |
| 16 #include "ui/gfx/size.h" | |
| 17 | |
| 18 namespace cc { | |
| 19 | |
| 20 class Tile; | |
| 21 class TileManager; | |
| 22 | |
| 23 class CC_EXPORT Tile : public base::RefCounted<Tile> { | |
| 24 public: | |
| 25 Tile(TileManager* tile_manager, | |
| 26 PicturePileImpl* picture_pile, | |
| 27 gfx::Size tile_size, | |
| 28 GLenum format, | |
| 29 gfx::Rect content_rect, | |
| 30 gfx::Rect opaque_rect, | |
| 31 float contents_scale, | |
| 32 int layer_id); | |
| 33 | |
| 34 PicturePileImpl* picture_pile() { | |
| 35 return picture_pile_.get(); | |
| 36 } | |
| 37 | |
| 38 const TilePriority& priority(WhichTree tree) const { | |
| 39 return priority_[tree]; | |
| 40 } | |
| 41 | |
| 42 TilePriority combined_priority() const { | |
| 43 return TilePriority(priority_[ACTIVE_TREE], | |
| 44 priority_[PENDING_TREE]); | |
| 45 } | |
| 46 | |
| 47 void SetPriority(WhichTree tree, const TilePriority& priority); | |
| 48 | |
| 49 scoped_ptr<base::Value> AsValue() const; | |
| 50 | |
| 51 const ManagedTileState::DrawingInfo& drawing_info() const { | |
| 52 return managed_state_.drawing_info; | |
| 53 } | |
| 54 ManagedTileState::DrawingInfo& drawing_info() { | |
| 55 return managed_state_.drawing_info; | |
| 56 } | |
| 57 | |
| 58 const gfx::Rect& opaque_rect() const { return opaque_rect_; } | |
| 59 | |
| 60 float contents_scale() const { return contents_scale_; } | |
| 61 gfx::Rect content_rect() const { return content_rect_; } | |
| 62 | |
| 63 int layer_id() const { return layer_id_; } | |
| 64 | |
| 65 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { | |
| 66 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); | |
| 67 picture_pile_ = pile; | |
| 68 } | |
| 69 | |
| 70 private: | |
| 71 // Methods called by by tile manager. | |
| 72 friend class TileManager; | |
| 73 friend class BinComparator; | |
| 74 ManagedTileState& managed_state() { return managed_state_; } | |
| 75 const ManagedTileState& managed_state() const { return managed_state_; } | |
| 76 | |
| 77 inline size_t bytes_consumed_if_allocated() const { | |
| 78 DCHECK(format_ == GL_RGBA); | |
| 79 return 4 * tile_size_.width() * tile_size_.height(); | |
| 80 } | |
| 81 | |
| 82 | |
| 83 // Normal private methods. | |
| 84 friend class base::RefCounted<Tile>; | |
| 85 ~Tile(); | |
| 86 | |
| 87 TileManager* tile_manager_; | |
| 88 scoped_refptr<PicturePileImpl> picture_pile_; | |
| 89 gfx::Rect tile_size_; | |
| 90 GLenum format_; | |
| 91 gfx::Rect content_rect_; | |
| 92 float contents_scale_; | |
| 93 gfx::Rect opaque_rect_; | |
| 94 | |
| 95 TilePriority priority_[NUM_BIN_PRIORITIES]; | |
| 96 ManagedTileState managed_state_; | |
| 97 int layer_id_; | |
| 98 }; | |
| 99 | |
| 100 } // namespace cc | |
| 101 | |
| 102 #endif // CC_TILE_H_ | |
| OLD | NEW |