Chromium Code Reviews| Index: ui/base/resource/resource_bundle.cc |
| diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc |
| index 24c05606eead09f08c2297556732a361cfc9aa56..f1606fc797a51a1d38a7d829132bd54033f03f7e 100644 |
| --- a/ui/base/resource/resource_bundle.cc |
| +++ b/ui/base/resource/resource_bundle.cc |
| @@ -26,6 +26,7 @@ |
| #include "ui/gfx/codec/png_codec.h" |
| #include "ui/gfx/font.h" |
| #include "ui/gfx/image/image.h" |
| +#include "ui/gfx/image/image_skia.h" |
| namespace ui { |
| @@ -241,14 +242,22 @@ gfx::Image& ResourceBundle::GetImageNamed(int resource_id) { |
| } |
| DCHECK(!data_packs_.empty()) << "Missing call to SetResourcesDataDLL?"; |
| - ScopedVector<const SkBitmap> bitmaps; |
| + gfx::ImageSkia image_skia; |
| for (size_t i = 0; i < data_packs_.size(); ++i) { |
| - SkBitmap* bitmap = LoadBitmap(*data_packs_[i], resource_id); |
| - if (bitmap) |
| - bitmaps.push_back(bitmap); |
| + // TODO(pkotwicz): Convert LoadBitmap to return reference instead of |
| + // pointer. |
| + scoped_ptr<SkBitmap> bitmap(LoadBitmap(*data_packs_[i], resource_id)); |
| + if (bitmap.get()) { |
| + // ImageSkia adds a reference to bitmap. |
|
sky
2012/05/08 22:38:07
Remove this comment as its a bit misleading.
|
| +#if defined(ENABLE_DIP) |
| + image_skia.AddBitmapForScale(*bitmap, data_packs_[i]->GetScaleFactor()); |
| +#else |
| + image_skia.AddBitmapForScale(*bitmap, 1.0f); |
| +#endif |
| + } |
| } |
| - if (bitmaps.empty()) { |
| + if (image_skia.empty()) { |
| LOG(WARNING) << "Unable to load image with id " << resource_id; |
| NOTREACHED(); // Want to assert in debug mode. |
| // The load failed to retrieve the image; show a debugging red square. |
| @@ -262,10 +271,7 @@ gfx::Image& ResourceBundle::GetImageNamed(int resource_id) { |
| if (images_.count(resource_id)) |
| return *images_[resource_id]; |
| - std::vector<const SkBitmap*> tmp_bitmaps; |
| - bitmaps.release(&tmp_bitmaps); |
| - // Takes ownership of bitmaps. |
| - gfx::Image* image = new gfx::Image(tmp_bitmaps); |
| + gfx::Image* image = new gfx::Image(image_skia); |
| images_[resource_id] = image; |
| return *image; |
| } |