| 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> |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 const SkRect canvas_bounds_; | 153 const SkRect canvas_bounds_; |
| 154 std::vector<SkPaint> saved_paints_; | 154 std::vector<SkPaint> saved_paints_; |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 } // namespace | 157 } // namespace |
| 158 | 158 |
| 159 DiscardableImageMap::DiscardableImageMap() {} | 159 DiscardableImageMap::DiscardableImageMap() {} |
| 160 | 160 |
| 161 DiscardableImageMap::~DiscardableImageMap() {} | 161 DiscardableImageMap::~DiscardableImageMap() {} |
| 162 | 162 |
| 163 skia::RefPtr<SkCanvas> DiscardableImageMap::BeginGeneratingMetadata( | 163 sk_sp<SkCanvas> DiscardableImageMap::BeginGeneratingMetadata( |
| 164 const gfx::Size& bounds) { | 164 const gfx::Size& bounds) { |
| 165 DCHECK(all_images_.empty()); | 165 DCHECK(all_images_.empty()); |
| 166 return skia::AdoptRef(new DiscardableImagesMetadataCanvas( | 166 return sk_make_sp<DiscardableImagesMetadataCanvas>( |
| 167 bounds.width(), bounds.height(), &all_images_)); | 167 bounds.width(), bounds.height(), &all_images_); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void DiscardableImageMap::EndGeneratingMetadata() { | 170 void DiscardableImageMap::EndGeneratingMetadata() { |
| 171 images_rtree_.Build(all_images_, | 171 images_rtree_.Build(all_images_, |
| 172 [](const std::pair<DrawImage, gfx::Rect>& image) { | 172 [](const std::pair<DrawImage, gfx::Rect>& image) { |
| 173 return image.second; | 173 return image.second; |
| 174 }); | 174 }); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void DiscardableImageMap::GetDiscardableImagesInRect( | 177 void DiscardableImageMap::GetDiscardableImagesInRect( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 188 DiscardableImageMap* image_map, | 188 DiscardableImageMap* image_map, |
| 189 const gfx::Size& bounds) | 189 const gfx::Size& bounds) |
| 190 : image_map_(image_map), | 190 : image_map_(image_map), |
| 191 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {} | 191 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {} |
| 192 | 192 |
| 193 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { | 193 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { |
| 194 image_map_->EndGeneratingMetadata(); | 194 image_map_->EndGeneratingMetadata(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace cc | 197 } // namespace cc |
| OLD | NEW |