Index: Source/platform/graphics/ImageBuffer.cpp |
diff --git a/Source/platform/graphics/ImageBuffer.cpp b/Source/platform/graphics/ImageBuffer.cpp |
index 6a207636bf19815b99422040a47429b3e8136c54..4485c50d31857cb5293829532afc8dab0f52d55b 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,57 @@ 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); |
Ken Russell (switch to Gerrit)
2014/03/12 21:23:38
Get calls are expensive in the command buffer. Is
|
+ |
+ 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()); |
+ sharedContext->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name); |
+ sharedContext->bindTexture(GL_TEXTURE_2D, boundTexture); |
+ sharedContext->flush(); |
+ |
+ mailbox->syncPoint = sharedContext->insertSyncPoint(); |
+ |
+ if (!context->makeContextCurrent()) |
+ return false; |
+ |
+ Platform3DObject sourceTexture = context->createTexture(); |
+ |
+ context->getIntegerv(GL_TEXTURE_BINDING_2D, &boundTexture); |
Ken Russell (switch to Gerrit)
2014/03/12 21:23:38
The only caller of ImageBuffer::copyToPlatformText
|
+ 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, boundTexture); |
Ken Russell (switch to Gerrit)
2014/03/12 21:23:38
In order to effectively delete sourceTexture below
|
+ context->deleteTexture(sourceTexture); |
+ |
context->flush(); |
+ sharedContext->waitSyncPoint(context->insertSyncPoint()); |
+ |
return true; |
} |