summaryrefslogtreecommitdiffstats
path: root/extensions/browser/extension_icon_image.cc
diff options
context:
space:
mode:
authorrdevlin.cronin <rdevlin.cronin@chromium.org>2015-01-29 12:03:53 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-29 20:05:28 +0000
commitbf734cdda75f3314996270eef0e924c63cac9743 (patch)
tree4b43c7b2c91f53f414cd509ae01b2bf58d093b41 /extensions/browser/extension_icon_image.cc
parentb2f01ad40020f6591c2d84af9a7b9e83279e79f3 (diff)
downloadchromium_src-bf734cdda75f3314996270eef0e924c63cac9743.zip
chromium_src-bf734cdda75f3314996270eef0e924c63cac9743.tar.gz
chromium_src-bf734cdda75f3314996270eef0e924c63cac9743.tar.bz2
[Extensions] Make extension actions use gfx::Image over gfx::ImageSkia.
gfx::Images cache different representations (such as NSImages), whereas gfx::ImageSkias (as a representation themselves) do not. Prefer to use gfx::Image in most icon code, so that these representations are cached. BUG=452971 Review URL: https://codereview.chromium.org/882243002 Cr-Commit-Position: refs/heads/master@{#313768}
Diffstat (limited to 'extensions/browser/extension_icon_image.cc')
-rw-r--r--extensions/browser/extension_icon_image.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/extensions/browser/extension_icon_image.cc b/extensions/browser/extension_icon_image.cc
index 5f237ff..5ebc400 100644
--- a/extensions/browser/extension_icon_image.cc
+++ b/extensions/browser/extension_icon_image.cc
@@ -145,6 +145,7 @@ IconImage::IconImage(
gfx::Size resource_size(resource_size_in_dip, resource_size_in_dip);
source_ = new Source(this, resource_size);
image_skia_ = gfx::ImageSkia(source_, resource_size);
+ image_ = gfx::Image(image_skia_);
registrar_.Add(this,
extensions::NOTIFICATION_EXTENSION_REMOVED,
@@ -226,6 +227,12 @@ void IconImage::OnImageLoaded(float scale, const gfx::Image& image_in) {
image_skia_.RemoveRepresentation(scale);
image_skia_.AddRepresentation(rep);
+ // Update the image to use the updated image skia.
+ // It's a shame we have to do this because it means that all the other
+ // representations stored on |image_| will be deleted, but unfortunately
+ // there's no way to combine the storage of two images.
+ image_ = gfx::Image(image_skia_);
+
FOR_EACH_OBSERVER(Observer, observers_, OnExtensionIconImageChanged(this));
}