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

Unified Diff: ui/base/resource/resource_bundle.cc

Issue 10245003: Makes ImageSkia more like SkBitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nicer diff Created 8 years, 8 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
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.
+#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;
}

Powered by Google App Engine
This is Rietveld 408576698