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

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: 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/avda_shared_state.h ('k') | media/gpu/avda_state_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/avda_shared_state.cc
diff --git a/media/gpu/avda_shared_state.cc b/media/gpu/avda_shared_state.cc
index 2b53620f39e2144b1165fe82bc54c26e6ab16720..7a023e620321dcdfc6629a5e188ce395d9aa1872 100644
--- a/media/gpu/avda_shared_state.cc
+++ b/media/gpu/avda_shared_state.cc
@@ -7,17 +7,25 @@
#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;
+
+ ui::ScopedMakeCurrent scoped_make_current(context_.get(), surface_.get());
+ if (scoped_make_current.Succeeded()) {
+ glDeleteTextures(1, &surface_texture_service_id_);
+ DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+ }
+}
void AVDASharedState::SignalFrameAvailable() {
frame_available_event_.Signal();
@@ -53,13 +61,15 @@ void AVDASharedState::WaitForFrameAvailable() {
}
}
-void AVDASharedState::DidAttachSurfaceTexture() {
+void AVDASharedState::SetSurfaceTexture(
+ scoped_refptr<gl::SurfaceTexture> surface_texture,
+ GLuint attached_service_id) {
+ surface_texture_ = surface_texture;
+ surface_texture_service_id_ = attached_service_id;
context_ = gl::GLContext::GetCurrent();
surface_ = gl::GLSurface::GetCurrent();
DCHECK(context_);
DCHECK(surface_);
-
- surface_texture_is_attached_ = true;
}
void AVDASharedState::CodecChanged(media::MediaCodecBridge* codec) {
« no previous file with comments | « media/gpu/avda_shared_state.h ('k') | media/gpu/avda_state_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698