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

Unified Diff: media/gpu/avda_shared_state.cc

Issue 2005103004: AVDACodecImages keep their backing SurfaceTexture alive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@neverdetach
Patch Set: Created 4 years, 7 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: media/gpu/avda_shared_state.cc
diff --git a/media/gpu/avda_shared_state.cc b/media/gpu/avda_shared_state.cc
index 7e73c041de0c7f6a4d3579b947dfa52a9eeae105..d96fb9dcfbb83429e8b6c1fb73e72d2add626bca 100644
--- a/media/gpu/avda_shared_state.cc
+++ b/media/gpu/avda_shared_state.cc
@@ -7,17 +7,30 @@
#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "media/gpu/avda_codec_image.h"
+#include "ui/gl/android/surface_texture.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/scoped_make_current.h"
namespace media {
AVDASharedState::AVDASharedState()
- : surface_texture_service_id_(0),
- frame_available_event_(false, false),
- surface_texture_is_attached_(false) {}
+ : surface_texture_service_id_(0), frame_available_event_(false, false) {}
-AVDASharedState::~AVDASharedState() {}
+AVDASharedState::~AVDASharedState() {
+ if (!surface_texture_service_id_)
+ return;
+
+ // XXX: Does this work in all the tear down paths? Should we be using the
+ // MakeContextCurrent callback that GVDA gives us, which observes stub
+ // destruction?
+ std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current;
+ if (!context_->IsCurrent(NULL)) {
+ scoped_make_current.reset(
+ new ui::ScopedMakeCurrent(context_.get(), surface_.get()));
+ }
+ if (!scoped_make_current || scoped_make_current->Succeeded())
+ glDeleteTextures(1, &surface_texture_service_id_);
+}
void AVDASharedState::SignalFrameAvailable() {
frame_available_event_.Signal();
@@ -53,13 +66,15 @@ void AVDASharedState::WaitForFrameAvailable() {
}
}
-void AVDASharedState::DidAttachSurfaceTexture() {
+void AVDASharedState::SetSurfaceTexture(
+ scoped_refptr<gfx::SurfaceTexture> surface_texture,
+ GLuint attached_service_id) {
+ surface_texture_ = surface_texture;
+ surface_texture_service_id_ = attached_service_id;
context_ = gfx::GLContext::GetCurrent();
surface_ = gfx::GLSurface::GetCurrent();
DCHECK(context_);
DCHECK(surface_);
-
- surface_texture_is_attached_ = true;
}
void AVDASharedState::CodecChanged(media::MediaCodecBridge* codec) {

Powered by Google App Engine
This is Rietveld 408576698