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

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

Issue 1939943002: Increase cases where back/front buffering early rendering occur. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fast_release
Patch Set: Created 4 years, 7 months 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
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return true; 118 return true;
119 } 119 }
120 120
121 void AVDACodecImage::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, 121 void AVDACodecImage::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
122 uint64_t process_tracing_id, 122 uint64_t process_tracing_id,
123 const std::string& dump_name) {} 123 const std::string& dump_name) {}
124 124
125 void AVDACodecImage::UpdateSurfaceTexture(RestoreBindingsMode mode) { 125 void AVDACodecImage::UpdateSurfaceTexture(RestoreBindingsMode mode) {
126 DCHECK(surface_texture_); 126 DCHECK(surface_texture_);
127 DCHECK_EQ(codec_buffer_index_, kUpdateOnly); 127 DCHECK_EQ(codec_buffer_index_, kUpdateOnly);
128 codec_buffer_index_ = kInvalidCodecBufferIndex; 128 codec_buffer_index_ = kRendered;
129 129
130 // Swap the rendered image to the front. 130 // Swap the rendered image to the front.
131 std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current = 131 std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current =
132 MakeCurrentIfNeeded(); 132 MakeCurrentIfNeeded();
133 133
134 // If we changed contexts, then we always want to restore it, since the caller 134 // If we changed contexts, then we always want to restore it, since the caller
135 // doesn't know that we're switching contexts. 135 // doesn't know that we're switching contexts.
136 if (scoped_make_current) 136 if (scoped_make_current)
137 mode = kDoRestoreBindings; 137 mode = kDoRestoreBindings;
138 138
139 // Save the current binding if requested. 139 // Save the current binding if requested.
140 GLint bound_service_id = 0; 140 GLint bound_service_id = 0;
141 if (mode == kDoRestoreBindings) 141 if (mode == kDoRestoreBindings)
142 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &bound_service_id); 142 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &bound_service_id);
143 143
144 surface_texture_->UpdateTexImage(); 144 surface_texture_->UpdateTexImage();
145 if (mode == kDoRestoreBindings) 145 if (mode == kDoRestoreBindings)
146 glBindTexture(GL_TEXTURE_EXTERNAL_OES, bound_service_id); 146 glBindTexture(GL_TEXTURE_EXTERNAL_OES, bound_service_id);
147 147
148 // Helpfully, this is already column major. 148 // Helpfully, this is already column major.
149 surface_texture_->GetTransformMatrix(gl_matrix_); 149 surface_texture_->GetTransformMatrix(gl_matrix_);
150 } 150 }
151 151
152 void AVDACodecImage::SetMediaCodecBufferIndex(int buffer_index) {
153 codec_buffer_index_ = buffer_index;
154 }
155
156 void AVDACodecImage::SetSize(const gfx::Size& size) {
157 size_ = size;
158 }
159
160 void AVDACodecImage::UpdateSurface(UpdateMode update_mode) { 152 void AVDACodecImage::UpdateSurface(UpdateMode update_mode) {
161 UpdateSurfaceInternal(update_mode, kDoRestoreBindings); 153 UpdateSurfaceInternal(update_mode, kDoRestoreBindings);
162 } 154 }
163 155
164 void AVDACodecImage::CodecChanged(media::MediaCodecBridge* codec) { 156 void AVDACodecImage::CodecChanged(media::MediaCodecBridge* codec) {
165 media_codec_ = codec; 157 media_codec_ = codec;
166 codec_buffer_index_ = kInvalidCodecBufferIndex; 158 codec_buffer_index_ = kInvalidCodecBufferIndex;
167 } 159 }
168 160
169 void AVDACodecImage::SetTexture(gpu::gles2::Texture* texture) {
170 texture_ = texture;
171 }
172
173 void AVDACodecImage::UpdateSurfaceInternal( 161 void AVDACodecImage::UpdateSurfaceInternal(
174 UpdateMode update_mode, 162 UpdateMode update_mode,
175 RestoreBindingsMode attached_bindings_mode) { 163 RestoreBindingsMode attached_bindings_mode) {
176 if (!IsCodecBufferOutstanding()) 164 if (!IsCodecBufferOutstanding())
177 return; 165 return;
178 166
179 ReleaseOutputBuffer(update_mode); 167 ReleaseOutputBuffer(update_mode);
180 168
181 // SurfaceViews are updated implicitly, so no further steps are necessary. 169 // SurfaceViews are updated implicitly, so no further steps are necessary.
182 if (!surface_texture_) { 170 if (!surface_texture_) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return; 209 return;
222 } 210 }
223 211
224 DCHECK(update_mode == UpdateMode::RENDER_TO_BACK_BUFFER || 212 DCHECK(update_mode == UpdateMode::RENDER_TO_BACK_BUFFER ||
225 update_mode == UpdateMode::RENDER_TO_FRONT_BUFFER); 213 update_mode == UpdateMode::RENDER_TO_FRONT_BUFFER);
226 214
227 if (!surface_texture_) { 215 if (!surface_texture_) {
228 DCHECK(update_mode == UpdateMode::RENDER_TO_FRONT_BUFFER); 216 DCHECK(update_mode == UpdateMode::RENDER_TO_FRONT_BUFFER);
229 DCHECK_GE(codec_buffer_index_, 0); 217 DCHECK_GE(codec_buffer_index_, 0);
230 media_codec_->ReleaseOutputBuffer(codec_buffer_index_, true); 218 media_codec_->ReleaseOutputBuffer(codec_buffer_index_, true);
231 codec_buffer_index_ = kInvalidCodecBufferIndex; 219 codec_buffer_index_ = kRendered;
232 return; 220 return;
233 } 221 }
234 222
235 // If we've already released to the back buffer, there's nothing left to do, 223 // If we've already released to the back buffer, there's nothing left to do,
236 // but wait for the previously released buffer if necessary. 224 // but wait for the previously released buffer if necessary.
237 if (codec_buffer_index_ != kUpdateOnly) { 225 if (codec_buffer_index_ != kUpdateOnly) {
238 DCHECK(surface_texture_); 226 DCHECK(surface_texture_);
239 DCHECK_GE(codec_buffer_index_, 0); 227 DCHECK_GE(codec_buffer_index_, 0);
240 shared_state_->RenderCodecBufferToSurfaceTexture(media_codec_, 228 shared_state_->RenderCodecBufferToSurfaceTexture(media_codec_,
241 codec_buffer_index_); 229 codec_buffer_index_);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 266 }
279 267
280 void AVDACodecImage::GetTextureMatrix(float matrix[16]) { 268 void AVDACodecImage::GetTextureMatrix(float matrix[16]) {
281 // Our current matrix may be stale. Update it if possible. 269 // Our current matrix may be stale. Update it if possible.
282 if (surface_texture_) 270 if (surface_texture_)
283 UpdateSurface(UpdateMode::RENDER_TO_FRONT_BUFFER); 271 UpdateSurface(UpdateMode::RENDER_TO_FRONT_BUFFER);
284 memcpy(matrix, gl_matrix_, sizeof(gl_matrix_)); 272 memcpy(matrix, gl_matrix_, sizeof(gl_matrix_));
285 } 273 }
286 274
287 bool AVDACodecImage::IsCodecBufferOutstanding() const { 275 bool AVDACodecImage::IsCodecBufferOutstanding() const {
288 return codec_buffer_index_ != kInvalidCodecBufferIndex && media_codec_; 276 static_assert(kUpdateOnly < 0 && kUpdateOnly > kRendered &&
277 kRendered > kInvalidCodecBufferIndex,
278 "Codec buffer index enum values are not ordered correctly.");
279 return codec_buffer_index_ > kRendered && media_codec_;
289 } 280 }
290 281
291 } // namespace media 282 } // namespace media
OLDNEW
« media/gpu/android_deferred_rendering_backing_strategy.cc ('K') | « media/gpu/avda_codec_image.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698