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