Chromium Code Reviews| 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 33cce6b0aec3bf0ce5f711a30d53b3592f3aa381..bc4530093088fe64e30405e11407ec9b5deb049e 100644 |
| --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| @@ -4384,7 +4384,7 @@ void WebGLRenderingContextBase::texImage2DCanvasByGPU(TexImageFunctionType funct |
| if (!canvas->is3D()) { |
| ImageBuffer* buffer = canvas->buffer(); |
| - if (!buffer->copyToPlatformTexture(webContext(), targetTexture, targetInternalformat, targetType, |
| + if (!buffer->copyToPlatformTexture(webContext(), GL_TEXTURE_2D, targetTexture, targetInternalformat, targetType, |
| targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| ASSERT_NOT_REACHED(); |
| } |
| @@ -4460,9 +4460,11 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in |
| // Otherwise, it will fall back to the normal SW path. |
| WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
| ASSERT(texture); |
| - if (GL_TEXTURE_2D == target) { |
| - if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type, level) |
| - && video->copyVideoTextureToPlatformTexture(webContext(), texture->object(), internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| + if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type, level)) { |
| + if (video->copyVideoTextureToPlatformTexture(webContext(), |
| + WebMediaPlayer::CopyVideoTextureParams( |
| + WebMediaPlayer::CopyVideoTextureParams::FullCopy, target, texture->object(), |
| + internalformat, type, level, 0, 0, m_unpackPremultiplyAlpha, m_unpackFlipY))) { |
| texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), 1, type); |
| return; |
| } |
| @@ -4479,7 +4481,7 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in |
| imageBuffer->canvas()->flush(); |
| // 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, |
| + 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; |
| @@ -4701,6 +4703,38 @@ void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint |
| || !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)) { |
|
Ken Russell (switch to Gerrit)
2015/10/25 01:08:40
It would be great if more code could be shared bet
dshwang
2015/10/26 14:17:32
I'll merge soon.
dshwang
2015/10/26 17:45:15
Done.
|
| + if (video->copyVideoTextureToPlatformTexture(webContext(), |
| + WebMediaPlayer::CopyVideoTextureParams( |
| + WebMediaPlayer::CopyVideoTextureParams::SubCopy, target, texture->object(), |
| + GL_FALSE, GL_FALSE, level, xoffset, yoffset, m_unpackPremultiplyAlpha, m_unpackFlipY))) { |
| + 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); |
| + imageBuffer->canvas()->flush(); |
| + |
| + // This is a straight GPU-GPU copy, any necessary color space conversion was handled in the paintCurrentFrameInContext() call. |
| + if (imageBuffer->copySubToPlatformTexture(webContext(), target, texture->object(), level, |
| + xoffset, yoffset, video->videoWidth(), video->videoHeight(), m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| + return; |
| + } |
| + } |
| + } |
| + } |
| + |
| RefPtr<Image> image = videoFrameToImage(video); |
| if (!image) |
| return; |