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 "gpu/command_buffer/common/command_buffer.h" | 22 #include "gpu/command_buffer/common/command_buffer.h" |
22 #include "gpu/command_buffer/service/gpu_preferences.h" | |
23 #include "ipc/ipc_message_macros.h" | 23 #include "ipc/ipc_message_macros.h" |
24 #include "ipc/ipc_message_utils.h" | 24 #include "ipc/ipc_message_utils.h" |
25 #include "ipc/message_filter.h" | 25 #include "ipc/message_filter.h" |
26 #include "media/base/limits.h" | 26 #include "media/base/limits.h" |
27 #include "media/gpu/ipc/common/media_messages.h" | 27 #include "media/gpu/ipc/common/media_messages.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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 textures_per_buffer_(0), | 162 textures_per_buffer_(0), |
136 filter_removed_(true, false), | 163 filter_removed_(true, false), |
137 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 164 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
138 io_task_runner_(io_task_runner), | 165 io_task_runner_(io_task_runner), |
139 weak_factory_for_io_(this) { | 166 weak_factory_for_io_(this) { |
140 DCHECK(stub_); | 167 DCHECK(stub_); |
141 stub_->AddDestructionObserver(this); | 168 stub_->AddDestructionObserver(this); |
142 make_context_current_ = | 169 get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr()); |
| 170 make_context_current_cb_ = |
143 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); | 171 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); |
| 172 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) |
| 173 bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr()); |
| 174 #endif |
| 175 get_gles2_decoder_cb_ = base::Bind(&GetGLES2Decoder, stub_->AsWeakPtr()); |
144 } | 176 } |
145 | 177 |
146 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { | 178 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { |
147 // This class can only be self-deleted from OnWillDestroyStub(), which means | 179 // This class can only be self-deleted from OnWillDestroyStub(), which means |
148 // the VDA has already been destroyed in there. | 180 // the VDA has already been destroyed in there. |
149 DCHECK(!video_decode_accelerator_); | 181 DCHECK(!video_decode_accelerator_); |
150 } | 182 } |
151 | 183 |
152 // static | 184 // static |
153 gpu::VideoDecodeAcceleratorCapabilities | 185 gpu::VideoDecodeAcceleratorCapabilities |
154 GpuVideoDecodeAccelerator::GetCapabilities( | 186 GpuVideoDecodeAccelerator::GetCapabilities( |
155 const gpu::GpuPreferences& gpu_preferences) { | 187 const gpu::GpuPreferences& gpu_preferences) { |
156 media::VideoDecodeAccelerator::Capabilities capabilities; | 188 return GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities( |
157 if (gpu_preferences.disable_accelerated_video_decode) | 189 gpu_preferences); |
158 return gpu::VideoDecodeAcceleratorCapabilities(); | |
159 | |
160 // Query supported profiles for each VDA. The order of querying VDAs should | |
161 // be the same as the order of initializing VDAs. Then the returned profile | |
162 // can be initialized by corresponding VDA successfully. | |
163 #if defined(OS_WIN) | |
164 capabilities.supported_profiles = | |
165 DXVAVideoDecodeAccelerator::GetSupportedProfiles(); | |
166 #elif defined(OS_CHROMEOS) | |
167 media::VideoDecodeAccelerator::SupportedProfiles vda_profiles; | |
168 #if defined(USE_V4L2_CODEC) | |
169 vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); | |
170 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( | |
171 vda_profiles, &capabilities.supported_profiles); | |
172 vda_profiles = V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(); | |
173 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( | |
174 vda_profiles, &capabilities.supported_profiles); | |
175 #endif | |
176 #if defined(ARCH_CPU_X86_FAMILY) | |
177 vda_profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles(); | |
178 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( | |
179 vda_profiles, &capabilities.supported_profiles); | |
180 #endif | |
181 #elif defined(OS_MACOSX) | |
182 capabilities.supported_profiles = | |
183 VTVideoDecodeAccelerator::GetSupportedProfiles(); | |
184 #elif defined(OS_ANDROID) | |
185 capabilities = | |
186 AndroidVideoDecodeAccelerator::GetCapabilities(gpu_preferences); | |
187 #endif | |
188 return GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeCapabilities( | |
189 capabilities); | |
190 } | 190 } |
191 | 191 |
192 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { | 192 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { |
193 if (!video_decode_accelerator_) | 193 if (!video_decode_accelerator_) |
194 return false; | 194 return false; |
195 | 195 |
196 bool handled = true; | 196 bool handled = true; |
197 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) | 197 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) |
198 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_SetCdm, OnSetCdm) | 198 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_SetCdm, OnSetCdm) |
199 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) | 199 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 322 |
323 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { | 323 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { |
324 if (filter_ && io_task_runner_->BelongsToCurrentThread()) | 324 if (filter_ && io_task_runner_->BelongsToCurrentThread()) |
325 return filter_->SendOnIOThread(message); | 325 return filter_->SendOnIOThread(message); |
326 DCHECK(child_task_runner_->BelongsToCurrentThread()); | 326 DCHECK(child_task_runner_->BelongsToCurrentThread()); |
327 return stub_->channel()->Send(message); | 327 return stub_->channel()->Send(message); |
328 } | 328 } |
329 | 329 |
330 bool GpuVideoDecodeAccelerator::Initialize( | 330 bool GpuVideoDecodeAccelerator::Initialize( |
331 const media::VideoDecodeAccelerator::Config& config) { | 331 const media::VideoDecodeAccelerator::Config& config) { |
332 const gpu::GpuPreferences& gpu_preferences = | |
333 stub_->channel()->gpu_channel_manager()->gpu_preferences(); | |
334 if (gpu_preferences.disable_accelerated_video_decode) | |
335 return false; | |
336 | |
337 DCHECK(!video_decode_accelerator_); | 332 DCHECK(!video_decode_accelerator_); |
338 | 333 |
339 if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { | 334 if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { |
340 DLOG(ERROR) << "Initialize(): failed to add route"; | 335 DLOG(ERROR) << "Initialize(): failed to add route"; |
341 return false; | 336 return false; |
342 } | 337 } |
343 | 338 |
344 #if !defined(OS_WIN) | 339 #if !defined(OS_WIN) |
345 // Ensure we will be able to get a GL context at all before initializing | 340 // Ensure we will be able to get a GL context at all before initializing |
346 // non-Windows VDAs. | 341 // non-Windows VDAs. |
347 if (!make_context_current_.Run()) { | 342 if (!make_context_current_cb_.Run()) |
| 343 return false; |
| 344 #endif |
| 345 |
| 346 scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory = |
| 347 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( |
| 348 get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, |
| 349 get_gles2_decoder_cb_); |
| 350 |
| 351 if (!vda_factory) { |
| 352 LOG(ERROR) << "Failed creating the VDA factory"; |
348 return false; | 353 return false; |
349 } | 354 } |
350 #endif | |
351 | 355 |
352 // Array of Create..VDA() function pointers, maybe applicable to the current | |
353 // platform. This list is ordered by priority of use and it should be the | |
354 // same as the order of querying supported profiles of VDAs. | |
355 const GpuVideoDecodeAccelerator::CreateVDAFp create_vda_fps[] = { | |
356 #if defined(OS_WIN) | |
357 &GpuVideoDecodeAccelerator::CreateDXVAVDA, | |
358 #endif | |
359 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | |
360 &GpuVideoDecodeAccelerator::CreateV4L2VDA, | |
361 &GpuVideoDecodeAccelerator::CreateV4L2SliceVDA, | |
362 #endif | |
363 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
364 &GpuVideoDecodeAccelerator::CreateVaapiVDA, | |
365 #endif | |
366 #if defined(OS_MACOSX) | |
367 &GpuVideoDecodeAccelerator::CreateVTVDA, | |
368 #endif | |
369 #if defined(OS_ANDROID) | |
370 &GpuVideoDecodeAccelerator::CreateAndroidVDA, | |
371 #endif | |
372 }; | |
373 | |
374 for (const auto& create_vda_function : create_vda_fps) { | |
375 video_decode_accelerator_ = (this->*create_vda_function)(); | |
376 if (!video_decode_accelerator_ || | |
377 !video_decode_accelerator_->Initialize(config, this)) | |
378 continue; | |
379 | |
380 if (video_decode_accelerator_->CanDecodeOnIOThread()) { | |
381 filter_ = new MessageFilter(this, host_route_id_); | |
382 stub_->channel()->AddFilter(filter_.get()); | |
383 } | |
384 return true; | |
385 } | |
386 video_decode_accelerator_.reset(); | |
387 LOG(ERROR) << "HW video decode not available for profile " << config.profile | |
388 << (config.is_encrypted ? " with encryption" : ""); | |
389 return false; | |
390 } | |
391 | |
392 #if defined(OS_WIN) | |
393 scoped_ptr<media::VideoDecodeAccelerator> | |
394 GpuVideoDecodeAccelerator::CreateDXVAVDA() { | |
395 scoped_ptr<media::VideoDecodeAccelerator> decoder; | |
396 const gpu::GpuPreferences& gpu_preferences = | 356 const gpu::GpuPreferences& gpu_preferences = |
397 stub_->channel()->gpu_channel_manager()->gpu_preferences(); | 357 stub_->channel()->gpu_channel_manager()->gpu_preferences(); |
398 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { | 358 video_decode_accelerator_ = |
399 DVLOG(0) << "Initializing DXVA HW decoder for windows."; | 359 vda_factory->CreateVDA(this, config, gpu_preferences); |
400 decoder.reset(new DXVAVideoDecodeAccelerator( | 360 if (!video_decode_accelerator_) { |
401 make_context_current_, stub_->decoder()->GetGLContext(), | 361 LOG(ERROR) << "HW video decode not available for profile " << config.profile |
402 gpu_preferences.enable_accelerated_vpx_decode)); | 362 << (config.is_encrypted ? " with encryption" : ""); |
403 } else { | 363 return false; |
404 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | |
405 } | 364 } |
406 return decoder; | 365 |
| 366 // Attempt to set up performing decoding tasks on IO thread, if supported by |
| 367 // the VDA. |
| 368 if (video_decode_accelerator_->TryToSetupDecodeOnSeparateThread( |
| 369 weak_factory_for_io_.GetWeakPtr(), io_task_runner_)) { |
| 370 filter_ = new MessageFilter(this, host_route_id_); |
| 371 stub_->channel()->AddFilter(filter_.get()); |
| 372 } |
| 373 |
| 374 return true; |
407 } | 375 } |
408 #endif | |
409 | |
410 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | |
411 scoped_ptr<media::VideoDecodeAccelerator> | |
412 GpuVideoDecodeAccelerator::CreateV4L2VDA() { | |
413 scoped_ptr<media::VideoDecodeAccelerator> decoder; | |
414 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | |
415 if (device.get()) { | |
416 decoder.reset(new V4L2VideoDecodeAccelerator( | |
417 gfx::GLSurfaceEGL::GetHardwareDisplay(), | |
418 stub_->decoder()->GetGLContext()->GetHandle(), | |
419 weak_factory_for_io_.GetWeakPtr(), | |
420 make_context_current_, | |
421 device, | |
422 io_task_runner_)); | |
423 } | |
424 return decoder; | |
425 } | |
426 | |
427 scoped_ptr<media::VideoDecodeAccelerator> | |
428 GpuVideoDecodeAccelerator::CreateV4L2SliceVDA() { | |
429 scoped_ptr<media::VideoDecodeAccelerator> decoder; | |
430 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | |
431 if (device.get()) { | |
432 decoder.reset(new V4L2SliceVideoDecodeAccelerator( | |
433 device, | |
434 gfx::GLSurfaceEGL::GetHardwareDisplay(), | |
435 stub_->decoder()->GetGLContext()->GetHandle(), | |
436 weak_factory_for_io_.GetWeakPtr(), | |
437 make_context_current_, | |
438 io_task_runner_)); | |
439 } | |
440 return decoder; | |
441 } | |
442 #endif | |
443 | |
444 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) | |
445 void GpuVideoDecodeAccelerator::BindImage(uint32_t client_texture_id, | |
446 uint32_t texture_target, | |
447 scoped_refptr<gl::GLImage> image, | |
448 bool can_bind_to_sampler) { | |
449 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); | |
450 gpu::gles2::TextureManager* texture_manager = | |
451 command_decoder->GetContextGroup()->texture_manager(); | |
452 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id); | |
453 if (ref) { | |
454 texture_manager->SetLevelImage(ref, texture_target, 0, image.get(), | |
455 can_bind_to_sampler | |
456 ? gpu::gles2::Texture::BOUND | |
457 : gpu::gles2::Texture::UNBOUND); | |
458 } | |
459 } | |
460 #endif | |
461 | |
462 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
463 scoped_ptr<media::VideoDecodeAccelerator> | |
464 GpuVideoDecodeAccelerator::CreateVaapiVDA() { | |
465 return make_scoped_ptr<media::VideoDecodeAccelerator>( | |
466 new VaapiVideoDecodeAccelerator( | |
467 make_context_current_, | |
468 base::Bind(&GpuVideoDecodeAccelerator::BindImage, | |
469 base::Unretained(this)))); | |
470 } | |
471 #endif | |
472 | |
473 #if defined(OS_MACOSX) | |
474 scoped_ptr<media::VideoDecodeAccelerator> | |
475 GpuVideoDecodeAccelerator::CreateVTVDA() { | |
476 return make_scoped_ptr<media::VideoDecodeAccelerator>( | |
477 new VTVideoDecodeAccelerator( | |
478 make_context_current_, | |
479 base::Bind(&GpuVideoDecodeAccelerator::BindImage, | |
480 base::Unretained(this)))); | |
481 } | |
482 #endif | |
483 | |
484 #if defined(OS_ANDROID) | |
485 scoped_ptr<media::VideoDecodeAccelerator> | |
486 GpuVideoDecodeAccelerator::CreateAndroidVDA() { | |
487 return make_scoped_ptr<media::VideoDecodeAccelerator>( | |
488 new AndroidVideoDecodeAccelerator(stub_->decoder()->AsWeakPtr(), | |
489 make_context_current_)); | |
490 } | |
491 #endif | |
492 | 376 |
493 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { | 377 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { |
494 DCHECK(video_decode_accelerator_); | 378 DCHECK(video_decode_accelerator_); |
495 video_decode_accelerator_->SetCdm(cdm_id); | 379 video_decode_accelerator_->SetCdm(cdm_id); |
496 } | 380 } |
497 | 381 |
498 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 382 // Runs on IO thread if VDA::TryToSetupDecodeOnSeparateThread() succeeded, |
499 // true, otherwise on the main thread. | 383 // otherwise on the main thread. |
500 void GpuVideoDecodeAccelerator::OnDecode( | 384 void GpuVideoDecodeAccelerator::OnDecode( |
501 const media::BitstreamBuffer& bitstream_buffer) { | 385 const media::BitstreamBuffer& bitstream_buffer) { |
502 DCHECK(video_decode_accelerator_); | 386 DCHECK(video_decode_accelerator_); |
503 video_decode_accelerator_->Decode(bitstream_buffer); | 387 video_decode_accelerator_->Decode(bitstream_buffer); |
504 } | 388 } |
505 | 389 |
506 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( | 390 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( |
507 const std::vector<int32_t>& buffer_ids, | 391 const std::vector<int32_t>& buffer_ids, |
508 const std::vector<media::PictureBuffer::TextureIds>& texture_ids) { | 392 const std::vector<media::PictureBuffer::TextureIds>& texture_ids) { |
509 if (buffer_ids.size() != texture_ids.size()) { | 393 if (buffer_ids.size() != texture_ids.size()) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; | 512 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; |
629 GLenum target = texture_ref->texture()->target(); | 513 GLenum target = texture_ref->texture()->target(); |
630 gpu::gles2::TextureManager* texture_manager = | 514 gpu::gles2::TextureManager* texture_manager = |
631 stub_->decoder()->GetContextGroup()->texture_manager(); | 515 stub_->decoder()->GetContextGroup()->texture_manager(); |
632 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); | 516 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); |
633 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); | 517 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); |
634 uncleared_textures_.erase(it); | 518 uncleared_textures_.erase(it); |
635 } | 519 } |
636 | 520 |
637 } // namespace content | 521 } // namespace content |
OLD | NEW |