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

Unified Diff: content/common/gpu/media/avda_shared_state.h

Issue 1682343002: AVDACodecImages keep a reference to the SurfaceTexture backing them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 4 years, 10 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/avda_shared_state.h
diff --git a/content/common/gpu/media/avda_shared_state.h b/content/common/gpu/media/avda_shared_state.h
index eb62681fcd5bd13474c0146f31eabaf1f8524b77..7b2ca49f0c031f981486e70c986ba2aede6157d6 100644
--- a/content/common/gpu/media/avda_shared_state.h
+++ b/content/common/gpu/media/avda_shared_state.h
@@ -5,22 +5,18 @@
#ifndef CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_
#define CONTENT_COMMON_GPU_AVDA_SHARED_STATE_H_
+#include "base/macros.h"
#include "base/synchronization/waitable_event.h"
-#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
-#include "media/base/android/media_codec_bridge.h"
-#include "media/base/android/sdk_media_codec_bridge.h"
+#include "ui/gl/android/surface_texture.h"
+#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
-#include "ui/gl/gl_image.h"
#include "ui/gl/gl_surface.h"
-namespace gfx {
-class SurfaceTexture;
-}
-
namespace content {
-// Shared state to allow communication between the AVDA and the
-// GLImages that configure GL for drawing the frames.
+// Shared state to allow communication between
+// AndroidDeferredRenderingBackingStrategy and the AVDACodecImages it creates.
+// It's refcounted so that it lives as long as the images that refer to it.
class AVDASharedState : public base::RefCounted<AVDASharedState> {
public:
AVDASharedState();
@@ -30,15 +26,21 @@ class AVDASharedState : public base::RefCounted<AVDASharedState> {
}
// Set the SurfaceTexture's client texture name, which the SurfaceTexture
- // might not know about yet (see surface_texture_is_attached()).
- void set_surface_texture_service_id(GLint id) {
- surface_texture_service_id_ = id;
- }
+ // might not know about yet (see surface_texture_is_attached()). Ownership of
+ // the texture is passed to this object. When it's destructed it will call
+ // the passed callback to delete it.
+ void SetSurfaceTextureServiceID(
+ GLuint id,
+ const base::Callback<void(GLuint)>& delete_texture_cb);
- // Signal the "frame available" event. This may be called from any thread.
- void SignalFrameAvailable();
+ scoped_refptr<gfx::SurfaceTexture> surface_texture() const {
+ return surface_texture_;
+ }
- void WaitForFrameAvailable();
+ void set_surface_texture(
+ const scoped_refptr<gfx::SurfaceTexture>& surface_texture) {
+ surface_texture_ = surface_texture;
+ }
// Context that the surface texture is bound to, or nullptr if it is not in
// the attached state.
@@ -50,16 +52,26 @@ class AVDASharedState : public base::RefCounted<AVDASharedState> {
return surface_texture_is_attached_;
}
+ // Signal the "frame available" event. This may be called from any thread.
+ void SignalFrameAvailable();
+
+ void WaitForFrameAvailable();
+
// Call this when the SurfaceTexture is attached to a GL context. This will
// update surface_texture_is_attached(), and set the context() and surface()
// to match.
- void did_attach_surface_texture();
+ void DidAttachSurfaceTexture();
private:
- // Platform gl texture Id for |surface_texture_|. This will be zero if
- // and only if |texture_owner_| is null.
- // TODO(liberato): This should be GLuint, but we don't seem to have the type.
- GLint surface_texture_service_id_;
+ friend class base::RefCounted<AVDASharedState>;
+ virtual ~AVDASharedState();
+
+ // Platform gl texture ID for |surface_texture_|.
+ GLuint surface_texture_service_id_;
+ // Valid when |surface_texture_service_id_| is valid. Used to delete it.
+ base::Callback<void(GLuint)> delete_texture_cb_;
+
+ scoped_refptr<gfx::SurfaceTexture> surface_texture_;
// For signalling OnFrameAvailable().
base::WaitableEvent frame_available_event_;
@@ -72,11 +84,7 @@ class AVDASharedState : public base::RefCounted<AVDASharedState> {
scoped_refptr<gfx::GLContext> context_;
scoped_refptr<gfx::GLSurface> surface_;
- protected:
- virtual ~AVDASharedState();
-
- private:
- friend class base::RefCounted<AVDASharedState>;
+ DISALLOW_COPY_AND_ASSIGN(AVDASharedState);
};
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698