| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 const gfx::Size canvas_size_; | 182 const gfx::Size canvas_size_; |
| 184 std::vector<SkPaint> saved_paints_; | 183 std::vector<SkPaint> saved_paints_; |
| 185 }; | 184 }; |
| 186 | 185 |
| 187 } // namespace | 186 } // namespace |
| 188 | 187 |
| 189 DiscardableImageMap::DiscardableImageMap() {} | 188 DiscardableImageMap::DiscardableImageMap() {} |
| 190 | 189 |
| 191 DiscardableImageMap::~DiscardableImageMap() {} | 190 DiscardableImageMap::~DiscardableImageMap() {} |
| 192 | 191 |
| 193 std::unique_ptr<SkCanvas> DiscardableImageMap::BeginGeneratingMetadata( | 192 sk_sp<SkCanvas> DiscardableImageMap::BeginGeneratingMetadata( |
| 194 const gfx::Size& bounds) { | 193 const gfx::Size& bounds) { |
| 195 DCHECK(all_images_.empty()); | 194 DCHECK(all_images_.empty()); |
| 196 return base::MakeUnique<DiscardableImagesMetadataCanvas>( | 195 return sk_make_sp<DiscardableImagesMetadataCanvas>( |
| 197 bounds.width(), bounds.height(), &all_images_); | 196 bounds.width(), bounds.height(), &all_images_); |
| 198 } | 197 } |
| 199 | 198 |
| 200 void DiscardableImageMap::EndGeneratingMetadata() { | 199 void DiscardableImageMap::EndGeneratingMetadata() { |
| 201 images_rtree_.Build(all_images_, | 200 images_rtree_.Build(all_images_, |
| 202 [](const std::pair<DrawImage, gfx::Rect>& image) { | 201 [](const std::pair<DrawImage, gfx::Rect>& image) { |
| 203 return image.second; | 202 return image.second; |
| 204 }); | 203 }); |
| 205 } | 204 } |
| 206 | 205 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 218 DiscardableImageMap* image_map, | 217 DiscardableImageMap* image_map, |
| 219 const gfx::Size& bounds) | 218 const gfx::Size& bounds) |
| 220 : image_map_(image_map), | 219 : image_map_(image_map), |
| 221 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {} | 220 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {} |
| 222 | 221 |
| 223 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { | 222 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { |
| 224 image_map_->EndGeneratingMetadata(); | 223 image_map_->EndGeneratingMetadata(); |
| 225 } | 224 } |
| 226 | 225 |
| 227 } // namespace cc | 226 } // namespace cc |
| OLD | NEW |