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 const ManagedTileState::TileVersion& tile_version() const { |
reveman
2013/06/05 18:01:32
tile_version() magically returning the tile versio
vmpstr
2013/06/06 01:54:20
Done.
| |
62 return managed_state_.tile_version; | 66 for (int mode = NUM_RASTER_MODES - 1; mode >= 0; --mode) { |
67 if (managed_state_.tile_versions[mode].IsReadyToDraw()) | |
68 return managed_state_.tile_versions[mode]; | |
69 } | |
70 return managed_state_.tile_versions[managed_state_.raster_mode]; | |
63 } | 71 } |
64 ManagedTileState::TileVersion& tile_version() { | 72 ManagedTileState::TileVersion& tile_version() { |
65 return managed_state_.tile_version; | 73 for (int mode = NUM_RASTER_MODES - 1; mode >= 0; --mode) { |
74 if (managed_state_.tile_versions[mode].IsReadyToDraw()) | |
75 return managed_state_.tile_versions[mode]; | |
76 } | |
77 return managed_state_.tile_versions[managed_state_.raster_mode]; | |
66 } | 78 } |
67 | 79 |
68 gfx::Rect opaque_rect() const { return opaque_rect_; } | 80 gfx::Rect opaque_rect() const { return opaque_rect_; } |
69 bool has_text() const { | 81 bool has_text() const { |
70 return managed_state_.picture_pile_analysis.has_text; | 82 return managed_state_.picture_pile_analysis.has_text; |
71 } | 83 } |
72 | 84 |
73 float contents_scale() const { return contents_scale_; } | 85 float contents_scale() const { return contents_scale_; } |
74 gfx::Rect content_rect() const { return content_rect_; } | 86 gfx::Rect content_rect() const { return content_rect_; } |
75 | 87 |
76 int layer_id() const { return layer_id_; } | 88 int layer_id() const { return layer_id_; } |
77 | 89 |
78 int source_frame_number() const { return source_frame_number_; } | 90 int source_frame_number() const { return source_frame_number_; } |
79 | 91 |
80 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { | 92 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { |
81 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); | 93 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); |
82 picture_pile_ = pile; | 94 picture_pile_ = pile; |
83 } | 95 } |
84 | 96 |
85 // For test only methods. | 97 // For test only methods. |
86 bool HasRasterTaskForTesting() const { | 98 bool HasRasterTaskForTesting() const { |
87 return !managed_state().raster_task.is_null(); | 99 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
100 if (!managed_state().tile_versions[mode].raster_task_.is_null()) | |
101 return true; | |
102 } | |
103 return false; | |
88 } | 104 } |
89 void ResetRasterTaskForTesting() { | 105 void ResetRasterTaskForTesting() { |
90 managed_state().raster_task.Reset(); | 106 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
107 if (!managed_state().tile_versions[mode].raster_task_.is_null()) | |
reveman
2013/06/05 18:01:32
can you remove this and always call Reset instead?
vmpstr
2013/06/06 01:54:20
Done.
| |
108 managed_state().tile_versions[mode].raster_task_.Reset(); | |
109 } | |
91 } | 110 } |
92 | 111 |
93 private: | 112 private: |
94 // Methods called by by tile manager. | 113 // Methods called by by tile manager. |
95 friend class TileManager; | 114 friend class TileManager; |
96 friend class BinComparator; | 115 friend class BinComparator; |
97 ManagedTileState& managed_state() { return managed_state_; } | 116 ManagedTileState& managed_state() { return managed_state_; } |
98 const ManagedTileState& managed_state() const { return managed_state_; } | 117 const ManagedTileState& managed_state() const { return managed_state_; } |
99 | 118 |
100 inline size_t bytes_consumed_if_allocated() const { | 119 inline size_t bytes_consumed_if_allocated() const { |
(...skipping 16 matching lines...) Expand all Loading... | |
117 ManagedTileState managed_state_; | 136 ManagedTileState managed_state_; |
118 int layer_id_; | 137 int layer_id_; |
119 int source_frame_number_; | 138 int source_frame_number_; |
120 | 139 |
121 DISALLOW_COPY_AND_ASSIGN(Tile); | 140 DISALLOW_COPY_AND_ASSIGN(Tile); |
122 }; | 141 }; |
123 | 142 |
124 } // namespace cc | 143 } // namespace cc |
125 | 144 |
126 #endif // CC_RESOURCES_TILE_H_ | 145 #endif // CC_RESOURCES_TILE_H_ |
OLD | NEW |