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 ManagedTileState& ManagedStateForTesting() { return managed_state_; } | 71 ManagedTileState& ManagedStateForTesting() { return managed_state_; } |
62 | 72 |
63 private: | 73 private: |
64 // Methods called by by tile manager. | 74 // Methods called by by tile manager. |
65 friend class TileManager; | 75 friend class TileManager; |
66 friend class BinComparator; | 76 friend class BinComparator; |
67 ManagedTileState& managed_state() { return managed_state_; } | 77 ManagedTileState& managed_state() { return managed_state_; } |
68 const ManagedTileState& managed_state() const { return managed_state_; } | 78 const ManagedTileState& managed_state() const { return managed_state_; } |
69 size_t bytes_consumed_if_allocated() const; | 79 |
| 80 inline size_t bytes_consumed_if_allocated() const { |
| 81 DCHECK(format_ == GL_RGBA); |
| 82 return 4 * tile_size_.width() * tile_size_.height(); |
| 83 } |
| 84 |
70 | 85 |
71 // Normal private methods. | 86 // Normal private methods. |
72 friend class base::RefCounted<Tile>; | 87 friend class base::RefCounted<Tile>; |
73 ~Tile(); | 88 ~Tile(); |
74 | 89 |
75 TileManager* tile_manager_; | 90 TileManager* tile_manager_; |
76 scoped_refptr<PicturePileImpl> picture_pile_; | 91 scoped_refptr<PicturePileImpl> picture_pile_; |
77 gfx::Rect tile_size_; | 92 gfx::Rect tile_size_; |
78 GLenum format_; | 93 GLenum format_; |
79 gfx::Rect content_rect_; | 94 gfx::Rect content_rect_; |
80 float contents_scale_; | 95 float contents_scale_; |
81 gfx::Rect opaque_rect_; | 96 gfx::Rect opaque_rect_; |
82 | 97 |
83 TilePriority priority_[2]; | 98 TilePriority priority_[2]; |
84 ManagedTileState managed_state_; | 99 ManagedTileState managed_state_; |
85 }; | 100 }; |
86 | 101 |
87 } // namespace cc | 102 } // namespace cc |
88 | 103 |
89 #endif // CC_TILE_H_ | 104 #endif // CC_TILE_H_ |
OLD | NEW |