Index: Source/platform/graphics/ImageBuffer.cpp |
diff --git a/Source/platform/graphics/ImageBuffer.cpp b/Source/platform/graphics/ImageBuffer.cpp |
index d0411279a138370e9c03bcf048ce8a3626b462a6..a0b53d6657fcce979b0b8b843f6cc9db3ca308a7 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,21 +139,54 @@ 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; |
+ |
+ GLint boundTexture = 0; |
+ sharedContext->getIntegerv(GL_TEXTURE_BINDING_2D, &boundTexture); |
+ |
+ OwnPtr<blink::WebExternalTextureMailbox> mailbox = adoptPtr(new blink::WebExternalTextureMailbox); |
+ |
+ // Context 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()); |
+ sharedContext->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name); |
+ sharedContext->flush(); |
+ |
+ mailbox->syncPoint = sharedContext->insertSyncPoint(); |
+ sharedContext->waitSyncPoint(mailbox->syncPoint); |
piman
2014/03/11 00:02:24
Same comments as in DrawingBuffer, you want to do
|
+ |
+ sharedContext->bindTexture(GL_TEXTURE_2D, boundTexture); |
+ |
+ if (!context->makeContextCurrent()) |
return false; |
+ Platform3DObject sourceTexture = context->createTexture(); |
+ |
+ context->getIntegerv(GL_TEXTURE_BINDING_2D, &boundTexture); |
+ context->bindTexture(GL_TEXTURE_2D, sourceTexture); |
+ 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, boundTexture); |
+ context->deleteTexture(sourceTexture); |
+ |
context->flush(); |
piman
2014/03/11 00:02:24
same comments as in DrawingBuffer, you can add sha
|
return true; |
} |