| 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 528 |
| 528 void DisplayItemList::GenerateDiscardableImagesMetadata() { | 529 void DisplayItemList::GenerateDiscardableImagesMetadata() { |
| 529 // This should be only called once. | 530 // This should be only called once. |
| 530 DCHECK(image_map_.empty()); | 531 DCHECK(image_map_.empty()); |
| 531 if (!has_discardable_images_) | 532 if (!has_discardable_images_) |
| 532 return; | 533 return; |
| 533 | 534 |
| 534 gfx::Rect bounds = rtree_.GetBounds(); | 535 gfx::Rect bounds = rtree_.GetBounds(); |
| 535 DiscardableImageMap::ScopedMetadataGenerator generator( | 536 DiscardableImageMap::ScopedMetadataGenerator generator( |
| 536 &image_map_, gfx::Size(bounds.right(), bounds.bottom())); | 537 &image_map_, gfx::Size(bounds.right(), bounds.bottom())); |
| 537 auto* canvas = generator.canvas(); | 538 GatherDiscardableImages(generator.image_store()); |
| 538 for (const auto& item : items_) | 539 } |
| 539 RasterItem(item, canvas, nullptr); | 540 |
| 541 void DisplayItemList::GatherDiscardableImages( |
| 542 DiscardableImageStore* image_store) const { |
| 543 // TODO(khushalsagar): Could we avoid this if the data was already stored in |
| 544 // the |image_map_|? |
| 545 SkCanvas* canvas = image_store->NoDrawCanvas(); |
| 546 for (const auto& item : items_) { |
| 547 if (item.type == DisplayItem::DRAWING) { |
| 548 const auto& drawing_item = static_cast<const DrawingDisplayItem&>(item); |
| 549 drawing_item.picture->GatherDiscardableImages(image_store); |
| 550 } else { |
| 551 RasterItem(item, canvas, nullptr); |
| 552 } |
| 553 } |
| 540 } | 554 } |
| 541 | 555 |
| 542 void DisplayItemList::GetDiscardableImagesInRect( | 556 void DisplayItemList::GetDiscardableImagesInRect( |
| 543 const gfx::Rect& rect, | 557 const gfx::Rect& rect, |
| 544 float contents_scale, | 558 float contents_scale, |
| 545 const gfx::ColorSpace& target_color_space, | 559 const gfx::ColorSpace& target_color_space, |
| 546 std::vector<DrawImage>* images) { | 560 std::vector<DrawImage>* images) { |
| 547 image_map_.GetDiscardableImagesInRect(rect, contents_scale, | 561 image_map_.GetDiscardableImagesInRect(rect, contents_scale, |
| 548 target_color_space, images); | 562 target_color_space, images); |
| 549 } | 563 } |
| 550 | 564 |
| 551 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const { | 565 gfx::Rect DisplayItemList::GetRectForImage(ImageId image_id) const { |
| 552 return image_map_.GetRectForImage(image_id); | 566 return image_map_.GetRectForImage(image_id); |
| 553 } | 567 } |
| 554 | 568 |
| 555 } // namespace cc | 569 } // namespace cc |
| OLD | NEW |