Index: third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp |
diff --git a/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp b/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp |
index 66c354d71901c4ad888f11ce23bfc660e0160a25..fa4679ac65ec3e2566f85d439e0e8ee886c30d42 100644 |
--- a/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp |
+++ b/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp |
@@ -6,6 +6,7 @@ |
#include "core/dom/ExceptionCode.h" |
#include "core/fileapi/Blob.h" |
+#include "core/frame/ImageBitmap.h" |
#include "core/html/ImageData.h" |
#include "core/html/canvas/CanvasAsyncBlobCreator.h" |
#include "core/html/canvas/CanvasContextCreationAttributes.h" |
@@ -111,6 +112,30 @@ PassRefPtr<Image> OffscreenCanvas::getSourceImageForCanvas( |
return image.release(); |
} |
+IntSize OffscreenCanvas::bitmapSourceSize() const { |
+ return m_size; |
+} |
+ |
+ScriptPromise OffscreenCanvas::createImageBitmap( |
+ ScriptState* scriptState, |
+ EventTarget&, |
+ Optional<IntRect> cropRect, |
+ const ImageBitmapOptions& options, |
+ ExceptionState& exceptionState) { |
+ if ((cropRect && |
+ !ImageBitmap::isSourceSizeValid(cropRect->width(), cropRect->height(), |
+ exceptionState)) || |
+ !ImageBitmap::isSourceSizeValid(bitmapSourceSize().width(), |
+ bitmapSourceSize().height(), |
+ exceptionState)) |
+ return ScriptPromise(); |
+ if (!ImageBitmap::isResizeOptionValid(options, exceptionState)) |
+ return ScriptPromise(); |
+ return ImageBitmapSource::fulfillImageBitmap( |
+ scriptState, |
+ isPaintable() ? ImageBitmap::create(this, cropRect, options) : nullptr); |
+} |
+ |
bool OffscreenCanvas::isOpaque() const { |
if (!m_context) |
return false; |