Chromium Code Reviews| Index: chrome/browser/ui/app_list/arc/arc_app_icon.cc |
| diff --git a/chrome/browser/ui/app_list/arc/arc_app_icon.cc b/chrome/browser/ui/app_list/arc/arc_app_icon.cc |
| index 8c9c2c97e7ebef6200b0d8f0c3cd835abf44906f..52474879652556a99855eb35222eee733e9c519a 100644 |
| --- a/chrome/browser/ui/app_list/arc/arc_app_icon.cc |
| +++ b/chrome/browser/ui/app_list/arc/arc_app_icon.cc |
| @@ -213,11 +213,7 @@ void ArcAppIcon::DecodeRequest::OnImageDecoded(const SkBitmap& bitmap) { |
| return; |
| } |
| - gfx::ImageSkia image_skia; |
| - image_skia.AddRepresentation(gfx::ImageSkiaRep( |
| - bitmap, |
| - ui::GetScaleForScaleFactor(scale_factor_))); |
| - host_->Update(&image_skia); |
| + host_->Update(scale_factor_, bitmap); |
| host_->DiscardDecodeRequest(this); |
| } |
| @@ -359,18 +355,32 @@ void ArcAppIcon::OnIconRead( |
| } |
| } |
| -void ArcAppIcon::Update(const gfx::ImageSkia* image) { |
| +void ArcAppIcon::Update(ui::ScaleFactor scale_factor, const SkBitmap& bitmap) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| - CHECK(image && !image->isNull()); |
| - std::vector<gfx::ImageSkiaRep> reps = image->image_reps(); |
| - for (const auto& image_rep : reps) { |
| - if (ui::IsSupportedScale(image_rep.scale())) { |
| - image_skia_.RemoveRepresentation(image_rep.scale()); |
| - image_skia_.AddRepresentation(image_rep); |
|
oshima
2017/05/26 18:13:23
I looked into a bit more, and the problem seems to
khmel
2017/05/26 19:31:20
Thanks for offline chat! As discussed I moved inva
|
| + gfx::ImageSkiaRep image_rep(bitmap, ui::GetScaleForScaleFactor(scale_factor)); |
| + DCHECK(ui::IsSupportedScale(image_rep.scale())); |
| + |
| + image_skia_.RemoveRepresentation(image_rep.scale()); |
| + |
| + // Regenerate existing non-supported image representations that depend on the |
| + // rep of |scale_factor|. |
| + std::vector<float> scales_to_regenerate; |
| + for (const gfx::ImageSkiaRep& image_rep_to_test : image_skia_.image_reps()) { |
| + if (gfx::ImageSkia::MapToSupportedScale(image_rep_to_test.scale()) == |
| + image_rep.scale()) { |
| + DCHECK(!ui::IsSupportedScale(image_rep_to_test.scale())); |
| + scales_to_regenerate.push_back(image_rep_to_test.scale()); |
| } |
| } |
| + image_skia_.AddRepresentation(image_rep); |
| + |
| + for (float scale_to_regenerate : scales_to_regenerate) { |
| + image_skia_.RemoveRepresentation(scale_to_regenerate); |
| + image_skia_.GetRepresentation(scale_to_regenerate); |
| + } |
| + |
| observer_->OnIconUpdated(this); |
| } |