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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 priority_[PENDING_TREE]); | 42 priority_[PENDING_TREE]); |
43 } | 43 } |
44 | 44 |
45 void set_priority(WhichTree tree, const TilePriority& priority) { | 45 void set_priority(WhichTree tree, const TilePriority& priority) { |
46 tile_manager_->WillModifyTilePriority(this, tree, priority); | 46 tile_manager_->WillModifyTilePriority(this, tree, priority); |
47 priority_[tree] = priority; | 47 priority_[tree] = priority; |
48 } | 48 } |
49 | 49 |
50 // Returns 0 if not drawable. | 50 // Returns 0 if not drawable. |
51 ResourceProvider::ResourceId GetResourceId() const { | 51 ResourceProvider::ResourceId GetResourceId() const { |
52 if (!managed_state_.resource) | 52 if (!managed_state_) |
53 return 0; | 53 return 0; |
54 if (managed_state_.resource_is_being_initialized) | 54 if (!managed_state_->resource) |
| 55 return 0; |
| 56 if (managed_state_->resource_is_being_initialized) |
55 return 0; | 57 return 0; |
56 | 58 |
57 return managed_state_.resource->id(); | 59 return managed_state_->resource->id(); |
58 } | 60 } |
59 | 61 |
60 const gfx::Rect& opaque_rect() const { return opaque_rect_; } | 62 const gfx::Rect& opaque_rect() const { return opaque_rect_; } |
61 | 63 |
62 bool contents_swizzled() const { return managed_state_.contents_swizzled; } | 64 bool contents_swizzled() const { |
| 65 CHECK(managed_state_); |
| 66 return managed_state_->contents_swizzled; |
| 67 } |
63 | 68 |
64 float contents_scale() const { return contents_scale_; } | 69 float contents_scale() const { return contents_scale_; } |
65 gfx::Rect content_rect() const { return content_rect_; } | 70 gfx::Rect content_rect() const { return content_rect_; } |
66 | 71 |
67 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { | 72 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { |
68 picture_pile_ = pile; | 73 picture_pile_ = pile; |
69 } | 74 } |
70 | 75 |
71 ManagedTileState& ManagedStateForTesting() { return managed_state_; } | 76 ManagedTileState* ManagedStateForTesting() { return managed_state_.get(); } |
72 | 77 |
73 private: | 78 private: |
74 // Methods called by by tile manager. | 79 // Methods called by by tile manager. |
75 friend class TileManager; | 80 friend class TileManager; |
76 friend class BinComparator; | 81 friend class BinComparator; |
77 ManagedTileState& managed_state() { return managed_state_; } | 82 ManagedTileState* managed_state() { return managed_state_.get(); } |
78 const ManagedTileState& managed_state() const { return managed_state_; } | 83 const ManagedTileState* managed_state() const { |
| 84 return managed_state_.get(); |
| 85 } |
| 86 void set_managed_state(ManagedTileState* managed_state) { |
| 87 managed_state_ = managed_state; |
| 88 } |
79 | 89 |
80 inline size_t bytes_consumed_if_allocated() const { | 90 inline size_t bytes_consumed_if_allocated() const { |
81 DCHECK(format_ == GL_RGBA); | 91 DCHECK(format_ == GL_RGBA); |
82 return 4 * tile_size_.width() * tile_size_.height(); | 92 return 4 * tile_size_.width() * tile_size_.height(); |
83 } | 93 } |
84 | 94 |
85 | 95 |
86 // Normal private methods. | 96 // Normal private methods. |
87 friend class base::RefCounted<Tile>; | 97 friend class base::RefCounted<Tile>; |
88 ~Tile(); | 98 ~Tile(); |
89 | 99 |
90 TileManager* tile_manager_; | 100 TileManager* tile_manager_; |
91 scoped_refptr<PicturePileImpl> picture_pile_; | 101 scoped_refptr<PicturePileImpl> picture_pile_; |
92 gfx::Rect tile_size_; | 102 gfx::Rect tile_size_; |
93 GLenum format_; | 103 GLenum format_; |
94 gfx::Rect content_rect_; | 104 gfx::Rect content_rect_; |
95 float contents_scale_; | 105 float contents_scale_; |
96 gfx::Rect opaque_rect_; | 106 gfx::Rect opaque_rect_; |
97 | 107 |
98 TilePriority priority_[2]; | 108 TilePriority priority_[2]; |
99 ManagedTileState managed_state_; | 109 scoped_refptr<ManagedTileState> managed_state_; |
100 }; | 110 }; |
101 | 111 |
102 } // namespace cc | 112 } // namespace cc |
103 | 113 |
104 #endif // CC_TILE_H_ | 114 #endif // CC_TILE_H_ |
OLD | NEW |