summaryrefslogtreecommitdiffstats
path: root/ui/base/resource
diff options
context:
space:
mode:
authorsaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-16 22:48:08 +0000
committersaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-16 22:48:08 +0000
commitcf469aeabb7aceef1903e70e2380ebbcba90c2b9 (patch)
tree28dc9f1fad635b1b9ad7cf938f006c40c7387255 /ui/base/resource
parent49bf5057c0b445c5953672304c5937c348e97742 (diff)
downloadchromium_src-cf469aeabb7aceef1903e70e2380ebbcba90c2b9.zip
chromium_src-cf469aeabb7aceef1903e70e2380ebbcba90c2b9.tar.gz
chromium_src-cf469aeabb7aceef1903e70e2380ebbcba90c2b9.tar.bz2
As per UX request this CL is changing the background for Aura. Note that this is the first resource which is a JPG. As a result I had to modify the bundle code (which assumes PNGs).
Converting that file to PNG even with all kind of fancy optimization would triple its size. Note on the PNGCodec, it says in the header: "This is currently designed for use in tests only (where we control the files)" So I investigated using the Skia decoding helper but it seems to be unused and not really working. Finally, I am not crazy about having a fallback for the PNG decoding failure like this in the code. I would have preferred testing for the image type (but there was no clean way which was obvious to me, of course we could look at the first few bytes in the header since we have it memory). BUG=105508 TEST=none Review URL: http://codereview.chromium.org/8970032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114871 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/resource')
-rw-r--r--ui/base/resource/resource_bundle.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index 1b3e293..66b3cf5 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -19,6 +19,7 @@
#include "ui/base/resource/data_pack.h"
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
+#include "ui/gfx/codec/jpeg_codec.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/font.h"
#include "ui/gfx/image/image.h"
@@ -369,12 +370,17 @@ SkBitmap* ResourceBundle::LoadBitmap(DataHandle data_handle, int resource_id) {
return NULL;
SkBitmap bitmap;
- if (!gfx::PNGCodec::Decode(memory->front(), memory->size(), &bitmap)) {
- NOTREACHED() << "Unable to decode theme image resource " << resource_id;
- return NULL;
- }
+ if (gfx::PNGCodec::Decode(memory->front(), memory->size(), &bitmap))
+ return new SkBitmap(bitmap);
+
+ // 99% of our assets are PNGs, however fallback to JPEG.
+ SkBitmap* allocated_bitmap =
+ gfx::JPEGCodec::Decode(memory->front(), memory->size());
+ if (allocated_bitmap)
+ return allocated_bitmap;
- return new SkBitmap(bitmap);
+ NOTREACHED() << "Unable to decode theme image resource " << resource_id;
+ return NULL;
}
gfx::Image* ResourceBundle::GetEmptyImage() {