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)) |