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/paint/display_item_list.h" | 5 #include "cc/paint/display_item_list.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); | 519 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); |
520 state->SetString("skp64", b64_picture); | 520 state->SetString("skp64", b64_picture); |
521 } | 521 } |
522 | 522 |
523 return state; | 523 return state; |
524 } | 524 } |
525 | 525 |
526 void DisplayItemList::GenerateDiscardableImagesMetadata() { | 526 void DisplayItemList::GenerateDiscardableImagesMetadata() { |
527 // This should be only called once. | 527 // This should be only called once. |
528 DCHECK(image_map_.empty()); | 528 DCHECK(image_map_.empty()); |
| 529 if (!has_discardable_images_) |
| 530 return; |
529 | 531 |
530 gfx::Rect bounds = rtree_.GetBounds(); | 532 gfx::Rect bounds = rtree_.GetBounds(); |
531 DiscardableImageMap::ScopedMetadataGenerator generator( | 533 DiscardableImageMap::ScopedMetadataGenerator generator( |
532 &image_map_, gfx::Size(bounds.right(), bounds.bottom())); | 534 &image_map_, gfx::Size(bounds.right(), bounds.bottom())); |
533 auto* canvas = generator.canvas(); | 535 auto* canvas = generator.canvas(); |
534 for (const auto& item : items_) | 536 for (const auto& item : items_) |
535 RasterItem(item, canvas, nullptr); | 537 RasterItem(item, canvas, nullptr); |
536 } | 538 } |
537 | 539 |
538 void DisplayItemList::GetDiscardableImagesInRect( | 540 void DisplayItemList::GetDiscardableImagesInRect( |
539 const gfx::Rect& rect, | 541 const gfx::Rect& rect, |
540 float contents_scale, | 542 float contents_scale, |
541 const gfx::ColorSpace& target_color_space, | 543 const gfx::ColorSpace& target_color_space, |
542 std::vector<DrawImage>* images) { | 544 std::vector<DrawImage>* images) { |
543 image_map_.GetDiscardableImagesInRect(rect, contents_scale, | 545 image_map_.GetDiscardableImagesInRect(rect, contents_scale, |
544 target_color_space, images); | 546 target_color_space, images); |
545 } | 547 } |
546 | 548 |
547 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const { | 549 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const { |
548 return image_map_.GetRectForImage(image_id); | 550 return image_map_.GetRectForImage(image_id); |
549 } | 551 } |
550 | 552 |
551 } // namespace cc | 553 } // namespace cc |
OLD | NEW |