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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2420203002: Implement convertToBlob() in OffscreenCanvas (Closed)
Patch Set: fix layout test and reviewer feedback Created 4 years, 2 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: 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

Powered by Google App Engine
This is Rietveld 408576698