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

Unified Diff: chrome/browser/android/thumbnail/thumbnail_store.cc

Issue 569483002: use NewUninitialized, cheaper than NewWithMalloc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/thumbnail/thumbnail_store.cc
diff --git a/chrome/browser/android/thumbnail/thumbnail_store.cc b/chrome/browser/android/thumbnail/thumbnail_store.cc
index a1652d15326d1e660e0ab07e85a3a99a7664d82d..3c9a25c485c01f3fd107358ee472a19bd5f090be 100644
--- a/chrome/browser/android/thumbnail/thumbnail_store.cc
+++ b/chrome/browser/android/thumbnail/thumbnail_store.cc
@@ -569,7 +569,7 @@ void ThumbnailStore::CompressionTask(
kUnknown_SkColorType,
kUnpremul_SkAlphaType);
skia::RefPtr<SkData> etc1_pixel_data = skia::AdoptRef(
- SkData::NewFromMalloc(new uint8_t[encoded_bytes], encoded_bytes));
+ SkData::NewUninitialized(encoded_bytes));
skia::RefPtr<SkMallocPixelRef> etc1_pixel_ref = skia::AdoptRef(
SkMallocPixelRef::NewWithData(info, 0, NULL, etc1_pixel_data.get()));
f(malita) 2014/09/12 11:49:59 Is this safe? Looks like SkMallocPixelRef is ref-i
f(malita) 2014/09/12 11:54:34 I see it's just writable_data() asserting it gets
reed1 2014/09/12 18:00:08 Yes, the existing code is tricky that way, but sin
@@ -682,13 +682,12 @@ bool ReadFromFile(base::File& file,
return false;
}
- skia::RefPtr<SkData> etc1_pixel_data;
int data_size = etc1_get_encoded_data_size(raw_width, raw_height);
- scoped_ptr<uint8_t[]> raw_data =
- scoped_ptr<uint8_t[]>(new uint8_t[data_size]);
+ skia::RefPtr<SkData> etc1_pixel_data =
+ skia::AdoptRef(SkData::NewUninitialized(data_size));
int pixel_bytes_read = file.ReadAtCurrentPos(
- reinterpret_cast<char*>(raw_data.get()),
+ reinterpret_cast<char*>(etc1_pixel_data->writable_data()),
data_size);
if (pixel_bytes_read != data_size)
@@ -699,9 +698,6 @@ bool ReadFromFile(base::File& file,
kUnknown_SkColorType,
kUnpremul_SkAlphaType);
- etc1_pixel_data = skia::AdoptRef(
- SkData::NewFromMalloc(raw_data.release(), data_size));
-
*out_pixels = skia::AdoptRef(
SkMallocPixelRef::NewWithData(info,
0,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698