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

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

Issue 1775153002: Make OffscreenCanvasRenderingContext2D renderable on a worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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/offscreencanvas/OffscreenCanvas.cpp
diff --git a/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp b/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
index df103939b734876ec2e0a55e7ed0fdbbd6e213da..d63ae1124067c94e07df2085f91ec87235ee7665 100644
--- a/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
+++ b/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
@@ -4,6 +4,10 @@
#include "modules/offscreencanvas/OffscreenCanvas.h"
+#include "core/dom/ExceptionCode.h"
+#if !ENABLE(OILPAN)
+#include "core/frame/ImageBitmap.h" // So ~RefPtr can call unref()
+#endif
#include "core/html/canvas/CanvasContextCreationAttributes.h"
#include "modules/offscreencanvas/OffscreenCanvasRenderingContext.h"
#include "modules/offscreencanvas/OffscreenCanvasRenderingContextFactory.h"
@@ -12,6 +16,13 @@
namespace blink {
+OffscreenCanvas::OffscreenCanvas(const IntSize& size)
+ : m_size(size)
+{ }
+
+OffscreenCanvas::~OffscreenCanvas()
+{ }
+
OffscreenCanvas* OffscreenCanvas::create(unsigned width, unsigned height)
{
return new OffscreenCanvas(IntSize(clampTo<int>(width), clampTo<int>(height)));
@@ -27,11 +38,6 @@ void OffscreenCanvas::setHeight(unsigned height)
m_size.setHeight(clampTo<int>(height));
}
-OffscreenCanvas::OffscreenCanvas(const IntSize& size)
- : m_size(size)
-{
-}
-
OffscreenCanvasRenderingContext2D* OffscreenCanvas::getContext(const String& id, const CanvasContextCreationAttributes& attributes)
{
OffscreenCanvasRenderingContext::ContextType contextType = OffscreenCanvasRenderingContext::contextTypeFromId(id);
@@ -59,6 +65,20 @@ OffscreenCanvasRenderingContext2D* OffscreenCanvas::getContext(const String& id,
return static_cast<OffscreenCanvasRenderingContext2D*>(m_context.get());
}
+PassRefPtrWillBeRawPtr<ImageBitmap> OffscreenCanvas::transferToImageBitmap(ExceptionState& exceptionState)
+{
+ if (!m_context) {
+ exceptionState.throwDOMException(InvalidStateError, "Cannot transfer an ImageBitmap from an OffscreenCanvas with no context");
+ return nullptr;
+ }
+ RefPtrWillBeRawPtr<ImageBitmap> image = m_context->transferToImageBitmap(exceptionState);
+ if (!image) {
+ // Undocumented exception (not in spec)
+ exceptionState.throwDOMException(V8GeneralError, "Out of memory");
+ }
+ return image.release();
+}
+
OffscreenCanvasRenderingContext2D* OffscreenCanvas::renderingContext() const
{
// TODO: When there're more than one context type implemented in the future,

Powered by Google App Engine
This is Rietveld 408576698