]> git.sesse.net Git - casparcg/blob - accelerator/ogl/util/device.h
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / accelerator / ogl / util / device.h
1 /*\r
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 * This file is part of CasparCG (www.casparcg.com).\r
5 *\r
6 * CasparCG is free software: you can redistribute it and/or modify\r
7 * it under the terms of the GNU General Public License as published by\r
8 * the Free Software Foundation, either version 3 of the License, or\r
9 * (at your option) any later version.\r
10 *\r
11 * CasparCG is distributed in the hope that it will be useful,\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 * GNU General Public License for more details.\r
15 *\r
16 * You should have received a copy of the GNU General Public License\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 * Author: Robert Nagy, ronag89@gmail.com\r
20 */\r
21 \r
22 #pragma once\r
23 \r
24 #include "host_buffer.h"\r
25 #include "device_buffer.h"\r
26 \r
27 #include <common/spl/memory.h>\r
28 \r
29 #include <boost/noncopyable.hpp>\r
30 #include <boost/thread/future.hpp>\r
31 \r
32 #include <common/concurrency/executor.h>\r
33 \r
34 namespace caspar { namespace accelerator { namespace ogl {\r
35         \r
36 class device : public std::enable_shared_from_this<device>, boost::noncopyable\r
37 {       \r
38         executor executor_;\r
39 public:         \r
40         device();\r
41                 \r
42         spl::shared_ptr<device_buffer>                                                  create_device_buffer(int width, int height, int stride);\r
43         spl::shared_ptr<host_buffer>                                                    create_host_buffer(int size, host_buffer::usage usage);\r
44 \r
45         boost::unique_future<spl::shared_ptr<device_buffer>>    copy_async(spl::shared_ptr<host_buffer>& source, int width, int height, int stride);\r
46         \r
47         std::wstring version();\r
48 \r
49         template<typename Func>\r
50         auto begin_invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> boost::unique_future<decltype(func())> // noexcept\r
51         {                       \r
52                 return executor_.begin_invoke(std::forward<Func>(func), priority);\r
53         }\r
54         \r
55         template<typename Func>\r
56         auto invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> decltype(func())\r
57         {\r
58                 return executor_.invoke(std::forward<Func>(func), priority);\r
59         }\r
60 private:\r
61         struct impl;\r
62         spl::shared_ptr<impl> impl_;\r
63 };\r
64 \r
65 }}}