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: Address the easy feedback, awaiting high level design sign off 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 <EGL/egl.h> 5 #include <EGL/egl.h>
6 #include <EGL/eglext.h> 6 #include <EGL/eglext.h>
7 7
8 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h " 8 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h "
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 scoped_refptr<gfx::SurfaceTexture> 97 scoped_refptr<gfx::SurfaceTexture>
98 AndroidDeferredRenderingBackingStrategy::GetSurfaceTexture() const { 98 AndroidDeferredRenderingBackingStrategy::GetSurfaceTexture() const {
99 return surface_texture_; 99 return surface_texture_;
100 } 100 }
101 101
102 uint32_t AndroidDeferredRenderingBackingStrategy::GetTextureTarget() const { 102 uint32_t AndroidDeferredRenderingBackingStrategy::GetTextureTarget() const {
103 return GL_TEXTURE_EXTERNAL_OES; 103 return GL_TEXTURE_EXTERNAL_OES;
104 } 104 }
105 105
106 gpu::gles2::TextureRef*
107 AndroidDeferredRenderingBackingStrategy::GetTextureForPicture(
108 const media::PictureBuffer& picture_buffer) {
109 RETURN_NULL_IF_NULL(state_provider_->GetGlDecoder());
110 gpu::gles2::TextureManager* texture_manager =
111 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager();
112 RETURN_NULL_IF_NULL(texture_manager);
113 gpu::gles2::TextureRef* texture_ref =
114 texture_manager->GetTexture(picture_buffer.internal_texture_id());
115 RETURN_NULL_IF_NULL(texture_ref);
116
117 return texture_ref;
118 }
119
120 AVDACodecImage* AndroidDeferredRenderingBackingStrategy::GetImageForPicture( 106 AVDACodecImage* AndroidDeferredRenderingBackingStrategy::GetImageForPicture(
121 const media::PictureBuffer& picture_buffer) { 107 const media::PictureBuffer& picture_buffer) {
122 gpu::gles2::TextureRef* texture_ref = GetTextureForPicture(picture_buffer); 108 gpu::gles2::TextureRef* texture_ref =
109 state_provider_->GetTextureForPicture(picture_buffer);
123 RETURN_NULL_IF_NULL(texture_ref); 110 RETURN_NULL_IF_NULL(texture_ref);
124 gl::GLImage* image = 111 gl::GLImage* image =
125 texture_ref->texture()->GetLevelImage(GetTextureTarget(), 0); 112 texture_ref->texture()->GetLevelImage(GetTextureTarget(), 0);
126 return static_cast<AVDACodecImage*>(image); 113 return static_cast<AVDACodecImage*>(image);
127 } 114 }
128 115
129 void AndroidDeferredRenderingBackingStrategy::SetImageForPicture( 116 void AndroidDeferredRenderingBackingStrategy::SetImageForPicture(
130 const media::PictureBuffer& picture_buffer, 117 const media::PictureBuffer& picture_buffer,
131 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image) { 118 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image) {
132 gpu::gles2::TextureRef* texture_ref = GetTextureForPicture(picture_buffer); 119 gpu::gles2::TextureRef* texture_ref =
120 state_provider_->GetTextureForPicture(picture_buffer);
133 RETURN_IF_NULL(texture_ref); 121 RETURN_IF_NULL(texture_ref);
134 122
135 gpu::gles2::TextureManager* texture_manager = 123 gpu::gles2::TextureManager* texture_manager =
136 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager(); 124 state_provider_->GetGlDecoder()->GetContextGroup()->texture_manager();
137 RETURN_IF_NULL(texture_manager); 125 RETURN_IF_NULL(texture_manager);
138 126
139 if (image) { 127 if (image) {
140 // Also set the parameters for the level if we're not clearing 128 // Also set the parameters for the level if we're not clearing
141 // the image. 129 // the image.
142 const gfx::Size size = state_provider_->GetSize(); 130 const gfx::Size size = state_provider_->GetSize();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 void AndroidDeferredRenderingBackingStrategy::OnFrameAvailable() { 238 void AndroidDeferredRenderingBackingStrategy::OnFrameAvailable() {
251 shared_state_->SignalFrameAvailable(); 239 shared_state_->SignalFrameAvailable();
252 } 240 }
253 241
254 bool AndroidDeferredRenderingBackingStrategy::ArePicturesOverlayable() { 242 bool AndroidDeferredRenderingBackingStrategy::ArePicturesOverlayable() {
255 // SurfaceView frames are always overlayable because that's the only way to 243 // SurfaceView frames are always overlayable because that's the only way to
256 // display them. 244 // display them.
257 return !surface_texture_; 245 return !surface_texture_;
258 } 246 }
259 247
248 void AndroidDeferredRenderingBackingStrategy::UpdatePictureBufferSize(
249 media::PictureBuffer* picture_buffer,
250 const gfx::Size& new_size) {
251 // This strategy uses EGL images, so those manage the texture size for us. We
DaleCurtis 2016/03/08 18:29:03 s/so those/which/
chcunningham 2016/03/08 22:19:12 Done.
252 // simply update the PictureBuffer meta-data and leave the texture as-is.
253 picture_buffer->set_size(new_size);
254 }
255
260 void AndroidDeferredRenderingBackingStrategy::CopySurfaceTextureToPictures( 256 void AndroidDeferredRenderingBackingStrategy::CopySurfaceTextureToPictures(
261 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) { 257 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) {
262 DVLOG(3) << __FUNCTION__; 258 DVLOG(3) << __FUNCTION__;
263 259
264 // Don't try to copy if the SurfaceTexture was never attached because that 260 // Don't try to copy if the SurfaceTexture was never attached because that
265 // means it was never updated. 261 // means it was never updated.
266 if (!shared_state_->surface_texture_is_attached()) 262 if (!shared_state_->surface_texture_is_attached())
267 return; 263 return;
268 264
269 gpu::gles2::GLES2Decoder* gl_decoder = state_provider_->GetGlDecoder().get(); 265 gpu::gles2::GLES2Decoder* gl_decoder = state_provider_->GetGlDecoder().get();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 303
308 glDeleteTextures(1, &tmp_texture_id); 304 glDeleteTextures(1, &tmp_texture_id);
309 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 305 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
310 306
311 if (egl_image == EGL_NO_IMAGE_KHR) { 307 if (egl_image == EGL_NO_IMAGE_KHR) {
312 DLOG(ERROR) << "Failed creating EGLImage: " << ui::GetLastEGLErrorString(); 308 DLOG(ERROR) << "Failed creating EGLImage: " << ui::GetLastEGLErrorString();
313 return; 309 return;
314 } 310 }
315 311
316 for (const std::pair<int, media::PictureBuffer>& entry : buffers) { 312 for (const std::pair<int, media::PictureBuffer>& entry : buffers) {
317 gpu::gles2::TextureRef* texture_ref = GetTextureForPicture(entry.second); 313 gpu::gles2::TextureRef* texture_ref =
314 state_provider_->GetTextureForPicture(entry.second);
318 gfx::ScopedTextureBinder texture_binder( 315 gfx::ScopedTextureBinder texture_binder(
319 GL_TEXTURE_EXTERNAL_OES, texture_ref->texture()->service_id()); 316 GL_TEXTURE_EXTERNAL_OES, texture_ref->texture()->service_id());
320 glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image); 317 glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image);
321 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 318 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
322 } 319 }
323 320
324 EGLBoolean result = 321 EGLBoolean result =
325 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), egl_image); 322 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), egl_image);
326 if (result == EGL_FALSE) { 323 if (result == EGL_FALSE) {
327 DLOG(ERROR) << "Error destroying EGLImage: " 324 DLOG(ERROR) << "Error destroying EGLImage: "
328 << ui::GetLastEGLErrorString(); 325 << ui::GetLastEGLErrorString();
329 } 326 }
330 } 327 }
331 328
332 } // namespace content 329 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698