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_RESOURCES_TILE_H_ | 5 #ifndef CC_RESOURCES_TILE_H_ |
6 #define CC_RESOURCES_TILE_H_ | 6 #define CC_RESOURCES_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/resources/managed_tile_state.h" | 11 #include "cc/resources/managed_tile_state.h" |
12 #include "cc/resources/picture_pile_impl.h" | 12 #include "cc/resources/picture_pile_impl.h" |
13 #include "cc/resources/tile_manager.h" | |
13 #include "cc/resources/tile_priority.h" | 14 #include "cc/resources/tile_priority.h" |
14 #include "cc/trees/layer_tree_host_impl.h" | 15 #include "cc/trees/layer_tree_host_impl.h" |
15 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
16 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 | 20 |
20 class Tile; | 21 class Tile; |
21 class TileManager; | |
22 | 22 |
23 class CC_EXPORT Tile : public base::RefCounted<Tile> { | 23 class CC_EXPORT Tile : public base::RefCounted<Tile> { |
24 public: | 24 public: |
25 Tile(TileManager* tile_manager, | 25 Tile(TileManager* tile_manager, |
26 PicturePileImpl* picture_pile, | 26 PicturePileImpl* picture_pile, |
27 gfx::Size tile_size, | 27 gfx::Size tile_size, |
28 gfx::Rect content_rect, | 28 gfx::Rect content_rect, |
29 gfx::Rect opaque_rect, | 29 gfx::Rect opaque_rect, |
30 float contents_scale, | 30 float contents_scale, |
31 int layer_id, | 31 int layer_id, |
32 int source_frame_number); | 32 int source_frame_number); |
33 | 33 |
34 PicturePileImpl* picture_pile() { | 34 PicturePileImpl* picture_pile() { |
35 return picture_pile_.get(); | 35 return picture_pile_.get(); |
36 } | 36 } |
37 | 37 |
38 const PicturePileImpl* picture_pile() const { | |
39 return picture_pile_.get(); | |
40 } | |
41 | |
38 const TilePriority& priority(WhichTree tree) const { | 42 const TilePriority& priority(WhichTree tree) const { |
39 return priority_[tree]; | 43 return priority_[tree]; |
40 } | 44 } |
41 | 45 |
42 TilePriority combined_priority() const { | 46 TilePriority combined_priority() const { |
43 return TilePriority(priority_[ACTIVE_TREE], | 47 return TilePriority(priority_[ACTIVE_TREE], |
44 priority_[PENDING_TREE]); | 48 priority_[PENDING_TREE]); |
45 } | 49 } |
46 | 50 |
47 void SetPriority(WhichTree tree, const TilePriority& priority) { | 51 void SetPriority(WhichTree tree, const TilePriority& priority) { |
48 priority_[tree] = priority; | 52 priority_[tree] = priority; |
49 } | 53 } |
50 | 54 |
51 void mark_required_for_activation() { | 55 void mark_required_for_activation() { |
52 priority_[PENDING_TREE].required_for_activation = true; | 56 priority_[PENDING_TREE].required_for_activation = true; |
53 } | 57 } |
54 | 58 |
55 bool required_for_activation() const { | 59 bool required_for_activation() const { |
56 return priority_[PENDING_TREE].required_for_activation; | 60 return priority_[PENDING_TREE].required_for_activation; |
57 } | 61 } |
58 | 62 |
59 scoped_ptr<base::Value> AsValue() const; | 63 scoped_ptr<base::Value> AsValue() const; |
60 | 64 |
61 const ManagedTileState::TileVersion& tile_version() const { | 65 bool IsReadyToDraw(TileRasterMode* ready_mode) const { |
62 return managed_state_.tile_version; | 66 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
67 if (managed_state_.tile_versions[mode].IsReadyToDraw()) { | |
68 if (ready_mode) | |
69 *ready_mode = static_cast<TileRasterMode>(mode); | |
70 return true; | |
71 } | |
72 } | |
73 return false; | |
63 } | 74 } |
64 ManagedTileState::TileVersion& tile_version() { | 75 |
65 return managed_state_.tile_version; | 76 const ManagedTileState::TileVersion& tile_version(TileRasterMode mode) const { |
77 return managed_state_.tile_versions[mode]; | |
78 } | |
79 | |
80 ManagedTileState::TileVersion& tile_version(TileRasterMode mode) { | |
81 return managed_state_.tile_versions[mode]; | |
66 } | 82 } |
67 | 83 |
68 gfx::Rect opaque_rect() const { return opaque_rect_; } | 84 gfx::Rect opaque_rect() const { return opaque_rect_; } |
69 bool has_text() const { | 85 bool has_text() const { |
70 return managed_state_.picture_pile_analysis.has_text; | 86 return managed_state_.picture_pile_analysis.has_text; |
71 } | 87 } |
72 | 88 |
73 float contents_scale() const { return contents_scale_; } | 89 float contents_scale() const { return contents_scale_; } |
74 gfx::Rect content_rect() const { return content_rect_; } | 90 gfx::Rect content_rect() const { return content_rect_; } |
75 | 91 |
76 int layer_id() const { return layer_id_; } | 92 int layer_id() const { return layer_id_; } |
77 | 93 |
78 int source_frame_number() const { return source_frame_number_; } | 94 int source_frame_number() const { return source_frame_number_; } |
79 | 95 |
80 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { | 96 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { |
81 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); | 97 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); |
82 picture_pile_ = pile; | 98 picture_pile_ = pile; |
83 } | 99 } |
84 | 100 |
85 // For test only methods. | 101 // For test only methods. |
86 bool HasRasterTaskForTesting() const { | 102 bool HasRasterTaskForTesting() const { |
87 return !managed_state().raster_task.is_null(); | 103 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
104 if (!managed_state().tile_versions[mode].raster_task_.is_null()) | |
105 return true; | |
106 } | |
107 return false; | |
88 } | 108 } |
89 void ResetRasterTaskForTesting() { | 109 void ResetRasterTaskForTesting() { |
90 managed_state().raster_task.Reset(); | 110 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
111 managed_state().tile_versions[mode].raster_task_.Reset(); | |
112 } | |
reveman
2013/06/06 06:02:02
nit: no need for {}
vmpstr
2013/06/06 15:20:22
Done.
| |
91 } | 113 } |
92 | 114 |
93 private: | 115 private: |
94 // Methods called by by tile manager. | 116 // Methods called by by tile manager. |
95 friend class TileManager; | 117 friend class TileManager; |
96 friend class BinComparator; | 118 friend class BinComparator; |
97 ManagedTileState& managed_state() { return managed_state_; } | 119 ManagedTileState& managed_state() { return managed_state_; } |
98 const ManagedTileState& managed_state() const { return managed_state_; } | 120 const ManagedTileState& managed_state() const { return managed_state_; } |
99 | 121 |
100 inline size_t bytes_consumed_if_allocated() const { | 122 inline size_t bytes_consumed_if_allocated() const { |
(...skipping 16 matching lines...) Expand all Loading... | |
117 ManagedTileState managed_state_; | 139 ManagedTileState managed_state_; |
118 int layer_id_; | 140 int layer_id_; |
119 int source_frame_number_; | 141 int source_frame_number_; |
120 | 142 |
121 DISALLOW_COPY_AND_ASSIGN(Tile); | 143 DISALLOW_COPY_AND_ASSIGN(Tile); |
122 }; | 144 }; |
123 | 145 |
124 } // namespace cc | 146 } // namespace cc |
125 | 147 |
126 #endif // CC_RESOURCES_TILE_H_ | 148 #endif // CC_RESOURCES_TILE_H_ |
OLD | NEW |