Index: third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.cpp |
diff --git a/third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.cpp b/third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.cpp |
index b35ffa2c3ad31c1e7f0e6f57af726f79945c63cb..ed312b8252328bba206edafa0e31722aa00f0fd0 100644 |
--- a/third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.cpp |
+++ b/third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.cpp |
@@ -158,6 +158,24 @@ PassRefPtr<Image> OffscreenCanvasRenderingContext2D::getImage( |
return image; |
} |
+ImageData* OffscreenCanvasRenderingContext2D::toImageData( |
+ SnapshotReason reason) const { |
+ if (!imageBuffer()) |
+ return nullptr; |
+ sk_sp<SkImage> snapshot = |
+ m_imageBuffer->newSkImageSnapshot(PreferNoAcceleration, reason); |
+ ImageData* imageData = nullptr; |
+ if (snapshot) { |
+ imageData = ImageData::create(this->getOffscreenCanvas()->size()); |
+ SkImageInfo imageInfo = |
+ SkImageInfo::Make(this->width(), this->height(), kRGBA_8888_SkColorType, |
+ kUnpremul_SkAlphaType); |
+ snapshot->readPixels(imageInfo, imageData->data()->data(), |
+ imageInfo.minRowBytes(), 0, 0); |
+ } |
+ return imageData; |
+} |
+ |
void OffscreenCanvasRenderingContext2D::setOffscreenCanvasGetContextResult( |
OffscreenRenderingContext& result) { |
result.setOffscreenCanvasRenderingContext2D(this); |