Commit 59c7989e authored by aleksandar.stojiljkovic's avatar aleksandar.stojiljkovic Committed by Commit bot

Avoid doing and then abandoning semi-accelerated texImageHelperHTMLVideoElement path.

This resolves performance issue when uploading video to e.g. FLOAT or
UNSIGNED_SHORT textures.  If canUseCopyTextureCHROMIUM returns false, we
shouldn't create AcceleratedImageBufferSurface, call paintCurrentFrame and
texImage2DBase since they would not be used.  This is because imageBuffer->
copyToPlatformTexture is not supported when canUseCopyTextureCHROMIUM is false
and it would early return false.

BUG=624436
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2527343002
Cr-Commit-Position: refs/heads/master@{#434926}
parent c6214813
...@@ -5139,55 +5139,52 @@ void WebGLRenderingContextBase::texImageHelperHTMLVideoElement( ...@@ -5139,55 +5139,52 @@ void WebGLRenderingContextBase::texImageHelperHTMLVideoElement(
sourceImageRect == sentinelEmptyRect() || sourceImageRect == sentinelEmptyRect() ||
sourceImageRect == sourceImageRect ==
IntRect(0, 0, video->videoWidth(), video->videoHeight()); IntRect(0, 0, video->videoWidth(), video->videoHeight());
if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1) { if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 &&
GL_TEXTURE_2D == target && Extensions3DUtil::canUseCopyTextureCHROMIUM(
target, internalformat, type, level)) {
DCHECK_EQ(xoffset, 0); DCHECK_EQ(xoffset, 0);
DCHECK_EQ(yoffset, 0); DCHECK_EQ(yoffset, 0);
DCHECK_EQ(zoffset, 0); DCHECK_EQ(zoffset, 0);
// Go through the fast path doing a GPU-GPU textures copy without a readback // 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 // to system memory if possible. Otherwise, it will fall back to the normal
// SW path. // SW path.
if (GL_TEXTURE_2D == target) { if (video->copyVideoTextureToPlatformTexture(
if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, contextGL(), texture->object(), internalformat, type,
type, level) && m_unpackPremultiplyAlpha, m_unpackFlipY)) {
video->copyVideoTextureToPlatformTexture( return;
contextGL(), texture->object(), internalformat, type, }
m_unpackPremultiplyAlpha, m_unpackFlipY)) {
return;
}
// Try using an accelerated image buffer, this allows YUV conversion to be // Try using an accelerated image buffer, this allows YUV conversion to be
// done on the GPU. // done on the GPU.
std::unique_ptr<ImageBufferSurface> surface = std::unique_ptr<ImageBufferSurface> surface =
wrapUnique(new AcceleratedImageBufferSurface( wrapUnique(new AcceleratedImageBufferSurface(
IntSize(video->videoWidth(), video->videoHeight()))); IntSize(video->videoWidth(), video->videoHeight())));
if (surface->isValid()) { if (surface->isValid()) {
std::unique_ptr<ImageBuffer> imageBuffer( std::unique_ptr<ImageBuffer> imageBuffer(
ImageBuffer::create(std::move(surface))); ImageBuffer::create(std::move(surface)));
if (imageBuffer) { if (imageBuffer) {
// The video element paints an RGBA frame into our surface here. By // The video element paints an RGBA frame into our surface here. By
// using an AcceleratedImageBufferSurface, we enable the // using an AcceleratedImageBufferSurface, we enable the
// WebMediaPlayer implementation to do any necessary color space // WebMediaPlayer implementation to do any necessary color space
// conversion on the GPU (though it // conversion on the GPU (though it
// may still do a CPU conversion and upload the results). // may still do a CPU conversion and upload the results).
video->paintCurrentFrame( video->paintCurrentFrame(
imageBuffer->canvas(), imageBuffer->canvas(),
IntRect(0, 0, video->videoWidth(), video->videoHeight()), IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr);
nullptr);
// This is a straight GPU-GPU copy, any necessary color space
// This is a straight GPU-GPU copy, any necessary color space // conversion was handled in the paintCurrentFrameInContext() call.
// conversion was handled in the paintCurrentFrameInContext() call.
// Note that copyToPlatformTexture no longer allocates the
// Note that copyToPlatformTexture no longer allocates the // destination texture.
// destination texture. texImage2DBase(target, level, internalformat, video->videoWidth(),
texImage2DBase(target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, nullptr);
video->videoHeight(), 0, format, type, nullptr);
if (imageBuffer->copyToPlatformTexture(
if (imageBuffer->copyToPlatformTexture( contextGL(), texture->object(), internalformat, type, level,
contextGL(), texture->object(), internalformat, type, level, m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0),
m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), IntRect(0, 0, video->videoWidth(), video->videoHeight()))) {
IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { return;
return;
}
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment