]> git.sesse.net Git - casparcg/commitdiff
2.1.0: array: Added "cacheable" property.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 18 Feb 2012 14:24:26 +0000 (14:24 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 18 Feb 2012 14:24:26 +0000 (14:24 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.1.0@2447 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

accelerator/cpu/image/image_mixer.cpp
accelerator/ogl/image/image_mixer.cpp
accelerator/ogl/util/device.cpp
common/memory/array.cpp
common/memory/array.h
core/frame/frame.cpp

index 34c5727d1a28589a876f4090b2884042cfd358e8..00e4253d879d01157da3b531f1e46fdfc0346203 100644 (file)
@@ -174,7 +174,7 @@ public:
                \r
                return async(launch::deferred, [=]\r
                {\r
-                       return core::const_array(result->data(), format_desc.size, result);\r
+                       return core::const_array(result->data(), format_desc.size, true, result);\r
                });     \r
        }\r
 \r
@@ -358,7 +358,7 @@ public:
                BOOST_FOREACH(auto& plane, desc.planes)\r
                {\r
                        auto buf = spl::make_shared<buffer>(plane.size);\r
-                       buffers.push_back(core::mutable_array(buf->data(), plane.size, buf));\r
+                       buffers.push_back(core::mutable_array(buf->data(), plane.size, true, buf));\r
                }\r
                return core::mutable_frame(std::move(buffers), core::audio_buffer(), tag, desc, frame_rate, field_mode);\r
        }\r
index 7084d0a0832ff72ddd091bab9a50f85c925e934a..08ce960601e52e582044b860647a922f33cc2847 100644 (file)
@@ -103,7 +103,7 @@ public:
                        auto buffer = spl::make_shared<const std::vector<uint8_t, tbb::cache_aligned_allocator<uint8_t>>>(format_desc.size, 0);\r
                        return async(launch::deferred, [=]\r
                        {\r
-                               return core::const_array(buffer->data(), static_cast<std::size_t>(format_desc.size), buffer);\r
+                               return core::const_array(buffer->data(), static_cast<std::size_t>(format_desc.size), true, buffer);\r
                        });\r
                }               \r
 \r
index d4e22a5c6d7592dc555e21bdc35ebc2568705465..706e6119a8c18721a1668606f9fc70d1c4adfc7f 100644 (file)
@@ -211,7 +211,7 @@ struct device::impl : public std::enable_shared_from_this<impl>
        core::mutable_array create_array(int size)\r
        {               \r
                auto buf = create_buffer(size, buffer::usage::write_only);\r
-               return core::mutable_array(buf->data(), buf->size(), buf);\r
+               return core::mutable_array(buf->data(), buf->size(), false, buf);\r
        }\r
 \r
        boost::unique_future<spl::shared_ptr<texture>> copy_async(const core::const_array& source, int width, int height, int stride)\r
@@ -247,7 +247,7 @@ struct device::impl : public std::enable_shared_from_this<impl>
                                if(!buf->data())\r
                                        alloc_executor_.invoke(std::bind(&buffer::map, std::ref(buf))); // Defer blocking "map" call until data is needed.\r
 \r
-                               return core::const_array(buf->data(), buf->size(), buffer);\r
+                               return core::const_array(buf->data(), buf->size(), true, buffer);\r
                        }));\r
                }, task_priority::high_priority));\r
        }\r
index 5540098c880e525fc4dc9fa942eafd5f1290c387..f635d0e2816366d77e1d4dc86699c4f04f2d7d21 100644 (file)
@@ -30,6 +30,7 @@ namespace caspar { namespace core {
 mutable_array::mutable_array(mutable_array&& other)\r
        : ptr_(other.ptr_)\r
        , size_(other.size_)\r
+       , cacheable_(other.cacheable_)\r
        , storage_(std::move(other.storage_))\r
 {\r
        CASPAR_ASSERT(storage_);\r
@@ -39,6 +40,7 @@ mutable_array& mutable_array::operator=(mutable_array&& other)
 {\r
        ptr_            = other.ptr_;\r
        size_           = other.size_;\r
+       cacheable_  = other.cacheable_;\r
        storage_        = std::move(other.storage_);\r
 \r
        CASPAR_ASSERT(storage_);\r
@@ -54,10 +56,12 @@ const std::uint8_t* mutable_array::data() const             {return ptr_;}
 const std::uint8_t* mutable_array::end() const         {return ptr_ + size_;}\r
 std::size_t mutable_array::size() const                                {return size_;}\r
 bool mutable_array::empty() const                                      {return size() == 0;}\r
+bool mutable_array::cacheable() const                          {return cacheable_;}\r
 \r
 const_array::const_array(const const_array& other)\r
        : ptr_(other.ptr_)\r
        , size_(other.size_)\r
+       , cacheable_(other.cacheable_)\r
        , storage_(other.storage_)\r
 {\r
        CASPAR_ASSERT(storage_);\r
@@ -66,6 +70,7 @@ const_array::const_array(const const_array& other)
 const_array::const_array(mutable_array&& other)\r
        : ptr_(other.ptr_)\r
        , size_(other.size_)\r
+       , cacheable_(other.cacheable_)\r
        , storage_(std::move(other.storage_))\r
 {\r
        CASPAR_ASSERT(storage_);\r
@@ -79,9 +84,10 @@ const_array& const_array::operator=(const const_array& other)
 \r
 void const_array::swap(const_array& other)\r
 {\r
-       std::swap(ptr_, other.ptr_);\r
-       std::swap(size_, other.size_);\r
-       std::swap(storage_, other.storage_);\r
+       ptr_            = other.ptr_;\r
+       size_           = other.size_;\r
+       storage_        = other.storage_;\r
+       cacheable_      = other.cacheable_;\r
 }\r
                        \r
 const std::uint8_t* const_array::begin() const {return ptr_;}          \r
@@ -89,5 +95,6 @@ const std::uint8_t* const_array::data() const {return ptr_;}
 const std::uint8_t* const_array::end() const   {return ptr_ + size_;}\r
 std::size_t const_array::size() const                  {return size_;}\r
 bool const_array::empty() const                                        {return size() == 0;}\r
+bool const_array::cacheable() const                            {return cacheable_;}\r
 \r
 }}
\ No newline at end of file
index 22aeb3d18839dfd7dd88382631d8ad108725c224..90e649e7e0333f7bb7a570ba55081674e1fe2763 100644 (file)
@@ -25,9 +25,10 @@ public:
        // Constructors\r
        \r
        template<typename T>\r
-       explicit mutable_array(std::uint8_t* ptr, std::size_t size, T&& storage)\r
+       explicit mutable_array(std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage)\r
                : ptr_(ptr)\r
                , size_(size)\r
+               , cacheable_(cacheable)\r
                , storage_(new boost::any(std::forward<T>(storage)))\r
        {\r
        }\r
@@ -48,6 +49,7 @@ public:
        const std::uint8_t* end() const;\r
        std::size_t size() const;\r
        bool empty() const;\r
+       bool cacheable() const;\r
        \r
        template<typename T>\r
        T storage() const\r
@@ -57,6 +59,7 @@ public:
 private:\r
        std::uint8_t*   ptr_;\r
        std::size_t             size_;\r
+       bool                    cacheable_;\r
        std::unique_ptr<boost::any>     storage_;\r
 };\r
 \r
@@ -69,9 +72,10 @@ public:
        // Constructors\r
 \r
        template<typename T>\r
-       explicit const_array(const std::uint8_t* ptr, std::size_t size, T&& storage)\r
+       explicit const_array(const std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage)\r
                : ptr_(ptr)\r
                , size_(size)\r
+               , cacheable_(cacheable)\r
                , storage_(new boost::any(std::forward<T>(storage)))\r
        {\r
        }\r
@@ -91,6 +95,7 @@ public:
        const std::uint8_t* end() const;\r
        std::size_t size() const;\r
        bool empty() const;\r
+       bool cacheable() const;\r
 \r
        template<typename T>\r
        T storage() const\r
@@ -101,6 +106,7 @@ public:
 private:\r
        const std::uint8_t*     ptr_;\r
        std::size_t                     size_;\r
+       bool                            cacheable_;\r
        std::shared_ptr<boost::any>     storage_;\r
 };\r
 \r
index 3ab7b8c939b5441673e4543e62a1f86e46203128..34ad6887efc7eb436bc4258c16b4ca319e21d54c 100644 (file)
@@ -136,7 +136,7 @@ struct const_frame::impl : boost::noncopyable
 \r
        const_array image_data(int index) const\r
        {\r
-               return tag_ != empty().tag() ? future_buffers_.at(index).get() : const_array(nullptr, 0, 0);\r
+               return tag_ != empty().tag() ? future_buffers_.at(index).get() : const_array(nullptr, 0, true, 0);\r
        }\r
 \r
        std::size_t width() const\r