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

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

Issue 17859003: Allow DrawingBuffer to present to a bitmap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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
Index: Source/core/platform/graphics/gpu/DrawingBuffer.cpp
diff --git a/Source/core/platform/graphics/gpu/DrawingBuffer.cpp b/Source/core/platform/graphics/gpu/DrawingBuffer.cpp
index 5940b06e7cd3d5cea867b30fbcc6f362f075d436..6874bd07564712f1773423d4e54d8759c53d2f9b 100644
--- a/Source/core/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/Source/core/platform/graphics/gpu/DrawingBuffer.cpp
@@ -39,6 +39,7 @@
#include "core/platform/graphics/GraphicsLayer.h"
#include "public/platform/Platform.h"
#include "public/platform/WebCompositorSupport.h"
+#include "public/platform/WebExternalBitmap.h"
#include "public/platform/WebExternalTextureLayer.h"
#include "public/platform/WebGraphicsContext3D.h"
@@ -176,7 +177,7 @@ WebKit::WebGraphicsContext3D* DrawingBuffer::context()
return m_context->webContext();
}
-bool DrawingBuffer::prepareMailbox(WebKit::WebExternalTextureMailbox* outMailbox)
+bool DrawingBuffer::prepareMailbox(WebKit::WebExternalTextureMailbox* outMailbox, WebKit::WebExternalBitmap* bitmap)
{
if (!m_context || !m_contentsChanged || !m_lastColorBuffer)
return false;
@@ -187,6 +188,16 @@ bool DrawingBuffer::prepareMailbox(WebKit::WebExternalTextureMailbox* outMailbox
if (multisample())
commit();
+ if (bitmap) {
+ bitmap->setSize(size());
+
+ unsigned char* pixels = bitmap->pixels();
+ bool needPremultiply = m_attributes.alpha && !m_attributes.premultipliedAlpha;
+ GraphicsContext3D::AlphaOp op = needPremultiply ? GraphicsContext3D::AlphaDoPremultiply : GraphicsContext3D::AlphaDoNothing;
+ if (pixels)
+ m_context->readBackFramebuffer(pixels, size().width(), size().height(), GraphicsContext3D::ReadbackSkia, op);
+ }
+
// We must restore the texture binding since creating new textures,
// consuming and producing mailboxes changes it.
ScopedTextureUnit0BindingRestorer restorer(m_context.get(), m_activeTextureUnit, m_texture2DBinding);
« no previous file with comments | « Source/core/platform/graphics/gpu/DrawingBuffer.h ('k') | Tools/DumpRenderTree/chromium/TestRunner/src/TestPlugin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698