Commit c9fedddb authored by noel.gordon@gmail.com's avatar noel.gordon@gmail.com
Browse files

[CG] ImageBuffer: check getPremultipliedImageData() error return

https://bugs.webkit.org/show_bug.cgi?id=84022

Reviewed by Eric Seidel.

ImageBuffer::getPremultipliedImageData() can fail. toDataURL() should check for a
failure return, and return "data:," if so.

No new tests. Covered by existing toDataURL tests, in particular:
  canvas/philip/tests/toDataURL.jpeg.alpha.html

* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::toDataURL): Rename |arr| variable to premultipliedData and
return "data:," if premultipliedData is empty. Clean up whitespace and a comment.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114491 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 34bbd7a4
2012-04-18 Noel Gordon <noel.gordon@gmail.com>
[CG] ImageBuffer: check getPremultipliedImageData() error return
https://bugs.webkit.org/show_bug.cgi?id=84022
Reviewed by Eric Seidel.
ImageBuffer::getPremultipliedImageData() can fail. toDataURL() should check for a
failure return, and return "data:," if so.
No new tests. Covered by existing toDataURL tests, in particular:
canvas/philip/tests/toDataURL.jpeg.alpha.html
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::toDataURL): Rename |arr| variable to premultipliedData and
return "data:," if premultipliedData is empty. Clean up whitespace and a comment.
2012-04-17 Rachel Blum <groby@chromium.org>
 
Skia OOM error when upscaling small subsets of images by large quantities
......@@ -436,23 +436,25 @@ static String CGImageToDataURL(CGImageRef image, const String& mimeType, const d
String ImageBuffer::toDataURL(const String& mimeType, const double* quality, CoordinateSystem) const
{
ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
RetainPtr<CGImageRef> image;
RetainPtr<CFStringRef> uti = utiFromMIMEType(mimeType);
ASSERT(uti);
RefPtr<ByteArray> arr;
RefPtr<ByteArray> premultipliedData;
RetainPtr<CGImageRef> image;
if (CFEqual(uti.get(), jpegUTI())) {
// JPEGs don't have an alpha channel, so we have to manually composite on top of black.
arr = getPremultipliedImageData(IntRect(IntPoint(0, 0), logicalSize()));
premultipliedData = getPremultipliedImageData(IntRect(IntPoint(0, 0), logicalSize()));
if (!premultipliedData)
return "data:,";
unsigned char *data = arr->data();
unsigned char *data = premultipliedData->data();
for (int i = 0; i < logicalSize().width() * logicalSize().height(); i++)
data[i * 4 + 3] = 255; // The image is already premultiplied, so we just need to make it opaque.
data[i * 4 + 3] = 255; // The data is premultiplied, we just need to make it opaque.
RetainPtr<CGDataProviderRef> dataProvider;
dataProvider.adoptCF(CGDataProviderCreateWithData(0, data, 4 * logicalSize().width() * logicalSize().height(), 0));
if (!dataProvider)
return "data:,";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment