3 #include "accelerator.h"
6 #include "cpu/image/image_mixer.h"
8 #include "ogl/image/image_mixer.h"
9 #include "ogl/util/device.h"
11 #include <common/env.h>
13 #include <core/mixer/image/image_mixer.h>
15 #include <tbb/mutex.h>
17 namespace caspar { namespace accelerator {
19 struct accelerator::impl
21 const std::wstring path_;
23 std::shared_ptr<ogl::device> ogl_device_;
25 impl(const std::wstring& path)
30 std::unique_ptr<core::image_mixer> create_image_mixer(int channel_id)
34 if(path_ == L"gpu" || path_ == L"ogl" || path_ == L"auto" || path_ == L"default")
36 tbb::mutex::scoped_lock lock(mutex_);
39 ogl_device_.reset(new ogl::device());
41 return std::unique_ptr<core::image_mixer>(new ogl::image_mixer(
42 spl::make_shared_ptr(ogl_device_),
43 env::properties().get(L"configuration.mixer.blend-modes", false),
44 env::properties().get(L"configuration.mixer.straight-alpha", false),
50 if(path_ == L"gpu" || path_ == L"ogl")
51 CASPAR_LOG_CURRENT_EXCEPTION();
54 return std::unique_ptr<core::image_mixer>(new cpu::image_mixer(channel_id));
56 CASPAR_THROW_EXCEPTION(not_supported());
61 accelerator::accelerator(const std::wstring& path)
62 : impl_(new impl(path))
66 accelerator::~accelerator()
70 std::unique_ptr<core::image_mixer> accelerator::create_image_mixer(int channel_id)
72 return impl_->create_image_mixer(channel_id);
75 std::shared_ptr<ogl::device> accelerator::get_ogl_device() const
77 return impl_->ogl_device_;