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

Unified Diff: extensions/browser/extension_icon_image.cc

Issue 1025513004: Ensure that the extension icons show up in the omnibox at fractional scales. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unsupported image scales from the ImageSkia cache when we receive the OnImageLoaded notifica… Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/image/image_skia.h » ('j') | ui/gfx/image/image_skia.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_icon_image.cc
diff --git a/extensions/browser/extension_icon_image.cc b/extensions/browser/extension_icon_image.cc
index 5ebc40017920f6190631bb21baf4fb5030308d28..cfd4fccac9df97302cda847bfd3c46e5df64f8d2 100644
--- a/extensions/browser/extension_icon_image.cc
+++ b/extensions/browser/extension_icon_image.cc
@@ -223,7 +223,21 @@ void IconImage::OnImageLoaded(float scale, const gfx::Image& image_in) {
DCHECK(!rep.is_null());
DCHECK_EQ(scale, rep.scale());
- // Remove old representation if there is one.
+ // Remove fractional scale image representations as they may have become
+ // stale here. These images are generated by ImageSkia on request from
+ // supported scales like 1x, 2x, etc.
+ // TODO(oshima)
+ // A better approach might be to set the |image_| member using the ImageSkia
+ // copy from the image passed in and set the |image_skia_| member using
+ // image_.ToImageSkia(). However that does not work correctly as the
+ // ImageSkia from the image does not contain a source which breaks requests
+ // for scaled images.
+ std::vector<gfx::ImageSkiaRep> reps = image_skia_.image_reps();
+ for (const auto rep : reps) {
+ if (!gfx::ImageSkia::IsSupportedScale(rep.scale()))
+ image_skia_.RemoveRepresentation(rep.scale());
+ }
+
image_skia_.RemoveRepresentation(scale);
image_skia_.AddRepresentation(rep);
« no previous file with comments | « no previous file | ui/gfx/image/image_skia.h » ('j') | ui/gfx/image/image_skia.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698