| 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/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 DisplayItemListSettings(proto.settings())); | 60 DisplayItemListSettings(proto.settings())); |
| 61 | 61 |
| 62 for (int i = 0; i < proto.items_size(); i++) { | 62 for (int i = 0; i < proto.items_size(); i++) { |
| 63 const proto::DisplayItem& item_proto = proto.items(i); | 63 const proto::DisplayItem& item_proto = proto.items(i); |
| 64 DisplayItem* item = DisplayItemProtoFactory::AllocateAndConstruct( | 64 DisplayItem* item = DisplayItemProtoFactory::AllocateAndConstruct( |
| 65 layer_rect, list.get(), item_proto); | 65 layer_rect, list.get(), item_proto); |
| 66 if (item) | 66 if (item) |
| 67 item->FromProtobuf(item_proto); | 67 item->FromProtobuf(item_proto); |
| 68 } | 68 } |
| 69 | 69 |
| 70 list->Finalize(); |
| 71 |
| 70 return list; | 72 return list; |
| 71 } | 73 } |
| 72 | 74 |
| 73 DisplayItemList::DisplayItemList(gfx::Rect layer_rect, | 75 DisplayItemList::DisplayItemList(gfx::Rect layer_rect, |
| 74 const DisplayItemListSettings& settings, | 76 const DisplayItemListSettings& settings, |
| 75 bool retain_individual_display_items) | 77 bool retain_individual_display_items) |
| 76 : items_(LargestDisplayItemSize(), | 78 : items_(LargestDisplayItemSize(), |
| 77 LargestDisplayItemSize() * kDefaultNumDisplayItemsToReserve), | 79 LargestDisplayItemSize() * kDefaultNumDisplayItemsToReserve), |
| 78 settings_(settings), | 80 settings_(settings), |
| 79 retain_individual_display_items_(retain_individual_display_items), | 81 retain_individual_display_items_(retain_individual_display_items), |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 DisplayItemsTracingEnabled())); | 322 DisplayItemsTracingEnabled())); |
| 321 } | 323 } |
| 322 | 324 |
| 323 void DisplayItemList::GenerateDiscardableImagesMetadata() { | 325 void DisplayItemList::GenerateDiscardableImagesMetadata() { |
| 324 DCHECK(ProcessAppendedItemsCalled()); | 326 DCHECK(ProcessAppendedItemsCalled()); |
| 325 // This should be only called once, and only after CreateAndCacheSkPicture. | 327 // This should be only called once, and only after CreateAndCacheSkPicture. |
| 326 DCHECK(image_map_.empty()); | 328 DCHECK(image_map_.empty()); |
| 327 DCHECK(!settings_.use_cached_picture || picture_); | 329 DCHECK(!settings_.use_cached_picture || picture_); |
| 328 if (settings_.use_cached_picture && !picture_->willPlayBackBitmaps()) | 330 if (settings_.use_cached_picture && !picture_->willPlayBackBitmaps()) |
| 329 return; | 331 return; |
| 330 | |
| 331 // The cached picture is translated by -layer_rect_.origin during record, | 332 // The cached picture is translated by -layer_rect_.origin during record, |
| 332 // so we need to offset that back in order to get right positioning for | 333 // so we need to offset that back in order to get right positioning for |
| 333 // images. | 334 // images. |
| 334 DiscardableImageMap::ScopedMetadataGenerator generator( | 335 DiscardableImageMap::ScopedMetadataGenerator generator( |
| 335 &image_map_, gfx::Size(layer_rect_.right(), layer_rect_.bottom())); | 336 &image_map_, gfx::Size(layer_rect_.right(), layer_rect_.bottom())); |
| 336 Raster(generator.canvas(), nullptr, | 337 Raster(generator.canvas(), nullptr, |
| 337 gfx::Rect(layer_rect_.right(), layer_rect_.bottom()), 1.f); | 338 gfx::Rect(layer_rect_.right(), layer_rect_.bottom()), 1.f); |
| 338 } | 339 } |
| 339 | 340 |
| 340 void DisplayItemList::GetDiscardableImagesInRect( | 341 void DisplayItemList::GetDiscardableImagesInRect( |
| 341 const gfx::Rect& rect, | 342 const gfx::Rect& rect, |
| 342 float raster_scale, | 343 float raster_scale, |
| 343 std::vector<DrawImage>* images) { | 344 std::vector<DrawImage>* images) { |
| 344 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); | 345 image_map_.GetDiscardableImagesInRect(rect, raster_scale, images); |
| 345 } | 346 } |
| 346 | 347 |
| 347 } // namespace cc | 348 } // namespace cc |
| OLD | NEW |