]> git.sesse.net Git - casparcg/blob - accelerator/ogl/util/device.h
2.1.0: -common: Restructured files. Moved most files into root for easier inclusion...
[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 <core/frame/frame.h>\r
25 \r
26 #include <common/memory.h>\r
27 #include <common/executor.h>\r
28 \r
29 namespace caspar { namespace accelerator { namespace ogl {\r
30 \r
31 class texture;\r
32 \r
33 class device sealed : public std::enable_shared_from_this<device>\r
34 {       \r
35         device(const device&);\r
36         device& operator=(const device&);\r
37 \r
38         executor executor_;\r
39 public:         \r
40 \r
41         // Static Members\r
42 \r
43         // Constructors\r
44 \r
45         device();\r
46         ~device();\r
47 \r
48         // Methods\r
49                         \r
50         spl::shared_ptr<texture> create_texture(int width, int height, int stride);\r
51         array<std::uint8_t>              create_array(int size);\r
52 \r
53         boost::unique_future<spl::shared_ptr<texture>>  copy_async(const array<const std::uint8_t>& source, int width, int height, int stride);\r
54         boost::unique_future<spl::shared_ptr<texture>>  copy_async(const array<std::uint8_t>& source, int width, int height, int stride);\r
55         boost::unique_future<array<const std::uint8_t>> copy_async(const spl::shared_ptr<texture>& source);\r
56         \r
57         template<typename Func>\r
58         auto begin_invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> boost::unique_future<decltype(func())> // noexcept\r
59         {                       \r
60                 return executor_.begin_invoke(std::forward<Func>(func), priority);\r
61         }\r
62         \r
63         template<typename Func>\r
64         auto invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> decltype(func())\r
65         {\r
66                 return executor_.invoke(std::forward<Func>(func), priority);\r
67         }\r
68 \r
69         // Properties\r
70         \r
71         std::wstring version() const;\r
72 \r
73 private:\r
74         struct impl;\r
75         spl::shared_ptr<impl> impl_;\r
76 };\r
77 \r
78 }}}