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 4a111e61cb7b2e8f66d5ad11de00a65a803ad417..27386459afbc7ca435571229282277ee45284eb6 100644 |
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
@@ -649,6 +649,23 @@ ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase() |
return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage()); |
} |
+void WebGLRenderingContextBase::commit(ExceptionState& exceptionState) |
+{ |
+ if (!getOffscreenCanvas()) { |
+ exceptionState.throwDOMException(InvalidStateError, "Commit() was called on a rendering context that was not created from an OffscreenCanvas."); |
+ return; |
+ } |
+ // no HTMLCanvas associated, thrown InvalidStateError |
+ if (getOffscreenCanvas()->getAssociatedCanvasId() == -1) { |
+ exceptionState.throwDOMException(InvalidStateError, "Commit() was called on a context whose OffscreenCanvas is not associated with a canvas element."); |
+ return; |
+ } |
+ if (!drawingBuffer()) |
+ return; |
+ // TODO(crbug.com/646864): Make commit() work correctly with { preserveDrawingBuffer : true }. |
+ getOffscreenCanvas()->getOrCreateFrameDispatcher()->dispatchFrame(std::move(drawingBuffer()->transferToStaticBitmapImage())); |
+} |
+ |
PassRefPtr<Image> WebGLRenderingContextBase::getImage(AccelerationHint hint, SnapshotReason reason) const |
{ |
if (!drawingBuffer()) |