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

Unified Diff: app/resource_bundle.cc

Issue 288005: First fix to minimize copying of image data. (Closed)
Patch Set: Modify gyp Created 11 years, 2 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: app/resource_bundle.cc
diff --git a/app/resource_bundle.cc b/app/resource_bundle.cc
index a108660cc5244974305dcd4f92ea7882d8d996a8..7261dfd5bb594e41b3e4f08d87159f1bd7546130 100644
--- a/app/resource_bundle.cc
+++ b/app/resource_bundle.cc
@@ -69,20 +69,20 @@ void ResourceBundle::FreeImages() {
/* static */
SkBitmap* ResourceBundle::LoadBitmap(DataHandle data_handle, int resource_id) {
- std::vector<unsigned char> raw_data, png_data;
- bool success = false;
+ std::vector<unsigned char> png_data;
- if (!success)
- success = LoadResourceBytes(data_handle, resource_id, &raw_data);
- if (!success)
+ scoped_refptr<RefCountedMemory> memory(
+ LoadResourceBytes(data_handle, resource_id));
+ if (!memory)
return NULL;
// Decode the PNG.
int image_width;
int image_height;
- if (!gfx::PNGCodec::Decode(&raw_data.front(), raw_data.size(),
- gfx::PNGCodec::FORMAT_BGRA,
- &png_data, &image_width, &image_height)) {
+ if (!gfx::PNGCodec::Decode(
+ memory->front(), memory->size(),
+ gfx::PNGCodec::FORMAT_BGRA,
+ &png_data, &image_width, &image_height)) {
NOTREACHED() << "Unable to decode image resource " << resource_id;
return NULL;
}
@@ -96,14 +96,14 @@ std::string ResourceBundle::GetDataResource(int resource_id) {
return GetRawDataResource(resource_id).as_string();
}
-bool ResourceBundle::LoadImageResourceBytes(int resource_id,
- std::vector<unsigned char>* bytes) {
- return LoadResourceBytes(theme_data_, resource_id, bytes);
+RefCountedStaticMemory* ResourceBundle::LoadImageResourceBytes(
+ int resource_id) {
+ return LoadResourceBytes(theme_data_, resource_id);
}
-bool ResourceBundle::LoadDataResourceBytes(int resource_id,
- std::vector<unsigned char>* bytes) {
- return LoadResourceBytes(resources_data_, resource_id, bytes);
+RefCountedStaticMemory* ResourceBundle::LoadDataResourceBytes(
+ int resource_id) {
+ return LoadResourceBytes(resources_data_, resource_id);
}
SkBitmap* ResourceBundle::GetBitmapNamed(int resource_id) {
« no previous file with comments | « app/resource_bundle.h ('k') | app/resource_bundle_linux.cc » ('j') | base/ref_counted_memory.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698