Chromium Code Reviews| 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/paint/discardable_image_map.h" | 5 #include "cc/paint/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 19 matching lines...) Expand all Loading... | |
| 30 [](const std::pair<DrawImage, gfx::Rect>& image) { | 30 [](const std::pair<DrawImage, gfx::Rect>& image) { |
| 31 return image.second; | 31 return image.second; |
| 32 }); | 32 }); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void DiscardableImageMap::GetDiscardableImagesInRect( | 35 void DiscardableImageMap::GetDiscardableImagesInRect( |
| 36 const gfx::Rect& rect, | 36 const gfx::Rect& rect, |
| 37 float contents_scale, | 37 float contents_scale, |
| 38 const gfx::ColorSpace& target_color_space, | 38 const gfx::ColorSpace& target_color_space, |
| 39 std::vector<DrawImage>* images) const { | 39 std::vector<DrawImage>* images) const { |
| 40 std::vector<size_t> indices; | 40 std::vector<size_t> indices = images_rtree_.Search(rect); |
| 41 images_rtree_.Search(rect, &indices); | |
| 42 for (size_t index : indices) { | 41 for (size_t index : indices) { |
|
danakj
2017/05/15 20:35:34
you could for (.. : Search()) directly if you want
vmpstr
2017/05/15 20:46:33
Done.
| |
| 43 images->push_back(all_images_[index] | 42 images->push_back(all_images_[index] |
| 44 .first.ApplyScale(contents_scale) | 43 .first.ApplyScale(contents_scale) |
| 45 .ApplyTargetColorSpace(target_color_space)); | 44 .ApplyTargetColorSpace(target_color_space)); |
| 46 } | 45 } |
| 47 } | 46 } |
| 48 | 47 |
| 49 gfx::Rect DiscardableImageMap::GetRectForImage(ImageId image_id) const { | 48 gfx::Rect DiscardableImageMap::GetRectForImage(ImageId image_id) const { |
| 50 const auto& it = image_id_to_rect_.find(image_id); | 49 const auto& it = image_id_to_rect_.find(image_id); |
| 51 return it == image_id_to_rect_.end() ? gfx::Rect() : it->second; | 50 return it == image_id_to_rect_.end() ? gfx::Rect() : it->second; |
| 52 } | 51 } |
| 53 | 52 |
| 54 DiscardableImageMap::ScopedMetadataGenerator::ScopedMetadataGenerator( | 53 DiscardableImageMap::ScopedMetadataGenerator::ScopedMetadataGenerator( |
| 55 DiscardableImageMap* image_map, | 54 DiscardableImageMap* image_map, |
| 56 const gfx::Size& bounds) | 55 const gfx::Size& bounds) |
| 57 : image_map_(image_map), | 56 : image_map_(image_map), |
| 58 image_store_(image_map->BeginGeneratingMetadata(bounds)) {} | 57 image_store_(image_map->BeginGeneratingMetadata(bounds)) {} |
| 59 | 58 |
| 60 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { | 59 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { |
| 61 image_map_->EndGeneratingMetadata(); | 60 image_map_->EndGeneratingMetadata(); |
| 62 } | 61 } |
| 63 | 62 |
| 64 } // namespace cc | 63 } // namespace cc |
| OLD | NEW |