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

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

Issue 1284603003: WebGL: optimize webgl.texSubImage2D(video) path. (Blink side) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase to ToT Created 5 years, 3 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
« no previous file with comments | « Source/platform/graphics/ImageBuffer.h ('k') | Source/platform/graphics/gpu/Extensions3DUtil.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/ImageBuffer.cpp
diff --git a/Source/platform/graphics/ImageBuffer.cpp b/Source/platform/graphics/ImageBuffer.cpp
index d1f305d1b878f65dc20522116998343b0293a356..5168e68716a6ad4e82f49eb585afbd13853e810f 100644
--- a/Source/platform/graphics/ImageBuffer.cpp
+++ b/Source/platform/graphics/ImageBuffer.cpp
@@ -178,12 +178,28 @@ WebLayer* ImageBuffer::platformLayer() const
return m_surface->layer();
}
-bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha, bool flipY)
+bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, GLenum target, Platform3DObject texture,
+ GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha, bool flipY)
+{
+ return copyToPlatformTextureInternal(true, context, target, texture, internalFormat,
+ destType, level, 0, 0, 0, 0, premultiplyAlpha, flipY);
+}
+
+bool ImageBuffer::copySubToPlatformTexture(WebGraphicsContext3D* context, GLenum target, Platform3DObject texture,
+ GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, bool premultiplyAlpha, bool flipY)
+{
+ return copyToPlatformTextureInternal(false, context, target, texture, GL_FALSE, GL_FALSE, level,
+ xoffset, yoffset, width, height, premultiplyAlpha, flipY);
+}
+
+bool ImageBuffer::copyToPlatformTextureInternal(bool isFullCopy, WebGraphicsContext3D* context, GLenum target,
+ Platform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height, bool premultiplyAlpha, bool flipY)
{
if (!m_surface->isAccelerated() || !isSurfaceValid())
return false;
- if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalFormat, destType, level))
+ if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalFormat, destType, level))
return false;
RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot();
@@ -215,9 +231,16 @@ bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3
context->waitSyncPoint(mailbox->syncPoint);
Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name);
+ WGC3Dboolean glFlipY = flipY ? GL_FALSE : GL_TRUE;
+ WGC3Dboolean glPremultiplyAlpha = premultiplyAlpha ? GL_FALSE : GL_TRUE;
+
// The canvas is stored in a premultiplied format, so unpremultiply if necessary.
// The canvas is stored in an inverted position, so the flip semantics are reversed.
- context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, internalFormat, destType, flipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FALSE : GL_TRUE);
+ if (isFullCopy) {
+ context->copyTextureCHROMIUM(target, sourceTexture, texture, internalFormat, destType, glFlipY, GL_FALSE, glPremultiplyAlpha);
+ } else {
+ context->copySubTextureCHROMIUM(target, sourceTexture, texture, xoffset, yoffset, 0, 0, width, height, glFlipY, GL_FALSE, glPremultiplyAlpha);
+ }
context->deleteTexture(sourceTexture);
« no previous file with comments | « Source/platform/graphics/ImageBuffer.h ('k') | Source/platform/graphics/gpu/Extensions3DUtil.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698