Chromium Code Reviews| Index: content/public/renderer/video_encode_accelerator.cc |
| diff --git a/content/public/renderer/video_encode_accelerator.cc b/content/public/renderer/video_encode_accelerator.cc |
| index f1859c3cc59b421d1c3d0e14bceca3341d056a06..0a2c0f1ec73b370d2f00520ebb246d8d6014bb69 100644 |
| --- a/content/public/renderer/video_encode_accelerator.cc |
| +++ b/content/public/renderer/video_encode_accelerator.cc |
| @@ -11,6 +11,21 @@ |
| namespace content { |
| +// The supported profiles of video encode accelerator. |
| +static std::vector<media::VideoEncodeAccelerator::SupportedProfile>* |
| + g_supported_profiles = NULL; |
| + |
| +static void GetSupportedVideoEncodeAcceleratorProfilesInternal( |
| + scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories, |
| + base::WaitableEvent* waiter, |
| + std::vector<media::VideoEncodeAccelerator::SupportedProfile>* profiles) { |
| + scoped_ptr<media::VideoEncodeAccelerator> video_encoder = |
| + gpu_factories->CreateVideoEncodeAccelerator(); |
| + if (video_encoder) |
| + *profiles = video_encoder->GetSupportedProfiles(); |
| + waiter->Signal(); |
| +} |
| + |
| void CreateVideoEncodeAccelerator( |
| const OnCreateVideoEncodeAcceleratorCallback& callback) { |
| DCHECK(!callback.is_null()); |
| @@ -35,7 +50,21 @@ void CreateVideoEncodeAccelerator( |
| std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
|
kcwu
2014/09/19 11:15:54
Since you cached the result to global variable, ch
|
| GetSupportedVideoEncodeAcceleratorProfiles() { |
| - return GpuVideoEncodeAcceleratorHost::GetSupportedProfiles(); |
| + if (!g_supported_profiles) { |
| + g_supported_profiles = |
| + new std::vector<media::VideoEncodeAccelerator::SupportedProfile>(); |
| + scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories = |
| + RenderThreadImpl::current()->GetGpuFactories(); |
| + base::WaitableEvent waiter(true, false); |
| + gpu_factories->GetTaskRunner()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&GetSupportedVideoEncodeAcceleratorProfilesInternal, |
| + gpu_factories, |
| + &waiter, |
| + g_supported_profiles)); |
| + waiter.Wait(); |
| + } |
| + return *g_supported_profiles; |
| } |
| } // namespace content |