aboutsummaryrefslogtreecommitdiff
path: root/src/wld/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wld/buffer.c')
-rw-r--r--src/wld/buffer.c149
1 files changed, 81 insertions, 68 deletions
diff --git a/src/wld/buffer.c b/src/wld/buffer.c
index e0dfee6..46b1b3b 100644
--- a/src/wld/buffer.c
+++ b/src/wld/buffer.c
@@ -21,104 +21,117 @@
* SOFTWARE.
*/
-#include "wld/wld-private.h"
-
-void buffer_initialize(struct buffer *buffer,
- const struct wld_buffer_impl *impl, uint32_t width,
- uint32_t height, uint32_t format, uint32_t pitch) {
- *((const struct wld_buffer_impl **)&buffer->base.impl) = impl;
- buffer->base.width = width;
- buffer->base.height = height;
- buffer->base.format = format;
- buffer->base.pitch = pitch;
- buffer->base.map = NULL;
- buffer->references = 1;
- buffer->map_references = 0;
- buffer->exporters = NULL;
- buffer->destructors = NULL;
- pixman_region32_init_rect(&buffer->base.damage, 0, 0, width, height);
+#include "wld-private.h"
+
+void buffer_initialize(struct buffer * buffer,
+ const struct wld_buffer_impl * impl,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch)
+{
+ *((const struct wld_buffer_impl **) &buffer->base.impl) = impl;
+ buffer->base.width = width;
+ buffer->base.height = height;
+ buffer->base.format = format;
+ buffer->base.pitch = pitch;
+ buffer->base.map = NULL;
+ buffer->references = 1;
+ buffer->map_references = 0;
+ buffer->exporters = NULL;
+ buffer->destructors = NULL;
+ pixman_region32_init_rect(&buffer->base.damage, 0, 0, width, height);
}
EXPORT
-bool wld_map(struct wld_buffer *base) {
- struct buffer *buffer = (void *)base;
+bool wld_map(struct wld_buffer * base)
+{
+ struct buffer * buffer = (void *) base;
- if (buffer->map_references == 0 && !buffer->base.impl->map(buffer))
- return false;
+ if (buffer->map_references == 0 && !buffer->base.impl->map(buffer))
+ return false;
- ++buffer->map_references;
- return true;
+ ++buffer->map_references;
+ return true;
}
EXPORT
-bool wld_unmap(struct wld_buffer *base) {
- struct buffer *buffer = (void *)base;
-
- if (buffer->map_references == 0 ||
- (buffer->map_references == 1 && !buffer->base.impl->unmap(buffer))) {
- return false;
- }
-
- --buffer->map_references;
- return true;
+bool wld_unmap(struct wld_buffer * base)
+{
+ struct buffer * buffer = (void *) base;
+
+ if (buffer->map_references == 0
+ || (buffer->map_references == 1 && !buffer->base.impl->unmap(buffer)))
+ {
+ return false;
+ }
+
+ --buffer->map_references;
+ return true;
}
EXPORT
-bool wld_export(struct wld_buffer *base, uint32_t type,
- union wld_object *object) {
- struct buffer *buffer = (void *)base;
- struct wld_exporter *exporter;
+bool wld_export(struct wld_buffer * base,
+ uint32_t type, union wld_object * object)
+{
+ struct buffer * buffer = (void *) base;
+ struct wld_exporter * exporter;
+
+ for (exporter = buffer->exporters; exporter; exporter = exporter->next)
+ {
+ if (exporter->export(exporter, &buffer->base, type, object))
+ return true;
+ }
- for (exporter = buffer->exporters; exporter; exporter = exporter->next) {
- if (exporter->export(exporter, &buffer->base, type, object))
- return true;
- }
-
- return false;
+ return false;
}
EXPORT
-void wld_buffer_add_exporter(struct wld_buffer *base,
- struct wld_exporter *exporter) {
- struct buffer *buffer = (void *)base;
+void wld_buffer_add_exporter(struct wld_buffer * base,
+ struct wld_exporter * exporter)
+{
+ struct buffer * buffer = (void *) base;
- exporter->next = buffer->exporters;
- buffer->exporters = exporter;
+ exporter->next = buffer->exporters;
+ buffer->exporters = exporter;
}
EXPORT
-void wld_buffer_add_destructor(struct wld_buffer *base,
- struct wld_destructor *destructor) {
- struct buffer *buffer = (void *)base;
+void wld_buffer_add_destructor(struct wld_buffer * base,
+ struct wld_destructor * destructor)
+{
+ struct buffer * buffer = (void *) base;
- destructor->next = buffer->destructors;
- buffer->destructors = destructor;
+ destructor->next = buffer->destructors;
+ buffer->destructors = destructor;
}
EXPORT
-void wld_buffer_reference(struct wld_buffer *base) {
- struct buffer *buffer = (void *)base;
+void wld_buffer_reference(struct wld_buffer * base)
+{
+ struct buffer * buffer = (void *) base;
- ++buffer->references;
+ ++buffer->references;
}
EXPORT
-void wld_buffer_unreference(struct wld_buffer *base) {
- struct buffer *buffer = (void *)base;
- struct wld_destructor *destructor, *next;
+void wld_buffer_unreference(struct wld_buffer * base)
+{
+ struct buffer * buffer = (void *) base;
+ struct wld_destructor * destructor, * next;
- if (--buffer->references > 0)
- return;
+ if (--buffer->references > 0)
+ return;
- pixman_region32_fini(&buffer->base.damage);
+ pixman_region32_fini(&buffer->base.damage);
- for (destructor = buffer->destructors; destructor; destructor = next) {
- next = destructor->next;
- destructor->destroy(destructor);
- }
+ for (destructor = buffer->destructors; destructor; destructor = next)
+ {
+ next = destructor->next;
+ destructor->destroy(destructor);
+ }
- if (buffer->map_references > 0)
- buffer->base.impl->unmap(buffer);
+ if (buffer->map_references > 0)
+ buffer->base.impl->unmap(buffer);
- buffer->base.impl->destroy(buffer);
+ buffer->base.impl->destroy(buffer);
}
+