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

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 description in 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') | no next file » | 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 e528872b1e5ad9690e1662216d2288b3657d74b3..8fb42427a38b02ee3798b1ae836e19b05763d231 100644
--- a/Source/core/html/canvas/WebGLRenderingContextBase.cpp
+++ b/Source/core/html/canvas/WebGLRenderingContextBase.cpp
@@ -505,6 +505,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:
@@ -912,6 +929,7 @@ bool WebGLRenderingContextBase::paintRenderingResultsToCanvas(SourceDrawingBuffe
m_markedCanvasDirty = false;
ScopedTexture2DRestorer restorer(this);
+ ScopedFramebufferRestorer fboRestorer(this);
drawingBuffer()->commit();
if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(drawingBuffer(), sourceBuffer)) {
@@ -920,7 +938,6 @@ bool WebGLRenderingContextBase::paintRenderingResultsToCanvas(SourceDrawingBuffe
drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer());
}
- restoreCurrentFramebuffer();
return true;
}
@@ -928,9 +945,12 @@ PassRefPtrWillBeRawPtr<ImageData> WebGLRenderingContextBase::paintRenderingResul
{
if (isContextLost())
return nullptr;
+ if (m_requestedAttributes.premultipliedAlpha())
+ return nullptr;
clearIfComposited();
drawingBuffer()->commit();
+ ScopedFramebufferRestorer restorer(this);
int width, height;
RefPtr<Uint8ClampedArray> imageDataPixels =
drawingBuffer()->paintRenderingResultsToImageData(width, height, sourceBuffer);
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698