commit c53915e66a530facebdaae94e0f418be6dc1fafa
parent e9462f03b18072aad3ded11ee08de5b38d6d61f0
Author: Michael Forney <mforney@mforney.org>
Date: Tue, 14 Jan 2014 01:04:46 -0800
Rename drawable -> buffer
Since buffers can not only be drawn to, but also copied from, I thought
buffer was a better name.
Diffstat:
21 files changed, 429 insertions(+), 419 deletions(-)
diff --git a/Makefile b/Makefile
@@ -16,9 +16,9 @@ CLEAN_FILES := $(TARGETS)
WLD_REQUIRES = fontconfig pixman-1
WLD_REQUIRES_PRIVATE = freetype2
WLD_SOURCES = \
+ buffer.c \
color.c \
context.c \
- drawable.c \
font.c \
renderer.c
WLD_HEADERS = wld.h
diff --git a/buffer.c b/buffer.c
@@ -0,0 +1,106 @@
+/* wld: buffer.c
+ *
+ * Copyright (c) 2013, 2014 Michael Forney
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "wld-private.h"
+
+void buffer_initialize(struct wld_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->impl) = impl;
+ buffer->width = width;
+ buffer->height = height;
+ buffer->format = format;
+ buffer->pitch = pitch;
+ buffer->map.data = NULL;
+ buffer->map.count = 0;
+ buffer->exporters = NULL;
+}
+
+void buffer_add_exporter(struct wld_buffer * buffer,
+ struct wld_exporter * exporter)
+{
+ exporter->next = buffer->exporters;
+ buffer->exporters = exporter;
+}
+
+void exporter_initialize(struct wld_exporter * exporter,
+ const struct wld_exporter_impl * impl)
+{
+ *((const struct wld_exporter_impl **) &exporter->impl) = impl;
+ exporter->next = NULL;
+}
+
+EXPORT
+bool wld_map(struct wld_buffer * buffer)
+{
+ if (buffer->map.count == 0 && !buffer->impl->map(buffer))
+ return false;
+
+ ++buffer->map.count;
+ return true;
+}
+
+EXPORT
+bool wld_unmap(struct wld_buffer * buffer)
+{
+ if (buffer->map.count == 0
+ || (buffer->map.count == 1 && !buffer->impl->unmap(buffer)))
+ {
+ return false;
+ }
+
+ --buffer->map.count;
+ return true;
+}
+
+EXPORT
+bool wld_export(struct wld_buffer * buffer,
+ uint32_t type, union wld_object * object)
+{
+ struct wld_exporter * exporter;
+
+ for (exporter = buffer->exporters; exporter; exporter = exporter->next)
+ {
+ if (exporter->impl->export(exporter, buffer, type, object))
+ return true;
+ }
+
+ return false;
+}
+
+EXPORT
+void wld_destroy_buffer(struct wld_buffer * buffer)
+{
+ struct wld_exporter * exporter;
+
+ if (buffer->map.count > 0)
+ wld_unmap(buffer);
+
+ for (exporter = buffer->exporters; exporter; exporter = exporter->next)
+ exporter->impl->destroy(exporter);
+
+ buffer->impl->destroy(buffer);
+}
+
diff --git a/context.c b/context.c
@@ -36,21 +36,21 @@ struct wld_renderer * wld_create_renderer(struct wld_context * context)
}
EXPORT
-struct wld_drawable * wld_create_drawable(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format)
+struct wld_buffer * wld_create_buffer(struct wld_context * context,
+ uint32_t width, uint32_t height,
+ uint32_t format)
{
- return context->impl->create_drawable(context, width, height, format);
+ return context->impl->create_buffer(context, width, height, format);
}
EXPORT
-struct wld_drawable * wld_import(struct wld_context * context,
- uint32_t type, union wld_object object,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch)
+struct wld_buffer * wld_import_buffer(struct wld_context * context,
+ uint32_t type, union wld_object object,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch)
{
- return context->impl->import(context, type, object,
- width, height, format, pitch);
+ return context->impl->import_buffer(context, type, object,
+ width, height, format, pitch);
}
EXPORT
diff --git a/drawable.c b/drawable.c
@@ -1,100 +0,0 @@
-/* wld: drawable.c
- *
- * Copyright (c) 2013 Michael Forney
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "wld-private.h"
-
-#include <assert.h>
-
-void drawable_initialize(struct wld_drawable * drawable,
- const struct wld_drawable_impl * impl,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch)
-{
- *((const struct wld_drawable_impl **) &drawable->impl) = impl;
- drawable->width = width;
- drawable->height = height;
- drawable->format = format;
- drawable->pitch = pitch;
- drawable->map.data = NULL;
- drawable->map.count = 0;
- drawable->exporters = NULL;
-}
-
-void drawable_add_exporter(struct wld_drawable * drawable,
- struct wld_exporter * exporter)
-{
- exporter->next = drawable->exporters;
- drawable->exporters = exporter;
-}
-
-void exporter_initialize(struct wld_exporter * exporter,
- const struct wld_exporter_impl * impl)
-{
- *((const struct wld_exporter_impl **) &exporter->impl) = impl;
- exporter->next = NULL;
-}
-
-EXPORT
-bool wld_map(struct wld_drawable * drawable)
-{
- if (drawable->map.count == 0 && !drawable->impl->map(drawable))
- return false;
-
- ++drawable->map.count;
- return true;
-}
-
-EXPORT
-bool wld_unmap(struct wld_drawable * drawable)
-{
- if (drawable->map.count == 0
- || (drawable->map.count == 1 && !drawable->impl->unmap(drawable)))
- {
- return false;
- }
-
- --drawable->map.count;
- return true;
-}
-
-EXPORT
-bool wld_export(struct wld_drawable * drawable,
- uint32_t type, union wld_object * object)
-{
- struct wld_exporter * exporter;
-
- for (exporter = drawable->exporters; exporter; exporter = exporter->next)
- {
- if (exporter->impl->export(exporter, drawable, type, object))
- return true;
- }
-
- return false;
-}
-
-EXPORT
-void wld_destroy_drawable(struct wld_drawable * drawable)
-{
- drawable->impl->destroy(drawable);
-}
-
diff --git a/dumb.c b/dumb.c
@@ -38,21 +38,21 @@ struct dumb_context
int fd;
};
-struct dumb_drawable
+struct dumb_buffer
{
- struct wld_drawable base;
+ struct wld_buffer base;
struct wld_exporter exporter;
struct dumb_context * context;
uint32_t handle;
};
#include "interface/context.h"
-#include "interface/drawable.h"
+#include "interface/buffer.h"
#include "interface/exporter.h"
#define DRM_DRIVER_NAME dumb
#include "interface/drm.h"
IMPL(dumb, context)
-IMPL(dumb, drawable)
+IMPL(dumb, buffer)
const struct wld_context_impl * dumb_context_impl = &context_impl;
@@ -79,32 +79,32 @@ struct wld_renderer * context_create_renderer(struct wld_context * context)
return wld_create_renderer(wld_pixman_context);
}
-static struct wld_drawable * new_drawable(struct dumb_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t handle,
- unsigned long pitch)
+static struct wld_buffer * new_buffer(struct dumb_context * context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t handle,
+ unsigned long pitch)
{
- struct dumb_drawable * drawable;
+ struct dumb_buffer * buffer;
- if (!(drawable = malloc(sizeof *drawable)))
+ if (!(buffer = malloc(sizeof *buffer)))
return NULL;
- drawable_initialize(&drawable->base, &drawable_impl,
- width, height, format, pitch);
- drawable->context = context;
- drawable->handle = handle;
- exporter_initialize(&drawable->exporter, &exporter_impl);
- drawable_add_exporter(&drawable->base, &drawable->exporter);
+ buffer_initialize(&buffer->base, &buffer_impl,
+ width, height, format, pitch);
+ buffer->context = context;
+ buffer->handle = handle;
+ exporter_initialize(&buffer->exporter, &exporter_impl);
+ buffer_add_exporter(&buffer->base, &buffer->exporter);
- return &drawable->base;
+ return &buffer->base;
}
-struct wld_drawable * context_create_drawable(struct wld_context * base,
- uint32_t width, uint32_t height,
- uint32_t format)
+struct wld_buffer * context_create_buffer(struct wld_context * base,
+ uint32_t width, uint32_t height,
+ uint32_t format)
{
struct dumb_context * context = dumb_context(base);
- struct wld_drawable * drawable;
+ struct wld_buffer * buffer;
struct drm_mode_create_dumb create_dumb_arg = {
.height = height, .width = width,
.bpp = format_bytes_per_pixel(format) * 8,
@@ -116,13 +116,13 @@ struct wld_drawable * context_create_drawable(struct wld_context * base,
if (ret != 0)
goto error0;
- drawable = new_drawable(context, width, height, format,
- create_dumb_arg.handle, create_dumb_arg.pitch);
+ buffer = new_buffer(context, width, height, format,
+ create_dumb_arg.handle, create_dumb_arg.pitch);
- if (!drawable)
+ if (!buffer)
goto error1;
- return drawable;
+ return buffer;
error1:
{
@@ -136,10 +136,11 @@ struct wld_drawable * context_create_drawable(struct wld_context * base,
return NULL;
}
-struct wld_drawable * context_import(struct wld_context * base,
- uint32_t type, union wld_object object,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch)
+struct wld_buffer * context_import_buffer(struct wld_context * base,
+ uint32_t type,
+ union wld_object object,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch)
{
struct dumb_context * context = dumb_context(base);
uint32_t handle;
@@ -163,7 +164,7 @@ struct wld_drawable * context_import(struct wld_context * base,
default: return NULL;
}
- return new_drawable(context, width, height, format, handle, pitch);
+ return new_buffer(context, width, height, format, handle, pitch);
}
void context_destroy(struct wld_context * base)
@@ -174,66 +175,66 @@ void context_destroy(struct wld_context * base)
free(context);
}
-/**** Drawable ****/
+/**** Buffer ****/
-bool drawable_map(struct wld_drawable * drawable)
+bool buffer_map(struct wld_buffer * base)
{
- struct dumb_drawable * dumb = dumb_drawable(drawable);
- struct drm_mode_map_dumb map_dumb = { .handle = dumb->handle };
+ struct dumb_buffer * buffer = dumb_buffer(base);
+ struct drm_mode_map_dumb map_dumb = { .handle = buffer->handle };
void * data;
- if (drmIoctl(dumb->context->fd, DRM_IOCTL_MODE_MAP_DUMB,
+ if (drmIoctl(buffer->context->fd, DRM_IOCTL_MODE_MAP_DUMB,
&map_dumb) != 0)
{
return false;
}
- data = mmap(NULL, drawable->pitch * drawable->height, PROT_READ | PROT_WRITE,
- MAP_SHARED, dumb->context->fd, map_dumb.offset);
+ data = mmap(NULL, base->pitch * base->height, PROT_READ | PROT_WRITE,
+ MAP_SHARED, buffer->context->fd, map_dumb.offset);
if (data == MAP_FAILED)
return false;
- drawable->map.data = data;
+ buffer->base.map.data = data;
return true;
}
-bool drawable_unmap(struct wld_drawable * drawable)
+bool buffer_unmap(struct wld_buffer * buffer)
{
- if (munmap(drawable->map.data, drawable->pitch * drawable->height) == -1)
+ if (munmap(buffer->map.data, buffer->pitch * buffer->height) == -1)
return false;
- drawable->map.data = NULL;
+ buffer->map.data = NULL;
return true;
}
-void drawable_destroy(struct wld_drawable * drawable_base)
+void buffer_destroy(struct wld_buffer * base)
{
- struct dumb_drawable * drawable = dumb_drawable(drawable_base);
+ struct dumb_buffer * buffer = dumb_buffer(base);
struct drm_mode_destroy_dumb destroy_dumb = {
- .handle = drawable->handle
+ .handle = buffer->handle
};
- drmIoctl(drawable->context->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
- free(drawable);
+ drmIoctl(buffer->context->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
+ free(buffer);
}
/**** Exporter ****/
-bool exporter_export(struct wld_exporter * exporter, struct wld_drawable * base,
+bool exporter_export(struct wld_exporter * exporter, struct wld_buffer * base,
uint32_t type, union wld_object * object)
{
- struct dumb_drawable * drawable = dumb_drawable(base);
+ struct dumb_buffer * buffer = dumb_buffer(base);
switch (type)
{
case WLD_DRM_OBJECT_HANDLE:
- object->u32 = drawable->handle;
+ object->u32 = buffer->handle;
return true;
case WLD_DRM_OBJECT_PRIME_FD:
- if (drmPrimeHandleToFD(drawable->context->fd, drawable->handle,
+ if (drmPrimeHandleToFD(buffer->context->fd, buffer->handle,
DRM_CLOEXEC, &object->i) != 0)
{
return false;
@@ -242,13 +243,10 @@ bool exporter_export(struct wld_exporter * exporter, struct wld_drawable * base,
return true;
case WLD_DRM_OBJECT_GEM_NAME:
{
- struct drm_gem_flink flink = { .handle = drawable->handle };
+ struct drm_gem_flink flink = { .handle = buffer->handle };
- if (drmIoctl(drawable->context->fd, DRM_IOCTL_GEM_FLINK,
- &flink) != 0)
- {
+ if (drmIoctl(buffer->context->fd, DRM_IOCTL_GEM_FLINK, &flink) != 0)
return false;
- }
object->u32 = flink.name;
return true;
diff --git a/intel.c b/intel.c
@@ -40,25 +40,25 @@ struct intel_renderer
{
struct wld_renderer base;
struct intel_batch * batch;
- struct intel_drawable * target;
+ struct intel_buffer * target;
};
-struct intel_drawable
+struct intel_buffer
{
- struct wld_drawable base;
+ struct wld_buffer base;
struct wld_exporter exporter;
drm_intel_bo * bo;
};
#include "interface/context.h"
#include "interface/renderer.h"
-#include "interface/drawable.h"
+#include "interface/buffer.h"
#include "interface/exporter.h"
#define DRM_DRIVER_NAME intel
#include "interface/drm.h"
IMPL(intel, context)
IMPL(intel, renderer)
-IMPL(intel, drawable)
+IMPL(intel, buffer)
bool driver_device_supported(uint32_t vendor_id, uint32_t device_id)
{
@@ -110,47 +110,48 @@ struct wld_renderer * context_create_renderer(struct wld_context * base)
return NULL;
}
-static struct intel_drawable * new_drawable(uint32_t width, uint32_t height,
- uint32_t format)
+static struct intel_buffer * new_buffer(uint32_t width, uint32_t height,
+ uint32_t format)
{
- struct intel_drawable * intel;
+ struct intel_buffer * buffer;
- if (!(intel = malloc(sizeof *intel)))
+ if (!(buffer = malloc(sizeof *buffer)))
return NULL;
- drawable_initialize(&intel->base, &drawable_impl,
- width, height, format, 0);
- exporter_initialize(&intel->exporter, &exporter_impl);
- drawable_add_exporter(&intel->base, &intel->exporter);
+ buffer_initialize(&buffer->base, &buffer_impl,
+ width, height, format, 0);
+ exporter_initialize(&buffer->exporter, &exporter_impl);
+ buffer_add_exporter(&buffer->base, &buffer->exporter);
- return intel;
+ return buffer;
}
-struct wld_drawable * context_create_drawable(struct wld_context * base,
- uint32_t width, uint32_t height,
- uint32_t format)
+struct wld_buffer * context_create_buffer(struct wld_context * base,
+ uint32_t width, uint32_t height,
+ uint32_t format)
{
struct intel_context * context = intel_context(base);
- struct intel_drawable * intel;
+ struct intel_buffer * buffer;
uint32_t tiling_mode = width >= 128 ? I915_TILING_X : I915_TILING_NONE;
- if (!(intel = new_drawable(width, height, format)))
+ if (!(buffer = new_buffer(width, height, format)))
return NULL;
- intel->bo = drm_intel_bo_alloc_tiled(context->bufmgr, "drawable",
- width, height, 4, &tiling_mode,
- &intel->base.pitch, 0);
+ buffer->bo = drm_intel_bo_alloc_tiled(context->bufmgr, "buffer",
+ width, height, 4, &tiling_mode,
+ &buffer->base.pitch, 0);
- return &intel->base;
+ return &buffer->base;
}
-struct wld_drawable * context_import(struct wld_context * base,
- uint32_t type, union wld_object object,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch)
+struct wld_buffer * context_import_buffer(struct wld_context * base,
+ uint32_t type,
+ union wld_object object,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch)
{
struct intel_context * context = intel_context(base);
- struct intel_drawable * intel;
+ struct intel_buffer * buffer;
drm_intel_bo * bo;
switch (type)
@@ -172,13 +173,13 @@ struct wld_drawable * context_import(struct wld_context * base,
if (!bo)
goto error0;
- if (!(intel = new_drawable(width, height, format)))
+ if (!(buffer = new_buffer(width, height, format)))
goto error1;
- intel->bo = bo;
- intel->base.pitch = pitch;
+ buffer->bo = bo;
+ buffer->base.pitch = pitch;
- return &intel->base;
+ return &buffer->base;
error1:
drm_intel_bo_unreference(bo);
@@ -196,23 +197,23 @@ void context_destroy(struct wld_context * base)
/**** Renderer ****/
uint32_t renderer_capabilities(struct wld_renderer * renderer,
- struct wld_drawable * drawable)
+ struct wld_buffer * buffer)
{
- if (drawable->impl == &drawable_impl)
+ if (buffer->impl == &buffer_impl)
return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
return 0;
}
bool renderer_set_target(struct wld_renderer * base,
- struct wld_drawable * drawable)
+ struct wld_buffer * buffer)
{
struct intel_renderer * renderer = intel_renderer(base);
- if (drawable && drawable->impl != &drawable_impl)
+ if (buffer && buffer->impl != &buffer_impl)
return false;
- renderer->target = drawable ? intel_drawable(drawable) : NULL;
+ renderer->target = buffer ? intel_buffer(buffer) : NULL;
return true;
}
@@ -229,19 +230,19 @@ void renderer_fill_rectangle(struct wld_renderer * base, uint32_t color,
}
void renderer_copy_rectangle(struct wld_renderer * base,
- struct wld_drawable * drawable_base,
+ struct wld_buffer * buffer_base,
int32_t dst_x, int32_t dst_y,
int32_t src_x, int32_t src_y,
uint32_t width, uint32_t height)
{
struct intel_renderer * renderer = intel_renderer(base);
- if (drawable_base->impl != &drawable_impl)
+ if (buffer_base->impl != &buffer_impl)
return;
- struct intel_drawable * drawable = intel_drawable(drawable_base);
+ struct intel_buffer * buffer = intel_buffer(buffer_base);
- xy_src_copy_blt(renderer->batch, drawable->bo, drawable->base.pitch,
+ xy_src_copy_blt(renderer->batch, buffer->bo, buffer->base.pitch,
src_x, src_y,
renderer->target->bo, renderer->target->base.pitch,
dst_x, dst_y, width, height);
@@ -329,54 +330,56 @@ void renderer_destroy(struct wld_renderer * base)
free(renderer);
}
-bool drawable_map(struct wld_drawable * base)
+/**** Buffer ****/
+bool buffer_map(struct wld_buffer * base)
{
- struct intel_drawable * drawable = intel_drawable(base);
+ struct intel_buffer * buffer = intel_buffer(base);
- if (drm_intel_gem_bo_map_gtt(drawable->bo) != 0)
+ if (drm_intel_gem_bo_map_gtt(buffer->bo) != 0)
return false;
- drawable->base.map.data = drawable->bo->virtual;
+ buffer->base.map.data = buffer->bo->virtual;
return true;
}
-bool drawable_unmap(struct wld_drawable * base)
+bool buffer_unmap(struct wld_buffer * base)
{
- struct intel_drawable * drawable = intel_drawable(base);
+ struct intel_buffer * buffer = intel_buffer(base);
- if (drm_intel_gem_bo_unmap_gtt(drawable->bo) != 0)
+ if (drm_intel_gem_bo_unmap_gtt(buffer->bo) != 0)
return false;
- drawable->base.map.data = NULL;
+ buffer->base.map.data = NULL;
return true;
}
-void drawable_destroy(struct wld_drawable * drawable)
+void buffer_destroy(struct wld_buffer * base)
{
- struct intel_drawable * intel = (void *) drawable;
- drm_intel_bo_unreference(intel->bo);
- free(intel);
+ struct intel_buffer * buffer = intel_buffer(base);
+
+ drm_intel_bo_unreference(buffer->bo);
+ free(buffer);
}
/**** Exporter ****/
-bool exporter_export(struct wld_exporter * exporter, struct wld_drawable * base,
+bool exporter_export(struct wld_exporter * exporter, struct wld_buffer * base,
uint32_t type, union wld_object * object)
{
- struct intel_drawable * drawable = intel_drawable(base);
+ struct intel_buffer * buffer = intel_buffer(base);
switch (type)
{
case WLD_DRM_OBJECT_HANDLE:
- object->u32 = drawable->bo->handle;
+ object->u32 = buffer->bo->handle;
return true;
case WLD_DRM_OBJECT_PRIME_FD:
- if (drm_intel_bo_gem_export_to_prime(drawable->bo, &object->i) != 0)
+ if (drm_intel_bo_gem_export_to_prime(buffer->bo, &object->i) != 0)
return false;
return true;
case WLD_DRM_OBJECT_GEM_NAME:
- if (drm_intel_bo_flink(drawable->bo, &object->u32) != 0)
+ if (drm_intel_bo_flink(buffer->bo, &object->u32) != 0)
return false;
return true;
default:
diff --git a/interface/buffer.h b/interface/buffer.h
@@ -0,0 +1,33 @@
+/* wld: interface/buffer.h
+ *
+ * Copyright (c) 2013, 2014 Michael Forney
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+static bool buffer_map(struct wld_buffer * drawable);
+static bool buffer_unmap(struct wld_buffer * drawable);
+static void buffer_destroy(struct wld_buffer * drawable);
+
+static const struct wld_buffer_impl buffer_impl = {
+ .map = &buffer_map,
+ .unmap = &buffer_unmap,
+ .destroy = &buffer_destroy
+};
+
diff --git a/interface/context.h b/interface/context.h
@@ -23,18 +23,18 @@
static struct wld_renderer * context_create_renderer
(struct wld_context * context);
-static struct wld_drawable * context_create_drawable
+static struct wld_buffer * context_create_buffer
(struct wld_context * context,
uint32_t width, uint32_t height, uint32_t format);
-static struct wld_drawable * context_import
+static struct wld_buffer * context_import_buffer
(struct wld_context * context, uint32_t type, union wld_object object,
uint32_t width, uint32_t height, uint32_t format, uint32_t pitch);
static void context_destroy(struct wld_context * context);
static const struct wld_context_impl context_impl = {
.create_renderer = &context_create_renderer,
- .create_drawable = &context_create_drawable,
- .import = &context_import,
+ .create_buffer = &context_create_buffer,
+ .import_buffer = &context_import_buffer,
.destroy = &context_destroy
};
diff --git a/interface/drawable.h b/interface/drawable.h
@@ -1,33 +0,0 @@
-/* wld: interface/drawable.h
- *
- * Copyright (c) 2013 Michael Forney
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-static bool drawable_map(struct wld_drawable * drawable);
-static bool drawable_unmap(struct wld_drawable * drawable);
-static void drawable_destroy(struct wld_drawable * drawable);
-
-static const struct wld_drawable_impl drawable_impl = {
- .map = &drawable_map,
- .unmap = &drawable_unmap,
- .destroy = &drawable_destroy
-};
-
diff --git a/interface/exporter.h b/interface/exporter.h
@@ -23,7 +23,7 @@
static void exporter_destroy(struct wld_exporter * exporter);
static bool exporter_export(struct wld_exporter * exporter,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
uint32_t type, union wld_object * object);
static const struct wld_exporter_impl exporter_impl = {
diff --git a/interface/renderer.h b/interface/renderer.h
@@ -22,14 +22,14 @@
*/
static uint32_t renderer_capabilities(struct wld_renderer * renderer,
- struct wld_drawable * drawable);
+ struct wld_buffer * buffer);
static bool renderer_set_target(struct wld_renderer * renderer,
- struct wld_drawable * drawable);
+ struct wld_buffer * buffer);
static void renderer_fill_rectangle(struct wld_renderer * renderer,
uint32_t color, int32_t x, int32_t y,
uint32_t width, uint32_t height);
static void renderer_copy_rectangle(struct wld_renderer * renderer,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
int32_t dst_x, int32_t dst_y,
int32_t src_x, int32_t src_y,
uint32_t width, uint32_t height);
@@ -37,7 +37,7 @@ static void renderer_copy_rectangle(struct wld_renderer * renderer,
static void renderer_fill_region(struct wld_renderer * base, uint32_t color,
pixman_region32_t * region);
static void renderer_copy_region(struct wld_renderer * base,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
int32_t dst_x, int32_t dst_y,
pixman_region32_t * region);
#endif
diff --git a/pixman.c b/pixman.c
@@ -38,9 +38,9 @@ struct pixman_renderer
pixman_glyph_cache_t * glyph_cache;
};
-struct pixman_drawable
+struct pixman_buffer
{
- struct wld_drawable base;
+ struct wld_buffer base;
pixman_image_t * image;
};
@@ -53,10 +53,10 @@ struct pixman_exporter
#include "interface/context.h"
#define RENDERER_IMPLEMENTS_REGION
#include "interface/renderer.h"
-#include "interface/drawable.h"
+#include "interface/buffer.h"
#include "interface/exporter.h"
IMPL(pixman, renderer)
-IMPL(pixman, drawable)
+IMPL(pixman, buffer)
IMPL(pixman, exporter)
static struct wld_context context = { .impl = &context_impl };
@@ -85,29 +85,29 @@ struct wld_renderer * context_create_renderer(struct wld_context * context)
return NULL;
}
-struct wld_drawable * new_drawable(pixman_image_t * image)
+static struct wld_buffer * new_buffer(pixman_image_t * image)
{
- struct pixman_drawable * drawable;
+ struct pixman_buffer * buffer;
- if (!(drawable = malloc(sizeof *drawable)))
+ if (!(buffer = malloc(sizeof *buffer)))
return NULL;
- drawable_initialize(&drawable->base, &drawable_impl,
- pixman_image_get_width(image),
- pixman_image_get_height(image),
- format_pixman_to_wld(pixman_image_get_format(image)),
- pixman_image_get_stride(image));
- drawable->base.map.data = pixman_image_get_data(image);
- drawable->image = image;
+ buffer_initialize(&buffer->base, &buffer_impl,
+ pixman_image_get_width(image),
+ pixman_image_get_height(image),
+ format_pixman_to_wld(pixman_image_get_format(image)),
+ pixman_image_get_stride(image));
+ buffer->base.map.data = pixman_image_get_data(image);
+ buffer->image = image;
- return &drawable->base;
+ return &buffer->base;
}
-struct wld_drawable * context_create_drawable(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format)
+struct wld_buffer * context_create_buffer(struct wld_context * context,
+ uint32_t width, uint32_t height,
+ uint32_t format)
{
- struct wld_drawable * drawable;
+ struct wld_buffer * buffer;
pixman_image_t * image;
image = pixman_image_create_bits(format_wld_to_pixman(format),
@@ -116,10 +116,10 @@ struct wld_drawable * context_create_drawable(struct wld_context * context,
if (!image)
goto error0;
- if (!(drawable = new_drawable(image)))
+ if (!(buffer = new_buffer(image)))
goto error1;
- return drawable;
+ return buffer;
error1:
pixman_image_unref(image);
@@ -127,12 +127,13 @@ struct wld_drawable * context_create_drawable(struct wld_context * context,
return NULL;
}
-struct wld_drawable * context_import(struct wld_context * context,
- uint32_t type, union wld_object object,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch)
+struct wld_buffer * context_import_buffer(struct wld_context * context,
+ uint32_t type,
+ union wld_object object,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch)
{
- struct wld_drawable * drawable;
+ struct wld_buffer * buffer;
pixman_image_t * image;
switch (type)
@@ -147,10 +148,10 @@ struct wld_drawable * context_import(struct wld_context * context,
if (!image)
goto error0;
- if (!(drawable = new_drawable(image)))
+ if (!(buffer = new_buffer(image)))
goto error1;
- return drawable;
+ return buffer;
error1:
pixman_image_unref(image);
@@ -164,40 +165,40 @@ void context_destroy(struct wld_context * context)
}
uint32_t renderer_capabilities(struct wld_renderer * renderer,
- struct wld_drawable * drawable)
+ struct wld_buffer * buffer)
{
- /* The pixman renderer can read and write to any drawable using it's map
+ /* The pixman renderer can read and write to any buffer using it's map
* implementation. */
return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
}
static void destroy_image(pixman_image_t * image, void * data)
{
- struct wld_drawable * drawable = data;
+ struct wld_buffer * buffer = data;
- wld_unmap(drawable);
+ wld_unmap(buffer);
}
-static pixman_image_t * pixman_image(struct wld_drawable * drawable)
+static pixman_image_t * pixman_image(struct wld_buffer * buffer)
{
- if (drawable->impl == &drawable_impl)
- return pixman_image_ref(pixman_drawable(drawable)->image);
+ if (buffer->impl == &buffer_impl)
+ return pixman_image_ref(pixman_buffer(buffer)->image);
union wld_object object;
- if (wld_export(drawable, WLD_PIXMAN_OBJECT_IMAGE, &object))
+ if (wld_export(buffer, WLD_PIXMAN_OBJECT_IMAGE, &object))
return object.ptr;
struct pixman_exporter * exporter;
pixman_image_t * image;
- if (!wld_map(drawable))
+ if (!wld_map(buffer))
goto error0;
- image = pixman_image_create_bits(format_wld_to_pixman(drawable->format),
- drawable->width, drawable->height,
- drawable->map.data, drawable->pitch);
- pixman_image_set_destroy_function(image, &destroy_image, drawable);
+ image = pixman_image_create_bits(format_wld_to_pixman(buffer->format),
+ buffer->width, buffer->height,
+ buffer->map.data, buffer->pitch);
+ pixman_image_set_destroy_function(image, &destroy_image, buffer);
if (!image)
goto error1;
@@ -207,26 +208,26 @@ static pixman_image_t * pixman_image(struct wld_drawable * drawable)
exporter_initialize(&exporter->base, &exporter_impl);
exporter->image = image;
- drawable_add_exporter(drawable, &exporter->base);
+ buffer_add_exporter(buffer, &exporter->base);
return pixman_image_ref(image);
error1:
- wld_unmap(drawable);
+ wld_unmap(buffer);
error0:
return NULL;
}
bool renderer_set_target(struct wld_renderer * base,
- struct wld_drawable * drawable)
+ struct wld_buffer * buffer)
{
struct pixman_renderer * renderer = pixman_renderer(base);
if (renderer->target)
pixman_image_unref(renderer->target);
- if (drawable)
- return (renderer->target = pixman_image(drawable));
+ if (buffer)
+ return (renderer->target = pixman_image(buffer));
renderer->target = NULL;
return true;
@@ -258,13 +259,13 @@ void renderer_fill_region(struct wld_renderer * base, uint32_t color,
}
void renderer_copy_rectangle(struct wld_renderer * base,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
int32_t dst_x, int32_t dst_y,
int32_t src_x, int32_t src_y,
uint32_t width, uint32_t height)
{
struct pixman_renderer * renderer = pixman_renderer(base);
- pixman_image_t * src = pixman_image(drawable), * dst = renderer->target;
+ pixman_image_t * src = pixman_image(buffer), * dst = renderer->target;
if (!src) return;
@@ -273,12 +274,12 @@ void renderer_copy_rectangle(struct wld_renderer * base,
}
void renderer_copy_region(struct wld_renderer * base,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
int32_t dst_x, int32_t dst_y,
pixman_region32_t * region)
{
struct pixman_renderer * renderer = pixman_renderer(base);
- pixman_image_t * src = pixman_image(drawable), * dst = renderer->target;
+ pixman_image_t * src = pixman_image(buffer), * dst = renderer->target;
if (!src) return;
@@ -405,26 +406,26 @@ void renderer_destroy(struct wld_renderer * base)
free(renderer);
}
-bool drawable_map(struct wld_drawable * drawable)
+bool buffer_map(struct wld_buffer * buffer)
{
return true;
}
-bool drawable_unmap(struct wld_drawable * drawable)
+bool buffer_unmap(struct wld_buffer * buffer)
{
return true;
}
-void drawable_destroy(struct wld_drawable * drawable)
+void buffer_destroy(struct wld_buffer * base)
{
- struct pixman_drawable * pixman = (void *) drawable;
+ struct pixman_buffer * buffer = pixman_buffer(base);
- pixman_image_unref(pixman->image);
- free(pixman);
+ pixman_image_unref(buffer->image);
+ free(buffer);
}
/**** Exporter ****/
-bool exporter_export(struct wld_exporter * base, struct wld_drawable * drawable,
+bool exporter_export(struct wld_exporter * base, struct wld_buffer * buffer,
uint32_t type, union wld_object * object)
{
struct pixman_exporter * exporter = pixman_exporter(base);
diff --git a/renderer.c b/renderer.c
@@ -40,7 +40,7 @@ void default_fill_region(struct wld_renderer * renderer, uint32_t color,
}
void default_copy_region(struct wld_renderer * renderer,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
int32_t dst_x, int32_t dst_y,
pixman_region32_t * region)
{
@@ -51,7 +51,7 @@ void default_copy_region(struct wld_renderer * renderer,
while (num_boxes--)
{
- renderer->impl->copy_rectangle(renderer, drawable,
+ renderer->impl->copy_rectangle(renderer, buffer,
dst_x + box->x1, dst_y + box->y1,
box->x1, box->y1,
box->x2 - box->x1, box->y2 - box->y1);
@@ -74,19 +74,19 @@ void wld_destroy_renderer(struct wld_renderer * renderer)
EXPORT
uint32_t wld_capabilities(struct wld_renderer * renderer,
- struct wld_drawable * drawable)
+ struct wld_buffer * buffer)
{
- return renderer->impl->capabilities(renderer, drawable);
+ return renderer->impl->capabilities(renderer, buffer);
}
EXPORT
-bool wld_set_target_drawable(struct wld_renderer * renderer,
- struct wld_drawable * drawable)
+bool wld_set_target_buffer(struct wld_renderer * renderer,
+ struct wld_buffer * buffer)
{
- if (!renderer->impl->set_target(renderer, drawable))
+ if (!renderer->impl->set_target(renderer, buffer))
return false;
- renderer->target = drawable;
+ renderer->target = buffer;
return true;
}
@@ -107,21 +107,21 @@ void wld_fill_region(struct wld_renderer * renderer, uint32_t color,
EXPORT
void wld_copy_rectangle(struct wld_renderer * renderer,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
int32_t dst_x, int32_t dst_y,
int32_t src_x, int32_t src_y,
uint32_t width, uint32_t height)
{
- renderer->impl->copy_rectangle(renderer, drawable, dst_x, dst_y,
- src_x, src_y, width, height);
+ renderer->impl->copy_rectangle(renderer, buffer, dst_x, dst_y, src_x, src_y,
+ width, height);
}
EXPORT
void wld_copy_region(struct wld_renderer * renderer,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
int32_t dst_x, int32_t dst_y, pixman_region32_t * region)
{
- renderer->impl->copy_region(renderer, drawable, dst_x, dst_y, region);
+ renderer->impl->copy_region(renderer, buffer, dst_x, dst_y, region);
}
EXPORT
diff --git a/wayland-drm.c b/wayland-drm.c
@@ -191,12 +191,12 @@ struct wld_renderer * context_create_renderer(struct wld_context * base)
return wld_create_renderer(context->driver_context);
}
-struct wld_drawable * context_create_drawable(struct wld_context * base,
- uint32_t width, uint32_t height,
- uint32_t format)
+struct wld_buffer * context_create_buffer(struct wld_context * base,
+ uint32_t width, uint32_t height,
+ uint32_t format)
{
struct drm_context * context = drm_context(base);
- struct wld_drawable * drawable;
+ struct wld_buffer * buffer;
struct wld_exporter * exporter;
union wld_object object;
struct wl_buffer * wl;
@@ -204,16 +204,16 @@ struct wld_drawable * context_create_drawable(struct wld_context * base,
if (!wld_wayland_drm_has_format(&context->base, format))
goto error0;
- drawable = wld_create_drawable(context->driver_context, width, height, format);
+ buffer = wld_create_buffer(context->driver_context, width, height, format);
- if (!drawable)
+ if (!buffer)
goto error0;
- if (!wld_export(drawable, WLD_DRM_OBJECT_PRIME_FD, &object))
+ if (!wld_export(buffer, WLD_DRM_OBJECT_PRIME_FD, &object))
goto error1;
wl = wl_drm_create_prime_buffer(context->wl, object.i, width, height,
- format, 0, drawable->pitch, 0, 0, 0, 0);
+ format, 0, buffer->pitch, 0, 0, 0, 0);
close(object.i);
if (!wl)
@@ -222,22 +222,23 @@ struct wld_drawable * context_create_drawable(struct wld_context * base,
if (!(exporter = wayland_create_exporter(wl)))
goto error2;
- drawable_add_exporter(drawable, exporter);
+ buffer_add_exporter(buffer, exporter);
- return drawable;
+ return buffer;
error2:
wl_buffer_destroy(wl);
error1:
- wld_destroy_drawable(drawable);
+ wld_destroy_buffer(buffer);
error0:
return NULL;
}
-struct wld_drawable * context_import(struct wld_context * context,
- uint32_t type, union wld_object object,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch)
+struct wld_buffer * context_import_buffer(struct wld_context * context,
+ uint32_t type,
+ union wld_object object,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch)
{
return NULL;
}
diff --git a/wayland-drm.h b/wayland-drm.h
@@ -31,8 +31,8 @@ struct wl_display;
struct wl_event_queue;
/**
- * Create a new drawable context which creates Wayland buffers through the
- * wl_drm interface, backed by hardware specific drawable implementations.
+ * Create a new WLD context which creates Wayland buffers through the wl_drm
+ * interface, backed by hardware specific buffer implementations.
*/
struct wld_context * wld_wayland_drm_create_context
(struct wl_display * display, struct wl_event_queue * queue);
diff --git a/wayland-shm.c b/wayland-shm.c
@@ -149,12 +149,12 @@ struct wld_renderer * context_create_renderer(struct wld_context * context)
return wld_create_renderer(wld_pixman_context);
}
-struct wld_drawable * context_create_drawable(struct wld_context * base,
- uint32_t width, uint32_t height,
- uint32_t format)
+struct wld_buffer * context_create_buffer(struct wld_context * base,
+ uint32_t width, uint32_t height,
+ uint32_t format)
{
struct shm_context * context = shm_context(base);
- struct wld_drawable * drawable;
+ struct wld_buffer * buffer;
struct wld_exporter * exporter;
char name[] = "/tmp/wld-XXXXXX";
uint32_t pitch = width * format_bytes_per_pixel(format);
@@ -182,10 +182,10 @@ struct wld_drawable * context_create_drawable(struct wld_context * base,
goto error1;
object.ptr = data;
- drawable = wld_import(wld_pixman_context, WLD_OBJECT_DATA, object,
- width, height, format, pitch);
+ buffer = wld_import_buffer(wld_pixman_context, WLD_OBJECT_DATA, object,
+ width, height, format, pitch);
- if (!drawable)
+ if (!buffer)
goto error2;
if (!(pool = wl_shm_create_pool(context->wl, fd, size)))
@@ -200,15 +200,15 @@ struct wld_drawable * context_create_drawable(struct wld_context * base,
if (!(exporter = wayland_create_exporter(wl)))
goto error4;
- drawable_add_exporter(drawable, exporter);
+ buffer_add_exporter(buffer, exporter);
close(fd);
- return drawable;
+ return buffer;
error4:
wl_buffer_destroy(wl);
error3:
- wld_destroy_drawable(drawable);
+ wld_destroy_buffer(buffer);
error2:
munmap(object.ptr, size);
error1:
@@ -217,10 +217,11 @@ struct wld_drawable * context_create_drawable(struct wld_context * base,
return NULL;
}
-struct wld_drawable * context_import(struct wld_context * context,
- uint32_t type, union wld_object object,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch)
+struct wld_buffer * context_import_buffer(struct wld_context * context,
+ uint32_t type,
+ union wld_object object,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch)
{
return NULL;
}
diff --git a/wayland-shm.h b/wayland-shm.h
@@ -31,8 +31,8 @@ struct wl_display;
struct wl_event_queue;
/**
- * Create a new drawable context which creates Wayland buffers through the
- * wl_shm interface, back by Pixman drawables.
+ * Create a new WLD context which creates Wayland buffers through the wl_shm
+ * interface, backed by Pixman images.
*/
struct wld_context * wld_shm_create_context(struct wl_display * display,
struct wl_event_queue * queue);
diff --git a/wayland.c b/wayland.c
@@ -139,7 +139,7 @@ struct wld_exporter * wayland_create_exporter(struct wl_buffer * buffer)
return &exporter->base;
}
-bool exporter_export(struct wld_exporter * base, struct wld_drawable * drawable,
+bool exporter_export(struct wld_exporter * base, struct wld_buffer * buffer,
uint32_t type, union wld_object * object)
{
struct wayland_exporter * exporter = wayland_exporter(base);
diff --git a/wayland.h b/wayland.h
@@ -50,9 +50,9 @@ enum wld_wayland_object_type
};
/**
- * Create a new drawing context which uses various available Wayland interfaces
- * (such as wl_shm and wl_drm) to create buffers backed by drawables specific
- * to the interface.
+ * Create a new WLD context which uses various available Wayland interfaces
+ * (such as wl_shm and wl_drm) to create wl_buffers backed by implementations
+ * specific to the interface.
*
* You can specify the particular interface you want to use by specifying them
* as arguments. Interfaces will be tried in the order they are given.
diff --git a/wld-private.h b/wld-private.h
@@ -86,34 +86,35 @@ struct font
struct wld_context_impl
{
struct wld_renderer * (* create_renderer)(struct wld_context * context);
- struct wld_drawable * (* create_drawable)(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format);
- struct wld_drawable * (* import)(struct wld_context * context,
- uint32_t type, union wld_object object,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch);
+ struct wld_buffer * (* create_buffer)(struct wld_context * context,
+ uint32_t width, uint32_t height,
+ uint32_t format);
+ struct wld_buffer * (* import_buffer)(struct wld_context * context,
+ uint32_t type,
+ union wld_object object,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch);
void (* destroy)(struct wld_context * context);
};
struct wld_renderer_impl
{
uint32_t (* capabilities)(struct wld_renderer * renderer,
- struct wld_drawable * buffer);
+ struct wld_buffer * buffer);
bool (* set_target)(struct wld_renderer * renderer,
- struct wld_drawable * drawable);
+ struct wld_buffer * buffer);
void (* fill_rectangle)(struct wld_renderer * renderer,
uint32_t color, int32_t x, int32_t y,
uint32_t width, uint32_t height);
void (* fill_region)(struct wld_renderer * renderer,
uint32_t color, pixman_region32_t * region);
void (* copy_rectangle)(struct wld_renderer * renderer,
- struct wld_drawable * src,
+ struct wld_buffer * src,
int32_t dst_x, int32_t dst_y,
int32_t src_x, int32_t src_y,
uint32_t width, uint32_t height);
void (* copy_region)(struct wld_renderer * renderer,
- struct wld_drawable * src,
+ struct wld_buffer * src,
int32_t dst_x, int32_t dst_y,
pixman_region32_t * region);
void (* draw_text)(struct wld_renderer * renderer,
@@ -124,11 +125,11 @@ struct wld_renderer_impl
void (* destroy)(struct wld_renderer * renderer);
};
-struct wld_drawable_impl
+struct wld_buffer_impl
{
- bool (* map)(struct wld_drawable * drawable);
- bool (* unmap)(struct wld_drawable * drawable);
- void (* destroy)(struct wld_drawable * drawable);
+ bool (* map)(struct wld_buffer * buffer);
+ bool (* unmap)(struct wld_buffer * buffer);
+ void (* destroy)(struct wld_buffer * buffer);
};
struct wld_exporter
@@ -139,8 +140,7 @@ struct wld_exporter
struct wld_exporter_impl
{
- bool (* export)(struct wld_exporter * exporter,
- struct wld_drawable * drawable,
+ bool (* export)(struct wld_exporter * exporter, struct wld_buffer * buffer,
uint32_t type, union wld_object * object);
void (* destroy)(struct wld_exporter * exporter);
};
@@ -198,7 +198,7 @@ void default_fill_region(struct wld_renderer * renderer, uint32_t color,
* This default copy_region method is implemented in terms of copy_rectangle.
*/
void default_copy_region(struct wld_renderer * renderer,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
int32_t dst_x, int32_t dst_y,
pixman_region32_t * region);
@@ -208,13 +208,13 @@ void context_initialize(struct wld_context * context,
void renderer_initialize(struct wld_renderer * renderer,
const struct wld_renderer_impl * impl);
-void drawable_initialize(struct wld_drawable * drawable,
- const struct wld_drawable_impl * impl,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch);
+void buffer_initialize(struct wld_buffer * buffer,
+ const struct wld_buffer_impl * impl,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch);
-void drawable_add_exporter(struct wld_drawable * drawable,
- struct wld_exporter * exporter);
+void buffer_add_exporter(struct wld_buffer * buffer,
+ struct wld_exporter * exporter);
void exporter_initialize(struct wld_exporter * exporter,
const struct wld_exporter_impl * impl);
diff --git a/wld.h b/wld.h
@@ -68,14 +68,14 @@ struct wld_context
struct wld_renderer * wld_create_renderer(struct wld_context * context);
-struct wld_drawable * wld_create_drawable(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format);
+struct wld_buffer * wld_create_buffer(struct wld_context * context,
+ uint32_t width, uint32_t height,
+ uint32_t format);
-struct wld_drawable * wld_import(struct wld_context * context, uint32_t type,
- union wld_object object,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch);
+struct wld_buffer * wld_import_buffer(struct wld_context * context,
+ uint32_t type, union wld_object object,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch);
void wld_destroy_context(struct wld_context * context);
@@ -144,10 +144,12 @@ static inline void wld_font_text_extents(struct wld_font * font,
wld_font_text_extents_n(font, text, INT32_MAX, extents);
}
-/**** Drawables ****/
+/**** Buffers ****/
-struct wld_drawable
+struct wld_buffer
{
+ const struct wld_buffer_impl * const impl;
+
uint32_t width, height;
unsigned long pitch;
enum wld_format format;
@@ -159,27 +161,25 @@ struct wld_drawable
} map;
struct wld_exporter * exporters;
-
- const struct wld_drawable_impl * impl;
};
-bool wld_map(struct wld_drawable * drawable);
-bool wld_unmap(struct wld_drawable * drawable);
+bool wld_map(struct wld_buffer * buffer);
+bool wld_unmap(struct wld_buffer * buffer);
-bool wld_export(struct wld_drawable * drawable,
+bool wld_export(struct wld_buffer * buffer,
uint32_t type, union wld_object * object);
/**
- * Destroy a drawable (created with any context).
+ * Destroy a buffer.
*/
-void wld_destroy_drawable(struct wld_drawable * drawable);
+void wld_destroy_buffer(struct wld_buffer * buffer);
/**** Renderers ****/
struct wld_renderer
{
const struct wld_renderer_impl * const impl;
- struct wld_drawable * target;
+ struct wld_buffer * target;
};
enum wld_capability
@@ -191,10 +191,10 @@ enum wld_capability
void wld_destroy_renderer(struct wld_renderer * renderer);
uint32_t wld_capabilities(struct wld_renderer * renderer,
- struct wld_drawable * drawable);
+ struct wld_buffer * buffer);
bool wld_set_target_buffer(struct wld_renderer * renderer,
- struct wld_drawable * drawable);
+ struct wld_buffer * buffer);
void wld_fill_rectangle(struct wld_renderer * renderer, uint32_t color,
int32_t x, int32_t y, uint32_t width, uint32_t height);
@@ -203,17 +203,17 @@ void wld_fill_region(struct wld_renderer * renderer, uint32_t color,
pixman_region32_t * region);
void wld_copy_rectangle(struct wld_renderer * renderer,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
int32_t dst_x, int32_t dst_y,
int32_t src_x, int32_t src_y,
uint32_t width, uint32_t height);
void wld_copy_region(struct wld_renderer * renderer,
- struct wld_drawable * drawable,
+ struct wld_buffer * buffer,
int32_t dst_x, int32_t dst_y, pixman_region32_t * region);
/**
- * Draw a UTF-8 text string to the given drawable.
+ * Draw a UTF-8 text string to the given buffer.
*
* @param length The maximum number of bytes in the string to process
* @param extents If not NULL, will be initialized to the extents of the