| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gpu_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 | 17 |
| 18 #include "content/common/gpu/gpu_channel.h" | 18 #include "content/common/gpu/gpu_channel.h" |
| 19 #include "content/common/gpu/gpu_channel_manager.h" | 19 #include "content/common/gpu/gpu_channel_manager.h" |
| 20 #include "content/common/gpu/media/gpu_video_accelerator_util.h" | 20 #include "content/common/gpu/media/gpu_video_accelerator_util.h" |
| 21 #include "content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h" |
| 21 #include "content/common/gpu/media/media_messages.h" | 22 #include "content/common/gpu/media/media_messages.h" |
| 22 #include "gpu/command_buffer/common/command_buffer.h" | 23 #include "gpu/command_buffer/common/command_buffer.h" |
| 23 #include "gpu/command_buffer/service/gpu_preferences.h" | |
| 24 #include "ipc/ipc_message_macros.h" | 24 #include "ipc/ipc_message_macros.h" |
| 25 #include "ipc/ipc_message_utils.h" | 25 #include "ipc/ipc_message_utils.h" |
| 26 #include "ipc/message_filter.h" | 26 #include "ipc/message_filter.h" |
| 27 #include "media/base/limits.h" | 27 #include "media/base/limits.h" |
| 28 #include "ui/gfx/geometry/size.h" |
| 28 #include "ui/gl/gl_context.h" | 29 #include "ui/gl/gl_context.h" |
| 29 #include "ui/gl/gl_image.h" | 30 #include "ui/gl/gl_image.h" |
| 30 #include "ui/gl/gl_surface_egl.h" | |
| 31 | |
| 32 #if defined(OS_WIN) | |
| 33 #include "base/win/windows_version.h" | |
| 34 #include "content/common/gpu/media/dxva_video_decode_accelerator_win.h" | |
| 35 #elif defined(OS_MACOSX) | |
| 36 #include "content/common/gpu/media/vt_video_decode_accelerator_mac.h" | |
| 37 #elif defined(OS_CHROMEOS) | |
| 38 #if defined(USE_V4L2_CODEC) | |
| 39 #include "content/common/gpu/media/v4l2_device.h" | |
| 40 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" | |
| 41 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | |
| 42 #endif | |
| 43 #if defined(ARCH_CPU_X86_FAMILY) | |
| 44 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | |
| 45 #include "ui/gl/gl_implementation.h" | |
| 46 #endif | |
| 47 #elif defined(OS_ANDROID) | |
| 48 #include "content/common/gpu/media/android_video_decode_accelerator.h" | |
| 49 #endif | |
| 50 | |
| 51 #include "ui/gfx/geometry/size.h" | |
| 52 | 31 |
| 53 namespace content { | 32 namespace content { |
| 54 | 33 |
| 34 namespace { |
| 35 static gfx::GLContext* GetGLContext( |
| 36 const base::WeakPtr<GpuCommandBufferStub>& stub) { |
| 37 if (!stub) { |
| 38 DLOG(ERROR) << "Stub is gone; no GLContext."; |
| 39 return nullptr; |
| 40 } |
| 41 |
| 42 return stub->decoder()->GetGLContext(); |
| 43 } |
| 44 |
| 55 static bool MakeDecoderContextCurrent( | 45 static bool MakeDecoderContextCurrent( |
| 56 const base::WeakPtr<GpuCommandBufferStub> stub) { | 46 const base::WeakPtr<GpuCommandBufferStub>& stub) { |
| 57 if (!stub) { | 47 if (!stub) { |
| 58 DLOG(ERROR) << "Stub is gone; won't MakeCurrent()."; | 48 DLOG(ERROR) << "Stub is gone; won't MakeCurrent()."; |
| 59 return false; | 49 return false; |
| 60 } | 50 } |
| 61 | 51 |
| 62 if (!stub->decoder()->MakeCurrent()) { | 52 if (!stub->decoder()->MakeCurrent()) { |
| 63 DLOG(ERROR) << "Failed to MakeCurrent()"; | 53 DLOG(ERROR) << "Failed to MakeCurrent()"; |
| 64 return false; | 54 return false; |
| 65 } | 55 } |
| 66 | 56 |
| 67 return true; | 57 return true; |
| 68 } | 58 } |
| 69 | 59 |
| 60 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) |
| 61 static bool BindImage(const base::WeakPtr<GpuCommandBufferStub>& stub, |
| 62 uint32_t client_texture_id, |
| 63 uint32_t texture_target, |
| 64 const scoped_refptr<gl::GLImage>& image, |
| 65 bool can_bind_to_sampler) { |
| 66 if (!stub) { |
| 67 DLOG(ERROR) << "Stub is gone; won't BindImage()."; |
| 68 return false; |
| 69 } |
| 70 |
| 71 gpu::gles2::GLES2Decoder* command_decoder = stub->decoder(); |
| 72 gpu::gles2::TextureManager* texture_manager = |
| 73 command_decoder->GetContextGroup()->texture_manager(); |
| 74 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id); |
| 75 if (ref) { |
| 76 texture_manager->SetLevelImage(ref, texture_target, 0, image.get(), |
| 77 can_bind_to_sampler |
| 78 ? gpu::gles2::Texture::BOUND |
| 79 : gpu::gles2::Texture::UNBOUND); |
| 80 } |
| 81 |
| 82 return true; |
| 83 } |
| 84 #endif |
| 85 |
| 86 static base::WeakPtr<gpu::gles2::GLES2Decoder> GetGLES2Decoder( |
| 87 const base::WeakPtr<GpuCommandBufferStub>& stub) { |
| 88 if (!stub) { |
| 89 DLOG(ERROR) << "Stub is gone; no GLES2Decoder."; |
| 90 return base::WeakPtr<gpu::gles2::GLES2Decoder>(); |
| 91 } |
| 92 |
| 93 return stub->decoder()->AsWeakPtr(); |
| 94 } |
| 95 } // anonymous namespace |
| 96 |
| 70 // DebugAutoLock works like AutoLock but only acquires the lock when | 97 // DebugAutoLock works like AutoLock but only acquires the lock when |
| 71 // DCHECK is on. | 98 // DCHECK is on. |
| 72 #if DCHECK_IS_ON() | 99 #if DCHECK_IS_ON() |
| 73 typedef base::AutoLock DebugAutoLock; | 100 typedef base::AutoLock DebugAutoLock; |
| 74 #else | 101 #else |
| 75 class DebugAutoLock { | 102 class DebugAutoLock { |
| 76 public: | 103 public: |
| 77 explicit DebugAutoLock(base::Lock&) {} | 104 explicit DebugAutoLock(base::Lock&) {} |
| 78 }; | 105 }; |
| 79 #endif | 106 #endif |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) | 158 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) |
| 132 : host_route_id_(host_route_id), | 159 : host_route_id_(host_route_id), |
| 133 stub_(stub), | 160 stub_(stub), |
| 134 texture_target_(0), | 161 texture_target_(0), |
| 135 filter_removed_(true, false), | 162 filter_removed_(true, false), |
| 136 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 163 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 137 io_task_runner_(io_task_runner), | 164 io_task_runner_(io_task_runner), |
| 138 weak_factory_for_io_(this) { | 165 weak_factory_for_io_(this) { |
| 139 DCHECK(stub_); | 166 DCHECK(stub_); |
| 140 stub_->AddDestructionObserver(this); | 167 stub_->AddDestructionObserver(this); |
| 141 make_context_current_ = | 168 get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr()); |
| 169 make_context_current_cb_ = |
| 142 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); | 170 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); |
| 171 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) |
| 172 bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr()); |
| 173 #endif |
| 174 get_gles2_decoder_cb_ = base::Bind(&GetGLES2Decoder, stub_->AsWeakPtr()); |
| 143 } | 175 } |
| 144 | 176 |
| 145 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { | 177 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { |
| 146 // This class can only be self-deleted from OnWillDestroyStub(), which means | 178 // This class can only be self-deleted from OnWillDestroyStub(), which means |
| 147 // the VDA has already been destroyed in there. | 179 // the VDA has already been destroyed in there. |
| 148 DCHECK(!video_decode_accelerator_); | 180 DCHECK(!video_decode_accelerator_); |
| 149 } | 181 } |
| 150 | 182 |
| 151 // static | 183 // static |
| 152 gpu::VideoDecodeAcceleratorCapabilities | 184 gpu::VideoDecodeAcceleratorCapabilities |
| 153 GpuVideoDecodeAccelerator::GetCapabilities( | 185 GpuVideoDecodeAccelerator::GetCapabilities( |
| 154 const gpu::GpuPreferences& gpu_preferences) { | 186 const gpu::GpuPreferences& gpu_preferences) { |
| 155 media::VideoDecodeAccelerator::Capabilities capabilities; | 187 return GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities( |
| 156 if (gpu_preferences.disable_accelerated_video_decode) | 188 gpu_preferences); |
| 157 return gpu::VideoDecodeAcceleratorCapabilities(); | |
| 158 | |
| 159 // Query supported profiles for each VDA. The order of querying VDAs should | |
| 160 // be the same as the order of initializing VDAs. Then the returned profile | |
| 161 // can be initialized by corresponding VDA successfully. | |
| 162 #if defined(OS_WIN) | |
| 163 capabilities.supported_profiles = | |
| 164 DXVAVideoDecodeAccelerator::GetSupportedProfiles(); | |
| 165 #elif defined(OS_CHROMEOS) | |
| 166 media::VideoDecodeAccelerator::SupportedProfiles vda_profiles; | |
| 167 #if defined(USE_V4L2_CODEC) | |
| 168 vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); | |
| 169 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( | |
| 170 vda_profiles, &capabilities.supported_profiles); | |
| 171 vda_profiles = V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(); | |
| 172 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( | |
| 173 vda_profiles, &capabilities.supported_profiles); | |
| 174 #endif | |
| 175 #if defined(ARCH_CPU_X86_FAMILY) | |
| 176 vda_profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles(); | |
| 177 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( | |
| 178 vda_profiles, &capabilities.supported_profiles); | |
| 179 #endif | |
| 180 #elif defined(OS_MACOSX) | |
| 181 capabilities.supported_profiles = | |
| 182 VTVideoDecodeAccelerator::GetSupportedProfiles(); | |
| 183 #elif defined(OS_ANDROID) | |
| 184 capabilities = | |
| 185 AndroidVideoDecodeAccelerator::GetCapabilities(gpu_preferences); | |
| 186 #endif | |
| 187 return GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeCapabilities( | |
| 188 capabilities); | |
| 189 } | 189 } |
| 190 | 190 |
| 191 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { | 191 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { |
| 192 if (!video_decode_accelerator_) | 192 if (!video_decode_accelerator_) |
| 193 return false; | 193 return false; |
| 194 | 194 |
| 195 bool handled = true; | 195 bool handled = true; |
| 196 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) | 196 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) |
| 197 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_SetCdm, OnSetCdm) | 197 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_SetCdm, OnSetCdm) |
| 198 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) | 198 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { | 322 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { |
| 323 if (filter_ && io_task_runner_->BelongsToCurrentThread()) | 323 if (filter_ && io_task_runner_->BelongsToCurrentThread()) |
| 324 return filter_->SendOnIOThread(message); | 324 return filter_->SendOnIOThread(message); |
| 325 DCHECK(child_task_runner_->BelongsToCurrentThread()); | 325 DCHECK(child_task_runner_->BelongsToCurrentThread()); |
| 326 return stub_->channel()->Send(message); | 326 return stub_->channel()->Send(message); |
| 327 } | 327 } |
| 328 | 328 |
| 329 bool GpuVideoDecodeAccelerator::Initialize( | 329 bool GpuVideoDecodeAccelerator::Initialize( |
| 330 const media::VideoDecodeAccelerator::Config& config) { | 330 const media::VideoDecodeAccelerator::Config& config) { |
| 331 const gpu::GpuPreferences& gpu_preferences = | |
| 332 stub_->channel()->gpu_channel_manager()->gpu_preferences(); | |
| 333 if (gpu_preferences.disable_accelerated_video_decode) | |
| 334 return false; | |
| 335 | |
| 336 DCHECK(!video_decode_accelerator_); | 331 DCHECK(!video_decode_accelerator_); |
| 337 | 332 |
| 338 if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { | 333 if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { |
| 339 DLOG(ERROR) << "Initialize(): failed to add route"; | 334 DLOG(ERROR) << "Initialize(): failed to add route"; |
| 340 return false; | 335 return false; |
| 341 } | 336 } |
| 342 | 337 |
| 343 #if !defined(OS_WIN) | 338 #if !defined(OS_WIN) |
| 344 // Ensure we will be able to get a GL context at all before initializing | 339 // Ensure we will be able to get a GL context at all before initializing |
| 345 // non-Windows VDAs. | 340 // non-Windows VDAs. |
| 346 if (!make_context_current_.Run()) { | 341 if (!make_context_current_cb_.Run()) |
| 342 return false; |
| 343 #endif |
| 344 |
| 345 scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory = |
| 346 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( |
| 347 get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, |
| 348 get_gles2_decoder_cb_); |
| 349 |
| 350 if (!vda_factory) { |
| 351 LOG(ERROR) << "Failed creating the VDA factory"; |
| 347 return false; | 352 return false; |
| 348 } | 353 } |
| 349 #endif | |
| 350 | 354 |
| 351 // Array of Create..VDA() function pointers, maybe applicable to the current | |
| 352 // platform. This list is ordered by priority of use and it should be the | |
| 353 // same as the order of querying supported profiles of VDAs. | |
| 354 const GpuVideoDecodeAccelerator::CreateVDAFp create_vda_fps[] = { | |
| 355 #if defined(OS_WIN) | |
| 356 &GpuVideoDecodeAccelerator::CreateDXVAVDA, | |
| 357 #endif | |
| 358 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | |
| 359 &GpuVideoDecodeAccelerator::CreateV4L2VDA, | |
| 360 &GpuVideoDecodeAccelerator::CreateV4L2SliceVDA, | |
| 361 #endif | |
| 362 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
| 363 &GpuVideoDecodeAccelerator::CreateVaapiVDA, | |
| 364 #endif | |
| 365 #if defined(OS_MACOSX) | |
| 366 &GpuVideoDecodeAccelerator::CreateVTVDA, | |
| 367 #endif | |
| 368 #if defined(OS_ANDROID) | |
| 369 &GpuVideoDecodeAccelerator::CreateAndroidVDA, | |
| 370 #endif | |
| 371 }; | |
| 372 | |
| 373 for (const auto& create_vda_function : create_vda_fps) { | |
| 374 video_decode_accelerator_ = (this->*create_vda_function)(); | |
| 375 if (!video_decode_accelerator_ || | |
| 376 !video_decode_accelerator_->Initialize(config, this)) | |
| 377 continue; | |
| 378 | |
| 379 if (video_decode_accelerator_->CanDecodeOnIOThread()) { | |
| 380 filter_ = new MessageFilter(this, host_route_id_); | |
| 381 stub_->channel()->AddFilter(filter_.get()); | |
| 382 } | |
| 383 return true; | |
| 384 } | |
| 385 video_decode_accelerator_.reset(); | |
| 386 LOG(ERROR) << "HW video decode not available for profile " << config.profile | |
| 387 << (config.is_encrypted ? " with encryption" : ""); | |
| 388 return false; | |
| 389 } | |
| 390 | |
| 391 #if defined(OS_WIN) | |
| 392 scoped_ptr<media::VideoDecodeAccelerator> | |
| 393 GpuVideoDecodeAccelerator::CreateDXVAVDA() { | |
| 394 scoped_ptr<media::VideoDecodeAccelerator> decoder; | |
| 395 const gpu::GpuPreferences& gpu_preferences = | 355 const gpu::GpuPreferences& gpu_preferences = |
| 396 stub_->channel()->gpu_channel_manager()->gpu_preferences(); | 356 stub_->channel()->gpu_channel_manager()->gpu_preferences(); |
| 397 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { | 357 video_decode_accelerator_ = |
| 398 DVLOG(0) << "Initializing DXVA HW decoder for windows."; | 358 vda_factory->CreateVDA(this, config, gpu_preferences); |
| 399 decoder.reset(new DXVAVideoDecodeAccelerator( | 359 if (!video_decode_accelerator_) { |
| 400 make_context_current_, stub_->decoder()->GetGLContext(), | 360 LOG(ERROR) << "HW video decode not available for profile " << config.profile |
| 401 gpu_preferences.enable_accelerated_vpx_decode)); | 361 << (config.is_encrypted ? " with encryption" : ""); |
| 402 } else { | 362 return false; |
| 403 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | |
| 404 } | 363 } |
| 405 return decoder; | 364 |
| 365 // Attempt to set up performing decoding tasks on IO thread, if supported by |
| 366 // the VDA. |
| 367 if (video_decode_accelerator_->TryToSetupDecodeOnSeparateThread( |
| 368 weak_factory_for_io_.GetWeakPtr(), io_task_runner_)) { |
| 369 filter_ = new MessageFilter(this, host_route_id_); |
| 370 stub_->channel()->AddFilter(filter_.get()); |
| 371 } |
| 372 |
| 373 return true; |
| 406 } | 374 } |
| 407 #endif | |
| 408 | |
| 409 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | |
| 410 scoped_ptr<media::VideoDecodeAccelerator> | |
| 411 GpuVideoDecodeAccelerator::CreateV4L2VDA() { | |
| 412 scoped_ptr<media::VideoDecodeAccelerator> decoder; | |
| 413 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | |
| 414 if (device.get()) { | |
| 415 decoder.reset(new V4L2VideoDecodeAccelerator( | |
| 416 gfx::GLSurfaceEGL::GetHardwareDisplay(), | |
| 417 stub_->decoder()->GetGLContext()->GetHandle(), | |
| 418 weak_factory_for_io_.GetWeakPtr(), | |
| 419 make_context_current_, | |
| 420 device, | |
| 421 io_task_runner_)); | |
| 422 } | |
| 423 return decoder; | |
| 424 } | |
| 425 | |
| 426 scoped_ptr<media::VideoDecodeAccelerator> | |
| 427 GpuVideoDecodeAccelerator::CreateV4L2SliceVDA() { | |
| 428 scoped_ptr<media::VideoDecodeAccelerator> decoder; | |
| 429 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | |
| 430 if (device.get()) { | |
| 431 decoder.reset(new V4L2SliceVideoDecodeAccelerator( | |
| 432 device, | |
| 433 gfx::GLSurfaceEGL::GetHardwareDisplay(), | |
| 434 stub_->decoder()->GetGLContext()->GetHandle(), | |
| 435 weak_factory_for_io_.GetWeakPtr(), | |
| 436 make_context_current_, | |
| 437 io_task_runner_)); | |
| 438 } | |
| 439 return decoder; | |
| 440 } | |
| 441 #endif | |
| 442 | |
| 443 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) | |
| 444 void GpuVideoDecodeAccelerator::BindImage(uint32_t client_texture_id, | |
| 445 uint32_t texture_target, | |
| 446 scoped_refptr<gl::GLImage> image, | |
| 447 bool can_bind_to_sampler) { | |
| 448 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); | |
| 449 gpu::gles2::TextureManager* texture_manager = | |
| 450 command_decoder->GetContextGroup()->texture_manager(); | |
| 451 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id); | |
| 452 if (ref) { | |
| 453 texture_manager->SetLevelImage(ref, texture_target, 0, image.get(), | |
| 454 can_bind_to_sampler | |
| 455 ? gpu::gles2::Texture::BOUND | |
| 456 : gpu::gles2::Texture::UNBOUND); | |
| 457 } | |
| 458 } | |
| 459 #endif | |
| 460 | |
| 461 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
| 462 scoped_ptr<media::VideoDecodeAccelerator> | |
| 463 GpuVideoDecodeAccelerator::CreateVaapiVDA() { | |
| 464 return make_scoped_ptr<media::VideoDecodeAccelerator>( | |
| 465 new VaapiVideoDecodeAccelerator( | |
| 466 make_context_current_, | |
| 467 base::Bind(&GpuVideoDecodeAccelerator::BindImage, | |
| 468 base::Unretained(this)))); | |
| 469 } | |
| 470 #endif | |
| 471 | |
| 472 #if defined(OS_MACOSX) | |
| 473 scoped_ptr<media::VideoDecodeAccelerator> | |
| 474 GpuVideoDecodeAccelerator::CreateVTVDA() { | |
| 475 return make_scoped_ptr<media::VideoDecodeAccelerator>( | |
| 476 new VTVideoDecodeAccelerator( | |
| 477 make_context_current_, | |
| 478 base::Bind(&GpuVideoDecodeAccelerator::BindImage, | |
| 479 base::Unretained(this)))); | |
| 480 } | |
| 481 #endif | |
| 482 | |
| 483 #if defined(OS_ANDROID) | |
| 484 scoped_ptr<media::VideoDecodeAccelerator> | |
| 485 GpuVideoDecodeAccelerator::CreateAndroidVDA() { | |
| 486 return make_scoped_ptr<media::VideoDecodeAccelerator>( | |
| 487 new AndroidVideoDecodeAccelerator(stub_->decoder()->AsWeakPtr(), | |
| 488 make_context_current_)); | |
| 489 } | |
| 490 #endif | |
| 491 | 375 |
| 492 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { | 376 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { |
| 493 DCHECK(video_decode_accelerator_); | 377 DCHECK(video_decode_accelerator_); |
| 494 video_decode_accelerator_->SetCdm(cdm_id); | 378 video_decode_accelerator_->SetCdm(cdm_id); |
| 495 } | 379 } |
| 496 | 380 |
| 497 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 381 // Runs on IO thread if VDA::TryToSetupDecodeOnSeparateThread() succeeded, |
| 498 // true, otherwise on the main thread. | 382 // otherwise on the main thread. |
| 499 void GpuVideoDecodeAccelerator::OnDecode( | 383 void GpuVideoDecodeAccelerator::OnDecode( |
| 500 const media::BitstreamBuffer& bitstream_buffer) { | 384 const media::BitstreamBuffer& bitstream_buffer) { |
| 501 DCHECK(video_decode_accelerator_); | 385 DCHECK(video_decode_accelerator_); |
| 502 video_decode_accelerator_->Decode(bitstream_buffer); | 386 video_decode_accelerator_->Decode(bitstream_buffer); |
| 503 } | 387 } |
| 504 | 388 |
| 505 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( | 389 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( |
| 506 const std::vector<int32_t>& buffer_ids, | 390 const std::vector<int32_t>& buffer_ids, |
| 507 const std::vector<uint32_t>& texture_ids) { | 391 const std::vector<uint32_t>& texture_ids) { |
| 508 if (buffer_ids.size() != texture_ids.size()) { | 392 if (buffer_ids.size() != texture_ids.size()) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; | 497 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; |
| 614 GLenum target = texture_ref->texture()->target(); | 498 GLenum target = texture_ref->texture()->target(); |
| 615 gpu::gles2::TextureManager* texture_manager = | 499 gpu::gles2::TextureManager* texture_manager = |
| 616 stub_->decoder()->GetContextGroup()->texture_manager(); | 500 stub_->decoder()->GetContextGroup()->texture_manager(); |
| 617 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); | 501 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); |
| 618 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); | 502 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); |
| 619 uncleared_textures_.erase(it); | 503 uncleared_textures_.erase(it); |
| 620 } | 504 } |
| 621 | 505 |
| 622 } // namespace content | 506 } // namespace content |
| OLD | NEW |