Index: Source/core/html/canvas/WebGLRenderingContextBase.cpp |
diff --git a/Source/core/html/canvas/WebGLRenderingContextBase.cpp b/Source/core/html/canvas/WebGLRenderingContextBase.cpp |
index 3159ce57288b9ab0d8ac972de6f8c0c7c699df7f..75b43aabc9f2bfffc247abdf620af5770777d6e7 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; |
} |
@@ -932,6 +949,7 @@ PassRefPtrWillBeRawPtr<ImageData> WebGLRenderingContextBase::paintRenderingResul |
clearIfComposited(); |
drawingBuffer()->commit(); |
+ ScopedFramebufferRestorer restorer(this); |
int width, height; |
WTF::ArrayBufferContents contents; |
if (!drawingBuffer()->paintRenderingResultsToImageData(width, height, sourceBuffer, contents)) |
dshwang
2015/01/05 16:44:26
drawingBuffer()->commit() binds DrawingBuffer::m_f
|