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

Unified Diff: Source/core/html/HTMLCanvasElement.cpp

Issue 1236173005: Revert of Canvas.toDataURL to use SkBitmap::readPixels to avoid uninitialized memory (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« no previous file with comments | « Source/core/html/HTMLCanvasElement.h ('k') | Source/platform/graphics/ImageBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLCanvasElement.cpp
diff --git a/Source/core/html/HTMLCanvasElement.cpp b/Source/core/html/HTMLCanvasElement.cpp
index a6b3d958f42631f5ebcfa7fbb1413c2180284ed3..a41bd5beb6c08ff3077a3349eed785e68b5293e3 100644
--- a/Source/core/html/HTMLCanvasElement.cpp
+++ b/Source/core/html/HTMLCanvasElement.cpp
@@ -463,43 +463,28 @@
return AtomicString(toDataURLInternal("image/png", 0, FrontBuffer));
}
-ImageData* HTMLCanvasElement::toImageData(SourceDrawingBuffer sourceBuffer) const
-{
- ImageData* imageData;
- if (is3D()) {
- // Get non-premultiplied data because of inaccurate premultiplied alpha conversion of buffer()->toDataURL().
- imageData = m_context->paintRenderingResultsToImageData(sourceBuffer);
- if (imageData)
- return imageData;
-
- m_context->paintRenderingResultsToCanvas(sourceBuffer);
- imageData = ImageData::create(m_size);
- SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8888_SkColorType, kUnpremul_SkAlphaType);
- buffer()->bitmap().readPixels(imageInfo, imageData->data()->data(), imageInfo.minRowBytes(), 0, 0);
- return imageData;
- }
-
- imageData = ImageData::create(m_size);
-
- if (m_context) {
- ASSERT(m_context->is2d());
- SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8888_SkColorType, kUnpremul_SkAlphaType);
- buffer()->bitmap().readPixels(imageInfo, imageData->data()->data(), imageInfo.minRowBytes(), 0, 0);
- }
- return imageData;
-}
-
String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double* quality, SourceDrawingBuffer sourceBuffer) const
{
if (!isPaintable())
return String("data:,");
String encodingMimeType = toEncodingMimeType(mimeType);
-
- ImageData* imageData = toImageData(sourceBuffer);
- ScopedDisposal<ImageData> disposer(imageData);
-
- return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataURL(encodingMimeType, quality);
+ if (!m_context) {
+ ImageData* imageData = ImageData::create(m_size);
+ ScopedDisposal<ImageData> disposer(imageData);
+ return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataURL(encodingMimeType, quality);
+ }
+
+ if (m_context->is3d()) {
+ // Get non-premultiplied data because of inaccurate premultiplied alpha conversion of buffer()->toDataURL().
+ ImageData* imageData = m_context->paintRenderingResultsToImageData(sourceBuffer);
+ ScopedDisposal<ImageData> disposer(imageData);
+ if (imageData)
+ return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataURL(encodingMimeType, quality);
+ m_context->paintRenderingResultsToCanvas(sourceBuffer);
+ }
+
+ return buffer()->toDataURL(encodingMimeType, quality);
}
String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& qualityArgument, ExceptionState& exceptionState) const
« no previous file with comments | « Source/core/html/HTMLCanvasElement.h ('k') | Source/platform/graphics/ImageBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698