| 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_picture_buffer_manager.h" | 5 #include "media/gpu/avda_picture_buffer_manager.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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 gpu::gles2::TextureRef* AVDAPictureBufferManager::GetTextureForPicture( | 203 gpu::gles2::TextureRef* AVDAPictureBufferManager::GetTextureForPicture( |
| 204 const PictureBuffer& picture_buffer) { | 204 const PictureBuffer& picture_buffer) { |
| 205 auto gles_decoder = state_provider_->GetGlDecoder(); | 205 auto gles_decoder = state_provider_->GetGlDecoder(); |
| 206 RETURN_NULL_IF_NULL(gles_decoder); | 206 RETURN_NULL_IF_NULL(gles_decoder); |
| 207 RETURN_NULL_IF_NULL(gles_decoder->GetContextGroup()); | 207 RETURN_NULL_IF_NULL(gles_decoder->GetContextGroup()); |
| 208 | 208 |
| 209 gpu::gles2::TextureManager* texture_manager = | 209 gpu::gles2::TextureManager* texture_manager = |
| 210 gles_decoder->GetContextGroup()->texture_manager(); | 210 gles_decoder->GetContextGroup()->texture_manager(); |
| 211 RETURN_NULL_IF_NULL(texture_manager); | 211 RETURN_NULL_IF_NULL(texture_manager); |
| 212 | 212 |
| 213 DCHECK_LE(1u, picture_buffer.internal_texture_ids().size()); | 213 DCHECK_LE(1u, picture_buffer.client_texture_ids().size()); |
| 214 gpu::gles2::TextureRef* texture_ref = | 214 gpu::gles2::TextureRef* texture_ref = |
| 215 texture_manager->GetTexture(picture_buffer.internal_texture_ids()[0]); | 215 texture_manager->GetTexture(picture_buffer.client_texture_ids()[0]); |
| 216 RETURN_NULL_IF_NULL(texture_ref); | 216 RETURN_NULL_IF_NULL(texture_ref); |
| 217 | 217 |
| 218 return texture_ref; | 218 return texture_ref; |
| 219 } | 219 } |
| 220 | 220 |
| 221 void AVDAPictureBufferManager::SetImageForPicture( | 221 void AVDAPictureBufferManager::SetImageForPicture( |
| 222 const PictureBuffer& picture_buffer, | 222 const PictureBuffer& picture_buffer, |
| 223 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image) { | 223 const scoped_refptr<gpu::gles2::GLStreamTextureImage>& image) { |
| 224 gpu::gles2::TextureRef* texture_ref = GetTextureForPicture(picture_buffer); | 224 gpu::gles2::TextureRef* texture_ref = GetTextureForPicture(picture_buffer); |
| 225 RETURN_IF_NULL(texture_ref); | 225 RETURN_IF_NULL(texture_ref); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 if (!surface_texture_ && have_context) { | 298 if (!surface_texture_ && have_context) { |
| 299 // To make devtools work, we're using a 2D texture. Make it transparent, | 299 // To make devtools work, we're using a 2D texture. Make it transparent, |
| 300 // so that it draws a hole for the SV to show through. This is only | 300 // so that it draws a hole for the SV to show through. This is only |
| 301 // because devtools draws and reads back, which skips overlay processing. | 301 // because devtools draws and reads back, which skips overlay processing. |
| 302 // It's unclear why devtools renders twice -- once normally, and once | 302 // It's unclear why devtools renders twice -- once normally, and once |
| 303 // including a readback layer. The result is that the device screen | 303 // including a readback layer. The result is that the device screen |
| 304 // flashes as we alternately draw the overlay hole and this texture, | 304 // flashes as we alternately draw the overlay hole and this texture, |
| 305 // unless we make the texture transparent. | 305 // unless we make the texture transparent. |
| 306 static const uint8_t rgba[] = {0, 0, 0, 0}; | 306 static const uint8_t rgba[] = {0, 0, 0, 0}; |
| 307 const gfx::Size size(1, 1); | 307 const gfx::Size size(1, 1); |
| 308 DCHECK_LE(1u, picture_buffer.texture_ids().size()); | 308 DCHECK_LE(1u, picture_buffer.service_texture_ids().size()); |
| 309 glBindTexture(GL_TEXTURE_2D, picture_buffer.texture_ids()[0]); | 309 glBindTexture(GL_TEXTURE_2D, picture_buffer.service_texture_ids()[0]); |
| 310 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), 0, | 310 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), 0, |
| 311 GL_RGBA, GL_UNSIGNED_BYTE, rgba); | 311 GL_RGBA, GL_UNSIGNED_BYTE, rgba); |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 void AVDAPictureBufferManager::ReleaseCodecBufferForPicture( | 315 void AVDAPictureBufferManager::ReleaseCodecBufferForPicture( |
| 316 const PictureBuffer& picture_buffer) { | 316 const PictureBuffer& picture_buffer) { |
| 317 AVDACodecImage* avda_image = | 317 AVDACodecImage* avda_image = |
| 318 shared_state_->GetImageForPicture(picture_buffer.id()); | 318 shared_state_->GetImageForPicture(picture_buffer.id()); |
| 319 RETURN_IF_NULL(avda_image); | 319 RETURN_IF_NULL(avda_image); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 shared_state_->CodecChanged(codec); | 401 shared_state_->CodecChanged(codec); |
| 402 } | 402 } |
| 403 | 403 |
| 404 bool AVDAPictureBufferManager::ArePicturesOverlayable() { | 404 bool AVDAPictureBufferManager::ArePicturesOverlayable() { |
| 405 // SurfaceView frames are always overlayable because that's the only way to | 405 // SurfaceView frames are always overlayable because that's the only way to |
| 406 // display them. | 406 // display them. |
| 407 return !surface_texture_; | 407 return !surface_texture_; |
| 408 } | 408 } |
| 409 | 409 |
| 410 } // namespace media | 410 } // namespace media |
| OLD | NEW |