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

Unified Diff: third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp

Issue 2570613002: Add OffscreenCanvas to ImageBitmapSource union typedef (Closed)
Patch Set: build fix Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698