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

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

Issue 2294383002: Make OffscreenCanvas a member of CanvasImageSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.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/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 879e4578873d86e2ec4f81b696bd4746b73ce923..8890125753091e53e5b8808e1ef9d22781fad2e4 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -649,6 +649,27 @@ ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase()
return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage());
}
+PassRefPtr<Image> WebGLRenderingContextBase::getImage(SnapshotReason reason) const
+{
+ if (!drawingBuffer())
+ return nullptr;
+
+ drawingBuffer()->commit();
+ IntSize size = clampedCanvasSize();
+ OpacityMode opacityMode = creationAttributes().hasAlpha() ? NonOpaque : Opaque;
+ std::unique_ptr<AcceleratedImageBufferSurface> surface = wrapUnique(new AcceleratedImageBufferSurface(size, opacityMode));
+ if (!surface->isValid())
+ return nullptr;
+ std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(std::move(surface));
+ if (!buffer->copyRenderingResultsFromDrawingBuffer(drawingBuffer(), BackBuffer)) {
+ // copyRenderingResultsFromDrawingBuffer is expected to always succeed because we've
+ // explicitly created an Accelerated surface and have already validated it.
+ NOTREACHED();
+ return nullptr;
+ }
+ return buffer->newImageSnapshot(PreferAcceleration, reason);
+}
+
namespace {
// ES2 enums
@@ -6301,7 +6322,7 @@ void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable)
contextGL()->Disable(capability);
}
-IntSize WebGLRenderingContextBase::clampedCanvasSize()
+IntSize WebGLRenderingContextBase::clampedCanvasSize() const
{
int width, height;
if (canvas()) {
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698