Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: media/gpu/avda_codec_image.cc

Issue 2461073002: Use MediaCodec.setOutputSurface() for fullscreen transitions on M. (Closed)
Patch Set: Add init_cb check. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 const scoped_refptr<AVDASharedState>& shared_state, 22 const scoped_refptr<AVDASharedState>& shared_state,
23 VideoCodecBridge* codec, 23 VideoCodecBridge* codec,
24 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder) 24 const base::WeakPtr<gpu::gles2::GLES2Decoder>& decoder)
25 : shared_state_(shared_state), 25 : shared_state_(shared_state),
26 codec_buffer_index_(kInvalidCodecBufferIndex), 26 codec_buffer_index_(kInvalidCodecBufferIndex),
27 media_codec_(codec), 27 media_codec_(codec),
28 decoder_(decoder), 28 decoder_(decoder),
29 has_surface_texture_(!!shared_state_->surface_texture_service_id()), 29 has_surface_texture_(false),
30 texture_(0) {} 30 texture_(0) {}
31 31
32 AVDACodecImage::~AVDACodecImage() {} 32 AVDACodecImage::~AVDACodecImage() {}
33 33
34 gfx::Size AVDACodecImage::GetSize() { 34 gfx::Size AVDACodecImage::GetSize() {
35 return size_; 35 return size_;
36 } 36 }
37 37
38 unsigned AVDACodecImage::GetInternalFormat() { 38 unsigned AVDACodecImage::GetInternalFormat() {
39 return GL_RGBA; 39 return GL_RGBA;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 void AVDACodecImage::UpdateSurface(UpdateMode update_mode) { 126 void AVDACodecImage::UpdateSurface(UpdateMode update_mode) {
127 UpdateSurfaceInternal(update_mode, kDoRestoreBindings); 127 UpdateSurfaceInternal(update_mode, kDoRestoreBindings);
128 } 128 }
129 129
130 void AVDACodecImage::CodecChanged(MediaCodecBridge* codec) { 130 void AVDACodecImage::CodecChanged(MediaCodecBridge* codec) {
131 media_codec_ = codec; 131 media_codec_ = codec;
132 codec_buffer_index_ = kInvalidCodecBufferIndex; 132 codec_buffer_index_ = kInvalidCodecBufferIndex;
133 } 133 }
134 134
135 void AVDACodecImage::SetBufferMetadata(int buffer_index,
136 bool has_surface_texture,
137 const gfx::Size& size) {
138 has_surface_texture_ = has_surface_texture;
139 codec_buffer_index_ = buffer_index;
140 size_ = size;
141 }
142
143 bool AVDACodecImage::SetSharedState(
144 const scoped_refptr<AVDASharedState>& shared_state) {
dcheng 2016/11/09 18:16:29 Nit: it's preferred to pass by value and std::move
DaleCurtis 2016/11/09 21:58:17 Done.
145 if (shared_state == shared_state_)
146 return false;
147 shared_state_ = shared_state;
148 return true;
149 }
150
135 void AVDACodecImage::UpdateSurfaceInternal( 151 void AVDACodecImage::UpdateSurfaceInternal(
136 UpdateMode update_mode, 152 UpdateMode update_mode,
137 RestoreBindingsMode attached_bindings_mode) { 153 RestoreBindingsMode attached_bindings_mode) {
138 if (!IsCodecBufferOutstanding()) 154 if (!IsCodecBufferOutstanding())
139 return; 155 return;
140 156
141 ReleaseOutputBuffer(update_mode); 157 ReleaseOutputBuffer(update_mode);
142 158
143 // SurfaceViews are updated implicitly, so no further steps are necessary. 159 // SurfaceViews are updated implicitly, so no further steps are necessary.
144 if (!has_surface_texture_) { 160 if (!has_surface_texture_) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 229 }
214 230
215 bool AVDACodecImage::IsCodecBufferOutstanding() const { 231 bool AVDACodecImage::IsCodecBufferOutstanding() const {
216 static_assert(kUpdateOnly < 0 && kUpdateOnly > kRendered && 232 static_assert(kUpdateOnly < 0 && kUpdateOnly > kRendered &&
217 kRendered > kInvalidCodecBufferIndex, 233 kRendered > kInvalidCodecBufferIndex,
218 "Codec buffer index enum values are not ordered correctly."); 234 "Codec buffer index enum values are not ordered correctly.");
219 return codec_buffer_index_ > kRendered && media_codec_; 235 return codec_buffer_index_ > kRendered && media_codec_;
220 } 236 }
221 237
222 } // namespace media 238 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698