27 #include <libvisual/lvconfig.h>
28 #include <libvisual/lv_defines.h>
29 #include <libvisual/lv_types.h>
38 #include <libvisual/lv_intrusive_ptr.hpp>
46 typedef IntrusivePtr<Buffer> BufferPtr;
47 typedef IntrusivePtr<Buffer const> BufferConstPtr;
72 static BufferPtr wrap (
void *data, std::size_t size,
bool own =
true);
79 static BufferPtr create (std::size_t size);
86 void destroy_content ();
96 void set (
void* data, std::size_t size);
106 void set_size (std::size_t size);
116 void set_data (
void* data);
126 void allocate (std::size_t size);
133 void* get_data ()
const;
142 void* get_data (std::size_t offset)
const;
149 std::size_t get_size ()
const;
156 bool is_allocated ()
const;
178 void copy_to (
void *dest, std::size_t size);
195 void put (
void const* data, std::size_t size, std::size_t offset);
202 void fill (uint8_t value);
210 void fill_with_pattern (
void const* data, std::size_t size);
214 friend void intrusive_ptr_add_ref (
Buffer const* buffer);
215 friend void intrusive_ptr_release (
Buffer const* buffer);
218 const std::unique_ptr<Impl> m_impl;
220 mutable unsigned int m_ref_count;
225 inline void intrusive_ptr_add_ref (
Buffer const* buffer)
227 buffer->m_ref_count++;
230 inline void intrusive_ptr_release (Buffer
const* buffer)
232 if (--buffer->m_ref_count == 0) {
244 typedef struct _VisBuffer VisBuffer;
250 LV_API VisBuffer *visual_buffer_new (
void);
251 LV_API VisBuffer *visual_buffer_new_wrap_data (
void *data, visual_size_t size,
int own);
252 LV_API VisBuffer *visual_buffer_new_allocate (visual_size_t size);
253 LV_API VisBuffer *visual_buffer_clone (VisBuffer *source);
255 LV_API
void visual_buffer_set_data_pair (VisBuffer *buffer,
void *data, visual_size_t size);
256 LV_API
void visual_buffer_set_data (VisBuffer *buffer,
void *data);
257 LV_API
void *visual_buffer_get_data (VisBuffer *buffer);
258 LV_API
void *visual_buffer_get_data_offset (VisBuffer *buffer, visual_size_t offset);
260 LV_API
void visual_buffer_set_size (VisBuffer *buffer, visual_size_t size);
261 LV_API visual_size_t visual_buffer_get_size (VisBuffer *buffer);
263 LV_API
int visual_buffer_is_allocated (VisBuffer *buffer);
264 LV_API
void visual_buffer_allocate (VisBuffer *buffer, visual_size_t size);
265 LV_API
void visual_buffer_destroy_content (VisBuffer *buffer);
267 LV_API
void visual_buffer_copy_to (VisBuffer *src, VisBuffer *dest);
268 LV_API
void visual_buffer_copy_to_data (VisBuffer *src,
void *dest, visual_size_t size);
270 LV_API
void visual_buffer_put (VisBuffer *dest, VisBuffer *src, visual_size_t offset);
271 LV_API
void visual_buffer_put_data (VisBuffer *dest,
const void *data, visual_size_t size, visual_size_t offset);
273 LV_API
void visual_buffer_fill (VisBuffer *buffer, uint8_t value);
274 LV_API
void visual_buffer_fill_with_pattern (VisBuffer *buffer,
const void *data, visual_size_t size);
276 LV_API
void visual_buffer_ref (VisBuffer *buffer);
277 LV_API
void visual_buffer_unref (VisBuffer *buffer);