\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
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
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
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
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
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
{\r
ptr_ = other.ptr_;\r
size_ = other.size_;\r
+ cacheable_ = other.cacheable_;\r
storage_ = std::move(other.storage_);\r
\r
CASPAR_ASSERT(storage_);\r
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
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
\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
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
// 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
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
private:\r
std::uint8_t* ptr_;\r
std::size_t size_;\r
+ bool cacheable_;\r
std::unique_ptr<boost::any> storage_;\r
};\r
\r
// 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
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
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
\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