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 50fe2ebca4ece288bff98a1135b8baa2d94a0966..1d56e1e783c8d05ba478783c9da01495e100ad42 100644 |
--- a/media/gpu/android_video_decode_accelerator.cc |
+++ b/media/gpu/android_video_decode_accelerator.cc |
@@ -1348,6 +1348,33 @@ 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; |
+ // To reduce context switching we used to create an unattached |
liberato (no reviews please)
2016/05/26 16:59:19
comment is out of date.
|
+ // SurfaceTexture and attach it lazily in the context used to draw with it, |
+ // but detaching SurfaceTextures doesn't work reliably on a lot of devices. |
+ // Now we attach it here and and possibly context switch later. Fortunately, |
+ // if virtual contexts are in use, we don't have to context switch at all. |
+ return gfx::SurfaceTexture::Create(texture_id); |
+} |
+ |
void AndroidVideoDecodeAccelerator::OnDestroyingSurface(int surface_id) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
TRACE_EVENT0("media", "AVDA::OnDestroyingSurface"); |