| Index: media/gpu/android_video_decode_accelerator.cc
|
| diff --git a/media/gpu/android_video_decode_accelerator.cc b/media/gpu/android_video_decode_accelerator.cc
|
| index c580d2224e7aceb844085d85ceff023290b60639..9a017b8b64e0892a593b93387185c8f1d5afba4c 100644
|
| --- a/media/gpu/android_video_decode_accelerator.cc
|
| +++ b/media/gpu/android_video_decode_accelerator.cc
|
| @@ -1385,6 +1385,34 @@ gpu::gles2::TextureRef* AndroidVideoDecodeAccelerator::GetTextureForPicture(
|
| return texture_ref;
|
| }
|
|
|
| +scoped_refptr<gfx::SurfaceTexture>
|
| +AndroidVideoDecodeAccelerator::CreateAttachedSurfaceTexture(
|
| + GLuint* service_id) {
|
| + GLuint texture_id;
|
| + glGenTextures(1, &texture_id);
|
| +
|
| + glActiveTexture(GL_TEXTURE0);
|
| + glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id);
|
| + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
| + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
| + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| +
|
| + auto gl_decoder = GetGlDecoder();
|
| + gl_decoder->RestoreTextureUnitBindings(0);
|
| + gl_decoder->RestoreActiveTexture();
|
| + DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
|
| +
|
| + *service_id = texture_id;
|
| + // Previously, to reduce context switching, we used to create an unattached
|
| + // SurfaceTexture and attach it lazily in the compositor's context. But that
|
| + // was flaky because SurfaceTexture#detachFromGLContext() is buggy on a lot of
|
| + // devices. Now we attach it to the current context, which means we might have
|
| + // to context switch later to call updateTexImage(). Fortunately, if virtual
|
| + // contexts are in use, we won't have to context switch.
|
| + return gfx::SurfaceTexture::Create(texture_id);
|
| +}
|
| +
|
| void AndroidVideoDecodeAccelerator::OnDestroyingSurface(int surface_id) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| TRACE_EVENT0("media", "AVDA::OnDestroyingSurface");
|
|
|