X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=accelerator%2Faccelerator.cpp;h=315ad97a345a4d5c8d36ed4c24859dbdf209761f;hb=b7aa720f705ff5c5c59616ddcb82e509ddff16e1;hp=ef5aaba36e6230bae9951e1815a122bd8e7b2300;hpb=435cf4b385c5099270bee44f89c3e2615af30521;p=casparcg diff --git a/accelerator/accelerator.cpp b/accelerator/accelerator.cpp index ef5aaba36..315ad97a3 100644 --- a/accelerator/accelerator.cpp +++ b/accelerator/accelerator.cpp @@ -1,63 +1,80 @@ -#include "stdafx.h" - -#include "accelerator.h" - -#include "cpu/image/image_mixer.h" -#include "ogl/image/image_mixer.h" - -#include "ogl/util/device.h" - -#include - -namespace caspar { namespace accelerator { - -struct accelerator::impl -{ - const std::wstring path_; - tbb::mutex mutex_; - std::shared_ptr ogl_device_; - - impl(const std::wstring& path) - : path_(path) - { - } - - std::unique_ptr create_image_mixer() - { - try - { - if(path_ == L"gpu" || path_ == L"ogl" || path_ == L"auto" || path_ == L"default") - { - tbb::mutex::scoped_lock lock(mutex_); - - if(!ogl_device_) - ogl_device_.reset(new ogl::device()); - - return std::unique_ptr(new ogl::image_mixer(spl::make_shared_ptr(ogl_device_))); - } - } - catch(...) - { - if(path_ == L"gpu" || path_ == L"ogl") - CASPAR_LOG_CURRENT_EXCEPTION(); - } - - return std::unique_ptr(new cpu::image_mixer()); - } -}; - -accelerator::accelerator(const std::wstring& path) - : impl_(new impl(path)) -{ -} - -accelerator::~accelerator() -{ -} - -std::unique_ptr accelerator::create_image_mixer() -{ - return impl_->create_image_mixer(); -} - -}} \ No newline at end of file +#include "StdAfx.h" + +#include "accelerator.h" + +#ifdef _MSC_VER +#include "cpu/image/image_mixer.h" +#endif +#include "ogl/image/image_mixer.h" +#include "ogl/util/device.h" + +#include + +#include + +#include + +namespace caspar { namespace accelerator { + +struct accelerator::impl +{ + const std::wstring path_; + tbb::mutex mutex_; + std::shared_ptr ogl_device_; + + impl(const std::wstring& path) + : path_(path) + { + } + + std::unique_ptr create_image_mixer(int channel_id) + { + try + { + if(path_ == L"gpu" || path_ == L"ogl" || path_ == L"auto" || path_ == L"default") + { + tbb::mutex::scoped_lock lock(mutex_); + + if(!ogl_device_) + ogl_device_.reset(new ogl::device()); + + return std::unique_ptr(new ogl::image_mixer( + spl::make_shared_ptr(ogl_device_), + env::properties().get(L"configuration.mixer.blend-modes", false), + env::properties().get(L"configuration.mixer.straight-alpha", false), + channel_id)); + } + } + catch(...) + { + if(path_ == L"gpu" || path_ == L"ogl") + CASPAR_LOG_CURRENT_EXCEPTION(); + } +#ifdef _MSC_VER + return std::unique_ptr(new cpu::image_mixer(channel_id)); +#else + CASPAR_THROW_EXCEPTION(not_supported()); +#endif + } +}; + +accelerator::accelerator(const std::wstring& path) + : impl_(new impl(path)) +{ +} + +accelerator::~accelerator() +{ +} + +std::unique_ptr accelerator::create_image_mixer(int channel_id) +{ + return impl_->create_image_mixer(channel_id); +} + +std::shared_ptr accelerator::get_ogl_device() const +{ + return impl_->ogl_device_; +} + +}}