libvisual  0.5.0
lv_buffer_c.cpp
1 #include "config.h"
2 #include "lv_buffer.h"
3 #include "lv_common.h"
4 
5 VisBuffer *visual_buffer_new (void)
6 {
7  auto self = LV::Buffer::create ();
8  if (self) {
9  LV::intrusive_ptr_add_ref (self.get ());
10  }
11 
12  return self.get ();
13 }
14 
15 VisBuffer *visual_buffer_new_wrap_data (void *data, visual_size_t size, int own)
16 {
17  auto self = LV::Buffer::wrap (data, size, own);
18  if (self) {
19  LV::intrusive_ptr_add_ref (self.get ());
20  }
21 
22  return self.get ();
23 }
24 
25 VisBuffer *visual_buffer_new_allocate (visual_size_t size)
26 {
27  auto self = LV::Buffer::create (size);
28  if (self) {
29  LV::intrusive_ptr_add_ref (self.get ());
30  }
31 
32  return self.get ();
33 }
34 
35 VisBuffer *visual_buffer_clone (VisBuffer *source)
36 {
37  visual_return_val_if_fail (source != nullptr, nullptr);
38 
39  auto self = LV::Buffer::create ();
40  if (self) {
41  LV::intrusive_ptr_add_ref (self.get ());
42  self->copy (LV::BufferPtr (source));
43  }
44 
45  return self.get ();
46 }
47 
48 void visual_buffer_free (VisBuffer *self)
49 {
50  delete self;
51 }
52 
53 void visual_buffer_set_data_pair (VisBuffer *self, void *data, visual_size_t size)
54 {
55  visual_return_if_fail (self != nullptr);
56 
57  self->set (data, size);
58 }
59 
60 void visual_buffer_set_data (VisBuffer *self, void *data)
61 {
62  visual_return_if_fail (self != nullptr);
63 
64  self->set_data (data);
65 }
66 
67 void *visual_buffer_get_data (VisBuffer *self)
68 {
69  visual_return_val_if_fail (self != nullptr, nullptr);
70 
71  return self->get_data ();
72 }
73 
74 void *visual_buffer_get_data_offset (VisBuffer *self, visual_size_t offset)
75 {
76  visual_return_val_if_fail (self != nullptr, nullptr);
77 
78  return self->get_data (offset);
79 }
80 
81 void visual_buffer_set_size (VisBuffer *self, visual_size_t size)
82 {
83  visual_return_if_fail (self != nullptr);
84 
85  self->set_size (size);
86 }
87 
88 visual_size_t visual_buffer_get_size (VisBuffer *self)
89 {
90  visual_return_val_if_fail (self != nullptr, 0);
91 
92  return self->get_size ();
93 }
94 
95 int visual_buffer_is_allocated (VisBuffer *self)
96 {
97  visual_return_val_if_fail (self != nullptr, FALSE);
98 
99  return self->is_allocated ();
100 }
101 
102 void visual_buffer_allocate (VisBuffer *self, visual_size_t size)
103 {
104  visual_return_if_fail (self != nullptr);
105 
106  return self->allocate (size);
107 }
108 
109 void visual_buffer_destroy_content (VisBuffer *self)
110 {
111  visual_return_if_fail (self != nullptr);
112 
113  self->destroy_content ();
114 }
115 
116 void visual_buffer_copy_to (VisBuffer *self, VisBuffer *dest)
117 {
118  visual_return_if_fail (self != nullptr);
119  visual_return_if_fail (dest != nullptr);
120 
121  self->copy_to (dest);
122 }
123 
124 void visual_buffer_copy_to_data (VisBuffer *self, void *dest, visual_size_t size)
125 {
126  visual_return_if_fail (self != nullptr);
127  visual_return_if_fail (dest != nullptr);
128 
129  self->copy_to (dest, size);
130 }
131 
132 void visual_buffer_put (VisBuffer *self, VisBuffer *src, visual_size_t offset)
133 {
134  visual_return_if_fail (self != nullptr);
135 
136  self->put (LV::BufferPtr (src), offset);
137 }
138 
139 void visual_buffer_put_data (VisBuffer *self, const void *data, visual_size_t size, visual_size_t offset)
140 {
141  visual_return_if_fail (self != nullptr);
142 
143  self->put (data, size, offset);
144 }
145 
146 void visual_buffer_fill (VisBuffer *self, uint8_t value)
147 {
148  visual_return_if_fail (self != nullptr);
149 
150  self->fill (value);
151 }
152 
153 void visual_buffer_fill_with_pattern (VisBuffer *self, const void *data, visual_size_t size)
154 {
155  visual_return_if_fail (self != nullptr);
156 
157  self->fill_with_pattern (data, size);
158 }
159 
160 void visual_buffer_ref (VisBuffer *self)
161 {
162  visual_return_if_fail (self != nullptr);
163 
164  LV::intrusive_ptr_add_ref (self);
165 }
166 
167 void visual_buffer_unref (VisBuffer *self)
168 {
169  visual_return_if_fail (self != nullptr);
170 
171  LV::intrusive_ptr_release (self);
172 }