| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_GPU_AVDA_CODEC_IMAGE_H_ | 5 #ifndef MEDIA_GPU_AVDA_CODEC_IMAGE_H_ |
| 6 #define MEDIA_GPU_AVDA_CODEC_IMAGE_H_ | 6 #define MEDIA_GPU_AVDA_CODEC_IMAGE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 int z_order, | 43 int z_order, |
| 44 gfx::OverlayTransform transform, | 44 gfx::OverlayTransform transform, |
| 45 const gfx::Rect& bounds_rect, | 45 const gfx::Rect& bounds_rect, |
| 46 const gfx::RectF& crop_rect) override; | 46 const gfx::RectF& crop_rect) override; |
| 47 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 47 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
| 48 uint64_t process_tracing_id, | 48 uint64_t process_tracing_id, |
| 49 const std::string& dump_name) override; | 49 const std::string& dump_name) override; |
| 50 // gpu::gles2::GLStreamTextureMatrix implementation | 50 // gpu::gles2::GLStreamTextureMatrix implementation |
| 51 void GetTextureMatrix(float xform[16]) override; | 51 void GetTextureMatrix(float xform[16]) override; |
| 52 | 52 |
| 53 // Decoded buffer index that has the image for us to display. | |
| 54 void SetMediaCodecBufferIndex(int buffer_index); | |
| 55 | |
| 56 // Set the size of the current image. | |
| 57 void SetSize(const gfx::Size& size); | |
| 58 | |
| 59 enum class UpdateMode { | 53 enum class UpdateMode { |
| 60 // Discards the codec buffer, no UpdateTexImage(). | 54 // Discards the codec buffer, no UpdateTexImage(). |
| 61 DISCARD_CODEC_BUFFER, | 55 DISCARD_CODEC_BUFFER, |
| 62 | 56 |
| 63 // Renders to back buffer, no UpdateTexImage(); can only be used with a | 57 // Renders to back buffer, no UpdateTexImage(); can only be used with a |
| 64 // valid |surface_texture_|. | 58 // valid |surface_texture_|. |
| 65 RENDER_TO_BACK_BUFFER, | 59 RENDER_TO_BACK_BUFFER, |
| 66 | 60 |
| 67 // Renders to the back buffer. When used with a SurfaceView, promotion to | 61 // Renders to the back buffer. When used with a SurfaceView, promotion to |
| 68 // the front buffer is automatic. When using a |surface_texture_|, | 62 // the front buffer is automatic. When using a |surface_texture_|, |
| 69 // UpdateTexImage() is called to promote the back buffer into the front. | 63 // UpdateTexImage() is called to promote the back buffer into the front. |
| 70 RENDER_TO_FRONT_BUFFER | 64 RENDER_TO_FRONT_BUFFER |
| 71 }; | 65 }; |
| 72 | 66 |
| 73 // Releases the attached codec buffer (if not already released) indicated by | 67 // Releases the attached codec buffer (if not already released) indicated by |
| 74 // |codec_buffer_index_| and updates the surface if specified by the given | 68 // |codec_buffer_index_| and updates the surface if specified by the given |
| 75 // |update_mode|. See UpdateMode documentation for details. | 69 // |update_mode|. See UpdateMode documentation for details. |
| 76 void UpdateSurface(UpdateMode update_mode); | 70 void UpdateSurface(UpdateMode update_mode); |
| 77 | 71 |
| 78 // Updates the MediaCodec for this image; clears |codec_buffer_index_|. | 72 // Updates the MediaCodec for this image; clears |codec_buffer_index_|. |
| 79 void CodecChanged(media::MediaCodecBridge* codec); | 73 void CodecChanged(media::MediaCodecBridge* codec); |
| 80 | 74 |
| 81 void SetTexture(gpu::gles2::Texture* texture); | 75 void set_texture(gpu::gles2::Texture* texture) { texture_ = texture; } |
| 76 |
| 77 // Decoded buffer index that has the image for us to display. |
| 78 void set_media_codec_buffer_index(int buffer_index) { |
| 79 codec_buffer_index_ = buffer_index; |
| 80 } |
| 81 |
| 82 // Set the size of the current image. |
| 83 void set_size(const gfx::Size& size) { size_ = size; } |
| 82 | 84 |
| 83 // Indicates if the codec buffer has been released to the back buffer. | 85 // Indicates if the codec buffer has been released to the back buffer. |
| 84 bool is_rendered_to_back_buffer() const { | 86 bool was_rendered_to_back_buffer() const { |
| 85 return codec_buffer_index_ == kUpdateOnly; | 87 return codec_buffer_index_ == kUpdateOnly; |
| 86 } | 88 } |
| 87 | 89 |
| 88 // Indicates if the codec buffer has been released to the front or back | 90 // Indicates if the codec buffer has been released to the front buffer. |
| 89 // buffer. | 91 bool was_rendered_to_front_buffer() const { |
| 90 bool is_rendered() const { | 92 return codec_buffer_index_ == kRendered; |
| 91 return codec_buffer_index_ <= kInvalidCodecBufferIndex; | |
| 92 } | 93 } |
| 93 | 94 |
| 94 protected: | 95 protected: |
| 95 ~AVDACodecImage() override; | 96 ~AVDACodecImage() override; |
| 96 | 97 |
| 97 private: | 98 private: |
| 98 enum { kInvalidCodecBufferIndex = -1, kUpdateOnly = -2 }; | |
| 99 | |
| 100 // Make sure that the surface texture's front buffer is current. This will | 99 // Make sure that the surface texture's front buffer is current. This will |
| 101 // save / restore the current context. It will optionally restore the texture | 100 // save / restore the current context. It will optionally restore the texture |
| 102 // bindings in the surface texture's context, based on |mode|. This is | 101 // bindings in the surface texture's context, based on |mode|. This is |
| 103 // intended as a hint if we don't need to change contexts. If we do need to | 102 // intended as a hint if we don't need to change contexts. If we do need to |
| 104 // change contexts, then we'll always preserve the texture bindings in the | 103 // change contexts, then we'll always preserve the texture bindings in the |
| 105 // both contexts. In other words, the caller is telling us whether it's | 104 // both contexts. In other words, the caller is telling us whether it's |
| 106 // okay to change the binding in the current context. | 105 // okay to change the binding in the current context. |
| 107 enum RestoreBindingsMode { kDontRestoreBindings, kDoRestoreBindings }; | 106 enum RestoreBindingsMode { kDontRestoreBindings, kDoRestoreBindings }; |
| 108 void UpdateSurfaceTexture(RestoreBindingsMode mode); | 107 void UpdateSurfaceTexture(RestoreBindingsMode mode); |
| 109 | 108 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 126 // Make shared_state_->context() current if it isn't already. | 125 // Make shared_state_->context() current if it isn't already. |
| 127 std::unique_ptr<ui::ScopedMakeCurrent> MakeCurrentIfNeeded(); | 126 std::unique_ptr<ui::ScopedMakeCurrent> MakeCurrentIfNeeded(); |
| 128 | 127 |
| 129 // Return whether there is a codec buffer that we haven't rendered yet. Will | 128 // Return whether there is a codec buffer that we haven't rendered yet. Will |
| 130 // return false also if there's no codec or we otherwise can't update. | 129 // return false also if there's no codec or we otherwise can't update. |
| 131 bool IsCodecBufferOutstanding() const; | 130 bool IsCodecBufferOutstanding() const; |
| 132 | 131 |
| 133 // Shared state between the AVDA and all AVDACodecImages. | 132 // Shared state between the AVDA and all AVDACodecImages. |
| 134 scoped_refptr<AVDASharedState> shared_state_; | 133 scoped_refptr<AVDASharedState> shared_state_; |
| 135 | 134 |
| 136 // The MediaCodec buffer index that we should render. Only valid if not equal | 135 // The MediaCodec buffer index that we should render. Must be >= 0 or one of |
| 137 // to |kInvalidCodecBufferIndex|. | 136 // the enum values below. |
| 137 enum { kUpdateOnly = -1, kRendered = -2, kInvalidCodecBufferIndex = -3 }; |
| 138 int codec_buffer_index_; | 138 int codec_buffer_index_; |
| 139 | 139 |
| 140 // Our image size. | 140 // Our image size. |
| 141 gfx::Size size_; | 141 gfx::Size size_; |
| 142 | 142 |
| 143 // May be null. | 143 // May be null. |
| 144 media::MediaCodecBridge* media_codec_; | 144 media::MediaCodecBridge* media_codec_; |
| 145 | 145 |
| 146 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder_; | 146 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder_; |
| 147 | 147 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 161 | 161 |
| 162 // The picture buffer id attached to this image. | 162 // The picture buffer id attached to this image. |
| 163 int picture_buffer_id_; | 163 int picture_buffer_id_; |
| 164 | 164 |
| 165 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); | 165 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 } // namespace media | 168 } // namespace media |
| 169 | 169 |
| 170 #endif // MEDIA_GPU_AVDA_CODEC_IMAGE_H_ | 170 #endif // MEDIA_GPU_AVDA_CODEC_IMAGE_H_ |
| OLD | NEW |