| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/discardable_image_map.h" | 5 #include "cc/playback/discardable_image_map.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| 11 | 11 |
| 12 #include "base/containers/adapters.h" | 12 #include "base/containers/adapters.h" |
| 13 #include "base/memory/ptr_util.h" | |
| 14 #include "cc/base/math_util.h" | 13 #include "cc/base/math_util.h" |
| 15 #include "cc/playback/display_item_list.h" | 14 #include "cc/playback/display_item_list.h" |
| 16 #include "third_party/skia/include/utils/SkNWayCanvas.h" | 15 #include "third_party/skia/include/utils/SkNWayCanvas.h" |
| 17 #include "ui/gfx/geometry/rect_conversions.h" | 16 #include "ui/gfx/geometry/rect_conversions.h" |
| 18 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
| 19 | 18 |
| 20 namespace cc { | 19 namespace cc { |
| 21 | 20 |
| 22 SkRect MapRect(const SkMatrix& matrix, const SkRect& src) { | 21 SkRect MapRect(const SkMatrix& matrix, const SkRect& src) { |
| 23 SkRect dst; | 22 SkRect dst; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 const gfx::Size canvas_size_; | 190 const gfx::Size canvas_size_; |
| 192 std::vector<SkPaint> saved_paints_; | 191 std::vector<SkPaint> saved_paints_; |
| 193 }; | 192 }; |
| 194 | 193 |
| 195 } // namespace | 194 } // namespace |
| 196 | 195 |
| 197 DiscardableImageMap::DiscardableImageMap() {} | 196 DiscardableImageMap::DiscardableImageMap() {} |
| 198 | 197 |
| 199 DiscardableImageMap::~DiscardableImageMap() {} | 198 DiscardableImageMap::~DiscardableImageMap() {} |
| 200 | 199 |
| 201 std::unique_ptr<SkCanvas> DiscardableImageMap::BeginGeneratingMetadata( | 200 sk_sp<SkCanvas> DiscardableImageMap::BeginGeneratingMetadata( |
| 202 const gfx::Size& bounds) { | 201 const gfx::Size& bounds) { |
| 203 DCHECK(all_images_.empty()); | 202 DCHECK(all_images_.empty()); |
| 204 return base::MakeUnique<DiscardableImagesMetadataCanvas>( | 203 return sk_make_sp<DiscardableImagesMetadataCanvas>( |
| 205 bounds.width(), bounds.height(), &all_images_, &image_id_to_region_); | 204 bounds.width(), bounds.height(), &all_images_, &image_id_to_region_); |
| 206 } | 205 } |
| 207 | 206 |
| 208 void DiscardableImageMap::EndGeneratingMetadata() { | 207 void DiscardableImageMap::EndGeneratingMetadata() { |
| 209 images_rtree_.Build(all_images_, | 208 images_rtree_.Build(all_images_, |
| 210 [](const std::pair<DrawImage, gfx::Rect>& image) { | 209 [](const std::pair<DrawImage, gfx::Rect>& image) { |
| 211 return image.second; | 210 return image.second; |
| 212 }); | 211 }); |
| 213 } | 212 } |
| 214 | 213 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 231 DiscardableImageMap* image_map, | 230 DiscardableImageMap* image_map, |
| 232 const gfx::Size& bounds) | 231 const gfx::Size& bounds) |
| 233 : image_map_(image_map), | 232 : image_map_(image_map), |
| 234 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {} | 233 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {} |
| 235 | 234 |
| 236 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { | 235 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { |
| 237 image_map_->EndGeneratingMetadata(); | 236 image_map_->EndGeneratingMetadata(); |
| 238 } | 237 } |
| 239 | 238 |
| 240 } // namespace cc | 239 } // namespace cc |
| OLD | NEW |