| 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" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "gpu/command_buffer/service/context_group.h" | 15 #include "gpu/command_buffer/service/context_group.h" |
| 16 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 16 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
| 17 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 17 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 18 #include "gpu/command_buffer/service/texture_manager.h" | 18 #include "gpu/command_buffer/service/texture_manager.h" |
| 19 #include "gpu/ipc/common/gpu_surface_lookup.h" | |
| 20 #include "gpu/ipc/service/gpu_channel.h" | 19 #include "gpu/ipc/service/gpu_channel.h" |
| 21 #include "media/base/android/media_codec_bridge_impl.h" | 20 #include "media/base/android/media_codec_bridge_impl.h" |
| 22 #include "media/gpu/avda_codec_image.h" | 21 #include "media/gpu/avda_codec_image.h" |
| 23 #include "media/gpu/avda_shared_state.h" | 22 #include "media/gpu/avda_shared_state.h" |
| 23 #include "ui/gl/android/scoped_java_surface.h" |
| 24 #include "ui/gl/android/surface_texture.h" | 24 #include "ui/gl/android/surface_texture.h" |
| 25 #include "ui/gl/egl_util.h" | 25 #include "ui/gl/egl_util.h" |
| 26 #include "ui/gl/gl_bindings.h" | 26 #include "ui/gl/gl_bindings.h" |
| 27 #include "ui/gl/gl_surface_egl.h" | 27 #include "ui/gl/gl_surface_egl.h" |
| 28 #include "ui/gl/scoped_binders.h" | 28 #include "ui/gl/scoped_binders.h" |
| 29 #include "ui/gl/scoped_make_current.h" | 29 #include "ui/gl/scoped_make_current.h" |
| 30 | 30 |
| 31 // If !|ptr|, log a message, notify |state_provider_| of the error, and | 31 // If !|ptr|, log a message, notify |state_provider_| of the error, and |
| 32 // return an optional value. | 32 // return an optional value. |
| 33 #define RETURN_IF_NULL(ptr, ...) \ | 33 #define RETURN_IF_NULL(ptr, ...) \ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 AVDAPictureBufferManager::AVDAPictureBufferManager( | 68 AVDAPictureBufferManager::AVDAPictureBufferManager( |
| 69 AVDAStateProvider* state_provider) | 69 AVDAStateProvider* state_provider) |
| 70 : state_provider_(state_provider), media_codec_(nullptr) {} | 70 : state_provider_(state_provider), media_codec_(nullptr) {} |
| 71 | 71 |
| 72 AVDAPictureBufferManager::~AVDAPictureBufferManager() {} | 72 AVDAPictureBufferManager::~AVDAPictureBufferManager() {} |
| 73 | 73 |
| 74 gl::ScopedJavaSurface AVDAPictureBufferManager::Initialize(int surface_id) { | 74 void AVDAPictureBufferManager::InitializeForOverlay() { |
| 75 shared_state_ = new AVDASharedState(); |
| 76 surface_texture_ = nullptr; |
| 77 } |
| 78 |
| 79 gl::ScopedJavaSurface AVDAPictureBufferManager::InitializeForSurfaceTexture() { |
| 75 shared_state_ = new AVDASharedState(); | 80 shared_state_ = new AVDASharedState(); |
| 76 surface_texture_ = nullptr; | 81 surface_texture_ = nullptr; |
| 77 | 82 |
| 78 // Acquire the SurfaceView surface if given a valid id. | 83 // Create a SurfaceTexture. |
| 79 if (surface_id != SurfaceManager::kNoSurfaceID) | |
| 80 return gpu::GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_id); | |
| 81 | |
| 82 // Otherwise create a SurfaceTexture. | |
| 83 surface_texture_ = | 84 surface_texture_ = |
| 84 CreateAttachedSurfaceTexture(state_provider_->GetGlDecoder()); | 85 CreateAttachedSurfaceTexture(state_provider_->GetGlDecoder()); |
| 85 shared_state_->SetSurfaceTexture(surface_texture_); | 86 shared_state_->SetSurfaceTexture(surface_texture_); |
| 86 return gl::ScopedJavaSurface(surface_texture_.get()); | 87 return gl::ScopedJavaSurface(surface_texture_.get()); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void AVDAPictureBufferManager::Destroy(const PictureBufferMap& buffers) { | 90 void AVDAPictureBufferManager::Destroy(const PictureBufferMap& buffers) { |
| 90 // Do nothing if Initialize() has not been called. | 91 // Do nothing if Initialize() has not been called. |
| 91 if (!shared_state_) | 92 if (!shared_state_) |
| 92 return; | 93 return; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 276 |
| 276 bool AVDAPictureBufferManager::HasUnrenderedPictures() const { | 277 bool AVDAPictureBufferManager::HasUnrenderedPictures() const { |
| 277 for (int id : pictures_out_for_display_) { | 278 for (int id : pictures_out_for_display_) { |
| 278 if (GetImageForPicture(id)->is_unrendered()) | 279 if (GetImageForPicture(id)->is_unrendered()) |
| 279 return true; | 280 return true; |
| 280 } | 281 } |
| 281 return false; | 282 return false; |
| 282 } | 283 } |
| 283 | 284 |
| 284 } // namespace media | 285 } // namespace media |
| OLD | NEW |