Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
index bd605b460e6e909af69feaa9b524191e9a78d91b..b30a2e61bb3e37bd646e8c8a3c44d64d748afe3b 100644 |
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
@@ -737,6 +737,26 @@ PassRefPtr<Image> WebGLRenderingContextBase::getImage( |
return buffer->newImageSnapshot(hint, reason); |
} |
+ImageData* WebGLRenderingContextBase::toImageData(SnapshotReason reason) const { |
+ // TODO: Furnish toImageData in webgl renderingcontext for jpeg and webp |
+ // images. See crbug.com/657531. |
+ ImageData* imageData = nullptr; |
+ if (this->drawingBuffer()) { |
+ sk_sp<SkImage> snapshot = this->drawingBuffer() |
+ ->transferToStaticBitmapImage() |
+ ->imageForCurrentFrame(); |
+ if (snapshot) { |
+ imageData = ImageData::create(this->getOffscreenCanvas()->size()); |
+ SkImageInfo imageInfo = SkImageInfo::Make( |
+ this->drawingBufferWidth(), this->drawingBufferHeight(), |
+ kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); |
+ snapshot->readPixels(imageInfo, imageData->data()->data(), |
+ imageInfo.minRowBytes(), 0, 0); |
+ } |
+ } |
+ return imageData; |
+} |
+ |
namespace { |
// Exposed by GL_ANGLE_depth_texture |