Index: media/gpu/avda_shared_state.h |
diff --git a/media/gpu/avda_shared_state.h b/media/gpu/avda_shared_state.h |
index 68ecf676a47b16e92b06003060d803a0d1bb53da..f7552a26787ed174bc0ce2ed5ff8caf0d6d4371b 100644 |
--- a/media/gpu/avda_shared_state.h |
+++ b/media/gpu/avda_shared_state.h |
@@ -5,10 +5,13 @@ |
#ifndef MEDIA_GPU_AVDA_SHARED_STATE_H_ |
#define MEDIA_GPU_AVDA_SHARED_STATE_H_ |
+#include "base/memory/weak_ptr.h" |
#include "base/synchronization/waitable_event.h" |
#include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
+#include "media/base/android/android_overlay.h" |
#include "media/base/android/media_codec_bridge.h" |
-#include "media/gpu/surface_texture_gl_owner.h" |
+#include "media/gpu/avda_shared_state.h" |
+#include "media/gpu/avda_surface_bundle.h" |
#include "ui/gl/gl_bindings.h" |
#include "ui/gl/gl_context.h" |
#include "ui/gl/gl_image.h" |
@@ -17,13 +20,16 @@ |
namespace media { |
// Shared state to allow communication between the AVDA and the |
-// GLImages that configure GL for drawing the frames. |
+// GLImages that configure GL for drawing the frames. This holds a reference to |
+// the surface bundle that's backing the frames. If it's an overlay, then we'll |
+// automatically drop our reference to the bundle if the overlay's surface gets |
+// an OnSurfaceDestroyed. |
class AVDASharedState : public base::RefCounted<AVDASharedState> { |
public: |
- AVDASharedState(); |
+ AVDASharedState(scoped_refptr<AVDASurfaceBundle> surface_bundle); |
GLuint surface_texture_service_id() const { |
- return surface_texture_ ? surface_texture_->texture_id() : 0; |
+ return surface_texture() ? surface_texture()->texture_id() : 0; |
} |
// Signal the "frame available" event. This may be called from any thread. |
@@ -31,16 +37,22 @@ class AVDASharedState : public base::RefCounted<AVDASharedState> { |
void WaitForFrameAvailable(); |
- void SetSurfaceTexture(scoped_refptr<SurfaceTextureGLOwner> surface_texture); |
+ SurfaceTextureGLOwner* surface_texture() const { |
+ return surface_bundle_ ? surface_bundle_->surface_texture.get() : nullptr; |
+ } |
+ |
+ AndroidOverlay* overlay() const { |
+ return surface_bundle_ ? surface_bundle_->overlay.get() : nullptr; |
+ } |
// Context and surface that |surface_texture_| is bound to, if |
// |surface_texture_| is not null. |
gl::GLContext* context() const { |
- return surface_texture_ ? surface_texture_->context() : nullptr; |
+ return surface_texture() ? surface_texture()->context() : nullptr; |
} |
gl::GLSurface* surface() const { |
- return surface_texture_ ? surface_texture_->surface() : nullptr; |
+ return surface_texture() ? surface_texture()->surface() : nullptr; |
} |
// Helper method for coordinating the interactions between |
@@ -80,7 +92,7 @@ class AVDASharedState : public base::RefCounted<AVDASharedState> { |
private: |
friend class base::RefCounted<AVDASharedState>; |
- scoped_refptr<SurfaceTextureGLOwner> surface_texture_; |
+ void OnSurfaceDestroyed(AndroidOverlay* overlay); |
// For signalling OnFrameAvailable(). |
base::WaitableEvent frame_available_event_; |
@@ -96,6 +108,10 @@ class AVDASharedState : public base::RefCounted<AVDASharedState> { |
class OnFrameAvailableHandler; |
scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_; |
+ scoped_refptr<AVDASurfaceBundle> surface_bundle_; |
+ |
+ base::WeakPtrFactory<AVDASharedState> weak_this_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(AVDASharedState); |
}; |