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

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

Issue 1963773003: Merge to M51: Various fixes to prevent playback hang on MotoX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
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: content/common/gpu/media/avda_codec_image.h
diff --git a/content/common/gpu/media/avda_codec_image.h b/content/common/gpu/media/avda_codec_image.h
index 46547e478c81e01563e048b7b0d0b29a17b7ad5e..b6f40b71d56a96161115ac657423382bddb0bb38 100644
--- a/content/common/gpu/media/avda_codec_image.h
+++ b/content/common/gpu/media/avda_codec_image.h
@@ -21,15 +21,12 @@ namespace content {
// needed in order to draw them.
class AVDACodecImage : public gpu::gles2::GLStreamTextureImage {
public:
- AVDACodecImage(const scoped_refptr<AVDASharedState>&,
+ AVDACodecImage(int picture_buffer_id,
+ const scoped_refptr<AVDASharedState>& shared_state,
media::VideoCodecBridge* codec,
const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder,
const scoped_refptr<gfx::SurfaceTexture>& surface_texture);
- protected:
- ~AVDACodecImage() override;
-
- public:
// gl::GLImage implementation
void Destroy(bool have_context) override;
gfx::Size GetSize() override;
@@ -51,24 +48,52 @@ class AVDACodecImage : public gpu::gles2::GLStreamTextureImage {
// gpu::gles2::GLStreamTextureMatrix implementation
void GetTextureMatrix(float xform[16]) override;
- public:
- // Decoded buffer index that has the image for us to display.
- void SetMediaCodecBufferIndex(int buffer_index);
+ enum class UpdateMode {
+ // Discards the codec buffer, no UpdateTexImage().
+ DISCARD_CODEC_BUFFER,
+
+ // Renders to back buffer, no UpdateTexImage(); can only be used with a
+ // valid |surface_texture_|.
+ RENDER_TO_BACK_BUFFER,
+
+ // Renders to the back buffer. When used with a SurfaceView, promotion to
+ // the front buffer is automatic. When using a |surface_texture_|,
+ // UpdateTexImage() is called to promote the back buffer into the front.
+ RENDER_TO_FRONT_BUFFER
+ };
+
+ // Releases the attached codec buffer (if not already released) indicated by
+ // |codec_buffer_index_| and updates the surface if specified by the given
+ // |update_mode|. See UpdateMode documentation for details.
+ void UpdateSurface(UpdateMode update_mode);
+
+ // Updates the MediaCodec for this image; clears |codec_buffer_index_|.
+ void CodecChanged(media::MediaCodecBridge* codec);
- // Return the codec buffer that we will return to the codec, or
- // <0 if there is no such buffer.
- int GetMediaCodecBufferIndex() const;
+ void set_texture(gpu::gles2::Texture* texture) { texture_ = texture; }
+
+ // Decoded buffer index that has the image for us to display.
+ void set_media_codec_buffer_index(int buffer_index) {
+ codec_buffer_index_ = buffer_index;
+ }
// Set the size of the current image.
- void SetSize(const gfx::Size& size);
+ void set_size(const gfx::Size& size) { size_ = size; }
- void SetMediaCodec(media::MediaCodecBridge* codec);
+ // Indicates if the codec buffer has been released to the back buffer.
+ bool was_rendered_to_back_buffer() const {
+ return codec_buffer_index_ == kUpdateOnly;
+ }
- void SetTexture(gpu::gles2::Texture* texture);
+ // Indicates if the codec buffer has been released to the front buffer.
+ bool was_rendered_to_front_buffer() const {
+ return codec_buffer_index_ == kRendered;
+ }
- private:
- enum { kInvalidCodecBufferIndex = -1 };
+ protected:
+ ~AVDACodecImage() override;
+ private:
// Make sure that the surface texture's front buffer is current. This will
// save / restore the current context. It will optionally restore the texture
// bindings in the surface texture's context, based on |mode|. This is
@@ -79,6 +104,18 @@ class AVDACodecImage : public gpu::gles2::GLStreamTextureImage {
enum RestoreBindingsMode { kDontRestoreBindings, kDoRestoreBindings };
void UpdateSurfaceTexture(RestoreBindingsMode mode);
+ // Internal helper for UpdateSurface() that allows callers to specify the
+ // RestoreBindingsMode when a SurfaceTexture is already attached prior to
+ // calling this method.
+ void UpdateSurfaceInternal(UpdateMode update_mode,
+ RestoreBindingsMode attached_bindings_mode);
+
+ // Releases the attached codec buffer (if not already released) indicated by
+ // |codec_buffer_index_|. Never updates the actual surface. See UpdateMode
+ // documentation for details. For the purposes of this function the values
+ // RENDER_TO_FRONT_BUFFER and RENDER_TO_BACK_BUFFER do the same thing.
+ void ReleaseOutputBuffer(UpdateMode update_mode);
+
// Attach the surface texture to our GL context to whatever texture is bound
// on the active unit.
void AttachSurfaceTextureToContext();
@@ -86,11 +123,6 @@ class AVDACodecImage : public gpu::gles2::GLStreamTextureImage {
// Make shared_state_->context() current if it isn't already.
scoped_ptr<ui::ScopedMakeCurrent> MakeCurrentIfNeeded();
- // Return whether or not the current context is in the same share group as
- // |surface_texture_|'s client texture.
- // TODO(liberato): is this needed?
- bool IsCorrectShareGroup() const;
-
// Return whether there is a codec buffer that we haven't rendered yet. Will
// return false also if there's no codec or we otherwise can't update.
bool IsCodecBufferOutstanding() const;
@@ -98,8 +130,9 @@ class AVDACodecImage : public gpu::gles2::GLStreamTextureImage {
// Shared state between the AVDA and all AVDACodecImages.
scoped_refptr<AVDASharedState> shared_state_;
- // The MediaCodec buffer index that we should render. Only valid if not equal
- // to |kInvalidCodecBufferIndex|.
+ // The MediaCodec buffer index that we should render. Must be >= 0 or one of
+ // the enum values below.
+ enum { kUpdateOnly = -1, kRendered = -2, kInvalidCodecBufferIndex = -3 };
int codec_buffer_index_;
// Our image size.
@@ -124,6 +157,9 @@ class AVDACodecImage : public gpu::gles2::GLStreamTextureImage {
// Texture matrix of the front buffer of the surface texture.
float gl_matrix_[16];
+ // The picture buffer id attached to this image.
+ int picture_buffer_id_;
+
DISALLOW_COPY_AND_ASSIGN(AVDACodecImage);
};
« no previous file with comments | « content/common/gpu/media/android_video_decode_accelerator.cc ('k') | content/common/gpu/media/avda_codec_image.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698