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

Unified Diff: Source/platform/graphics/ImageBuffer.cpp

Issue 179973004: Share Group plumbing in Blink; Remove WebGL from default share group (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed Ken's feedback Created 6 years, 9 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/platform/graphics/ImageBuffer.cpp
diff --git a/Source/platform/graphics/ImageBuffer.cpp b/Source/platform/graphics/ImageBuffer.cpp
index 8b36a9d13a53166dba14682903eda09c6d99d9e4..d6064a5c562f4a6af47475eaec456351c6c15b43 100644
--- a/Source/platform/graphics/ImageBuffer.cpp
+++ b/Source/platform/graphics/ImageBuffer.cpp
@@ -47,6 +47,7 @@
#include "platform/image-encoders/skia/PNGImageEncoder.h"
#include "platform/image-encoders/skia/WEBPImageEncoder.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebExternalTextureMailbox.h"
#include "public/platform/WebGraphicsContext3D.h"
#include "public/platform/WebGraphicsContext3DProvider.h"
#include "third_party/skia/include/effects/SkTableColorFilter.h"
@@ -138,22 +139,52 @@ bool ImageBuffer::copyToPlatformTexture(blink::WebGraphicsContext3D* context, Pl
if (!m_surface->isAccelerated() || !platformLayer() || !isValid())
return false;
- if (!context->makeContextCurrent())
+ if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, level))
return false;
- if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, level))
+ OwnPtr<blink::WebGraphicsContext3DProvider> provider = adoptPtr(blink::Platform::current()->createSharedOffscreenGraphicsContext3DProvider());
+ if (!provider)
+ return false;
+ blink::WebGraphicsContext3D* sharedContext = provider->context3d();
+ if (!sharedContext || !sharedContext->makeContextCurrent())
+ return false;
+
+ OwnPtr<blink::WebExternalTextureMailbox> mailbox = adoptPtr(new blink::WebExternalTextureMailbox);
+
+ // Contexts may be in a different share group. We must transfer the texture through a mailbox first
+ sharedContext->genMailboxCHROMIUM(mailbox->name);
+ sharedContext->bindTexture(GL_TEXTURE_2D, getBackingTexture());
Ken Russell (switch to Gerrit) 2014/03/13 19:35:54 I recall you mentioned that it was always necessar
+ sharedContext->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name);
+ sharedContext->flush();
+
+ mailbox->syncPoint = sharedContext->insertSyncPoint();
+
+ if (!context->makeContextCurrent())
return false;
+ Platform3DObject sourceTexture = context->createTexture();
+
+ context->bindTexture(GL_TEXTURE_2D, sourceTexture);
+
+ context->waitSyncPoint(mailbox->syncPoint);
+ context->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name);
+
// The canvas is stored in a premultiplied format, so unpremultiply if necessary.
context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyAlpha);
// The canvas is stored in an inverted position, so the flip semantics are reversed.
context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, !flipY);
- context->copyTextureCHROMIUM(GL_TEXTURE_2D, getBackingTexture(), texture, level, internalFormat, destType);
+ context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, level, internalFormat, destType);
context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, false);
context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false);
+
+ context->bindTexture(GL_TEXTURE_2D, 0);
dshwang 2014/03/14 21:47:54 If changing context->bindTexture(GL_TEXTURE_2D, te
+ context->deleteTexture(sourceTexture);
+
context->flush();
+ sharedContext->waitSyncPoint(context->insertSyncPoint());
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698