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> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 13 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
14 #include "media/gpu/avda_shared_state.h" | 14 #include "media/gpu/avda_shared_state.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 class ScopedMakeCurrent; | 17 class ScopedMakeCurrent; |
18 } | 18 } |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 | 21 |
22 class VideoCodecBridge; | 22 class VideoCodecBridge; |
23 | 23 |
24 // GLImage that renders MediaCodec buffers to a SurfaceTexture or SurfaceView as | 24 // GLImage that renders MediaCodec buffers to a SurfaceTexture or SurfaceView as |
25 // needed in order to draw them. | 25 // needed in order to draw them. |
26 class AVDACodecImage : public gpu::gles2::GLStreamTextureImage { | 26 class AVDACodecImage : public gpu::gles2::GLStreamTextureImage { |
27 public: | 27 public: |
28 AVDACodecImage(int picture_buffer_id, | 28 AVDACodecImage(int picture_buffer_id, |
29 const scoped_refptr<AVDASharedState>& shared_state, | 29 const scoped_refptr<AVDASharedState>& shared_state, |
30 media::VideoCodecBridge* codec, | 30 VideoCodecBridge* codec, |
31 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, | 31 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, |
32 const scoped_refptr<gl::SurfaceTexture>& surface_texture); | 32 const scoped_refptr<gl::SurfaceTexture>& surface_texture); |
33 | 33 |
34 // gl::GLImage implementation | 34 // gl::GLImage implementation |
35 void Destroy(bool have_context) override; | 35 void Destroy(bool have_context) override; |
36 gfx::Size GetSize() override; | 36 gfx::Size GetSize() override; |
37 unsigned GetInternalFormat() override; | 37 unsigned GetInternalFormat() override; |
38 bool BindTexImage(unsigned target) override; | 38 bool BindTexImage(unsigned target) override; |
39 void ReleaseTexImage(unsigned target) override; | 39 void ReleaseTexImage(unsigned target) override; |
40 bool CopyTexImage(unsigned target) override; | 40 bool CopyTexImage(unsigned target) override; |
(...skipping 24 matching lines...) Expand all Loading... |
65 // UpdateTexImage() is called to promote the back buffer into the front. | 65 // UpdateTexImage() is called to promote the back buffer into the front. |
66 RENDER_TO_FRONT_BUFFER | 66 RENDER_TO_FRONT_BUFFER |
67 }; | 67 }; |
68 | 68 |
69 // Releases the attached codec buffer (if not already released) indicated by | 69 // Releases the attached codec buffer (if not already released) indicated by |
70 // |codec_buffer_index_| and updates the surface if specified by the given | 70 // |codec_buffer_index_| and updates the surface if specified by the given |
71 // |update_mode|. See UpdateMode documentation for details. | 71 // |update_mode|. See UpdateMode documentation for details. |
72 void UpdateSurface(UpdateMode update_mode); | 72 void UpdateSurface(UpdateMode update_mode); |
73 | 73 |
74 // Updates the MediaCodec for this image; clears |codec_buffer_index_|. | 74 // Updates the MediaCodec for this image; clears |codec_buffer_index_|. |
75 void CodecChanged(media::MediaCodecBridge* codec); | 75 void CodecChanged(MediaCodecBridge* codec); |
76 | 76 |
77 void set_texture(gpu::gles2::Texture* texture) { texture_ = texture; } | 77 void set_texture(gpu::gles2::Texture* texture) { texture_ = texture; } |
78 | 78 |
79 // Decoded buffer index that has the image for us to display. | 79 // Decoded buffer index that has the image for us to display. |
80 void set_media_codec_buffer_index(int buffer_index) { | 80 void set_media_codec_buffer_index(int buffer_index) { |
81 codec_buffer_index_ = buffer_index; | 81 codec_buffer_index_ = buffer_index; |
82 } | 82 } |
83 | 83 |
84 // Set the size of the current image. | 84 // Set the size of the current image. |
85 void set_size(const gfx::Size& size) { size_ = size; } | 85 void set_size(const gfx::Size& size) { size_ = size; } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 // The MediaCodec buffer index that we should render. Must be >= 0 or one of | 133 // The MediaCodec buffer index that we should render. Must be >= 0 or one of |
134 // the enum values below. | 134 // the enum values below. |
135 enum { kUpdateOnly = -1, kRendered = -2, kInvalidCodecBufferIndex = -3 }; | 135 enum { kUpdateOnly = -1, kRendered = -2, kInvalidCodecBufferIndex = -3 }; |
136 int codec_buffer_index_; | 136 int codec_buffer_index_; |
137 | 137 |
138 // Our image size. | 138 // Our image size. |
139 gfx::Size size_; | 139 gfx::Size size_; |
140 | 140 |
141 // May be null. | 141 // May be null. |
142 media::MediaCodecBridge* media_codec_; | 142 MediaCodecBridge* media_codec_; |
143 | 143 |
144 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder_; | 144 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder_; |
145 | 145 |
146 // The SurfaceTexture to render to. This is null when rendering to a | 146 // The SurfaceTexture to render to. This is null when rendering to a |
147 // SurfaceView. | 147 // SurfaceView. |
148 const scoped_refptr<gl::SurfaceTexture> surface_texture_; | 148 const scoped_refptr<gl::SurfaceTexture> surface_texture_; |
149 | 149 |
150 // The texture that we're attached to. | 150 // The texture that we're attached to. |
151 gpu::gles2::Texture* texture_; | 151 gpu::gles2::Texture* texture_; |
152 | 152 |
153 // Texture matrix of the front buffer of the surface texture. | 153 // Texture matrix of the front buffer of the surface texture. |
154 float gl_matrix_[16]; | 154 float gl_matrix_[16]; |
155 | 155 |
156 // The picture buffer id attached to this image. | 156 // The picture buffer id attached to this image. |
157 int picture_buffer_id_; | 157 int picture_buffer_id_; |
158 | 158 |
159 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); | 159 DISALLOW_COPY_AND_ASSIGN(AVDACodecImage); |
160 }; | 160 }; |
161 | 161 |
162 } // namespace media | 162 } // namespace media |
163 | 163 |
164 #endif // MEDIA_GPU_AVDA_CODEC_IMAGE_H_ | 164 #endif // MEDIA_GPU_AVDA_CODEC_IMAGE_H_ |
OLD | NEW |