-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-* Author: Robert Nagy, ronag89@gmail.com\r
-*/\r
-\r
-#pragma once\r
-\r
-#include <core/frame/frame.h>\r
-\r
-#include <common/memory.h>\r
-#include <common/executor.h>\r
-\r
-namespace caspar { namespace accelerator { namespace ogl {\r
-\r
-class texture;\r
-\r
-class device sealed : public std::enable_shared_from_this<device>\r
-{ \r
- device(const device&);\r
- device& operator=(const device&);\r
-\r
- executor executor_;\r
-public: \r
-\r
- // Static Members\r
-\r
- // Constructors\r
-\r
- device();\r
- ~device();\r
-\r
- // Methods\r
- \r
- spl::shared_ptr<texture> create_texture(int width, int height, int stride);\r
- array<std::uint8_t> create_array(int size);\r
-\r
- boost::unique_future<spl::shared_ptr<texture>> copy_async(const array<const std::uint8_t>& source, int width, int height, int stride);\r
- boost::unique_future<spl::shared_ptr<texture>> copy_async(const array<std::uint8_t>& source, int width, int height, int stride);\r
- boost::unique_future<array<const std::uint8_t>> copy_async(const spl::shared_ptr<texture>& source);\r
- \r
- template<typename Func>\r
- auto begin_invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> boost::unique_future<decltype(func())> // noexcept\r
- { \r
- return executor_.begin_invoke(std::forward<Func>(func), priority);\r
- }\r
- \r
- template<typename Func>\r
- auto invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> decltype(func())\r
- {\r
- return executor_.invoke(std::forward<Func>(func), priority);\r
- }\r
-\r
- // Properties\r
- \r
- std::wstring version() const;\r
-\r
-private:\r
- struct impl;\r
- spl::shared_ptr<impl> impl_;\r
-};\r
-\r
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#pragma once
+
+#include <core/frame/frame.h>
+
+#include <common/memory.h>
+#include <common/executor.h>
+#include <common/except.h>
+
+#include <boost/property_tree/ptree_fwd.hpp>
+
+namespace caspar { namespace accelerator { namespace ogl {
+
+class texture;
+
+class device final : public std::enable_shared_from_this<device>
+{
+ device(const device&);
+ device& operator=(const device&);
+
+ executor executor_;
+public:
+
+ // Static Members
+
+ // Constructors
+
+ device();
+ ~device();
+
+ // Methods
+
+ spl::shared_ptr<texture> create_texture(int width, int height, int stride, bool mipmapped);
+ array<std::uint8_t> create_array(int size);
+
+ // NOTE: Since the returned texture is cached it SHOULD NOT be modified.
+ std::future<std::shared_ptr<texture>> copy_async(const array<const std::uint8_t>& source, int width, int height, int stride, bool mipmapped);
+
+ std::future<std::shared_ptr<texture>> copy_async(const array<std::uint8_t>& source, int width, int height, int stride, bool mipmapped);
+ std::future<array<const std::uint8_t>> copy_async(const spl::shared_ptr<texture>& source);
+
+ template<typename Func>
+ auto begin_invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> std::future<decltype(func())> // noexcept
+ {
+ auto context = executor_.is_current() ? std::string() : get_context();
+
+ return executor_.begin_invoke([func, context]() mutable
+ {
+ CASPAR_SCOPED_CONTEXT_MSG(context);
+ return func();
+ }, priority);
+ }
+
+ template<typename Func>
+ auto invoke(Func&& func, task_priority priority = task_priority::normal_priority) -> decltype(func())
+ {
+ auto context = executor_.is_current() ? std::string() : get_context();
+
+ return executor_.invoke([func, context]() mutable
+ {
+ CASPAR_SCOPED_CONTEXT_MSG(context);
+ return func();
+ }, priority);
+ }
+
+ std::future<void> gc();
+
+ // Properties
+
+ boost::property_tree::wptree info() const;
+ std::wstring version() const;
+
+private:
+ struct impl;
+ spl::shared_ptr<impl> impl_;
+};
+
}}}
\ No newline at end of file