OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "cc/playback/display_item_list.h" | 5 #include "cc/playback/display_item_list.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 DCHECK(canvas_); | 161 DCHECK(canvas_); |
162 approximate_op_count_ += item->approximate_op_count(); | 162 approximate_op_count_ += item->approximate_op_count(); |
163 item->Raster(canvas_.get(), gfx::Rect(), nullptr); | 163 item->Raster(canvas_.get(), gfx::Rect(), nullptr); |
164 } else { | 164 } else { |
165 is_suitable_for_gpu_rasterization_ &= | 165 is_suitable_for_gpu_rasterization_ &= |
166 item->is_suitable_for_gpu_rasterization(); | 166 item->is_suitable_for_gpu_rasterization(); |
167 approximate_op_count_ += item->approximate_op_count(); | 167 approximate_op_count_ += item->approximate_op_count(); |
168 } | 168 } |
169 | 169 |
170 if (retain_individual_display_items_) { | 170 if (retain_individual_display_items_) { |
171 // Warning: this double-counts SkPicture data if use_cached_picture_ is | 171 // Warning: this double-counts SkPicture data if use_cached_picture is |
172 // also true. | 172 // also true. |
173 external_memory_usage_ += item->external_memory_usage(); | 173 external_memory_usage_ += item->external_memory_usage(); |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 if (!retain_individual_display_items_) | 177 if (!retain_individual_display_items_) |
178 items_.clear(); | 178 items_.clear(); |
179 } | 179 } |
180 | 180 |
181 void DisplayItemList::RasterIntoCanvas(const DisplayItem& item) { | 181 void DisplayItemList::RasterIntoCanvas(const DisplayItem& item) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 DCHECK(ProcessAppendedItemsCalled()); | 226 DCHECK(ProcessAppendedItemsCalled()); |
227 return approximate_op_count_; | 227 return approximate_op_count_; |
228 } | 228 } |
229 | 229 |
230 size_t DisplayItemList::ApproximateMemoryUsage() const { | 230 size_t DisplayItemList::ApproximateMemoryUsage() const { |
231 DCHECK(ProcessAppendedItemsCalled()); | 231 DCHECK(ProcessAppendedItemsCalled()); |
232 // We double-count in this case. Produce zero to avoid being misleading. | 232 // We double-count in this case. Produce zero to avoid being misleading. |
233 if (settings_.use_cached_picture && retain_individual_display_items_) | 233 if (settings_.use_cached_picture && retain_individual_display_items_) |
234 return 0; | 234 return 0; |
235 | 235 |
236 DCHECK_IMPLIES(settings_.use_cached_picture, picture_); | 236 DCHECK(!settings_.use_cached_picture || picture_); |
237 | 237 |
238 size_t memory_usage = sizeof(*this); | 238 size_t memory_usage = sizeof(*this); |
239 | 239 |
240 // Memory outside this class due to |items_|. | 240 // Memory outside this class due to |items_|. |
241 memory_usage += items_.GetCapacityInBytes() + external_memory_usage_; | 241 memory_usage += items_.GetCapacityInBytes() + external_memory_usage_; |
242 | 242 |
243 // Memory outside this class due to |picture|. | 243 // Memory outside this class due to |picture|. |
244 memory_usage += picture_memory_usage_; | 244 memory_usage += picture_memory_usage_; |
245 | 245 |
246 // TODO(jbroman): Does anything else owned by this class substantially | 246 // TODO(jbroman): Does anything else owned by this class substantially |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.picture"), | 296 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.picture"), |
297 "cc::DisplayItemList", this, | 297 "cc::DisplayItemList", this, |
298 TracedDisplayItemList::AsTraceableDisplayItemList(this, | 298 TracedDisplayItemList::AsTraceableDisplayItemList(this, |
299 DisplayItemsTracingEnabled())); | 299 DisplayItemsTracingEnabled())); |
300 } | 300 } |
301 | 301 |
302 void DisplayItemList::GenerateDiscardableImagesMetadata() { | 302 void DisplayItemList::GenerateDiscardableImagesMetadata() { |
303 DCHECK(ProcessAppendedItemsCalled()); | 303 DCHECK(ProcessAppendedItemsCalled()); |
304 // This should be only called once, and only after CreateAndCacheSkPicture. | 304 // This should be only called once, and only after CreateAndCacheSkPicture. |
305 DCHECK(image_map_.empty()); | 305 DCHECK(image_map_.empty()); |
306 DCHECK_IMPLIES(settings_.use_cached_picture, picture_); | 306 DCHECK(!settings_.use_cached_picture || picture_); |
307 if (settings_.use_cached_picture && !picture_->willPlayBackBitmaps()) | 307 if (settings_.use_cached_picture && !picture_->willPlayBackBitmaps()) |
308 return; | 308 return; |
309 | 309 |
310 // The cached picture is translated by -layer_rect_.origin during record, | 310 // The cached picture is translated by -layer_rect_.origin during record, |
311 // so we need to offset that back in order to get right positioning for | 311 // so we need to offset that back in order to get right positioning for |
312 // images. | 312 // images. |
313 DiscardableImageMap::ScopedMetadataGenerator generator( | 313 DiscardableImageMap::ScopedMetadataGenerator generator( |
314 &image_map_, gfx::Size(layer_rect_.right(), layer_rect_.bottom())); | 314 &image_map_, gfx::Size(layer_rect_.right(), layer_rect_.bottom())); |
315 Raster(generator.canvas(), nullptr, | 315 Raster(generator.canvas(), nullptr, |
316 gfx::Rect(layer_rect_.right(), layer_rect_.bottom()), 1.f); | 316 gfx::Rect(layer_rect_.right(), layer_rect_.bottom()), 1.f); |
317 } | 317 } |
318 | 318 |
319 void DisplayItemList::GetDiscardableImagesInRect( | 319 void DisplayItemList::GetDiscardableImagesInRect( |
320 const gfx::Rect& rect, | 320 const gfx::Rect& rect, |
321 float raster_scale, | 321 float raster_scale, |
322 std::vector<DrawImage>* images) { | 322 std::vector<DrawImage>* images) { |
323 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); | 323 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); |
324 } | 324 } |
325 | 325 |
326 } // namespace cc | 326 } // namespace cc |
OLD | NEW |