Chromium Code Reviews| 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); |
|
dshwang
2014/11/21 09:05:40
new test, webgl/canvas-to-data-url.html, covers th
|
| + } 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); |
| + } |
| + |
| return pixels.release(); |
| } |