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

Unified Diff: Source/platform/image-encoders/skia/WEBPImageEncoder.cpp

Issue 1285533002: [WEBPImageEncoder] Use local buffer allocation instead of WTF::Vector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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: Source/platform/image-encoders/skia/WEBPImageEncoder.cpp
diff --git a/Source/platform/image-encoders/skia/WEBPImageEncoder.cpp b/Source/platform/image-encoders/skia/WEBPImageEncoder.cpp
index e82e4bffa23940a81d8f68219ebb6a53e62eb6e9..5edcf10eee691e45c13728479856d42547163155 100644
--- a/Source/platform/image-encoders/skia/WEBPImageEncoder.cpp
+++ b/Source/platform/image-encoders/skia/WEBPImageEncoder.cpp
@@ -54,9 +54,12 @@ static bool rgbPictureImport(const unsigned char* pixels, bool premultiplied, We
// Write the RGB pixels to an rgb data buffer, alpha premultiplied, then import the rgb data.
size_t pixelCount = picture->height * picture->width;
- Vector<unsigned char> rgb(pixelCount * 3);
- for (unsigned char* data = rgb.data(); pixelCount-- > 0; pixels += 4) {
+ OwnPtr<unsigned char[]> rgb = adoptArrayPtr(new unsigned char[pixelCount * 3]);
+ if (!rgb.get())
+ return false;
+
+ for (unsigned char* data = rgb.get(); pixelCount-- > 0; pixels += 4) {
unsigned char alpha = pixels[3];
if (alpha != 255) {
*data++ = SkMulDiv255Round(pixels[0], alpha);
@@ -69,7 +72,7 @@ static bool rgbPictureImport(const unsigned char* pixels, bool premultiplied, We
}
}
- return importRGB(picture, rgb.data(), picture->width * 3);
+ return importRGB(picture, rgb.get(), picture->width * 3);
}
template <bool Premultiplied> inline bool importPictureBGRX(const unsigned char* pixels, WebPPicture* picture)
« 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