]> git.sesse.net Git - casparcg/blob - accelerator/ogl/util/device.h
Merged GL INFO command from 2.0.
[casparcg] / accelerator / ogl / util / device.h
1 /*
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
3 *
4 * This file is part of CasparCG (www.casparcg.com).
5 *
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: Robert Nagy, ronag89@gmail.com
20 */
21
22 #pragma once
23
24 #include <core/frame/frame.h>
25
26 #include <common/memory.h>
27 #include <common/executor.h>
28
29 #include <boost/property_tree/ptree_fwd.hpp>
30
31 namespace caspar { namespace accelerator { namespace ogl {
32
33 class texture;
34
35 class device final : public std::enable_shared_from_this<device>
36 {       
37         device(const device&);
38         device& operator=(const device&);
39
40         executor executor_;
41 public:         
42
43         // Static Members
44
45         // Constructors
46
47         device();
48         ~device();
49
50         // Methods
51                         
52         spl::shared_ptr<texture> create_texture(int width, int height, int stride, bool mipmapped);
53         array<std::uint8_t>              create_array(int size);
54                 
55         // NOTE: Since the returned texture is cached it SHOULD NOT be modified.
56         std::future<std::shared_ptr<texture>>   copy_async(const array<const std::uint8_t>& source, int width, int height, int stride, bool mipmapped);
57
58         std::future<std::shared_ptr<texture>>   copy_async(const array<std::uint8_t>& source, int width, int height, int stride, bool mipmapped);
59         std::future<array<const std::uint8_t>>  copy_async(const spl::shared_ptr<texture>& source);
60                         
61         template<typename Func>
62         auto begin_invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> std::future<decltype(func())> // noexcept
63         {                       
64                 return executor_.begin_invoke(std::forward<Func>(func), priority);
65         }
66         
67         template<typename Func>
68         auto invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> decltype(func())
69         {
70                 return executor_.invoke(std::forward<Func>(func), priority);
71         }
72
73         // Properties
74         
75         boost::property_tree::wptree    info() const;
76         std::wstring                                    version() const;
77
78 private:
79         struct impl;
80         spl::shared_ptr<impl> impl_;
81 };
82
83 }}}