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