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

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

Issue 805273005: WebGL: paintRenderingResultsToImageData() must restore FBO. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add layout test Created 5 years, 11 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/gpu/DrawingBuffer.cpp » ('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 ff97de11acf75cf4a90ffab76b833348a325b689..c53d1c6e26532019ffc16558e92e3d66aafdbb3e 100644
--- a/Source/core/html/canvas/WebGLRenderingContextBase.cpp
+++ b/Source/core/html/canvas/WebGLRenderingContextBase.cpp
@@ -506,6 +506,23 @@ private:
RawPtrWillBeMember<WebGLRenderingContextBase> m_context;
};
+class ScopedFramebufferRestorer {
+ STACK_ALLOCATED();
+public:
+ explicit ScopedFramebufferRestorer(WebGLRenderingContextBase* context)
+ : m_context(context)
+ {
+ }
+
+ ~ScopedFramebufferRestorer()
+ {
+ m_context->restoreCurrentFramebuffer();
+ }
+
+private:
+ RawPtrWillBeMember<WebGLRenderingContextBase> m_context;
+};
+
class WebGLRenderingContextLostCallback final : public NoBaseWillBeGarbageCollectedFinalized<WebGLRenderingContextLostCallback>, public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public:
@@ -913,6 +930,7 @@ bool WebGLRenderingContextBase::paintRenderingResultsToCanvas(SourceDrawingBuffe
m_markedCanvasDirty = false;
ScopedTexture2DRestorer restorer(this);
+ ScopedFramebufferRestorer fboRestorer(this);
drawingBuffer()->commit();
if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(drawingBuffer(), sourceBuffer)) {
@@ -921,7 +939,6 @@ bool WebGLRenderingContextBase::paintRenderingResultsToCanvas(SourceDrawingBuffe
drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer());
}
- restoreCurrentFramebuffer();
return true;
}
@@ -929,9 +946,12 @@ PassRefPtrWillBeRawPtr<ImageData> WebGLRenderingContextBase::paintRenderingResul
{
if (isContextLost())
return nullptr;
+ if (m_requestedAttributes.premultipliedAlpha())
+ return nullptr;
dshwang 2015/01/08 15:44:59 add optimization not to bind fbo unnecessary.
clearIfComposited();
drawingBuffer()->commit();
+ ScopedFramebufferRestorer restorer(this);
int width, height;
WTF::ArrayBufferContents contents;
if (!drawingBuffer()->paintRenderingResultsToImageData(width, height, sourceBuffer, contents))
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.h ('k') | Source/platform/graphics/gpu/DrawingBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698