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

Unified Diff: Source/platform/graphics/ImageBuffer.cpp

Issue 1234083003: Canvas.toDataURL to use SkBitmap::readPixels to avoid uninitialized memory (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: batter asan fix Created 5 years, 5 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: Source/platform/graphics/ImageBuffer.cpp
diff --git a/Source/platform/graphics/ImageBuffer.cpp b/Source/platform/graphics/ImageBuffer.cpp
index 7c1c32943be7f9626c45a5dd80d243c317fae131..74213e280821408ec7c084866bed333880c71649 100644
--- a/Source/platform/graphics/ImageBuffer.cpp
+++ b/Source/platform/graphics/ImageBuffer.cpp
@@ -317,8 +317,7 @@ void ImageBuffer::putByteArray(Multiply multiplied, const unsigned char* source,
canvas()->writePixels(info, srcAddr, srcBytesPerRow, destX, destY);
}
-template <typename T>
-static bool encodeImage(T& source, const String& mimeType, const double* quality, Vector<char>* output)
+static bool encodeImage(const ImageDataBuffer& source, const String& mimeType, const double* quality, Vector<char>* output)
{
Vector<unsigned char>* encodedImage = reinterpret_cast<Vector<unsigned char>*>(output);
@@ -343,17 +342,6 @@ static bool encodeImage(T& source, const String& mimeType, const double* quality
return true;
}
-String ImageBuffer::toDataURL(const String& mimeType, const double* quality) const
-{
- ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
-
- Vector<char> encodedImage;
- if (!isSurfaceValid() || !encodeImage(m_surface->bitmap(), mimeType, quality, &encodedImage))
- return "data:,";
-
- return "data:" + mimeType + ";base64," + base64Encode(encodedImage);
-}
-
String ImageDataBuffer::toDataURL(const String& mimeType, const double* quality) const
{
ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));

Powered by Google App Engine
This is Rietveld 408576698