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

Unified Diff: content/common/gpu/media/android_copying_backing_strategy.cc

Issue 1639963002: AndroidVideoDecodeAccelerator can now render to a SurfaceView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
Index: content/common/gpu/media/android_copying_backing_strategy.cc
diff --git a/content/common/gpu/media/android_copying_backing_strategy.cc b/content/common/gpu/media/android_copying_backing_strategy.cc
index f80a16f3d72da05a59b3be947857dc0baf86b6de..050695484bb1fe0c735faa448b2983d2a7f9b70c 100644
--- a/content/common/gpu/media/android_copying_backing_strategy.cc
+++ b/content/common/gpu/media/android_copying_backing_strategy.cc
@@ -27,27 +27,13 @@ AndroidCopyingBackingStrategy::AndroidCopyingBackingStrategy()
AndroidCopyingBackingStrategy::~AndroidCopyingBackingStrategy() {}
void AndroidCopyingBackingStrategy::Initialize(
- AVDAStateProvider* state_provider) {
+ AVDAStateProvider* state_provider,
+ scoped_refptr<gfx::SurfaceTexture> surface_texture) {
+ DCHECK(surface_texture);
state_provider_ = state_provider;
-}
+ surface_texture_ = surface_texture;
-void AndroidCopyingBackingStrategy::Cleanup(
- bool have_context,
- const AndroidVideoDecodeAccelerator::OutputBufferMap&) {
- DCHECK(state_provider_->ThreadChecker().CalledOnValidThread());
- if (copier_)
- copier_->Destroy();
-
- if (surface_texture_id_ && have_context)
- glDeleteTextures(1, &surface_texture_id_);
-}
-
-uint32_t AndroidCopyingBackingStrategy::GetTextureTarget() const {
- return GL_TEXTURE_2D;
-}
-
-scoped_refptr<gfx::SurfaceTexture>
-AndroidCopyingBackingStrategy::CreateSurfaceTexture() {
+ // Create a texture and attach the SurfaceTexture to it.
glGenTextures(1, &surface_texture_id_);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, surface_texture_id_);
@@ -56,12 +42,26 @@ AndroidCopyingBackingStrategy::CreateSurfaceTexture() {
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
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);
+
+ surface_texture_->AttachToGLContext();
+
state_provider_->GetGlDecoder()->RestoreTextureUnitBindings(0);
state_provider_->GetGlDecoder()->RestoreActiveTexture();
+}
- surface_texture_ = gfx::SurfaceTexture::Create(surface_texture_id_);
+void AndroidCopyingBackingStrategy::Cleanup(
+ bool have_context,
+ const AndroidVideoDecodeAccelerator::OutputBufferMap&) {
+ DCHECK(state_provider_->ThreadChecker().CalledOnValidThread());
+ if (copier_)
+ copier_->Destroy();
- return surface_texture_;
+ if (surface_texture_id_ && have_context)
+ glDeleteTextures(1, &surface_texture_id_);
+}
+
+uint32_t AndroidCopyingBackingStrategy::GetTextureTarget() const {
+ return GL_TEXTURE_2D;
}
void AndroidCopyingBackingStrategy::UseCodecBufferForPictureBuffer(

Powered by Google App Engine
This is Rietveld 408576698