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

Unified Diff: third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.cpp

Issue 2420203002: Implement convertToBlob() in OffscreenCanvas (Closed)
Patch Set: rebase and fix global-interface-listing-service-worker-expected.txt 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/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);

Powered by Google App Engine
This is Rietveld 408576698