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

Unified Diff: Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 749653002: WebGL: clarify which Front or Back buffer is used by each API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase to ToT Created 6 years, 1 month 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
Index: Source/platform/graphics/gpu/DrawingBuffer.cpp
diff --git a/Source/platform/graphics/gpu/DrawingBuffer.cpp b/Source/platform/graphics/gpu/DrawingBuffer.cpp
index 60a9d9862c845d8daf7e086ded9f085bd0552242..a1e2e6dc00496731f39ef03b8f19e4cea8bc83e9 100644
--- a/Source/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/Source/platform/graphics/gpu/DrawingBuffer.cpp
@@ -887,7 +887,7 @@ void DrawingBuffer::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer)
paintFramebufferToCanvas(framebuffer(), size().width(), size().height(), !m_actualAttributes.premultipliedAlpha, imageBuffer);
}
-PassRefPtr<Uint8ClampedArray> DrawingBuffer::paintRenderingResultsToImageData(int& width, int& height)
+PassRefPtr<Uint8ClampedArray> DrawingBuffer::paintRenderingResultsToImageData(int& width, int& height, SourceBuffer sourceBuffer)
{
if (m_actualAttributes.premultipliedAlpha)
return nullptr;
@@ -903,10 +903,23 @@ PassRefPtr<Uint8ClampedArray> DrawingBuffer::paintRenderingResultsToImageData(in
RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(width * height * 4);
- m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer());
+ GLint fbo = 0;
+ if (sourceBuffer == Front && m_frontColorBuffer.texInfo.textureId) {
+ GLint fbo = m_context->createFramebuffer();
+ m_context->bindFramebuffer(GL_FRAMEBUFFER, fbo);
+ m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_frontColorBuffer.texInfo.textureId, 0);
+ } else {
+ m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer());
+ }
+
readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing);
flipVertically(pixels->data(), width, height);
+ if (fbo) {
+ m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
+ m_context->deleteFramebuffer(fbo);
Ken Russell (switch to Gerrit) 2014/11/26 00:49:10 Please bind either the 0 framebuffer or framebuffe
dshwang 2014/11/26 13:37:30 I intentionally don't bind FBO because WebGLRender
+ }
+
return pixels.release();
}
« Source/core/html/HTMLCanvasElement.h ('K') | « Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698