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 0dca9165b5c0d6bc54ff70dfccbba8dadcb2cdd6..c49119f216bb550e199ed423bdcfee1cb06d46e6 100644 |
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
@@ -736,6 +736,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 |