]> git.sesse.net Git - casparcg/blob - accelerator/accelerator.cpp
* added geometry to frames for custom rendering
[casparcg] / accelerator / accelerator.cpp
1 #include "stdafx.h"
2
3 #include "accelerator.h"
4
5 #include "cpu/image/image_mixer.h"
6 #include "ogl/image/image_mixer.h"
7
8 #include "ogl/util/device.h"
9
10 #include <tbb/mutex.h>
11
12 namespace caspar { namespace accelerator {
13         
14 struct accelerator::impl
15 {
16         const std::wstring                              path_;
17         tbb::mutex                                              mutex_;
18         std::shared_ptr<ogl::device>    ogl_device_;
19
20         impl(const std::wstring& path)
21                 : path_(path)
22         {
23         }
24
25         std::unique_ptr<core::image_mixer> create_image_mixer()
26         {
27                 try
28                 {
29                         if(path_ == L"gpu" || path_ == L"ogl" || path_ == L"auto" || path_ == L"default")
30                         {
31                                 tbb::mutex::scoped_lock lock(mutex_);
32
33                                 if(!ogl_device_)
34                                         ogl_device_.reset(new ogl::device());
35
36                                 return std::unique_ptr<core::image_mixer>(new ogl::image_mixer(spl::make_shared_ptr(ogl_device_)));
37                         }
38                 }
39                 catch(...)
40                 {
41                         if(path_ == L"gpu" || path_ == L"ogl")
42                                 CASPAR_LOG_CURRENT_EXCEPTION();
43                 }
44
45                 return std::unique_ptr<core::image_mixer>(new cpu::image_mixer());
46         }
47 };
48
49 accelerator::accelerator(const std::wstring& path)
50         : impl_(new impl(path))
51 {
52 }
53
54 accelerator::~accelerator()
55 {
56 }
57
58 std::unique_ptr<core::image_mixer> accelerator::create_image_mixer()
59 {
60         return impl_->create_image_mixer();
61 }
62
63 }}