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_TILE_H_ | 5 #ifndef CC_TILE_H_ |
6 #define CC_TILE_H_ | 6 #define CC_TILE_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "cc/layer_tree_host_impl.h" | 11 #include "cc/layer_tree_host_impl.h" |
12 #include "cc/picture_pile_impl.h" | 12 #include "cc/picture_pile_impl.h" |
13 #include "cc/resource_provider.h" | 13 #include "cc/tile_drawing_info.h" |
14 #include "cc/tile_manager.h" | 14 #include "cc/tile_manager.h" |
15 #include "cc/tile_priority.h" | 15 #include "cc/tile_priority.h" |
16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 class Tile; | 21 class Tile; |
22 | 22 |
23 class CC_EXPORT Tile : public base::RefCounted<Tile> { | 23 class CC_EXPORT Tile : public base::RefCounted<Tile> { |
(...skipping 20 matching lines...) Expand all Loading... |
44 priority_[PENDING_TREE]); | 44 priority_[PENDING_TREE]); |
45 } | 45 } |
46 | 46 |
47 void set_priority(WhichTree tree, const TilePriority& priority) { | 47 void set_priority(WhichTree tree, const TilePriority& priority) { |
48 tile_manager_->WillModifyTilePriority(this, tree, priority); | 48 tile_manager_->WillModifyTilePriority(this, tree, priority); |
49 priority_[tree] = priority; | 49 priority_[tree] = priority; |
50 } | 50 } |
51 | 51 |
52 scoped_ptr<base::Value> AsValue() const; | 52 scoped_ptr<base::Value> AsValue() const; |
53 | 53 |
54 // Returns 0 if not drawable. | 54 const TileDrawingInfo& drawing_info() const { return drawing_info_; } |
55 ResourceProvider::ResourceId GetResourceId() const { | 55 TileDrawingInfo& drawing_info() { return drawing_info_; } |
56 if (!managed_state_.resource) | |
57 return 0; | |
58 if (managed_state_.resource_is_being_initialized) | |
59 return 0; | |
60 | |
61 return managed_state_.resource->id(); | |
62 } | |
63 | 56 |
64 const gfx::Rect& opaque_rect() const { return opaque_rect_; } | 57 const gfx::Rect& opaque_rect() const { return opaque_rect_; } |
65 | 58 |
66 bool contents_swizzled() const { return managed_state_.contents_swizzled; } | 59 bool contents_swizzled() const { return managed_state_.contents_swizzled; } |
67 | 60 |
68 float contents_scale() const { return contents_scale_; } | 61 float contents_scale() const { return contents_scale_; } |
69 gfx::Rect content_rect() const { return content_rect_; } | 62 gfx::Rect content_rect() const { return content_rect_; } |
70 | 63 |
71 int layer_id() const { return layer_id_; } | 64 int layer_id() const { return layer_id_; } |
72 | 65 |
73 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { | 66 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { |
74 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); | 67 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); |
75 picture_pile_ = pile; | 68 picture_pile_ = pile; |
76 } | 69 } |
77 | 70 |
78 ManagedTileState& ManagedStateForTesting() { return managed_state_; } | 71 ManagedTileState& ManagedStateForTesting() { return managed_state_; } |
79 | 72 |
80 private: | 73 private: |
81 // Methods called by by tile manager. | 74 // Methods called by by tile manager. |
82 friend class TileManager; | 75 friend class TileManager; |
83 friend class BinComparator; | 76 friend class BinComparator; |
| 77 friend class TileDrawingInfo; |
| 78 |
84 ManagedTileState& managed_state() { return managed_state_; } | 79 ManagedTileState& managed_state() { return managed_state_; } |
85 const ManagedTileState& managed_state() const { return managed_state_; } | 80 const ManagedTileState& managed_state() const { return managed_state_; } |
86 | 81 |
87 inline size_t bytes_consumed_if_allocated() const { | 82 inline size_t bytes_consumed_if_allocated() const { |
88 DCHECK(format_ == GL_RGBA); | 83 DCHECK(format_ == GL_RGBA); |
89 return 4 * tile_size_.width() * tile_size_.height(); | 84 return 4 * tile_size_.width() * tile_size_.height(); |
90 } | 85 } |
91 | 86 |
92 | 87 |
93 // Normal private methods. | 88 // Normal private methods. |
94 friend class base::RefCounted<Tile>; | 89 friend class base::RefCounted<Tile>; |
95 ~Tile(); | 90 ~Tile(); |
96 | 91 |
97 TileManager* tile_manager_; | 92 TileManager* tile_manager_; |
98 scoped_refptr<PicturePileImpl> picture_pile_; | 93 scoped_refptr<PicturePileImpl> picture_pile_; |
99 gfx::Rect tile_size_; | 94 gfx::Rect tile_size_; |
100 GLenum format_; | 95 GLenum format_; |
101 gfx::Rect content_rect_; | 96 gfx::Rect content_rect_; |
102 float contents_scale_; | 97 float contents_scale_; |
103 gfx::Rect opaque_rect_; | 98 gfx::Rect opaque_rect_; |
104 | 99 |
105 TilePriority priority_[NUM_BIN_PRIORITIES]; | 100 TilePriority priority_[NUM_BIN_PRIORITIES]; |
106 ManagedTileState managed_state_; | 101 ManagedTileState managed_state_; |
107 int layer_id_; | 102 int layer_id_; |
| 103 TileDrawingInfo drawing_info_; |
108 }; | 104 }; |
109 | 105 |
110 } // namespace cc | 106 } // namespace cc |
111 | 107 |
112 #endif // CC_TILE_H_ | 108 #endif // CC_TILE_H_ |
OLD | NEW |