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

Side by Side Diff: content/common/gpu/media/android_deferred_rendering_backing_strategy.cc

Issue 1750213002: Fix Android black frames from MSE config changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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 "content/common/gpu/media/android_deferred_rendering_backing_strategy.h " 5 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h "
6 6
7 #include <EGL/egl.h> 7 #include <EGL/egl.h>
8 #include <EGL/eglext.h> 8 #include <EGL/eglext.h>
9 9
10 #include "base/android/build_info.h" 10 #include "base/android/build_info.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 scoped_refptr<gfx::SurfaceTexture> 106 scoped_refptr<gfx::SurfaceTexture>
107 AndroidDeferredRenderingBackingStrategy::GetSurfaceTexture() const { 107 AndroidDeferredRenderingBackingStrategy::GetSurfaceTexture() const {
108 return surface_texture_; 108 return surface_texture_;
109 } 109 }
110 110
111 uint32_t AndroidDeferredRenderingBackingStrategy::GetTextureTarget() const { 111 uint32_t AndroidDeferredRenderingBackingStrategy::GetTextureTarget() const {
112 return GL_TEXTURE_EXTERNAL_OES; 112 return GL_TEXTURE_EXTERNAL_OES;
113 } 113 }
114 114
115 gpu::gles2::TextureRef*
116 AndroidDeferredRenderingBackingStrategy::GetTextureForPicture(
117 const media::PictureBuffer& picture_buffer) {
118 RETURN_NULL_IF_NULL(state_provider_->GetGlDecoder());
119 gpu::gles2::TextureManager* texture_manager =
120 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager();
121 RETURN_NULL_IF_NULL(texture_manager);
122 gpu::gles2::TextureRef* texture_ref =
123 texture_manager->GetTexture(picture_buffer.internal_texture_id());
124 RETURN_NULL_IF_NULL(texture_ref);
125
126 return texture_ref;
127 }
128
129 AVDACodecImage* AndroidDeferredRenderingBackingStrategy::GetImageForPicture( 115 AVDACodecImage* AndroidDeferredRenderingBackingStrategy::GetImageForPicture(
130 const media::PictureBuffer& picture_buffer) { 116 const media::PictureBuffer& picture_buffer) {
131 gpu::gles2::TextureRef* texture_ref = GetTextureForPicture(picture_buffer); 117 gpu::gles2::TextureRef* texture_ref =
118 state_provider_->GetTextureForPicture(picture_buffer);
132 RETURN_NULL_IF_NULL(texture_ref); 119 RETURN_NULL_IF_NULL(texture_ref);
133 gl::GLImage* image = 120 gl::GLImage* image =
134 texture_ref->texture()->GetLevelImage(GetTextureTarget(), 0); 121 texture_ref->texture()->GetLevelImage(GetTextureTarget(), 0);
135 return static_cast<AVDACodecImage*>(image); 122 return static_cast<AVDACodecImage*>(image);
136 } 123 }
137 124
138 void AndroidDeferredRenderingBackingStrategy::SetImageForPicture( 125 void AndroidDeferredRenderingBackingStrategy::SetImageForPicture(
139 const media::PictureBuffer& picture_buffer, 126 const media::PictureBuffer& picture_buffer,
140 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image) { 127 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image) {
141 gpu::gles2::TextureRef* texture_ref = GetTextureForPicture(picture_buffer); 128 gpu::gles2::TextureRef* texture_ref =
129 state_provider_->GetTextureForPicture(picture_buffer);
142 RETURN_IF_NULL(texture_ref); 130 RETURN_IF_NULL(texture_ref);
143 131
144 gpu::gles2::TextureManager* texture_manager = 132 gpu::gles2::TextureManager* texture_manager =
145 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); 133 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager();
146 RETURN_IF_NULL(texture_manager); 134 RETURN_IF_NULL(texture_manager);
147 135
148 if (image) { 136 if (image) {
149 // Also set the parameters for the level if we're not clearing 137 // Also set the parameters for the level if we're not clearing
150 // the image. 138 // the image.
151 const gfx::Size size = state_provider_->GetSize(); 139 const gfx::Size size = state_provider_->GetSize();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 void AndroidDeferredRenderingBackingStrategy::OnFrameAvailable() { 247 void AndroidDeferredRenderingBackingStrategy::OnFrameAvailable() {
260 shared_state_->SignalFrameAvailable(); 248 shared_state_->SignalFrameAvailable();
261 } 249 }
262 250
263 bool AndroidDeferredRenderingBackingStrategy::ArePicturesOverlayable() { 251 bool AndroidDeferredRenderingBackingStrategy::ArePicturesOverlayable() {
264 // SurfaceView frames are always overlayable because that's the only way to 252 // SurfaceView frames are always overlayable because that's the only way to
265 // display them. 253 // display them.
266 return !surface_texture_; 254 return !surface_texture_;
267 } 255 }
268 256
257 void AndroidDeferredRenderingBackingStrategy::UpdatePictureBufferSize(
258 media::PictureBuffer* picture_buffer,
259 const gfx::Size& new_size) {
260 // This strategy uses EGL images which manage the texture size for us. We
261 // simply update the PictureBuffer meta-data and leave the texture as-is.
262 picture_buffer->set_size(new_size);
263 }
264
269 void AndroidDeferredRenderingBackingStrategy::CopySurfaceTextureToPictures( 265 void AndroidDeferredRenderingBackingStrategy::CopySurfaceTextureToPictures(
270 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) { 266 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) {
271 DVLOG(3) << __FUNCTION__; 267 DVLOG(3) << __FUNCTION__;
272 268
273 // Don't try to copy if the SurfaceTexture was never attached because that 269 // Don't try to copy if the SurfaceTexture was never attached because that
274 // means it was never updated. 270 // means it was never updated.
275 if (!shared_state_->surface_texture_is_attached()) 271 if (!shared_state_->surface_texture_is_attached())
276 return; 272 return;
277 273
278 gpu::gles2::GLES2Decoder* gl_decoder = state_provider_->GetGlDecoder().get(); 274 gpu::gles2::GLES2Decoder* gl_decoder = state_provider_->GetGlDecoder().get();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 317
322 glDeleteTextures(1, &tmp_texture_id); 318 glDeleteTextures(1, &tmp_texture_id);
323 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 319 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
324 320
325 if (egl_image == EGL_NO_IMAGE_KHR) { 321 if (egl_image == EGL_NO_IMAGE_KHR) {
326 DLOG(ERROR) << "Failed creating EGLImage: " << ui::GetLastEGLErrorString(); 322 DLOG(ERROR) << "Failed creating EGLImage: " << ui::GetLastEGLErrorString();
327 return; 323 return;
328 } 324 }
329 325
330 for (const std::pair<int, media::PictureBuffer>& entry : buffers) { 326 for (const std::pair<int, media::PictureBuffer>& entry : buffers) {
331 gpu::gles2::TextureRef* texture_ref = GetTextureForPicture(entry.second); 327 gpu::gles2::TextureRef* texture_ref =
328 state_provider_->GetTextureForPicture(entry.second);
332 if (!texture_ref) 329 if (!texture_ref)
333 continue; 330 continue;
334 gfx::ScopedTextureBinder texture_binder( 331 gfx::ScopedTextureBinder texture_binder(
335 GL_TEXTURE_EXTERNAL_OES, texture_ref->texture()->service_id()); 332 GL_TEXTURE_EXTERNAL_OES, texture_ref->texture()->service_id());
336 glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image); 333 glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image);
337 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 334 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
338 } 335 }
339 336
340 EGLBoolean result = 337 EGLBoolean result =
341 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), egl_image); 338 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), egl_image);
(...skipping 13 matching lines...) Expand all
355 surface_texture_detach_works = 352 surface_texture_detach_works =
356 !feature_info->workarounds().surface_texture_cant_detach; 353 !feature_info->workarounds().surface_texture_cant_detach;
357 } 354 }
358 } 355 }
359 } 356 }
360 357
361 return surface_texture_detach_works; 358 return surface_texture_detach_works;
362 } 359 }
363 360
364 } // namespace content 361 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698