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

Unified Diff: Source/core/html/canvas/WebGLRenderingContextBase.cpp

Issue 179973004: Share Group plumbing in Blink; Remove WebGL from default share group (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Style nit and comment Created 6 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
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.h ('k') | Source/platform/graphics/ImageBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/canvas/WebGLRenderingContextBase.cpp
diff --git a/Source/core/html/canvas/WebGLRenderingContextBase.cpp b/Source/core/html/canvas/WebGLRenderingContextBase.cpp
index 7a058de37660e0c8cb33f72632d224e1f26ff20c..3c70156b7733b78505c627bbb57f591ba07413dc 100644
--- a/Source/core/html/canvas/WebGLRenderingContextBase.cpp
+++ b/Source/core/html/canvas/WebGLRenderingContextBase.cpp
@@ -455,6 +455,22 @@ namespace {
}
} // namespace anonymous
+class ScopedTexture2DRestorer {
+public:
+ ScopedTexture2DRestorer(WebGLRenderingContextBase* context)
+ : m_context(context)
+ {
+ }
+
+ ~ScopedTexture2DRestorer()
+ {
+ m_context->restoreCurrentTexture2D();
+ }
+
+private:
+ WebGLRenderingContextBase* m_context;
+};
+
class WebGLRenderingContextLostCallback : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -831,6 +847,8 @@ void WebGLRenderingContextBase::paintRenderingResultsToCanvas()
canvas()->clearCopiedImage();
m_markedCanvasDirty = false;
+ ScopedTexture2DRestorer restorer(this);
+
m_drawingBuffer->commit();
if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(m_drawingBuffer.get())) {
canvas()->ensureUnacceleratedImageBuffer();
@@ -3406,9 +3424,12 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
return;
WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
+
// If possible, copy from the canvas element directly to the texture
// via the GPU, without a read-back to system memory.
if (GL_TEXTURE_2D == target && texture) {
+ ScopedTexture2DRestorer restorer(this);
+
if (!canvas->is3D()) {
ImageBuffer* buffer = canvas->buffer();
if (buffer && buffer->copyToPlatformTexture(m_context.get(), texture->object(), internalformat, type,
@@ -3418,6 +3439,7 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
}
} else {
WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->renderingContext());
+ ScopedTexture2DRestorer restorer(gl);
if (gl && gl->m_drawingBuffer->copyToPlatformTexture(m_context.get(), texture->object(), internalformat, type,
level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
texture->setLevelInfo(target, level, internalformat, canvas->width(), canvas->height(), type);
@@ -5338,7 +5360,7 @@ void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB
return;
blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->attributes(canvas()->document().topDocument().url().string(), settings);
- OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::current()->createOffscreenGraphicsContext3D(attributes));
+ OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::current()->createOffscreenGraphicsContext3D(attributes, 0));
if (!context) {
if (m_contextLostMode == RealLostContext) {
m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE);
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.h ('k') | Source/platform/graphics/ImageBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698