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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 const TilePriority& priority(WhichTree tree) const { | 36 const TilePriority& priority(WhichTree tree) const { |
37 return priority_[tree]; | 37 return priority_[tree]; |
38 } | 38 } |
39 | 39 |
40 TilePriority combined_priority() const { | 40 TilePriority combined_priority() const { |
41 return TilePriority(priority_[ACTIVE_TREE], | 41 return TilePriority(priority_[ACTIVE_TREE], |
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); |
| 47 priority_[tree] = priority; |
| 48 } |
46 | 49 |
47 // Returns 0 if not drawable. | 50 // Returns 0 if not drawable. |
48 ResourceProvider::ResourceId GetResourceId() const; | 51 ResourceProvider::ResourceId GetResourceId() const { |
| 52 if (!managed_state_.resource) |
| 53 return 0; |
| 54 if (managed_state_.resource_is_being_initialized) |
| 55 return 0; |
| 56 |
| 57 return managed_state_.resource->id(); |
| 58 } |
49 | 59 |
50 const gfx::Rect& opaque_rect() const { return opaque_rect_; } | 60 const gfx::Rect& opaque_rect() const { return opaque_rect_; } |
51 | 61 |
52 bool contents_swizzled() const { return managed_state_.contents_swizzled; } | 62 bool contents_swizzled() const { return managed_state_.contents_swizzled; } |
53 | 63 |
54 float contents_scale() const { return contents_scale_; } | 64 float contents_scale() const { return contents_scale_; } |
55 gfx::Rect content_rect() const { return content_rect_; } | 65 gfx::Rect content_rect() const { return content_rect_; } |
56 | 66 |
57 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { | 67 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { |
58 picture_pile_ = pile; | 68 picture_pile_ = pile; |
59 } | 69 } |
60 | 70 |
61 private: | 71 private: |
62 // Methods called by by tile manager. | 72 // Methods called by by tile manager. |
63 friend class TileManager; | 73 friend class TileManager; |
64 friend class BinComparator; | 74 friend class BinComparator; |
65 ManagedTileState& managed_state() { return managed_state_; } | 75 ManagedTileState& managed_state() { return managed_state_; } |
66 const ManagedTileState& managed_state() const { return managed_state_; } | 76 const ManagedTileState& managed_state() const { return managed_state_; } |
67 size_t bytes_consumed_if_allocated() const; | 77 |
| 78 inline size_t bytes_consumed_if_allocated() const { |
| 79 DCHECK(format_ == GL_RGBA); |
| 80 return 4 * tile_size_.width() * tile_size_.height(); |
| 81 } |
| 82 |
68 | 83 |
69 // Normal private methods. | 84 // Normal private methods. |
70 friend class base::RefCounted<Tile>; | 85 friend class base::RefCounted<Tile>; |
71 ~Tile(); | 86 ~Tile(); |
72 | 87 |
73 TileManager* tile_manager_; | 88 TileManager* tile_manager_; |
74 scoped_refptr<PicturePileImpl> picture_pile_; | 89 scoped_refptr<PicturePileImpl> picture_pile_; |
75 gfx::Rect tile_size_; | 90 gfx::Rect tile_size_; |
76 GLenum format_; | 91 GLenum format_; |
77 gfx::Rect content_rect_; | 92 gfx::Rect content_rect_; |
78 float contents_scale_; | 93 float contents_scale_; |
79 gfx::Rect opaque_rect_; | 94 gfx::Rect opaque_rect_; |
80 | 95 |
81 TilePriority priority_[2]; | 96 TilePriority priority_[2]; |
82 ManagedTileState managed_state_; | 97 ManagedTileState managed_state_; |
83 }; | 98 }; |
84 | 99 |
85 } // namespace cc | 100 } // namespace cc |
86 | 101 |
87 #endif // CC_TILE_H_ | 102 #endif // CC_TILE_H_ |
OLD | NEW |