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; } | |
67 | |
68 float contents_scale() const { return contents_scale_; } | 59 float contents_scale() const { return contents_scale_; } |
69 gfx::Rect content_rect() const { return content_rect_; } | 60 gfx::Rect content_rect() const { return content_rect_; } |
70 | 61 |
71 int layer_id() const { return layer_id_; } | 62 int layer_id() const { return layer_id_; } |
72 | 63 |
73 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { | 64 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { |
74 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); | 65 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); |
75 picture_pile_ = pile; | 66 picture_pile_ = pile; |
76 } | 67 } |
77 | 68 |
78 ManagedTileState& ManagedStateForTesting() { return managed_state_; } | 69 ManagedTileState& ManagedStateForTesting() { return managed_state_; } |
79 | 70 |
80 private: | 71 private: |
81 // Methods called by by tile manager. | 72 // Methods called by by tile manager. |
82 friend class TileManager; | 73 friend class TileManager; |
83 friend class BinComparator; | 74 friend class BinComparator; |
75 friend class TileDrawingInfo; | |
76 | |
84 ManagedTileState& managed_state() { return managed_state_; } | 77 ManagedTileState& managed_state() { return managed_state_; } |
85 const ManagedTileState& managed_state() const { return managed_state_; } | 78 const ManagedTileState& managed_state() const { return managed_state_; } |
86 | 79 |
87 inline size_t bytes_consumed_if_allocated() const { | 80 inline size_t bytes_consumed_if_texture_allocated() const { |
reveman
2013/03/07 22:02:14
I don't think you want to use texture here. textur
| |
88 DCHECK(format_ == GL_RGBA); | 81 DCHECK(format_ == GL_RGBA); |
89 return 4 * tile_size_.width() * tile_size_.height(); | 82 return 4 * tile_size_.width() * tile_size_.height(); |
90 } | 83 } |
91 | 84 |
92 | 85 |
93 // Normal private methods. | 86 // Normal private methods. |
94 friend class base::RefCounted<Tile>; | 87 friend class base::RefCounted<Tile>; |
95 ~Tile(); | 88 ~Tile(); |
96 | 89 |
97 TileManager* tile_manager_; | 90 TileManager* tile_manager_; |
98 scoped_refptr<PicturePileImpl> picture_pile_; | 91 scoped_refptr<PicturePileImpl> picture_pile_; |
99 gfx::Rect tile_size_; | 92 gfx::Rect tile_size_; |
100 GLenum format_; | 93 GLenum format_; |
101 gfx::Rect content_rect_; | 94 gfx::Rect content_rect_; |
102 float contents_scale_; | 95 float contents_scale_; |
103 gfx::Rect opaque_rect_; | 96 gfx::Rect opaque_rect_; |
104 | 97 |
105 TilePriority priority_[NUM_BIN_PRIORITIES]; | 98 TilePriority priority_[NUM_BIN_PRIORITIES]; |
106 ManagedTileState managed_state_; | 99 ManagedTileState managed_state_; |
107 int layer_id_; | 100 int layer_id_; |
101 TileDrawingInfo drawing_info_; | |
reveman
2013/03/07 22:02:14
The drawing state is maintained by the tile manage
| |
108 }; | 102 }; |
109 | 103 |
110 } // namespace cc | 104 } // namespace cc |
111 | 105 |
112 #endif // CC_TILE_H_ | 106 #endif // CC_TILE_H_ |
OLD | NEW |