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

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: Address nits 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
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5996ff8feb6ead894f07fc13219b828fe4c38253 100644
--- a/Source/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/Source/platform/graphics/gpu/DrawingBuffer.cpp
@@ -459,7 +459,7 @@ bool DrawingBuffer::initialize(const IntSize& size)
}
bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3DObject texture, GLenum internalFormat,
- GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceBuffer source)
+ GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceDrawingBuffer sourceBuffer)
{
if (m_contentsChanged) {
if (m_multisampleMode != None) {
@@ -478,7 +478,7 @@ bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platfor
// Contexts may be in a different share group. We must transfer the texture through a mailbox first
WebExternalTextureMailbox mailbox;
GLint textureId = 0;
- if (source == Front && m_frontColorBuffer.texInfo.textureId) {
+ if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) {
textureId = m_frontColorBuffer.texInfo.textureId;
mailbox = m_frontColorBuffer.mailbox;
} else {
@@ -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, SourceDrawingBuffer sourceBuffer)
{
if (m_actualAttributes.premultipliedAlpha)
return nullptr;
@@ -903,10 +903,29 @@ PassRefPtr<Uint8ClampedArray> DrawingBuffer::paintRenderingResultsToImageData(in
RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(width * height * 4);
- m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer());
+ GLint fbo = 0;
+ if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) {
+ GLint fbo = m_context->createFramebuffer();
Yuki 2014/11/27 04:30:22 Hi dongseong.hwang, It seems that you're shadowin
dshwang 2014/11/27 09:46:30 Thank you very much for noting! it's a mistake.
+ 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);
+ }
+
+ if (m_framebufferBinding) {
+ restoreFramebufferBinding();
+ } else {
+ bind();
+ }
+
return pixels.release();
}
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698