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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 1421873005: Revert of "webgl: optimize webgl.texSubImage2D(video) path." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
index 41fb11d70974553e7414a2be6bb7e52d39f561a9..83b8af45aac6fd127223c0f04e34d05639e9fac9 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -4390,7 +4390,7 @@
if (!canvas->is3D()) {
ImageBuffer* buffer = canvas->buffer();
- if (!buffer->copyToPlatformTexture(webContext(), GL_TEXTURE_2D, targetTexture, targetInternalformat, targetType,
+ if (!buffer->copyToPlatformTexture(webContext(), targetTexture, targetInternalformat, targetType,
targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
ASSERT_NOT_REACHED();
}
@@ -4422,51 +4422,6 @@
}
}
-bool WebGLRenderingContextBase::texImage2DVideoByGPU(TexImageFunctionType functionType, WebGLTexture* texture, GLenum target,
- GLint level, GLenum internalformat, GLenum type, GLint xoffset, GLint yoffset, HTMLVideoElement* video)
-{
- typedef WebMediaPlayer::CopyVideoTextureParams CopyParams;
- if (video->copyVideoTextureToPlatformTexture(webContext(),
- CopyParams(
- functionType == NotTexSubImage2D ? CopyParams::FullCopy : CopyParams::SubCopy,
- target, texture->object(), internalformat, type, level, xoffset,
- yoffset, m_unpackPremultiplyAlpha, m_unpackFlipY))) {
- if (functionType == NotTexSubImage2D)
- texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), 1, type);
- return true;
- }
-
- // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU.
- OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBufferSurface(IntSize(video->videoWidth(), video->videoHeight())));
- if (surface->isValid()) {
- OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release()));
- if (imageBuffer) {
- // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface,
- // we enable the WebMediaPlayer implementation to do any necessary color space conversion on the GPU (though it
- // may still do a CPU conversion and upload the results).
- video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr);
-
- // This is a straight GPU-GPU copy, any necessary color space conversion was handled in the paintCurrentFrameInContext() call.
- switch (functionType) {
- case NotTexSubImage2D:
- if (imageBuffer->copyToPlatformTexture(webContext(), target, texture->object(), internalformat, type,
- level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
- texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), 1, type);
- return true;
- }
- break;
- case TexSubImage2D:
- if (imageBuffer->copySubToPlatformTexture(webContext(), target, texture->object(), level,
- xoffset, yoffset, video->videoWidth(), video->videoHeight(), m_unpackPremultiplyAlpha, m_unpackFlipY)) {
- return true;
- }
- break;
- }
- }
- }
- return false;
-}
-
void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum internalformat,
GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& exceptionState)
{
@@ -4513,9 +4468,31 @@
// Otherwise, it will fall back to the normal SW path.
WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
ASSERT(texture);
- if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type, level)) {
- if (texImage2DVideoByGPU(NotTexSubImage2D, texture, target, level, internalformat, type, 0, 0, video))
+ if (GL_TEXTURE_2D == target) {
+ if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type, level)
+ && video->copyVideoTextureToPlatformTexture(webContext(), texture->object(), internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
+ texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), 1, type);
return;
+ }
+
+ // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU.
+ OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBufferSurface(IntSize(video->videoWidth(), video->videoHeight())));
+ if (surface->isValid()) {
+ OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release()));
+ if (imageBuffer) {
+ // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface,
+ // we enable the WebMediaPlayer implementation to do any necessary color space conversion on the GPU (though it
+ // may still do a CPU conversion and upload the results).
+ video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr);
+
+ // This is a straight GPU-GPU copy, any necessary color space conversion was handled in the paintCurrentFrameInContext() call.
+ if (imageBuffer->copyToPlatformTexture(webContext(), texture->object(), internalformat, type,
+ level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
+ texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), 1, type);
+ return;
+ }
+ }
+ }
}
// Normal pure SW path.
@@ -4730,16 +4707,6 @@
if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exceptionState)
|| !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoElement, target, level, 0, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
return;
-
- // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible.
- // Otherwise, it will fall back to the normal SW path.
- WebGLTexture* texture = validateTextureBinding("texSubImage2D", target, true);
- ASSERT(texture);
- if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, GL_RGBA, type, level)) {
- if (texImage2DVideoByGPU(TexSubImage2D, texture, target, level, GL_FALSE,
- GL_FALSE, xoffset, yoffset, video))
- return;
- }
RefPtr<Image> image = videoFrameToImage(video);
if (!image)

Powered by Google App Engine
This is Rietveld 408576698