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