Chromium Code Reviews| Index: cc/tiles/software_image_decode_cache.cc |
| diff --git a/cc/tiles/software_image_decode_cache.cc b/cc/tiles/software_image_decode_cache.cc |
| index a113be9dd198ca6faeb12bb6092c98033554cea9..d7b9bee09cc4789408cd025fa6ebe4b15dbd8c33 100644 |
| --- a/cc/tiles/software_image_decode_cache.cc |
| +++ b/cc/tiles/software_image_decode_cache.cc |
| @@ -611,9 +611,9 @@ SoftwareImageDecodeCache::GetSubrectImageDecode(const ImageKey& key, |
| // Construct a key to use in GetDecodedImageForDrawInternal(). |
| // This allows us to reuse an image in any cache if available. |
| gfx::Rect full_image_rect(image->width(), image->height()); |
| - DrawImage original_size_draw_image(std::move(image), |
| - gfx::RectToSkIRect(full_image_rect), |
| - kNone_SkFilterQuality, SkMatrix::I()); |
| + DrawImage original_size_draw_image( |
| + std::move(image), gfx::RectToSkIRect(full_image_rect), |
| + kNone_SkFilterQuality, SkMatrix::I(), key.target_color_space()); |
| ImageKey original_size_key = |
| ImageKey::FromDrawImage(original_size_draw_image); |
| // Sanity checks. |
| @@ -667,9 +667,9 @@ SoftwareImageDecodeCache::GetScaledImageDecode(const ImageKey& key, |
| // Construct a key to use in GetDecodedImageForDrawInternal(). |
| // This allows us to reuse an image in any cache if available. |
| gfx::Rect full_image_rect(image->width(), image->height()); |
| - DrawImage original_size_draw_image(std::move(image), |
| - gfx::RectToSkIRect(full_image_rect), |
| - kNone_SkFilterQuality, SkMatrix::I()); |
| + DrawImage original_size_draw_image( |
| + std::move(image), gfx::RectToSkIRect(full_image_rect), |
| + kNone_SkFilterQuality, SkMatrix::I(), key.target_color_space()); |
| ImageKey original_size_key = |
| ImageKey::FromDrawImage(original_size_draw_image); |
| // Sanity checks. |
| @@ -963,6 +963,16 @@ ImageDecodeCacheKey ImageDecodeCacheKey::FromDrawImage(const DrawImage& image) { |
| bool can_use_original_decode = |
| quality == kLow_SkFilterQuality || quality == kNone_SkFilterQuality; |
| + |
| + // Disallow using the original decode if it does not match the target color |
| + // space. |
| + if (image.target_color_space().IsValid()) { |
|
vmpstr
2017/04/04 01:16:43
Hmm, right now the check whether we can use the or
ccameron
2017/04/04 06:41:10
I renamed can_use_original_decode to can_use_origi
|
| + sk_sp<SkColorSpace> target_sk_color_space = |
| + image.target_color_space().ToSkColorSpace(); |
| + can_use_original_decode &= SkColorSpace::Equals( |
| + image.image()->colorSpace(), target_sk_color_space.get()); |
| + } |
| + |
| bool should_use_subrect = false; |
| if (can_use_original_decode && |
| (image.image()->width() >= kMinDimensionToSubrect || |
| @@ -1004,19 +1014,22 @@ ImageDecodeCacheKey ImageDecodeCacheKey::FromDrawImage(const DrawImage& image) { |
| } |
| return ImageDecodeCacheKey(image.image()->uniqueID(), src_rect, target_size, |
| - quality, can_use_original_decode, |
| - should_use_subrect); |
| + image.target_color_space(), quality, |
| + can_use_original_decode, should_use_subrect); |
| } |
| -ImageDecodeCacheKey::ImageDecodeCacheKey(uint32_t image_id, |
| - const gfx::Rect& src_rect, |
| - const gfx::Size& target_size, |
| - SkFilterQuality filter_quality, |
| - bool can_use_original_decode, |
| - bool should_use_subrect) |
| +ImageDecodeCacheKey::ImageDecodeCacheKey( |
| + uint32_t image_id, |
| + const gfx::Rect& src_rect, |
| + const gfx::Size& target_size, |
| + const gfx::ColorSpace& target_color_space, |
| + SkFilterQuality filter_quality, |
| + bool can_use_original_decode, |
| + bool should_use_subrect) |
| : image_id_(image_id), |
| src_rect_(src_rect), |
| target_size_(target_size), |
| + target_color_space_(target_color_space), |
| filter_quality_(filter_quality), |
| can_use_original_decode_(can_use_original_decode), |
| should_use_subrect_(should_use_subrect) { |
| @@ -1046,7 +1059,8 @@ std::string ImageDecodeCacheKey::ToString() const { |
| str << "id[" << image_id_ << "] src_rect[" << src_rect_.x() << "," |
| << src_rect_.y() << " " << src_rect_.width() << "x" << src_rect_.height() |
| << "] target_size[" << target_size_.width() << "x" |
| - << target_size_.height() << "] filter_quality[" << filter_quality_ |
| + << target_size_.height() << "] target_color_space" |
| + << target_color_space_.ToString() << " filter_quality[" << filter_quality_ |
| << "] can_use_original_decode [" << can_use_original_decode_ |
| << "] should_use_subrect [" << should_use_subrect_ << "] hash [" << hash_ |
| << "]"; |