| 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 if (!stub) { |
| 66 DLOG(ERROR) << "Stub is gone; won't BindImage()."; |
| 67 return false; |
| 68 } |
| 69 |
| 70 gpu::gles2::GLES2Decoder* command_decoder = stub->decoder(); |
| 71 gpu::gles2::TextureManager* texture_manager = |
| 72 command_decoder->GetContextGroup()->texture_manager(); |
| 73 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id); |
| 74 if (ref) { |
| 75 texture_manager->SetLevelImage(ref, texture_target, 0, image.get(), |
| 76 gpu::gles2::Texture::BOUND); |
| 77 } |
| 78 |
| 79 return true; |
| 80 } |
| 81 #endif |
| 82 |
| 83 static base::WeakPtr<gpu::gles2::GLES2Decoder> GetGLES2Decoder( |
| 84 const base::WeakPtr<GpuCommandBufferStub>& stub) { |
| 85 if (!stub) { |
| 86 DLOG(ERROR) << "Stub is gone; no GLES2Decoder."; |
| 87 return base::WeakPtr<gpu::gles2::GLES2Decoder>(); |
| 88 } |
| 89 |
| 90 return stub->decoder()->AsWeakPtr(); |
| 91 } |
| 92 } // anonymous namespace |
| 93 |
| 70 // DebugAutoLock works like AutoLock but only acquires the lock when | 94 // DebugAutoLock works like AutoLock but only acquires the lock when |
| 71 // DCHECK is on. | 95 // DCHECK is on. |
| 72 #if DCHECK_IS_ON() | 96 #if DCHECK_IS_ON() |
| 73 typedef base::AutoLock DebugAutoLock; | 97 typedef base::AutoLock DebugAutoLock; |
| 74 #else | 98 #else |
| 75 class DebugAutoLock { | 99 class DebugAutoLock { |
| 76 public: | 100 public: |
| 77 explicit DebugAutoLock(base::Lock&) {} | 101 explicit DebugAutoLock(base::Lock&) {} |
| 78 }; | 102 }; |
| 79 #endif | 103 #endif |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) | 155 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) |
| 132 : host_route_id_(host_route_id), | 156 : host_route_id_(host_route_id), |
| 133 stub_(stub), | 157 stub_(stub), |
| 134 texture_target_(0), | 158 texture_target_(0), |
| 135 filter_removed_(true, false), | 159 filter_removed_(true, false), |
| 136 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 160 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 137 io_task_runner_(io_task_runner), | 161 io_task_runner_(io_task_runner), |
| 138 weak_factory_for_io_(this) { | 162 weak_factory_for_io_(this) { |
| 139 DCHECK(stub_); | 163 DCHECK(stub_); |
| 140 stub_->AddDestructionObserver(this); | 164 stub_->AddDestructionObserver(this); |
| 141 make_context_current_ = | 165 get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr()); |
| 166 make_context_current_cb_ = |
| 142 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); | 167 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); |
| 168 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) |
| 169 bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr()); |
| 170 #endif |
| 171 get_gles2_decoder_cb_ = base::Bind(&GetGLES2Decoder, stub_->AsWeakPtr()); |
| 143 } | 172 } |
| 144 | 173 |
| 145 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { | 174 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { |
| 146 // This class can only be self-deleted from OnWillDestroyStub(), which means | 175 // This class can only be self-deleted from OnWillDestroyStub(), which means |
| 147 // the VDA has already been destroyed in there. | 176 // the VDA has already been destroyed in there. |
| 148 DCHECK(!video_decode_accelerator_); | 177 DCHECK(!video_decode_accelerator_); |
| 149 } | 178 } |
| 150 | 179 |
| 151 // static | 180 // static |
| 152 gpu::VideoDecodeAcceleratorCapabilities | 181 gpu::VideoDecodeAcceleratorCapabilities |
| 153 GpuVideoDecodeAccelerator::GetCapabilities( | 182 GpuVideoDecodeAccelerator::GetCapabilities( |
| 154 const gpu::GpuPreferences& gpu_preferences) { | 183 const gpu::GpuPreferences& gpu_preferences) { |
| 155 media::VideoDecodeAccelerator::Capabilities capabilities; | 184 return GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities( |
| 156 if (gpu_preferences.disable_accelerated_video_decode) | 185 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 } | 186 } |
| 190 | 187 |
| 191 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { | 188 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { |
| 192 if (!video_decode_accelerator_) | 189 if (!video_decode_accelerator_) |
| 193 return false; | 190 return false; |
| 194 | 191 |
| 195 bool handled = true; | 192 bool handled = true; |
| 196 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) | 193 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) |
| 197 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_SetCdm, OnSetCdm) | 194 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_SetCdm, OnSetCdm) |
| 198 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) | 195 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 318 |
| 322 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { | 319 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { |
| 323 if (filter_ && io_task_runner_->BelongsToCurrentThread()) | 320 if (filter_ && io_task_runner_->BelongsToCurrentThread()) |
| 324 return filter_->SendOnIOThread(message); | 321 return filter_->SendOnIOThread(message); |
| 325 DCHECK(child_task_runner_->BelongsToCurrentThread()); | 322 DCHECK(child_task_runner_->BelongsToCurrentThread()); |
| 326 return stub_->channel()->Send(message); | 323 return stub_->channel()->Send(message); |
| 327 } | 324 } |
| 328 | 325 |
| 329 bool GpuVideoDecodeAccelerator::Initialize( | 326 bool GpuVideoDecodeAccelerator::Initialize( |
| 330 const media::VideoDecodeAccelerator::Config& config) { | 327 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_); | 328 DCHECK(!video_decode_accelerator_); |
| 337 | 329 |
| 338 if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { | 330 if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { |
| 339 DLOG(ERROR) << "Initialize(): failed to add route"; | 331 DLOG(ERROR) << "Initialize(): failed to add route"; |
| 340 return false; | 332 return false; |
| 341 } | 333 } |
| 342 | 334 |
| 343 #if !defined(OS_WIN) | 335 #if !defined(OS_WIN) |
| 344 // Ensure we will be able to get a GL context at all before initializing | 336 // Ensure we will be able to get a GL context at all before initializing |
| 345 // non-Windows VDAs. | 337 // non-Windows VDAs. |
| 346 if (!make_context_current_.Run()) { | 338 if (!make_context_current_cb_.Run()) |
| 339 return false; |
| 340 #endif |
| 341 |
| 342 scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory = |
| 343 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( |
| 344 get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, |
| 345 get_gles2_decoder_cb_); |
| 346 |
| 347 if (!vda_factory) { |
| 348 LOG(ERROR) << "Failed creating the VDA factory"; |
| 347 return false; | 349 return false; |
| 348 } | 350 } |
| 349 #endif | |
| 350 | 351 |
| 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 = | 352 const gpu::GpuPreferences& gpu_preferences = |
| 396 stub_->channel()->gpu_channel_manager()->gpu_preferences(); | 353 stub_->channel()->gpu_channel_manager()->gpu_preferences(); |
| 397 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { | 354 video_decode_accelerator_ = |
| 398 DVLOG(0) << "Initializing DXVA HW decoder for windows."; | 355 vda_factory->CreateVDA(this, config, gpu_preferences); |
| 399 decoder.reset(new DXVAVideoDecodeAccelerator( | 356 if (!video_decode_accelerator_) { |
| 400 make_context_current_, stub_->decoder()->GetGLContext(), | 357 LOG(ERROR) << "HW video decode not available for profile " << config.profile |
| 401 gpu_preferences.enable_accelerated_vpx_decode)); | 358 << (config.is_encrypted ? " with encryption" : ""); |
| 402 } else { | 359 return false; |
| 403 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | |
| 404 } | 360 } |
| 405 return decoder; | 361 |
| 362 // Attempt to set up performing decoding tasks on IO thread, if supported by |
| 363 // the VDA. |
| 364 if (video_decode_accelerator_->TryToSetupDecodeOnSeparateThread( |
| 365 weak_factory_for_io_.GetWeakPtr(), io_task_runner_)) { |
| 366 filter_ = new MessageFilter(this, host_route_id_); |
| 367 stub_->channel()->AddFilter(filter_.get()); |
| 368 } |
| 369 |
| 370 return true; |
| 406 } | 371 } |
| 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 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); | |
| 448 gpu::gles2::TextureManager* texture_manager = | |
| 449 command_decoder->GetContextGroup()->texture_manager(); | |
| 450 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id); | |
| 451 if (ref) { | |
| 452 texture_manager->SetLevelImage(ref, texture_target, 0, image.get(), | |
| 453 gpu::gles2::Texture::BOUND); | |
| 454 } | |
| 455 } | |
| 456 #endif | |
| 457 | |
| 458 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
| 459 scoped_ptr<media::VideoDecodeAccelerator> | |
| 460 GpuVideoDecodeAccelerator::CreateVaapiVDA() { | |
| 461 return make_scoped_ptr<media::VideoDecodeAccelerator>( | |
| 462 new VaapiVideoDecodeAccelerator( | |
| 463 make_context_current_, | |
| 464 base::Bind(&GpuVideoDecodeAccelerator::BindImage, | |
| 465 base::Unretained(this)))); | |
| 466 } | |
| 467 #endif | |
| 468 | |
| 469 #if defined(OS_MACOSX) | |
| 470 scoped_ptr<media::VideoDecodeAccelerator> | |
| 471 GpuVideoDecodeAccelerator::CreateVTVDA() { | |
| 472 return make_scoped_ptr<media::VideoDecodeAccelerator>( | |
| 473 new VTVideoDecodeAccelerator( | |
| 474 make_context_current_, | |
| 475 base::Bind(&GpuVideoDecodeAccelerator::BindImage, | |
| 476 base::Unretained(this)))); | |
| 477 } | |
| 478 #endif | |
| 479 | |
| 480 #if defined(OS_ANDROID) | |
| 481 scoped_ptr<media::VideoDecodeAccelerator> | |
| 482 GpuVideoDecodeAccelerator::CreateAndroidVDA() { | |
| 483 return make_scoped_ptr<media::VideoDecodeAccelerator>( | |
| 484 new AndroidVideoDecodeAccelerator(stub_->decoder()->AsWeakPtr(), | |
| 485 make_context_current_)); | |
| 486 } | |
| 487 #endif | |
| 488 | 372 |
| 489 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { | 373 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { |
| 490 DCHECK(video_decode_accelerator_); | 374 DCHECK(video_decode_accelerator_); |
| 491 video_decode_accelerator_->SetCdm(cdm_id); | 375 video_decode_accelerator_->SetCdm(cdm_id); |
| 492 } | 376 } |
| 493 | 377 |
| 494 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 378 // Runs on IO thread if VDA::TryToSetupDecodeOnSeparateThread() succeeded, |
| 495 // true, otherwise on the main thread. | 379 // otherwise on the main thread. |
| 496 void GpuVideoDecodeAccelerator::OnDecode( | 380 void GpuVideoDecodeAccelerator::OnDecode( |
| 497 const media::BitstreamBuffer& bitstream_buffer) { | 381 const media::BitstreamBuffer& bitstream_buffer) { |
| 498 DCHECK(video_decode_accelerator_); | 382 DCHECK(video_decode_accelerator_); |
| 499 video_decode_accelerator_->Decode(bitstream_buffer); | 383 video_decode_accelerator_->Decode(bitstream_buffer); |
| 500 } | 384 } |
| 501 | 385 |
| 502 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( | 386 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( |
| 503 const std::vector<int32_t>& buffer_ids, | 387 const std::vector<int32_t>& buffer_ids, |
| 504 const std::vector<uint32_t>& texture_ids) { | 388 const std::vector<uint32_t>& texture_ids) { |
| 505 if (buffer_ids.size() != texture_ids.size()) { | 389 if (buffer_ids.size() != texture_ids.size()) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; | 494 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; |
| 611 GLenum target = texture_ref->texture()->target(); | 495 GLenum target = texture_ref->texture()->target(); |
| 612 gpu::gles2::TextureManager* texture_manager = | 496 gpu::gles2::TextureManager* texture_manager = |
| 613 stub_->decoder()->GetContextGroup()->texture_manager(); | 497 stub_->decoder()->GetContextGroup()->texture_manager(); |
| 614 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); | 498 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); |
| 615 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); | 499 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); |
| 616 uncleared_textures_.erase(it); | 500 uncleared_textures_.erase(it); |
| 617 } | 501 } |
| 618 | 502 |
| 619 } // namespace content | 503 } // namespace content |
| OLD | NEW |