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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2328463004: Implement WebGL's commit on the main thread (Closed)
Patch Set: fix compile error on win_dbg Created 4 years, 3 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/webgl/WebGLRenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
index 95e07416683a6e2fab96e5c131e4d69a8379e0df..15f814c38c393fe23550fbc11cadd2ae3786e230 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -650,6 +650,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())

Powered by Google App Engine
This is Rietveld 408576698