| 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 CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "content/common/gpu/media/avda_shared_state.h" | 11 #include "content/common/gpu/media/avda_shared_state.h" |
| 12 #include "ui/gl/gl_image.h" | 12 #include "ui/gl/gl_image.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 // GLImage that renders MediaCodec buffers to a SurfaceTexture as needed | 16 // GLImage that renders MediaCodec buffers to a SurfaceTexture or SurfaceView as |
| 17 // in order to draw them. | 17 // needed in order to draw them. |
| 18 class AVDACodecImage : public gl::GLImage { | 18 class AVDACodecImage : public gl::GLImage { |
| 19 public: | 19 public: |
| 20 AVDACodecImage(const scoped_refptr<AVDASharedState>&, | 20 AVDACodecImage(const scoped_refptr<AVDASharedState>&, |
| 21 media::VideoCodecBridge* codec, | 21 media::VideoCodecBridge* codec, |
| 22 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, | 22 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, |
| 23 const scoped_refptr<gfx::SurfaceTexture>& surface_texture); | 23 const scoped_refptr<gfx::SurfaceTexture>& surface_texture); |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 ~AVDACodecImage() override; | 26 ~AVDACodecImage() override; |
| 27 | 27 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 51 | 51 |
| 52 // Return the codec buffer that we will return to the codec, or | 52 // Return the codec buffer that we will return to the codec, or |
| 53 // <0 if there is no such buffer. | 53 // <0 if there is no such buffer. |
| 54 int GetMediaCodecBufferIndex() const; | 54 int GetMediaCodecBufferIndex() const; |
| 55 | 55 |
| 56 // Set the size of the current image. | 56 // Set the size of the current image. |
| 57 void SetSize(const gfx::Size& size); | 57 void SetSize(const gfx::Size& size); |
| 58 | 58 |
| 59 void SetMediaCodec(media::MediaCodecBridge* codec); | 59 void SetMediaCodec(media::MediaCodecBridge* codec); |
| 60 | 60 |
| 61 void setTexture(gpu::gles2::Texture* texture); | 61 void SetTexture(gpu::gles2::Texture* texture); |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 enum { kInvalidCodecBufferIndex = -1 }; |
| 65 |
| 64 // Make sure that the surface texture's front buffer is current. | 66 // Make sure that the surface texture's front buffer is current. |
| 65 void UpdateSurfaceTexture(); | 67 void UpdateSurfaceTexture(); |
| 66 | 68 |
| 67 // Attach the surface texture to our GL context, with a texture that we | 69 // Attach the surface texture to our GL context, with a texture that we |
| 68 // create for it. | 70 // create for it. |
| 69 void AttachSurfaceTextureToContext(); | 71 void AttachSurfaceTextureToContext(); |
| 70 | 72 |
| 71 // Install the current texture matrix into the shader. | 73 // Install the current texture matrix into the shader. |
| 72 void InstallTextureMatrix(); | 74 void InstallTextureMatrix(); |
| 73 | 75 |
| 74 // Shared state between the AVDA and all AVDACodecImages. | 76 // Shared state between the AVDA and all AVDACodecImages. |
| 75 scoped_refptr<AVDASharedState> shared_state_; | 77 scoped_refptr<AVDASharedState> shared_state_; |
| 76 | 78 |
| 77 // Codec's buffer index that we should render to the surface texture, | 79 // The MediaCodec buffer index that we should render. Only valid if not equal |
| 78 // or <0 if none. | 80 // to |kInvalidCodecBufferIndex|. |
| 79 int codec_buffer_index_; | 81 int codec_buffer_index_; |
| 80 | 82 |
| 81 // Our image size. | 83 // Our image size. |
| 82 gfx::Size size_; | 84 gfx::Size size_; |
| 83 | 85 |
| 84 // May be null. | 86 // May be null. |
| 85 media::MediaCodecBridge* media_codec_; | 87 media::MediaCodecBridge* media_codec_; |
| 86 | 88 |
| 87 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder_; | 89 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder_; |
| 88 | 90 |
| 91 // The SurfaceTexture to render to. This is null when rendering to a |
| 92 // SurfaceView. |
| 89 const scoped_refptr<gfx::SurfaceTexture> surface_texture_; | 93 const scoped_refptr<gfx::SurfaceTexture> surface_texture_; |
| 90 | 94 |
| 91 // Should we detach |surface_texture_| from its GL context when we are | 95 // Should we detach |surface_texture_| from its GL context when we are |
| 92 // deleted? This happens when it's using our Texture's texture handle. | 96 // deleted? This happens when it's using our Texture's texture handle. |
| 93 bool detach_surface_texture_on_destruction_; | 97 bool detach_surface_texture_on_destruction_; |
| 94 | 98 |
| 95 // The texture that we're attached to. | 99 // The texture that we're attached to. |
| 96 gpu::gles2::Texture* texture_; | 100 gpu::gles2::Texture* texture_; |
| 97 | 101 |
| 98 // Have we cached |texmatrix_uniform_location_| yet? | 102 // Have we cached |texmatrix_uniform_location_| yet? |
| 99 bool need_shader_info_; | 103 bool need_shader_info_; |
| 100 | 104 |
| 101 // Uniform ID of the texture matrix in the shader. | 105 // Uniform ID of the texture matrix in the shader. |
| 102 GLint texmatrix_uniform_location_; | 106 GLint texmatrix_uniform_location_; |
| 103 | 107 |
| 104 // Texture matrix of the front buffer of the surface texture. | 108 // Texture matrix of the front buffer of the surface texture. |
| 105 float gl_matrix_[16]; | 109 float gl_matrix_[16]; |
| 106 | 110 |
| 107 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); | 111 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); |
| 108 }; | 112 }; |
| 109 | 113 |
| 110 } // namespace content | 114 } // namespace content |
| 111 | 115 |
| 112 #endif // CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ | 116 #endif // CONTENT_COMMON_GPU_MEDIA_AVDA_CODEC_IMAGE_H_ |
| OLD | NEW |