| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 void DiscardableImageMap::EndGeneratingMetadata() { | 208 void DiscardableImageMap::EndGeneratingMetadata() { |
| 209 images_rtree_.Build(all_images_, | 209 images_rtree_.Build(all_images_, |
| 210 [](const std::pair<DrawImage, gfx::Rect>& image) { | 210 [](const std::pair<DrawImage, gfx::Rect>& image) { |
| 211 return image.second; | 211 return image.second; |
| 212 }); | 212 }); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void DiscardableImageMap::GetDiscardableImagesInRect( | 215 void DiscardableImageMap::GetDiscardableImagesInRect( |
| 216 const gfx::Rect& rect, | 216 const gfx::Rect& rect, |
| 217 const gfx::SizeF& raster_scales, | 217 float raster_scale, |
| 218 std::vector<DrawImage>* images) const { | 218 std::vector<DrawImage>* images) const { |
| 219 std::vector<size_t> indices; | 219 std::vector<size_t> indices; |
| 220 images_rtree_.Search(rect, &indices); | 220 images_rtree_.Search(rect, &indices); |
| 221 for (size_t index : indices) | 221 for (size_t index : indices) |
| 222 images->push_back(all_images_[index].first.ApplyScale(raster_scales)); | 222 images->push_back(all_images_[index].first.ApplyScale(raster_scale)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 Region DiscardableImageMap::GetRegionForImage(uint32_t image_id) const { | 225 Region DiscardableImageMap::GetRegionForImage(uint32_t image_id) const { |
| 226 const auto& it = image_id_to_region_.find(image_id); | 226 const auto& it = image_id_to_region_.find(image_id); |
| 227 return it == image_id_to_region_.end() ? Region() : it->second; | 227 return it == image_id_to_region_.end() ? Region() : it->second; |
| 228 } | 228 } |
| 229 | 229 |
| 230 DiscardableImageMap::ScopedMetadataGenerator::ScopedMetadataGenerator( | 230 DiscardableImageMap::ScopedMetadataGenerator::ScopedMetadataGenerator( |
| 231 DiscardableImageMap* image_map, | 231 DiscardableImageMap* image_map, |
| 232 const gfx::Size& bounds) | 232 const gfx::Size& bounds) |
| 233 : image_map_(image_map), | 233 : image_map_(image_map), |
| 234 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {} | 234 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {} |
| 235 | 235 |
| 236 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { | 236 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { |
| 237 image_map_->EndGeneratingMetadata(); | 237 image_map_->EndGeneratingMetadata(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace cc | 240 } // namespace cc |
| OLD | NEW |