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/base/ref_counted_managed.h" | 11 #include "cc/base/ref_counted_managed.h" |
12 #include "cc/resources/managed_tile_state.h" | 12 #include "cc/resources/managed_tile_state.h" |
13 #include "cc/resources/picture_pile_impl.h" | 13 #include "cc/resources/picture_pile_impl.h" |
14 #include "cc/resources/raster_mode.h" | |
15 #include "cc/resources/tile_priority.h" | 14 #include "cc/resources/tile_priority.h" |
16 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
17 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
18 | 17 |
19 namespace cc { | 18 namespace cc { |
20 | 19 |
21 class CC_EXPORT Tile : public RefCountedManaged<Tile> { | 20 class CC_EXPORT Tile : public RefCountedManaged<Tile> { |
22 public: | 21 public: |
23 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 }; | 22 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 }; |
24 | 23 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 void MarkRequiredForActivation(); | 86 void MarkRequiredForActivation(); |
88 | 87 |
89 bool required_for_activation() const { | 88 bool required_for_activation() const { |
90 return priority_[PENDING_TREE].required_for_activation; | 89 return priority_[PENDING_TREE].required_for_activation; |
91 } | 90 } |
92 | 91 |
93 bool use_picture_analysis() const { | 92 bool use_picture_analysis() const { |
94 return !!(flags_ & USE_PICTURE_ANALYSIS); | 93 return !!(flags_ & USE_PICTURE_ANALYSIS); |
95 } | 94 } |
96 | 95 |
97 bool NeedsRasterForMode(RasterMode mode) const { | 96 bool HasResources() const { return managed_state_.draw_info_.has_resource(); } |
98 return !managed_state_.tile_versions[mode].IsReadyToDraw(); | |
99 } | |
100 | |
101 bool HasResources() const { | |
102 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | |
103 if (managed_state_.tile_versions[mode].has_resource()) | |
104 return true; | |
105 } | |
106 return false; | |
107 } | |
108 | 97 |
109 void AsValueInto(base::debug::TracedValue* dict) const; | 98 void AsValueInto(base::debug::TracedValue* dict) const; |
110 | 99 |
111 inline bool IsReadyToDraw() const { | 100 inline bool IsReadyToDraw() const { |
112 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 101 return managed_state_.draw_info_.IsReadyToDraw(); |
113 if (managed_state_.tile_versions[mode].IsReadyToDraw()) | |
114 return true; | |
115 } | |
116 return false; | |
117 } | 102 } |
118 | 103 |
119 const ManagedTileState::TileVersion& GetTileVersionForDrawing() const { | 104 const ManagedTileState::TileDrawInfo& GetTileDrawInfo() const { |
reveman
2014/09/27 02:57:32
draw_info()?
vmpstr
2014/09/29 14:09:50
Done.
| |
120 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 105 return managed_state_.draw_info_; |
121 if (managed_state_.tile_versions[mode].IsReadyToDraw()) | 106 } |
122 return managed_state_.tile_versions[mode]; | 107 |
123 } | 108 ManagedTileState::TileDrawInfo& GetTileDrawInfo() { |
reveman
2014/09/27 02:57:32
ditto
vmpstr
2014/09/29 14:09:50
Done.
| |
124 return managed_state_.tile_versions[HIGH_QUALITY_RASTER_MODE]; | 109 return managed_state_.draw_info_; |
125 } | 110 } |
126 | 111 |
127 float contents_scale() const { return contents_scale_; } | 112 float contents_scale() const { return contents_scale_; } |
128 gfx::Rect content_rect() const { return content_rect_; } | 113 gfx::Rect content_rect() const { return content_rect_; } |
129 | 114 |
130 int layer_id() const { return layer_id_; } | 115 int layer_id() const { return layer_id_; } |
131 | 116 |
132 int source_frame_number() const { return source_frame_number_; } | 117 int source_frame_number() const { return source_frame_number_; } |
133 | 118 |
134 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { | 119 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { |
135 DCHECK(pile->CanRaster(contents_scale_, content_rect_)) | 120 DCHECK(pile->CanRaster(contents_scale_, content_rect_)) |
136 << "Recording rect: " | 121 << "Recording rect: " |
137 << gfx::ScaleToEnclosingRect(content_rect_, 1.f / contents_scale_) | 122 << gfx::ScaleToEnclosingRect(content_rect_, 1.f / contents_scale_) |
138 .ToString(); | 123 .ToString(); |
139 picture_pile_ = pile; | 124 picture_pile_ = pile; |
140 } | 125 } |
141 | 126 |
142 size_t GPUMemoryUsageInBytes() const; | 127 size_t GPUMemoryUsageInBytes() const; |
143 | 128 |
144 gfx::Size size() const { return size_; } | 129 gfx::Size size() const { return size_; } |
145 | 130 |
146 RasterMode DetermineRasterModeForTree(WhichTree tree) const; | |
147 RasterMode DetermineOverallRasterMode() const; | |
148 | |
149 // Functionality used in tests. | |
150 RasterMode GetRasterModeForTesting() const { | |
151 return managed_state().raster_mode; | |
152 } | |
153 ManagedTileState::TileVersion& GetTileVersionForTesting(RasterMode mode) { | |
154 return managed_state_.tile_versions[mode]; | |
155 } | |
156 | |
157 private: | 131 private: |
158 friend class TileManager; | 132 friend class TileManager; |
159 friend class PrioritizedTileSet; | 133 friend class PrioritizedTileSet; |
160 friend class FakeTileManager; | 134 friend class FakeTileManager; |
161 friend class BinComparator; | 135 friend class BinComparator; |
162 friend class FakePictureLayerImpl; | 136 friend class FakePictureLayerImpl; |
163 | 137 |
164 // Methods called by by tile manager. | 138 // Methods called by by tile manager. |
165 Tile(TileManager* tile_manager, | 139 Tile(TileManager* tile_manager, |
166 PicturePileImpl* picture_pile, | 140 PicturePileImpl* picture_pile, |
167 const gfx::Size& tile_size, | 141 const gfx::Size& tile_size, |
168 const gfx::Rect& content_rect, | 142 const gfx::Rect& content_rect, |
169 float contents_scale, | 143 float contents_scale, |
170 int layer_id, | 144 int layer_id, |
171 int source_frame_number, | 145 int source_frame_number, |
172 int flags); | 146 int flags); |
173 ~Tile(); | 147 ~Tile(); |
174 | 148 |
175 ManagedTileState& managed_state() { return managed_state_; } | 149 ManagedTileState& managed_state() { return managed_state_; } |
176 const ManagedTileState& managed_state() const { return managed_state_; } | 150 const ManagedTileState& managed_state() const { return managed_state_; } |
177 RasterMode DetermineRasterModeForResolution(TileResolution resolution) const; | |
178 | 151 |
179 bool HasRasterTask() const; | 152 bool HasRasterTask() const; |
180 | 153 |
181 TileManager* tile_manager_; | 154 TileManager* tile_manager_; |
182 scoped_refptr<PicturePileImpl> picture_pile_; | 155 scoped_refptr<PicturePileImpl> picture_pile_; |
183 gfx::Size size_; | 156 gfx::Size size_; |
184 gfx::Rect content_rect_; | 157 gfx::Rect content_rect_; |
185 float contents_scale_; | 158 float contents_scale_; |
186 bool is_occluded_[NUM_TREES]; | 159 bool is_occluded_[NUM_TREES]; |
187 | 160 |
188 TilePriority priority_[NUM_TREES]; | 161 TilePriority priority_[NUM_TREES]; |
189 ManagedTileState managed_state_; | 162 ManagedTileState managed_state_; |
190 int layer_id_; | 163 int layer_id_; |
191 int source_frame_number_; | 164 int source_frame_number_; |
192 int flags_; | 165 int flags_; |
193 bool is_shared_; | 166 bool is_shared_; |
194 | 167 |
195 Id id_; | 168 Id id_; |
196 static Id s_next_id_; | 169 static Id s_next_id_; |
197 | 170 |
198 DISALLOW_COPY_AND_ASSIGN(Tile); | 171 DISALLOW_COPY_AND_ASSIGN(Tile); |
199 }; | 172 }; |
200 | 173 |
201 } // namespace cc | 174 } // namespace cc |
202 | 175 |
203 #endif // CC_RESOURCES_TILE_H_ | 176 #endif // CC_RESOURCES_TILE_H_ |
OLD | NEW |