| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/public/gpu/gpu_video_decode_accelerator_factory.h" | 5 #include "content/public/gpu/gpu_video_decode_accelerator_factory.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 7 #include "content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h" | 8 #include "content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h" |
| 8 #include "content/gpu/gpu_child_thread.h" | 9 #include "content/gpu/gpu_child_thread.h" |
| 9 | 10 |
| 10 namespace content { | 11 namespace content { |
| 11 | 12 |
| 12 GpuVideoDecodeAcceleratorFactory::~GpuVideoDecodeAcceleratorFactory() {} | 13 GpuVideoDecodeAcceleratorFactory::~GpuVideoDecodeAcceleratorFactory() {} |
| 13 | 14 |
| 14 // static | 15 // static |
| 15 scoped_ptr<GpuVideoDecodeAcceleratorFactory> | 16 std::unique_ptr<GpuVideoDecodeAcceleratorFactory> |
| 16 GpuVideoDecodeAcceleratorFactory::Create( | 17 GpuVideoDecodeAcceleratorFactory::Create( |
| 17 const GetGLContextCallback& get_gl_context_cb, | 18 const GetGLContextCallback& get_gl_context_cb, |
| 18 const MakeGLContextCurrentCallback& make_context_current_cb, | 19 const MakeGLContextCurrentCallback& make_context_current_cb, |
| 19 const BindGLImageCallback& bind_image_cb) { | 20 const BindGLImageCallback& bind_image_cb) { |
| 20 auto gvdafactory_impl = GpuVideoDecodeAcceleratorFactoryImpl::Create( | 21 auto gvdafactory_impl = GpuVideoDecodeAcceleratorFactoryImpl::Create( |
| 21 get_gl_context_cb, make_context_current_cb, bind_image_cb); | 22 get_gl_context_cb, make_context_current_cb, bind_image_cb); |
| 22 if (!gvdafactory_impl) | 23 if (!gvdafactory_impl) |
| 23 return nullptr; | 24 return nullptr; |
| 24 | 25 |
| 25 return make_scoped_ptr( | 26 return base::WrapUnique( |
| 26 new GpuVideoDecodeAcceleratorFactory(std::move(gvdafactory_impl))); | 27 new GpuVideoDecodeAcceleratorFactory(std::move(gvdafactory_impl))); |
| 27 } | 28 } |
| 28 | 29 |
| 29 // static | 30 // static |
| 30 scoped_ptr<GpuVideoDecodeAcceleratorFactory> | 31 std::unique_ptr<GpuVideoDecodeAcceleratorFactory> |
| 31 GpuVideoDecodeAcceleratorFactory::CreateWithGLES2Decoder( | 32 GpuVideoDecodeAcceleratorFactory::CreateWithGLES2Decoder( |
| 32 const GetGLContextCallback& get_gl_context_cb, | 33 const GetGLContextCallback& get_gl_context_cb, |
| 33 const MakeGLContextCurrentCallback& make_context_current_cb, | 34 const MakeGLContextCurrentCallback& make_context_current_cb, |
| 34 const BindGLImageCallback& bind_image_cb, | 35 const BindGLImageCallback& bind_image_cb, |
| 35 const GetGLES2DecoderCallback& get_gles2_decoder_cb) { | 36 const GetGLES2DecoderCallback& get_gles2_decoder_cb) { |
| 36 auto gvdafactory_impl = | 37 auto gvdafactory_impl = |
| 37 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( | 38 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( |
| 38 get_gl_context_cb, make_context_current_cb, bind_image_cb, | 39 get_gl_context_cb, make_context_current_cb, bind_image_cb, |
| 39 get_gles2_decoder_cb); | 40 get_gles2_decoder_cb); |
| 40 if (!gvdafactory_impl) | 41 if (!gvdafactory_impl) |
| 41 return nullptr; | 42 return nullptr; |
| 42 | 43 |
| 43 return make_scoped_ptr( | 44 return base::WrapUnique( |
| 44 new GpuVideoDecodeAcceleratorFactory(std::move(gvdafactory_impl))); | 45 new GpuVideoDecodeAcceleratorFactory(std::move(gvdafactory_impl))); |
| 45 } | 46 } |
| 46 | 47 |
| 47 // static | 48 // static |
| 48 gpu::VideoDecodeAcceleratorCapabilities | 49 gpu::VideoDecodeAcceleratorCapabilities |
| 49 GpuVideoDecodeAcceleratorFactory::GetDecoderCapabilities() { | 50 GpuVideoDecodeAcceleratorFactory::GetDecoderCapabilities() { |
| 50 const gpu::GpuPreferences gpu_preferences = | 51 const gpu::GpuPreferences gpu_preferences = |
| 51 GpuChildThread::current()->gpu_preferences(); | 52 GpuChildThread::current()->gpu_preferences(); |
| 52 return GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities( | 53 return GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities( |
| 53 gpu_preferences); | 54 gpu_preferences); |
| 54 } | 55 } |
| 55 | 56 |
| 56 scoped_ptr<media::VideoDecodeAccelerator> | 57 std::unique_ptr<media::VideoDecodeAccelerator> |
| 57 GpuVideoDecodeAcceleratorFactory::CreateVDA( | 58 GpuVideoDecodeAcceleratorFactory::CreateVDA( |
| 58 media::VideoDecodeAccelerator::Client* client, | 59 media::VideoDecodeAccelerator::Client* client, |
| 59 const media::VideoDecodeAccelerator::Config& config) { | 60 const media::VideoDecodeAccelerator::Config& config) { |
| 60 if (!gvdafactory_impl_) | 61 if (!gvdafactory_impl_) |
| 61 return nullptr; | 62 return nullptr; |
| 62 | 63 |
| 63 const gpu::GpuPreferences gpu_preferences = | 64 const gpu::GpuPreferences gpu_preferences = |
| 64 GpuChildThread::current()->gpu_preferences(); | 65 GpuChildThread::current()->gpu_preferences(); |
| 65 return gvdafactory_impl_->CreateVDA(client, config, gpu_preferences); | 66 return gvdafactory_impl_->CreateVDA(client, config, gpu_preferences); |
| 66 } | 67 } |
| 67 | 68 |
| 68 GpuVideoDecodeAcceleratorFactory::GpuVideoDecodeAcceleratorFactory( | 69 GpuVideoDecodeAcceleratorFactory::GpuVideoDecodeAcceleratorFactory( |
| 69 scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> gvdafactory_impl) | 70 std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> gvdafactory_impl) |
| 70 : gvdafactory_impl_(std::move(gvdafactory_impl)) {} | 71 : gvdafactory_impl_(std::move(gvdafactory_impl)) {} |
| 71 | 72 |
| 72 } // namespace content | 73 } // namespace content |
| OLD | NEW |