| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 DCHECK(ProcessAppendedItemsCalled()); | 196 DCHECK(ProcessAppendedItemsCalled()); |
| 197 return approximate_op_count_; | 197 return approximate_op_count_; |
| 198 } | 198 } |
| 199 | 199 |
| 200 size_t DisplayItemList::ApproximateMemoryUsage() const { | 200 size_t DisplayItemList::ApproximateMemoryUsage() const { |
| 201 DCHECK(ProcessAppendedItemsCalled()); | 201 DCHECK(ProcessAppendedItemsCalled()); |
| 202 // We double-count in this case. Produce zero to avoid being misleading. | 202 // We double-count in this case. Produce zero to avoid being misleading. |
| 203 if (use_cached_picture_ && retain_individual_display_items_) | 203 if (use_cached_picture_ && retain_individual_display_items_) |
| 204 return 0; | 204 return 0; |
| 205 | 205 |
| 206 DCHECK_IMPLIES(use_cached_picture_, picture_); | 206 DCHECK(!use_cached_picture_ || picture_); |
| 207 | 207 |
| 208 size_t memory_usage = sizeof(*this); | 208 size_t memory_usage = sizeof(*this); |
| 209 | 209 |
| 210 // Memory outside this class due to |items_|. | 210 // Memory outside this class due to |items_|. |
| 211 memory_usage += items_.GetCapacityInBytes() + external_memory_usage_; | 211 memory_usage += items_.GetCapacityInBytes() + external_memory_usage_; |
| 212 | 212 |
| 213 // Memory outside this class due to |picture|. | 213 // Memory outside this class due to |picture|. |
| 214 memory_usage += picture_memory_usage_; | 214 memory_usage += picture_memory_usage_; |
| 215 | 215 |
| 216 // TODO(jbroman): Does anything else owned by this class substantially | 216 // TODO(jbroman): Does anything else owned by this class substantially |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.picture"), | 266 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.picture"), |
| 267 "cc::DisplayItemList", this, | 267 "cc::DisplayItemList", this, |
| 268 TracedDisplayItemList::AsTraceableDisplayItemList(this, | 268 TracedDisplayItemList::AsTraceableDisplayItemList(this, |
| 269 DisplayItemsTracingEnabled())); | 269 DisplayItemsTracingEnabled())); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void DisplayItemList::GenerateDiscardableImagesMetadata() { | 272 void DisplayItemList::GenerateDiscardableImagesMetadata() { |
| 273 DCHECK(ProcessAppendedItemsCalled()); | 273 DCHECK(ProcessAppendedItemsCalled()); |
| 274 // This should be only called once, and only after CreateAndCacheSkPicture. | 274 // This should be only called once, and only after CreateAndCacheSkPicture. |
| 275 DCHECK(image_map_.empty()); | 275 DCHECK(image_map_.empty()); |
| 276 DCHECK_IMPLIES(use_cached_picture_, picture_); | 276 DCHECK(!use_cached_picture_ || picture_); |
| 277 if (use_cached_picture_ && !picture_->willPlayBackBitmaps()) | 277 if (use_cached_picture_ && !picture_->willPlayBackBitmaps()) |
| 278 return; | 278 return; |
| 279 | 279 |
| 280 // The cached picture is translated by -layer_rect_.origin during record, | 280 // The cached picture is translated by -layer_rect_.origin during record, |
| 281 // so we need to offset that back in order to get right positioning for | 281 // so we need to offset that back in order to get right positioning for |
| 282 // images. | 282 // images. |
| 283 DiscardableImageMap::ScopedMetadataGenerator generator( | 283 DiscardableImageMap::ScopedMetadataGenerator generator( |
| 284 &image_map_, gfx::Size(layer_rect_.right(), layer_rect_.bottom())); | 284 &image_map_, gfx::Size(layer_rect_.right(), layer_rect_.bottom())); |
| 285 Raster(generator.canvas(), nullptr, | 285 Raster(generator.canvas(), nullptr, |
| 286 gfx::Rect(layer_rect_.right(), layer_rect_.bottom()), 1.f); | 286 gfx::Rect(layer_rect_.right(), layer_rect_.bottom()), 1.f); |
| 287 } | 287 } |
| 288 | 288 |
| 289 void DisplayItemList::GetDiscardableImagesInRect( | 289 void DisplayItemList::GetDiscardableImagesInRect( |
| 290 const gfx::Rect& rect, | 290 const gfx::Rect& rect, |
| 291 float raster_scale, | 291 float raster_scale, |
| 292 std::vector<DrawImage>* images) { | 292 std::vector<DrawImage>* images) { |
| 293 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); | 293 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace cc | 296 } // namespace cc |
| OLD | NEW |