| 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 |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "base/trace_event/trace_event_argument.h" | 15 #include "base/trace_event/trace_event_argument.h" |
| 16 #include "cc/base/math_util.h" | 16 #include "cc/base/math_util.h" |
| 17 #include "cc/base/render_surface_filters.h" | 17 #include "cc/base/render_surface_filters.h" |
| 18 #include "cc/debug/picture_debug_util.h" | 18 #include "cc/debug/picture_debug_util.h" |
| 19 #include "cc/paint/clip_display_item.h" | 19 #include "cc/paint/clip_display_item.h" |
| 20 #include "cc/paint/clip_path_display_item.h" | 20 #include "cc/paint/clip_path_display_item.h" |
| 21 #include "cc/paint/compositing_display_item.h" | 21 #include "cc/paint/compositing_display_item.h" |
| 22 #include "cc/paint/discardable_image_store.h" |
| 22 #include "cc/paint/drawing_display_item.h" | 23 #include "cc/paint/drawing_display_item.h" |
| 23 #include "cc/paint/filter_display_item.h" | 24 #include "cc/paint/filter_display_item.h" |
| 24 #include "cc/paint/float_clip_display_item.h" | 25 #include "cc/paint/float_clip_display_item.h" |
| 25 #include "cc/paint/largest_display_item.h" | 26 #include "cc/paint/largest_display_item.h" |
| 26 #include "cc/paint/transform_display_item.h" | 27 #include "cc/paint/transform_display_item.h" |
| 27 #include "third_party/skia/include/core/SkCanvas.h" | 28 #include "third_party/skia/include/core/SkCanvas.h" |
| 28 #include "third_party/skia/include/core/SkImageFilter.h" | 29 #include "third_party/skia/include/core/SkImageFilter.h" |
| 29 #include "third_party/skia/include/core/SkPaint.h" | 30 #include "third_party/skia/include/core/SkPaint.h" |
| 30 #include "third_party/skia/include/core/SkPictureRecorder.h" | 31 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 31 #include "ui/gfx/geometry/rect.h" | 32 #include "ui/gfx/geometry/rect.h" |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 | 526 |
| 526 void DisplayItemList::GenerateDiscardableImagesMetadata() { | 527 void DisplayItemList::GenerateDiscardableImagesMetadata() { |
| 527 // This should be only called once. | 528 // This should be only called once. |
| 528 DCHECK(image_map_.empty()); | 529 DCHECK(image_map_.empty()); |
| 529 if (!has_discardable_images_) | 530 if (!has_discardable_images_) |
| 530 return; | 531 return; |
| 531 | 532 |
| 532 gfx::Rect bounds = rtree_.GetBounds(); | 533 gfx::Rect bounds = rtree_.GetBounds(); |
| 533 DiscardableImageMap::ScopedMetadataGenerator generator( | 534 DiscardableImageMap::ScopedMetadataGenerator generator( |
| 534 &image_map_, gfx::Size(bounds.right(), bounds.bottom())); | 535 &image_map_, gfx::Size(bounds.right(), bounds.bottom())); |
| 535 auto* canvas = generator.canvas(); | 536 GatherDiscardableImages(generator.image_store()); |
| 536 for (const auto& item : items_) | 537 } |
| 537 RasterItem(item, canvas, nullptr); | 538 |
| 539 void DisplayItemList::GatherDiscardableImages( |
| 540 DiscardableImageStore* image_store) const { |
| 541 // TODO(khushalsagar): Could we avoid this if the data was already stored in |
| 542 // the |image_map_|? |
| 543 SkCanvas* canvas = image_store->GetNoDrawCanvas(); |
| 544 for (const auto& item : items_) { |
| 545 if (item.type == DisplayItem::DRAWING) { |
| 546 const auto& drawing_item = static_cast<const DrawingDisplayItem&>(item); |
| 547 image_store->GatherDiscardableImages(drawing_item.picture.get()); |
| 548 } else { |
| 549 RasterItem(item, canvas, nullptr); |
| 550 } |
| 551 } |
| 538 } | 552 } |
| 539 | 553 |
| 540 void DisplayItemList::GetDiscardableImagesInRect( | 554 void DisplayItemList::GetDiscardableImagesInRect( |
| 541 const gfx::Rect& rect, | 555 const gfx::Rect& rect, |
| 542 float contents_scale, | 556 float contents_scale, |
| 543 const gfx::ColorSpace& target_color_space, | 557 const gfx::ColorSpace& target_color_space, |
| 544 std::vector<DrawImage>* images) { | 558 std::vector<DrawImage>* images) { |
| 545 image_map_.GetDiscardableImagesInRect(rect, contents_scale, | 559 image_map_.GetDiscardableImagesInRect(rect, contents_scale, |
| 546 target_color_space, images); | 560 target_color_space, images); |
| 547 } | 561 } |
| 548 | 562 |
| 549 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const { | 563 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const { |
| 550 return image_map_.GetRectForImage(image_id); | 564 return image_map_.GetRectForImage(image_id); |
| 551 } | 565 } |
| 552 | 566 |
| 553 } // namespace cc | 567 } // namespace cc |
| OLD | NEW |