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

Unified Diff: media/gpu/avda_shared_state.cc

Issue 2889603005: Position overlays in AVDACodecImage (Closed)
Patch Set: rebased Created 3 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
« no previous file with comments | « media/gpu/avda_shared_state.h ('k') | media/gpu/avda_surface_bundle.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 1309dabe2385dc409b8c3a7c395257a1b5bba9c1..17e403f6413233d7af2adfde9a10cffdb3146ae8 100644
--- a/media/gpu/avda_shared_state.cc
+++ b/media/gpu/avda_shared_state.cc
@@ -61,7 +61,8 @@ class AVDASharedState::OnFrameAvailableHandler
DISALLOW_COPY_AND_ASSIGN(OnFrameAvailableHandler);
};
-AVDASharedState::AVDASharedState()
+AVDASharedState::AVDASharedState(
+ scoped_refptr<AVDASurfaceBundle> surface_bundle)
: frame_available_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED),
@@ -70,13 +71,27 @@ AVDASharedState::AVDASharedState()
0, 1, 0, 0, // matrix on the first call. Will be Y-flipped later.
0, 0, 1, 0, //
0, 0, 0, 1, // Comment preserves 4x4 formatting.
- } {}
+ },
+ surface_bundle_(surface_bundle),
+ weak_this_factory_(this) {
+ // If the surface bundle has a surface texture, then register to receive
+ // OnFrameAvailable notifications.
+ if (surface_texture()) {
+ on_frame_available_handler_ =
+ new OnFrameAvailableHandler(this, surface_texture());
+ }
-AVDASharedState::~AVDASharedState() {
- if (!surface_texture_)
- return;
+ // If we're holding a reference to an overlay, then register to drop it if the
+ // overlay's surface is destroyed.
+ if (overlay()) {
+ overlay()->AddSurfaceDestroyedCallback(base::Bind(
+ &AVDASharedState::OnSurfaceDestroyed, weak_this_factory_.GetWeakPtr()));
+ }
+}
- on_frame_available_handler_->ClearListener();
+AVDASharedState::~AVDASharedState() {
+ if (on_frame_available_handler_)
+ on_frame_available_handler_->ClearListener();
}
void AVDASharedState::SignalFrameAvailable() {
@@ -113,14 +128,6 @@ void AVDASharedState::WaitForFrameAvailable() {
}
}
-void AVDASharedState::SetSurfaceTexture(
- scoped_refptr<SurfaceTextureGLOwner> surface_texture) {
- DCHECK(surface_texture);
- surface_texture_ = surface_texture;
- on_frame_available_handler_ =
- new OnFrameAvailableHandler(this, surface_texture_.get());
-}
-
void AVDASharedState::RenderCodecBufferToSurfaceTexture(
MediaCodecBridge* codec,
int codec_buffer_index) {
@@ -131,13 +138,18 @@ void AVDASharedState::RenderCodecBufferToSurfaceTexture(
}
void AVDASharedState::UpdateTexImage() {
- surface_texture_->UpdateTexImage();
+ surface_texture()->UpdateTexImage();
// Helpfully, this is already column major.
- surface_texture_->GetTransformMatrix(gl_matrix_);
+ surface_texture()->GetTransformMatrix(gl_matrix_);
}
void AVDASharedState::GetTransformMatrix(float matrix[16]) const {
memcpy(matrix, gl_matrix_, sizeof(gl_matrix_));
}
+void AVDASharedState::OnSurfaceDestroyed(AndroidOverlay* overlay_raw) {
+ if (surface_bundle_ && overlay() == overlay_raw)
+ surface_bundle_ = nullptr;
+}
+
} // namespace media
« no previous file with comments | « media/gpu/avda_shared_state.h ('k') | media/gpu/avda_surface_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698