]> git.sesse.net Git - casparcg/blobdiff - accelerator/ogl/util/device.h
#430 Fixed bug where it was assumed that all Decklink devices implements the IDeckLin...
[casparcg] / accelerator / ogl / util / device.h
index b97f45be3b2eda15d81f5cf288304b1167b7a582..faef96cc8f8fe9cdd9fa4074be32d7f27d1fd422 100644 (file)
 
 #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>
+class device final : public std::enable_shared_from_this<device>
 {      
        device(const device&);
        device& operator=(const device&);
@@ -47,30 +50,45 @@ public:
 
        // Methods
                        
-       spl::shared_ptr<texture> create_texture(int width, int height, int stride);
+       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);
+       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);
+       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
        {                       
-               return executor_.begin_invoke(std::forward<Func>(func), priority);
+               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())
        {
-               return executor_.invoke(std::forward<Func>(func), priority);
+               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
        
-       std::wstring version() const;
+       boost::property_tree::wptree    info() const;
+       std::wstring                                    version() const;
 
 private:
        struct impl;