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" | |
22 #include "content/common/gpu/media/media_messages.h" | 21 #include "content/common/gpu/media/media_messages.h" |
23 #include "gpu/command_buffer/common/command_buffer.h" | 22 #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" | |
29 #include "ui/gl/gl_context.h" | 28 #include "ui/gl/gl_context.h" |
30 #include "ui/gl/gl_image.h" | 29 #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" |
31 | 52 |
32 namespace content { | 53 namespace content { |
33 | 54 |
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 | |
45 static bool MakeDecoderContextCurrent( | 55 static bool MakeDecoderContextCurrent( |
46 const base::WeakPtr<GpuCommandBufferStub>& stub) { | 56 const base::WeakPtr<GpuCommandBufferStub> stub) { |
47 if (!stub) { | 57 if (!stub) { |
48 DLOG(ERROR) << "Stub is gone; won't MakeCurrent()."; | 58 DLOG(ERROR) << "Stub is gone; won't MakeCurrent()."; |
49 return false; | 59 return false; |
50 } | 60 } |
51 | 61 |
52 if (!stub->decoder()->MakeCurrent()) { | 62 if (!stub->decoder()->MakeCurrent()) { |
53 DLOG(ERROR) << "Failed to MakeCurrent()"; | 63 DLOG(ERROR) << "Failed to MakeCurrent()"; |
54 return false; | 64 return false; |
55 } | 65 } |
56 | 66 |
57 return true; | 67 return true; |
58 } | 68 } |
59 | 69 |
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 | |
97 // DebugAutoLock works like AutoLock but only acquires the lock when | 70 // DebugAutoLock works like AutoLock but only acquires the lock when |
98 // DCHECK is on. | 71 // DCHECK is on. |
99 #if DCHECK_IS_ON() | 72 #if DCHECK_IS_ON() |
100 typedef base::AutoLock DebugAutoLock; | 73 typedef base::AutoLock DebugAutoLock; |
101 #else | 74 #else |
102 class DebugAutoLock { | 75 class DebugAutoLock { |
103 public: | 76 public: |
104 explicit DebugAutoLock(base::Lock&) {} | 77 explicit DebugAutoLock(base::Lock&) {} |
105 }; | 78 }; |
106 #endif | 79 #endif |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) | 131 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) |
159 : host_route_id_(host_route_id), | 132 : host_route_id_(host_route_id), |
160 stub_(stub), | 133 stub_(stub), |
161 texture_target_(0), | 134 texture_target_(0), |
162 filter_removed_(true, false), | 135 filter_removed_(true, false), |
163 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 136 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
164 io_task_runner_(io_task_runner), | 137 io_task_runner_(io_task_runner), |
165 weak_factory_for_io_(this) { | 138 weak_factory_for_io_(this) { |
166 DCHECK(stub_); | 139 DCHECK(stub_); |
167 stub_->AddDestructionObserver(this); | 140 stub_->AddDestructionObserver(this); |
168 get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr()); | 141 make_context_current_ = |
169 make_context_current_cb_ = | |
170 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); | 142 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()); | |
175 } | 143 } |
176 | 144 |
177 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { | 145 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { |
178 // This class can only be self-deleted from OnWillDestroyStub(), which means | 146 // This class can only be self-deleted from OnWillDestroyStub(), which means |
179 // the VDA has already been destroyed in there. | 147 // the VDA has already been destroyed in there. |
180 DCHECK(!video_decode_accelerator_); | 148 DCHECK(!video_decode_accelerator_); |
181 } | 149 } |
182 | 150 |
183 // static | 151 // static |
184 gpu::VideoDecodeAcceleratorCapabilities | 152 gpu::VideoDecodeAcceleratorCapabilities |
185 GpuVideoDecodeAccelerator::GetCapabilities( | 153 GpuVideoDecodeAccelerator::GetCapabilities( |
186 const gpu::GpuPreferences& gpu_preferences) { | 154 const gpu::GpuPreferences& gpu_preferences) { |
187 return GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities( | 155 media::VideoDecodeAccelerator::Capabilities capabilities; |
188 gpu_preferences); | 156 if (gpu_preferences.disable_accelerated_video_decode) |
| 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 |
331 DCHECK(!video_decode_accelerator_); | 336 DCHECK(!video_decode_accelerator_); |
332 | 337 |
333 if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { | 338 if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { |
334 DLOG(ERROR) << "Initialize(): failed to add route"; | 339 DLOG(ERROR) << "Initialize(): failed to add route"; |
335 return false; | 340 return false; |
336 } | 341 } |
337 | 342 |
338 #if !defined(OS_WIN) | 343 #if !defined(OS_WIN) |
339 // Ensure we will be able to get a GL context at all before initializing | 344 // Ensure we will be able to get a GL context at all before initializing |
340 // non-Windows VDAs. | 345 // non-Windows VDAs. |
341 if (!make_context_current_cb_.Run()) | 346 if (!make_context_current_.Run()) { |
342 return false; | 347 return false; |
| 348 } |
343 #endif | 349 #endif |
344 | 350 |
345 scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory = | 351 // Array of Create..VDA() function pointers, maybe applicable to the current |
346 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( | 352 // platform. This list is ordered by priority of use and it should be the |
347 get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, | 353 // same as the order of querying supported profiles of VDAs. |
348 get_gles2_decoder_cb_); | 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 }; |
349 | 372 |
350 if (!vda_factory) { | 373 for (const auto& create_vda_function : create_vda_fps) { |
351 LOG(ERROR) << "Failed creating the VDA factory"; | 374 video_decode_accelerator_ = (this->*create_vda_function)(); |
352 return false; | 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; |
353 } | 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 } |
354 | 390 |
| 391 #if defined(OS_WIN) |
| 392 scoped_ptr<media::VideoDecodeAccelerator> |
| 393 GpuVideoDecodeAccelerator::CreateDXVAVDA() { |
| 394 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
355 const gpu::GpuPreferences& gpu_preferences = | 395 const gpu::GpuPreferences& gpu_preferences = |
356 stub_->channel()->gpu_channel_manager()->gpu_preferences(); | 396 stub_->channel()->gpu_channel_manager()->gpu_preferences(); |
357 video_decode_accelerator_ = | 397 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { |
358 vda_factory->CreateVDA(this, config, gpu_preferences); | 398 DVLOG(0) << "Initializing DXVA HW decoder for windows."; |
359 if (!video_decode_accelerator_) { | 399 decoder.reset(new DXVAVideoDecodeAccelerator( |
360 LOG(ERROR) << "HW video decode not available for profile " << config.profile | 400 make_context_current_, stub_->decoder()->GetGLContext(), |
361 << (config.is_encrypted ? " with encryption" : ""); | 401 gpu_preferences.enable_accelerated_vpx_decode)); |
362 return false; | 402 } else { |
| 403 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
363 } | 404 } |
| 405 return decoder; |
| 406 } |
| 407 #endif |
364 | 408 |
365 // Attempt to set up performing decoding tasks on IO thread, if supported by | 409 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
366 // the VDA. | 410 scoped_ptr<media::VideoDecodeAccelerator> |
367 if (video_decode_accelerator_->TryToSetupDecodeOnSeparateThread( | 411 GpuVideoDecodeAccelerator::CreateV4L2VDA() { |
368 weak_factory_for_io_.GetWeakPtr(), io_task_runner_)) { | 412 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
369 filter_ = new MessageFilter(this, host_route_id_); | 413 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
370 stub_->channel()->AddFilter(filter_.get()); | 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_)); |
371 } | 422 } |
| 423 return decoder; |
| 424 } |
372 | 425 |
373 return true; | 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; |
374 } | 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 |
375 | 491 |
376 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { | 492 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { |
377 DCHECK(video_decode_accelerator_); | 493 DCHECK(video_decode_accelerator_); |
378 video_decode_accelerator_->SetCdm(cdm_id); | 494 video_decode_accelerator_->SetCdm(cdm_id); |
379 } | 495 } |
380 | 496 |
381 // Runs on IO thread if VDA::TryToSetupDecodeOnSeparateThread() succeeded, | 497 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
382 // otherwise on the main thread. | 498 // true, otherwise on the main thread. |
383 void GpuVideoDecodeAccelerator::OnDecode( | 499 void GpuVideoDecodeAccelerator::OnDecode( |
384 const media::BitstreamBuffer& bitstream_buffer) { | 500 const media::BitstreamBuffer& bitstream_buffer) { |
385 DCHECK(video_decode_accelerator_); | 501 DCHECK(video_decode_accelerator_); |
386 video_decode_accelerator_->Decode(bitstream_buffer); | 502 video_decode_accelerator_->Decode(bitstream_buffer); |
387 } | 503 } |
388 | 504 |
389 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( | 505 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( |
390 const std::vector<int32_t>& buffer_ids, | 506 const std::vector<int32_t>& buffer_ids, |
391 const std::vector<uint32_t>& texture_ids) { | 507 const std::vector<uint32_t>& texture_ids) { |
392 if (buffer_ids.size() != texture_ids.size()) { | 508 if (buffer_ids.size() != texture_ids.size()) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; | 613 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; |
498 GLenum target = texture_ref->texture()->target(); | 614 GLenum target = texture_ref->texture()->target(); |
499 gpu::gles2::TextureManager* texture_manager = | 615 gpu::gles2::TextureManager* texture_manager = |
500 stub_->decoder()->GetContextGroup()->texture_manager(); | 616 stub_->decoder()->GetContextGroup()->texture_manager(); |
501 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); | 617 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); |
502 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); | 618 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); |
503 uncleared_textures_.erase(it); | 619 uncleared_textures_.erase(it); |
504 } | 620 } |
505 | 621 |
506 } // namespace content | 622 } // namespace content |
OLD | NEW |