Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: cc/paint/discardable_image_map.cc

Issue 2797583002: cc: Add color space to image decode caches (Closed)
Patch Set: Remove dead code Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/paint/discardable_image_map.h ('k') | cc/paint/discardable_image_map_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // this here by outsetting the image rect by 1. Note that this only affects 208 // this here by outsetting the image rect by 1. Note that this only affects
209 // queries into the rtree, which will now return images that only touch the 209 // queries into the rtree, which will now return images that only touch the
210 // bounds of the query rect. 210 // bounds of the query rect.
211 // 211 //
212 // Note that it's not sufficient for us to inset the device clip bounds at 212 // Note that it's not sufficient for us to inset the device clip bounds at
213 // raster time, since we might be sending a larger-than-one-item display 213 // raster time, since we might be sending a larger-than-one-item display
214 // item to skia, which means that skia will internally determine whether to 214 // item to skia, which means that skia will internally determine whether to
215 // raster the picture (using device clip bounds that are outset). 215 // raster the picture (using device clip bounds that are outset).
216 image_rect.Inset(-1, -1); 216 image_rect.Inset(-1, -1);
217 217
218 // The true target color space will be assigned when it is known, in
219 // GetDiscardableImagesInRect.
220 gfx::ColorSpace target_color_space;
221
218 (*image_id_to_rect_)[image->uniqueID()].Union(image_rect); 222 (*image_id_to_rect_)[image->uniqueID()].Union(image_rect);
219 image_set_->push_back(std::make_pair( 223 image_set_->push_back(
220 DrawImage(std::move(image), src_irect, filter_quality, matrix), 224 std::make_pair(DrawImage(std::move(image), src_irect, filter_quality,
221 image_rect)); 225 matrix, target_color_space),
226 image_rect));
222 } 227 }
223 228
224 // Currently this function only handles extracting images from SkImageShaders 229 // Currently this function only handles extracting images from SkImageShaders
225 // embedded in SkPaints. Other embedded image cases, such as SkPictures, 230 // embedded in SkPaints. Other embedded image cases, such as SkPictures,
226 // are not yet handled. 231 // are not yet handled.
227 void AddPaintImage(const SkRect& rect, const SkPaint& paint) { 232 void AddPaintImage(const SkRect& rect, const SkPaint& paint) {
228 SkShader* shader = paint.getShader(); 233 SkShader* shader = paint.getShader();
229 if (shader) { 234 if (shader) {
230 SkMatrix matrix; 235 SkMatrix matrix;
231 SkShader::TileMode xy[2]; 236 SkShader::TileMode xy[2];
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 void DiscardableImageMap::EndGeneratingMetadata() { 269 void DiscardableImageMap::EndGeneratingMetadata() {
265 images_rtree_.Build(all_images_, 270 images_rtree_.Build(all_images_,
266 [](const std::pair<DrawImage, gfx::Rect>& image) { 271 [](const std::pair<DrawImage, gfx::Rect>& image) {
267 return image.second; 272 return image.second;
268 }); 273 });
269 } 274 }
270 275
271 void DiscardableImageMap::GetDiscardableImagesInRect( 276 void DiscardableImageMap::GetDiscardableImagesInRect(
272 const gfx::Rect& rect, 277 const gfx::Rect& rect,
273 float contents_scale, 278 float contents_scale,
279 const gfx::ColorSpace& target_color_space,
274 std::vector<DrawImage>* images) const { 280 std::vector<DrawImage>* images) const {
275 std::vector<size_t> indices; 281 std::vector<size_t> indices;
276 images_rtree_.Search(rect, &indices); 282 images_rtree_.Search(rect, &indices);
277 for (size_t index : indices) 283 for (size_t index : indices) {
278 images->push_back(all_images_[index].first.ApplyScale(contents_scale)); 284 images->push_back(all_images_[index]
285 .first.ApplyScale(contents_scale)
286 .ApplyTargetColorSpace(target_color_space));
287 }
279 } 288 }
280 289
281 gfx::Rect DiscardableImageMap::GetRectForImage(ImageId image_id) const { 290 gfx::Rect DiscardableImageMap::GetRectForImage(ImageId image_id) const {
282 const auto& it = image_id_to_rect_.find(image_id); 291 const auto& it = image_id_to_rect_.find(image_id);
283 return it == image_id_to_rect_.end() ? gfx::Rect() : it->second; 292 return it == image_id_to_rect_.end() ? gfx::Rect() : it->second;
284 } 293 }
285 294
286 DiscardableImageMap::ScopedMetadataGenerator::ScopedMetadataGenerator( 295 DiscardableImageMap::ScopedMetadataGenerator::ScopedMetadataGenerator(
287 DiscardableImageMap* image_map, 296 DiscardableImageMap* image_map,
288 const gfx::Size& bounds) 297 const gfx::Size& bounds)
289 : image_map_(image_map), 298 : image_map_(image_map),
290 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {} 299 metadata_canvas_(image_map->BeginGeneratingMetadata(bounds)) {}
291 300
292 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() { 301 DiscardableImageMap::ScopedMetadataGenerator::~ScopedMetadataGenerator() {
293 image_map_->EndGeneratingMetadata(); 302 image_map_->EndGeneratingMetadata();
294 } 303 }
295 304
296 } // namespace cc 305 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/discardable_image_map.h ('k') | cc/paint/discardable_image_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698