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 #include "media/gpu/avda_codec_image.h" | 5 #include "media/gpu/avda_codec_image.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 11 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
12 #include "gpu/command_buffer/service/texture_manager.h" | 12 #include "gpu/command_buffer/service/texture_manager.h" |
13 #include "media/base/android/sdk_media_codec_bridge.h" | 13 #include "media/base/android/sdk_media_codec_bridge.h" |
14 #include "media/gpu/avda_shared_state.h" | 14 #include "media/gpu/avda_shared_state.h" |
15 #include "ui/gl/android/surface_texture.h" | 15 #include "ui/gl/android/surface_texture.h" |
16 #include "ui/gl/gl_context.h" | 16 #include "ui/gl/gl_context.h" |
17 #include "ui/gl/scoped_make_current.h" | 17 #include "ui/gl/scoped_make_current.h" |
18 | 18 |
19 namespace media { | 19 namespace media { |
20 | 20 |
21 AVDACodecImage::AVDACodecImage( | 21 AVDACodecImage::AVDACodecImage( |
22 int picture_buffer_id, | 22 int picture_buffer_id, |
23 const scoped_refptr<AVDASharedState>& shared_state, | 23 const scoped_refptr<AVDASharedState>& shared_state, |
24 media::VideoCodecBridge* codec, | 24 VideoCodecBridge* codec, |
25 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, | 25 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder, |
26 const scoped_refptr<gl::SurfaceTexture>& surface_texture) | 26 const scoped_refptr<gl::SurfaceTexture>& surface_texture) |
27 : shared_state_(shared_state), | 27 : shared_state_(shared_state), |
28 codec_buffer_index_(kInvalidCodecBufferIndex), | 28 codec_buffer_index_(kInvalidCodecBufferIndex), |
29 media_codec_(codec), | 29 media_codec_(codec), |
30 decoder_(decoder), | 30 decoder_(decoder), |
31 surface_texture_(surface_texture), | 31 surface_texture_(surface_texture), |
32 texture_(0), | 32 texture_(0), |
33 picture_buffer_id_(picture_buffer_id) { | 33 picture_buffer_id_(picture_buffer_id) { |
34 // Default to a sane guess of "flip Y", just in case we can't get | 34 // Default to a sane guess of "flip Y", just in case we can't get |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 glBindTexture(GL_TEXTURE_EXTERNAL_OES, bound_service_id); | 140 glBindTexture(GL_TEXTURE_EXTERNAL_OES, bound_service_id); |
141 | 141 |
142 // Helpfully, this is already column major. | 142 // Helpfully, this is already column major. |
143 surface_texture_->GetTransformMatrix(gl_matrix_); | 143 surface_texture_->GetTransformMatrix(gl_matrix_); |
144 } | 144 } |
145 | 145 |
146 void AVDACodecImage::UpdateSurface(UpdateMode update_mode) { | 146 void AVDACodecImage::UpdateSurface(UpdateMode update_mode) { |
147 UpdateSurfaceInternal(update_mode, kDoRestoreBindings); | 147 UpdateSurfaceInternal(update_mode, kDoRestoreBindings); |
148 } | 148 } |
149 | 149 |
150 void AVDACodecImage::CodecChanged(media::MediaCodecBridge* codec) { | 150 void AVDACodecImage::CodecChanged(MediaCodecBridge* codec) { |
151 media_codec_ = codec; | 151 media_codec_ = codec; |
152 codec_buffer_index_ = kInvalidCodecBufferIndex; | 152 codec_buffer_index_ = kInvalidCodecBufferIndex; |
153 } | 153 } |
154 | 154 |
155 void AVDACodecImage::UpdateSurfaceInternal( | 155 void AVDACodecImage::UpdateSurfaceInternal( |
156 UpdateMode update_mode, | 156 UpdateMode update_mode, |
157 RestoreBindingsMode attached_bindings_mode) { | 157 RestoreBindingsMode attached_bindings_mode) { |
158 if (!IsCodecBufferOutstanding()) | 158 if (!IsCodecBufferOutstanding()) |
159 return; | 159 return; |
160 | 160 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 234 } |
235 | 235 |
236 bool AVDACodecImage::IsCodecBufferOutstanding() const { | 236 bool AVDACodecImage::IsCodecBufferOutstanding() const { |
237 static_assert(kUpdateOnly < 0 && kUpdateOnly > kRendered && | 237 static_assert(kUpdateOnly < 0 && kUpdateOnly > kRendered && |
238 kRendered > kInvalidCodecBufferIndex, | 238 kRendered > kInvalidCodecBufferIndex, |
239 "Codec buffer index enum values are not ordered correctly."); | 239 "Codec buffer index enum values are not ordered correctly."); |
240 return codec_buffer_index_ > kRendered && media_codec_; | 240 return codec_buffer_index_ > kRendered && media_codec_; |
241 } | 241 } |
242 | 242 |
243 } // namespace media | 243 } // namespace media |
OLD | NEW |