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

Unified Diff: media/gpu/android_video_decode_accelerator.cc

Issue 2005103004: AVDACodecImages keep their backing SurfaceTexture alive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@neverdetach
Patch Set: Comments and add a DCHECK for glGetError after glDelete Created 4 years, 6 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 | « media/gpu/android_video_decode_accelerator.h ('k') | media/gpu/avda_codec_image.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dab6844a00c0c64ff1fe8d8897f6c1194c3231e1..bf92549e56783a32e2c70fbbcf1ad448c9e2310d 100644
--- a/media/gpu/android_video_decode_accelerator.cc
+++ b/media/gpu/android_video_decode_accelerator.cc
@@ -1379,6 +1379,34 @@ gpu::gles2::TextureRef* AndroidVideoDecodeAccelerator::GetTextureForPicture(
return texture_ref;
}
+scoped_refptr<gl::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 gl::SurfaceTexture::Create(texture_id);
+}
+
void AndroidVideoDecodeAccelerator::OnDestroyingSurface(int surface_id) {
DCHECK(thread_checker_.CalledOnValidThread());
TRACE_EVENT0("media", "AVDA::OnDestroyingSurface");
« no previous file with comments | « media/gpu/android_video_decode_accelerator.h ('k') | media/gpu/avda_codec_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698