commit 81232b2e8cd276eaf91cb16d9a09b85c8507144b
parent 0da359a9e140539b87335b74e313166b74627018
Author: Michael Forney <mforney@mforney.org>
Date: Wed, 10 Jul 2019 20:55:25 -0700
Reformat with clang-format
Diffstat:
| M | buffer.c | | | 140 | +++++++++++++++++++++++++++++++++++++++++-------------------------------------- |
| M | buffered_surface.c | | | 311 | +++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | color.c | | | 1564 | +++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | context.c | | | 53 | ++++++++++++++++++++++++++++++----------------------- |
| M | drm-private.h | | | 12 | +++++------- |
| M | drm.c | | | 119 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
| M | drm.h | | | 19 | ++++++++----------- |
| M | dumb.c | | | 290 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
| M | font.c | | | 259 | +++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | intel.c | | | 510 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
| M | intel/batch.c | | | 152 | +++++++++++++++++++++++++++++++++++++++++-------------------------------------- |
| M | intel/batch.h | | | 87 | +++++++++++++++++++++++++++++++++++++++++-------------------------------------- |
| M | intel/blt.h | | | 542 | ++++++++++++++++++++++++++++++++++++++----------------------------------------- |
| M | intel/mi.h | | | 25 | ++++++++++++------------- |
| M | interface/buffer.h | | | 13 | ++++++------- |
| M | interface/context.h | | | 33 | ++++++++++++++------------------- |
| M | interface/drm.h | | | 15 | +++++++-------- |
| M | interface/renderer.h | | | 59 | +++++++++++++++++++++++++++++------------------------------ |
| M | interface/surface.h | | | 29 | ++++++++++++++--------------- |
| M | interface/wayland.h | | | 16 | +++++++--------- |
| M | nouveau.c | | | 925 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
| M | pixman.c | | | 608 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
| M | pixman.h | | | 13 | ++++++------- |
| M | renderer.c | | | 164 | ++++++++++++++++++++++++++++++++++++++++++------------------------------------- |
| M | surface.c | | | 46 | ++++++++++++++++++++++++++-------------------- |
| M | wayland-drm.c | | | 375 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
| M | wayland-private.h | | | 23 | ++++++++++------------- |
| M | wayland-shm.c | | | 334 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
| M | wayland.c | | | 349 | +++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | wayland.h | | | 34 | +++++++++++++++------------------- |
| M | wld-private.h | | | 275 | ++++++++++++++++++++++++++++++++++++++----------------------------------------- |
| M | wld.h | | | 241 | +++++++++++++++++++++++++++++++++++++------------------------------------------ |
32 files changed, 3819 insertions(+), 3816 deletions(-)
diff --git a/buffer.c b/buffer.c
@@ -23,115 +23,119 @@
#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)
+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);
+ *((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)
+bool
+wld_map(struct wld_buffer *base)
{
- struct buffer * buffer = (void *) 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)
+bool
+wld_unmap(struct wld_buffer *base)
{
- struct buffer * buffer = (void *) base;
+ struct buffer *buffer = (void *)base;
- if (buffer->map_references == 0
- || (buffer->map_references == 1 && !buffer->base.impl->unmap(buffer)))
- {
- return false;
- }
+ if (buffer->map_references == 0
+ || (buffer->map_references == 1 && !buffer->base.impl->unmap(buffer))) {
+ return false;
+ }
- --buffer->map_references;
- return true;
+ --buffer->map_references;
+ return true;
}
EXPORT
-bool wld_export(struct wld_buffer * base,
- uint32_t type, union wld_object * object)
+bool
+wld_export(struct wld_buffer *base,
+ uint32_t type, union wld_object *object)
{
- struct buffer * buffer = (void *) base;
- struct wld_exporter * exporter;
+ 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)
+void
+wld_buffer_add_exporter(struct wld_buffer *base,
+ struct wld_exporter *exporter)
{
- struct buffer * buffer = (void *) base;
+ 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)
+void
+wld_buffer_add_destructor(struct wld_buffer *base,
+ struct wld_destructor *destructor)
{
- struct buffer * buffer = (void *) base;
+ 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)
+void
+wld_buffer_reference(struct wld_buffer *base)
{
- struct buffer * buffer = (void *) base;
+ struct buffer *buffer = (void *)base;
- ++buffer->references;
+ ++buffer->references;
}
EXPORT
-void wld_buffer_unreference(struct wld_buffer * base)
+void
+wld_buffer_unreference(struct wld_buffer *base)
{
- struct buffer * buffer = (void *) base;
- struct wld_destructor * destructor, * next;
+ 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);
}
-
diff --git a/buffered_surface.c b/buffered_surface.c
@@ -26,199 +26,194 @@
#include "interface/surface.h"
IMPL(buffered_surface, wld_surface)
-struct buffer_entry
-{
- struct buffer * buffer;
- bool busy;
+struct buffer_entry {
+ struct buffer *buffer;
+ bool busy;
};
-struct buffered_surface
-{
- struct wld_surface base;
+struct buffered_surface {
+ struct wld_surface base;
- struct wld_context * context;
- struct buffer_entry * entries, * back;
- unsigned entries_size, entries_capacity;
+ struct wld_context *context;
+ struct buffer_entry *entries, *back;
+ unsigned entries_size, entries_capacity;
- struct buffer_socket * buffer_socket;
+ struct buffer_socket *buffer_socket;
- uint32_t width, height;
- enum wld_format format;
- uint32_t flags;
+ uint32_t width, height;
+ enum wld_format format;
+ uint32_t flags;
};
-struct wld_surface * buffered_surface_create
- (struct wld_context * context, uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags, struct buffer_socket * buffer_socket)
+struct wld_surface *
+buffered_surface_create(struct wld_context *context, uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags, struct buffer_socket *buffer_socket)
{
- struct buffered_surface * surface;
-
- if (!(surface = malloc(sizeof *surface)))
- return NULL;
-
- surface_initialize(&surface->base, &wld_surface_impl);
- surface->context = context;
- surface->entries = NULL;
- surface->back = NULL;
- surface->entries_size = 0;
- surface->entries_capacity = 0;
- surface->buffer_socket = buffer_socket;
- surface->width = width;
- surface->height = height;
- surface->format = format;
- surface->flags = flags;
-
- return &surface->base;
+ struct buffered_surface *surface;
+
+ if (!(surface = malloc(sizeof *surface)))
+ return NULL;
+
+ surface_initialize(&surface->base, &wld_surface_impl);
+ surface->context = context;
+ surface->entries = NULL;
+ surface->back = NULL;
+ surface->entries_size = 0;
+ surface->entries_capacity = 0;
+ surface->buffer_socket = buffer_socket;
+ surface->width = width;
+ surface->height = height;
+ surface->format = format;
+ surface->flags = flags;
+
+ return &surface->base;
}
-pixman_region32_t * surface_damage(struct wld_surface * base,
- pixman_region32_t * new_damage)
+pixman_region32_t *
+surface_damage(struct wld_surface *base,
+ pixman_region32_t *new_damage)
{
- struct buffered_surface * surface = buffered_surface(base);
- struct buffer * back_buffer;
- unsigned index;
-
- if (pixman_region32_not_empty(new_damage))
- {
- for (index = 0; index < surface->entries_size; ++index)
- {
- pixman_region32_union(&surface->entries[index].buffer->base.damage,
- &surface->entries[index].buffer->base.damage,
- new_damage);
- }
- }
-
- if (!(back_buffer = surface_back(base)))
- return NULL;
-
- return &back_buffer->base.damage;
+ struct buffered_surface *surface = buffered_surface(base);
+ struct buffer *back_buffer;
+ unsigned index;
+
+ if (pixman_region32_not_empty(new_damage)) {
+ for (index = 0; index < surface->entries_size; ++index) {
+ pixman_region32_union(&surface->entries[index].buffer->base.damage,
+ &surface->entries[index].buffer->base.damage,
+ new_damage);
+ }
+ }
+
+ if (!(back_buffer = surface_back(base)))
+ return NULL;
+
+ return &back_buffer->base.damage;
}
-struct buffer * surface_back(struct wld_surface * base)
+struct buffer *
+surface_back(struct wld_surface *base)
{
- struct buffered_surface * surface = buffered_surface(base);
- unsigned index;
-
- if (surface->back)
- return surface->back->buffer;
-
- /* The buffer socket may need to process any incoming buffer releases. */
- if (surface->buffer_socket)
- surface->buffer_socket->impl->process(surface->buffer_socket);
-
- for (index = 0; index < surface->entries_size; ++index)
- {
- if (!surface->entries[index].busy)
- {
- surface->back = &surface->entries[index];
- return surface->back->buffer;
- }
- }
-
- /* If there are no free buffers, we need to allocate another one. */
- struct buffer * buffer;
-
- buffer = surface->context->impl->create_buffer
- (surface->context, surface->width, surface->height,
- surface->format, surface->flags);
-
- if (!buffer)
- goto error0;
-
- if (surface->entries_size == surface->entries_capacity)
- {
- struct buffer_entry * new_entries;
- size_t new_capacity = surface->entries_capacity * 2 + 1;
-
- new_entries = realloc(surface->entries,
- new_capacity * sizeof surface->entries[0]);
-
- if (!new_entries)
- goto error1;
-
- surface->entries = new_entries;
- surface->entries_capacity = new_capacity;
- }
-
- surface->back = &surface->entries[surface->entries_size++];
- *surface->back = (struct buffer_entry) {
- .buffer = buffer,
- .busy = false
- };
-
- return buffer;
-
- error1:
- wld_buffer_unreference(&buffer->base);
- error0:
- return NULL;
+ struct buffered_surface *surface = buffered_surface(base);
+ unsigned index;
+
+ if (surface->back)
+ return surface->back->buffer;
+
+ /* The buffer socket may need to process any incoming buffer releases. */
+ if (surface->buffer_socket)
+ surface->buffer_socket->impl->process(surface->buffer_socket);
+
+ for (index = 0; index < surface->entries_size; ++index) {
+ if (!surface->entries[index].busy) {
+ surface->back = &surface->entries[index];
+ return surface->back->buffer;
+ }
+ }
+
+ /* If there are no free buffers, we need to allocate another one. */
+ struct buffer *buffer;
+
+ buffer = surface->context->impl->create_buffer(surface->context, surface->width, surface->height,
+ surface->format, surface->flags);
+
+ if (!buffer)
+ goto error0;
+
+ if (surface->entries_size == surface->entries_capacity) {
+ struct buffer_entry *new_entries;
+ size_t new_capacity = surface->entries_capacity * 2 + 1;
+
+ new_entries = realloc(surface->entries,
+ new_capacity * sizeof surface->entries[0]);
+
+ if (!new_entries)
+ goto error1;
+
+ surface->entries = new_entries;
+ surface->entries_capacity = new_capacity;
+ }
+
+ surface->back = &surface->entries[surface->entries_size++];
+ *surface->back = (struct buffer_entry){
+ .buffer = buffer,
+ .busy = false
+ };
+
+ return buffer;
+
+error1:
+ wld_buffer_unreference(&buffer->base);
+error0:
+ return NULL;
}
-struct buffer * surface_take(struct wld_surface * base)
+struct buffer *
+surface_take(struct wld_surface *base)
{
- struct buffered_surface * surface = buffered_surface(base);
- struct buffer * buffer;
+ struct buffered_surface *surface = buffered_surface(base);
+ struct buffer *buffer;
- if (!(buffer = surface_back(base)))
- return NULL;
+ if (!(buffer = surface_back(base)))
+ return NULL;
- surface->back->busy = true;
- surface->back = NULL;
- pixman_region32_clear(&buffer->base.damage);
+ surface->back->busy = true;
+ surface->back = NULL;
+ pixman_region32_clear(&buffer->base.damage);
- return buffer;
+ return buffer;
}
-bool surface_release(struct wld_surface * base, struct buffer * buffer)
+bool
+surface_release(struct wld_surface *base, struct buffer *buffer)
{
- struct buffered_surface * surface = buffered_surface(base);
- unsigned index;
-
- for (index = 0; index < surface->entries_size; ++index)
- {
- if (surface->entries[index].buffer == buffer)
- {
- surface->entries[index].busy = false;
- return true;
- }
- }
-
- return false;
+ struct buffered_surface *surface = buffered_surface(base);
+ unsigned index;
+
+ for (index = 0; index < surface->entries_size; ++index) {
+ if (surface->entries[index].buffer == buffer) {
+ surface->entries[index].busy = false;
+ return true;
+ }
+ }
+
+ return false;
}
-bool surface_swap(struct wld_surface * base)
+bool
+surface_swap(struct wld_surface *base)
{
- struct buffered_surface * surface = buffered_surface(base);
- struct buffer * buffer;
+ struct buffered_surface *surface = buffered_surface(base);
+ struct buffer *buffer;
- if (!surface->buffer_socket)
- return false;
+ if (!surface->buffer_socket)
+ return false;
- if (!(buffer = surface_back(base)))
- return false;
+ if (!(buffer = surface_back(base)))
+ return false;
- if (!surface->buffer_socket->impl->attach(surface->buffer_socket, buffer))
- return false;
+ if (!surface->buffer_socket->impl->attach(surface->buffer_socket, buffer))
+ return false;
- surface->back->busy = true;
- surface->back = NULL;
- pixman_region32_clear(&buffer->base.damage);
+ surface->back->busy = true;
+ surface->back = NULL;
+ pixman_region32_clear(&buffer->base.damage);
- return true;
+ return true;
}
-void surface_destroy(struct wld_surface * base)
+void
+surface_destroy(struct wld_surface *base)
{
- struct buffered_surface * surface = buffered_surface(base);
- unsigned index;
+ struct buffered_surface *surface = buffered_surface(base);
+ unsigned index;
- if (surface->buffer_socket)
- surface->buffer_socket->impl->destroy(surface->buffer_socket);
+ if (surface->buffer_socket)
+ surface->buffer_socket->impl->destroy(surface->buffer_socket);
- for (index = 0; index < surface->entries_size; ++index)
- wld_buffer_unreference(&surface->entries[index].buffer->base);
+ for (index = 0; index < surface->entries_size; ++index)
+ wld_buffer_unreference(&surface->entries[index].buffer->base);
- free(surface->entries);
- free(surface);
+ free(surface->entries);
+ free(surface);
}
-
diff --git a/color.c b/color.c
@@ -50,801 +50,797 @@ SOFTWARE.
#include <strings.h>
-struct named_color
-{
- const char * name;
- uint32_t color;
+struct named_color {
+ const char *name;
+ uint32_t color;
};
static const struct named_color named_colors[] = {
- { "alice blue", 0xfff0f8ff },
- { "AliceBlue", 0xfff0f8ff },
- { "antique white", 0xfffaebd7 },
- { "AntiqueWhite", 0xfffaebd7 },
- { "AntiqueWhite1", 0xffffefdb },
- { "AntiqueWhite2", 0xffeedfcc },
- { "AntiqueWhite3", 0xffcdc0b0 },
- { "AntiqueWhite4", 0xff8b8378 },
- { "aquamarine", 0xff7fffd4 },
- { "aquamarine1", 0xff7fffd4 },
- { "aquamarine2", 0xff76eec6 },
- { "aquamarine3", 0xff66cdaa },
- { "aquamarine4", 0xff458b74 },
- { "azure", 0xfff0ffff },
- { "azure1", 0xfff0ffff },
- { "azure2", 0xffe0eeee },
- { "azure3", 0xffc1cdcd },
- { "azure4", 0xff838b8b },
- { "beige", 0xfff5f5dc },
- { "bisque", 0xffffe4c4 },
- { "bisque1", 0xffffe4c4 },
- { "bisque2", 0xffeed5b7 },
- { "bisque3", 0xffcdb79e },
- { "bisque4", 0xff8b7d6b },
- { "black", 0xff000000 },
- { "blanched almond", 0xffffebcd },
- { "BlanchedAlmond", 0xffffebcd },
- { "blue", 0xff0000ff },
- { "blue violet", 0xff8a2be2 },
- { "blue1", 0xff0000ff },
- { "blue2", 0xff0000ee },
- { "blue3", 0xff0000cd },
- { "blue4", 0xff00008b },
- { "BlueViolet", 0xff8a2be2 },
- { "brown", 0xffa52a2a },
- { "brown1", 0xffff4040 },
- { "brown2", 0xffee3b3b },
- { "brown3", 0xffcd3333 },
- { "brown4", 0xff8b2323 },
- { "burlywood", 0xffdeb887 },
- { "burlywood1", 0xffffd39b },
- { "burlywood2", 0xffeec591 },
- { "burlywood3", 0xffcdaa7d },
- { "burlywood4", 0xff8b7355 },
- { "cadet blue", 0xff5f9ea0 },
- { "CadetBlue", 0xff5f9ea0 },
- { "CadetBlue1", 0xff98f5ff },
- { "CadetBlue2", 0xff8ee5ee },
- { "CadetBlue3", 0xff7ac5cd },
- { "CadetBlue4", 0xff53868b },
- { "chartreuse", 0xff7fff00 },
- { "chartreuse1", 0xff7fff00 },
- { "chartreuse2", 0xff76ee00 },
- { "chartreuse3", 0xff66cd00 },
- { "chartreuse4", 0xff458b00 },
- { "chocolate", 0xffd2691e },
- { "chocolate1", 0xffff7f24 },
- { "chocolate2", 0xffee7621 },
- { "chocolate3", 0xffcd661d },
- { "chocolate4", 0xff8b4513 },
- { "coral", 0xffff7f50 },
- { "coral1", 0xffff7256 },
- { "coral2", 0xffee6a50 },
- { "coral3", 0xffcd5b45 },
- { "coral4", 0xff8b3e2f },
- { "cornflower blue", 0xff6495ed },
- { "CornflowerBlue", 0xff6495ed },
- { "cornsilk", 0xfffff8dc },
- { "cornsilk1", 0xfffff8dc },
- { "cornsilk2", 0xffeee8cd },
- { "cornsilk3", 0xffcdc8b1 },
- { "cornsilk4", 0xff8b8878 },
- { "cyan", 0xff00ffff },
- { "cyan1", 0xff00ffff },
- { "cyan2", 0xff00eeee },
- { "cyan3", 0xff00cdcd },
- { "cyan4", 0xff008b8b },
- { "dark blue", 0xff00008b },
- { "dark cyan", 0xff008b8b },
- { "dark goldenrod", 0xffb8860b },
- { "dark gray", 0xffa9a9a9 },
- { "dark green", 0xff006400 },
- { "dark grey", 0xffa9a9a9 },
- { "dark khaki", 0xffbdb76b },
- { "dark magenta", 0xff8b008b },
- { "dark olive green", 0xff556b2f },
- { "dark orange", 0xffff8c00 },
- { "dark orchid", 0xff9932cc },
- { "dark red", 0xff8b0000 },
- { "dark salmon", 0xffe9967a },
- { "dark sea green", 0xff8fbc8f },
- { "dark slate blue", 0xff483d8b },
- { "dark slate gray", 0xff2f4f4f },
- { "dark slate grey", 0xff2f4f4f },
- { "dark turquoise", 0xff00ced1 },
- { "dark violet", 0xff9400d3 },
- { "DarkBlue", 0xff00008b },
- { "DarkCyan", 0xff008b8b },
- { "DarkGoldenrod", 0xffb8860b },
- { "DarkGoldenrod1", 0xffffb90f },
- { "DarkGoldenrod2", 0xffeead0e },
- { "DarkGoldenrod3", 0xffcd950c },
- { "DarkGoldenrod4", 0xff8b6508 },
- { "DarkGray", 0xffa9a9a9 },
- { "DarkGreen", 0xff006400 },
- { "DarkGrey", 0xffa9a9a9 },
- { "DarkKhaki", 0xffbdb76b },
- { "DarkMagenta", 0xff8b008b },
- { "DarkOliveGreen", 0xff556b2f },
- { "DarkOliveGreen1", 0xffcaff70 },
- { "DarkOliveGreen2", 0xffbcee68 },
- { "DarkOliveGreen3", 0xffa2cd5a },
- { "DarkOliveGreen4", 0xff6e8b3d },
- { "DarkOrange", 0xffff8c00 },
- { "DarkOrange1", 0xffff7f00 },
- { "DarkOrange2", 0xffee7600 },
- { "DarkOrange3", 0xffcd6600 },
- { "DarkOrange4", 0xff8b4500 },
- { "DarkOrchid", 0xff9932cc },
- { "DarkOrchid1", 0xffbf3eff },
- { "DarkOrchid2", 0xffb23aee },
- { "DarkOrchid3", 0xff9a32cd },
- { "DarkOrchid4", 0xff68228b },
- { "DarkRed", 0xff8b0000 },
- { "DarkSalmon", 0xffe9967a },
- { "DarkSeaGreen", 0xff8fbc8f },
- { "DarkSeaGreen1", 0xffc1ffc1 },
- { "DarkSeaGreen2", 0xffb4eeb4 },
- { "DarkSeaGreen3", 0xff9bcd9b },
- { "DarkSeaGreen4", 0xff698b69 },
- { "DarkSlateBlue", 0xff483d8b },
- { "DarkSlateGray", 0xff2f4f4f },
- { "DarkSlateGray1", 0xff97ffff },
- { "DarkSlateGray2", 0xff8deeee },
- { "DarkSlateGray3", 0xff79cdcd },
- { "DarkSlateGray4", 0xff528b8b },
- { "DarkSlateGrey", 0xff2f4f4f },
- { "DarkTurquoise", 0xff00ced1 },
- { "DarkViolet", 0xff9400d3 },
- { "deep pink", 0xffff1493 },
- { "deep sky blue", 0xff00bfff },
- { "DeepPink", 0xffff1493 },
- { "DeepPink1", 0xffff1493 },
- { "DeepPink2", 0xffee1289 },
- { "DeepPink3", 0xffcd1076 },
- { "DeepPink4", 0xff8b0a50 },
- { "DeepSkyBlue", 0xff00bfff },
- { "DeepSkyBlue1", 0xff00bfff },
- { "DeepSkyBlue2", 0xff00b2ee },
- { "DeepSkyBlue3", 0xff009acd },
- { "DeepSkyBlue4", 0xff00688b },
- { "dim gray", 0xff696969 },
- { "dim grey", 0xff696969 },
- { "DimGray", 0xff696969 },
- { "DimGrey", 0xff696969 },
- { "dodger blue", 0xff1e90ff },
- { "DodgerBlue", 0xff1e90ff },
- { "DodgerBlue1", 0xff1e90ff },
- { "DodgerBlue2", 0xff1c86ee },
- { "DodgerBlue3", 0xff1874cd },
- { "DodgerBlue4", 0xff104e8b },
- { "firebrick", 0xffb22222 },
- { "firebrick1", 0xffff3030 },
- { "firebrick2", 0xffee2c2c },
- { "firebrick3", 0xffcd2626 },
- { "firebrick4", 0xff8b1a1a },
- { "floral white", 0xfffffaf0 },
- { "FloralWhite", 0xfffffaf0 },
- { "forest green", 0xff228b22 },
- { "ForestGreen", 0xff228b22 },
- { "gainsboro", 0xffdcdcdc },
- { "ghost white", 0xfff8f8ff },
- { "GhostWhite", 0xfff8f8ff },
- { "gold", 0xffffd700 },
- { "gold1", 0xffffd700 },
- { "gold2", 0xffeec900 },
- { "gold3", 0xffcdad00 },
- { "gold4", 0xff8b7500 },
- { "goldenrod", 0xffdaa520 },
- { "goldenrod1", 0xffffc125 },
- { "goldenrod2", 0xffeeb422 },
- { "goldenrod3", 0xffcd9b1d },
- { "goldenrod4", 0xff8b6914 },
- { "gray", 0xffbebebe },
- { "gray0", 0xff000000 },
- { "gray1", 0xff030303 },
- { "gray10", 0xff1a1a1a },
- { "gray100", 0xffffffff },
- { "gray11", 0xff1c1c1c },
- { "gray12", 0xff1f1f1f },
- { "gray13", 0xff212121 },
- { "gray14", 0xff242424 },
- { "gray15", 0xff262626 },
- { "gray16", 0xff292929 },
- { "gray17", 0xff2b2b2b },
- { "gray18", 0xff2e2e2e },
- { "gray19", 0xff303030 },
- { "gray2", 0xff050505 },
- { "gray20", 0xff333333 },
- { "gray21", 0xff363636 },
- { "gray22", 0xff383838 },
- { "gray23", 0xff3b3b3b },
- { "gray24", 0xff3d3d3d },
- { "gray25", 0xff404040 },
- { "gray26", 0xff424242 },
- { "gray27", 0xff454545 },
- { "gray28", 0xff474747 },
- { "gray29", 0xff4a4a4a },
- { "gray3", 0xff080808 },
- { "gray30", 0xff4d4d4d },
- { "gray31", 0xff4f4f4f },
- { "gray32", 0xff525252 },
- { "gray33", 0xff545454 },
- { "gray34", 0xff575757 },
- { "gray35", 0xff595959 },
- { "gray36", 0xff5c5c5c },
- { "gray37", 0xff5e5e5e },
- { "gray38", 0xff616161 },
- { "gray39", 0xff636363 },
- { "gray4", 0xff0a0a0a },
- { "gray40", 0xff666666 },
- { "gray41", 0xff696969 },
- { "gray42", 0xff6b6b6b },
- { "gray43", 0xff6e6e6e },
- { "gray44", 0xff707070 },
- { "gray45", 0xff737373 },
- { "gray46", 0xff757575 },
- { "gray47", 0xff787878 },
- { "gray48", 0xff7a7a7a },
- { "gray49", 0xff7d7d7d },
- { "gray5", 0xff0d0d0d },
- { "gray50", 0xff7f7f7f },
- { "gray51", 0xff828282 },
- { "gray52", 0xff858585 },
- { "gray53", 0xff878787 },
- { "gray54", 0xff8a8a8a },
- { "gray55", 0xff8c8c8c },
- { "gray56", 0xff8f8f8f },
- { "gray57", 0xff919191 },
- { "gray58", 0xff949494 },
- { "gray59", 0xff969696 },
- { "gray6", 0xff0f0f0f },
- { "gray60", 0xff999999 },
- { "gray61", 0xff9c9c9c },
- { "gray62", 0xff9e9e9e },
- { "gray63", 0xffa1a1a1 },
- { "gray64", 0xffa3a3a3 },
- { "gray65", 0xffa6a6a6 },
- { "gray66", 0xffa8a8a8 },
- { "gray67", 0xffababab },
- { "gray68", 0xffadadad },
- { "gray69", 0xffb0b0b0 },
- { "gray7", 0xff121212 },
- { "gray70", 0xffb3b3b3 },
- { "gray71", 0xffb5b5b5 },
- { "gray72", 0xffb8b8b8 },
- { "gray73", 0xffbababa },
- { "gray74", 0xffbdbdbd },
- { "gray75", 0xffbfbfbf },
- { "gray76", 0xffc2c2c2 },
- { "gray77", 0xffc4c4c4 },
- { "gray78", 0xffc7c7c7 },
- { "gray79", 0xffc9c9c9 },
- { "gray8", 0xff141414 },
- { "gray80", 0xffcccccc },
- { "gray81", 0xffcfcfcf },
- { "gray82", 0xffd1d1d1 },
- { "gray83", 0xffd4d4d4 },
- { "gray84", 0xffd6d6d6 },
- { "gray85", 0xffd9d9d9 },
- { "gray86", 0xffdbdbdb },
- { "gray87", 0xffdedede },
- { "gray88", 0xffe0e0e0 },
- { "gray89", 0xffe3e3e3 },
- { "gray9", 0xff171717 },
- { "gray90", 0xffe5e5e5 },
- { "gray91", 0xffe8e8e8 },
- { "gray92", 0xffebebeb },
- { "gray93", 0xffededed },
- { "gray94", 0xfff0f0f0 },
- { "gray95", 0xfff2f2f2 },
- { "gray96", 0xfff5f5f5 },
- { "gray97", 0xfff7f7f7 },
- { "gray98", 0xfffafafa },
- { "gray99", 0xfffcfcfc },
- { "green", 0xff00ff00 },
- { "green yellow", 0xffadff2f },
- { "green1", 0xff00ff00 },
- { "green2", 0xff00ee00 },
- { "green3", 0xff00cd00 },
- { "green4", 0xff008b00 },
- { "GreenYellow", 0xffadff2f },
- { "grey", 0xffbebebe },
- { "grey0", 0xff000000 },
- { "grey1", 0xff030303 },
- { "grey10", 0xff1a1a1a },
- { "grey100", 0xffffffff },
- { "grey11", 0xff1c1c1c },
- { "grey12", 0xff1f1f1f },
- { "grey13", 0xff212121 },
- { "grey14", 0xff242424 },
- { "grey15", 0xff262626 },
- { "grey16", 0xff292929 },
- { "grey17", 0xff2b2b2b },
- { "grey18", 0xff2e2e2e },
- { "grey19", 0xff303030 },
- { "grey2", 0xff050505 },
- { "grey20", 0xff333333 },
- { "grey21", 0xff363636 },
- { "grey22", 0xff383838 },
- { "grey23", 0xff3b3b3b },
- { "grey24", 0xff3d3d3d },
- { "grey25", 0xff404040 },
- { "grey26", 0xff424242 },
- { "grey27", 0xff454545 },
- { "grey28", 0xff474747 },
- { "grey29", 0xff4a4a4a },
- { "grey3", 0xff080808 },
- { "grey30", 0xff4d4d4d },
- { "grey31", 0xff4f4f4f },
- { "grey32", 0xff525252 },
- { "grey33", 0xff545454 },
- { "grey34", 0xff575757 },
- { "grey35", 0xff595959 },
- { "grey36", 0xff5c5c5c },
- { "grey37", 0xff5e5e5e },
- { "grey38", 0xff616161 },
- { "grey39", 0xff636363 },
- { "grey4", 0xff0a0a0a },
- { "grey40", 0xff666666 },
- { "grey41", 0xff696969 },
- { "grey42", 0xff6b6b6b },
- { "grey43", 0xff6e6e6e },
- { "grey44", 0xff707070 },
- { "grey45", 0xff737373 },
- { "grey46", 0xff757575 },
- { "grey47", 0xff787878 },
- { "grey48", 0xff7a7a7a },
- { "grey49", 0xff7d7d7d },
- { "grey5", 0xff0d0d0d },
- { "grey50", 0xff7f7f7f },
- { "grey51", 0xff828282 },
- { "grey52", 0xff858585 },
- { "grey53", 0xff878787 },
- { "grey54", 0xff8a8a8a },
- { "grey55", 0xff8c8c8c },
- { "grey56", 0xff8f8f8f },
- { "grey57", 0xff919191 },
- { "grey58", 0xff949494 },
- { "grey59", 0xff969696 },
- { "grey6", 0xff0f0f0f },
- { "grey60", 0xff999999 },
- { "grey61", 0xff9c9c9c },
- { "grey62", 0xff9e9e9e },
- { "grey63", 0xffa1a1a1 },
- { "grey64", 0xffa3a3a3 },
- { "grey65", 0xffa6a6a6 },
- { "grey66", 0xffa8a8a8 },
- { "grey67", 0xffababab },
- { "grey68", 0xffadadad },
- { "grey69", 0xffb0b0b0 },
- { "grey7", 0xff121212 },
- { "grey70", 0xffb3b3b3 },
- { "grey71", 0xffb5b5b5 },
- { "grey72", 0xffb8b8b8 },
- { "grey73", 0xffbababa },
- { "grey74", 0xffbdbdbd },
- { "grey75", 0xffbfbfbf },
- { "grey76", 0xffc2c2c2 },
- { "grey77", 0xffc4c4c4 },
- { "grey78", 0xffc7c7c7 },
- { "grey79", 0xffc9c9c9 },
- { "grey8", 0xff141414 },
- { "grey80", 0xffcccccc },
- { "grey81", 0xffcfcfcf },
- { "grey82", 0xffd1d1d1 },
- { "grey83", 0xffd4d4d4 },
- { "grey84", 0xffd6d6d6 },
- { "grey85", 0xffd9d9d9 },
- { "grey86", 0xffdbdbdb },
- { "grey87", 0xffdedede },
- { "grey88", 0xffe0e0e0 },
- { "grey89", 0xffe3e3e3 },
- { "grey9", 0xff171717 },
- { "grey90", 0xffe5e5e5 },
- { "grey91", 0xffe8e8e8 },
- { "grey92", 0xffebebeb },
- { "grey93", 0xffededed },
- { "grey94", 0xfff0f0f0 },
- { "grey95", 0xfff2f2f2 },
- { "grey96", 0xfff5f5f5 },
- { "grey97", 0xfff7f7f7 },
- { "grey98", 0xfffafafa },
- { "grey99", 0xfffcfcfc },
- { "honeydew", 0xfff0fff0 },
- { "honeydew1", 0xfff0fff0 },
- { "honeydew2", 0xffe0eee0 },
- { "honeydew3", 0xffc1cdc1 },
- { "honeydew4", 0xff838b83 },
- { "hot pink", 0xffff69b4 },
- { "HotPink", 0xffff69b4 },
- { "HotPink1", 0xffff6eb4 },
- { "HotPink2", 0xffee6aa7 },
- { "HotPink3", 0xffcd6090 },
- { "HotPink4", 0xff8b3a62 },
- { "indian red", 0xffcd5c5c },
- { "IndianRed", 0xffcd5c5c },
- { "IndianRed1", 0xffff6a6a },
- { "IndianRed2", 0xffee6363 },
- { "IndianRed3", 0xffcd5555 },
- { "IndianRed4", 0xff8b3a3a },
- { "ivory", 0xfffffff0 },
- { "ivory1", 0xfffffff0 },
- { "ivory2", 0xffeeeee0 },
- { "ivory3", 0xffcdcdc1 },
- { "ivory4", 0xff8b8b83 },
- { "khaki", 0xfff0e68c },
- { "khaki1", 0xfffff68f },
- { "khaki2", 0xffeee685 },
- { "khaki3", 0xffcdc673 },
- { "khaki4", 0xff8b864e },
- { "lavender", 0xffe6e6fa },
- { "lavender blush", 0xfffff0f5 },
- { "LavenderBlush", 0xfffff0f5 },
- { "LavenderBlush1", 0xfffff0f5 },
- { "LavenderBlush2", 0xffeee0e5 },
- { "LavenderBlush3", 0xffcdc1c5 },
- { "LavenderBlush4", 0xff8b8386 },
- { "lawn green", 0xff7cfc00 },
- { "LawnGreen", 0xff7cfc00 },
- { "lemon chiffon", 0xfffffacd },
- { "LemonChiffon", 0xfffffacd },
- { "LemonChiffon1", 0xfffffacd },
- { "LemonChiffon2", 0xffeee9bf },
- { "LemonChiffon3", 0xffcdc9a5 },
- { "LemonChiffon4", 0xff8b8970 },
- { "light blue", 0xffadd8e6 },
- { "light coral", 0xfff08080 },
- { "light cyan", 0xffe0ffff },
- { "light goldenrod", 0xffeedd82 },
- { "light goldenrod yellow", 0xfffafad2 },
- { "light gray", 0xffd3d3d3 },
- { "light green", 0xff90ee90 },
- { "light grey", 0xffd3d3d3 },
- { "light pink", 0xffffb6c1 },
- { "light salmon", 0xffffa07a },
- { "light sea green", 0xff20b2aa },
- { "light sky blue", 0xff87cefa },
- { "light slate blue", 0xff8470ff },
- { "light slate gray", 0xff778899 },
- { "light slate grey", 0xff778899 },
- { "light steel blue", 0xffb0c4de },
- { "light yellow", 0xffffffe0 },
- { "LightBlue", 0xffadd8e6 },
- { "LightBlue1", 0xffbfefff },
- { "LightBlue2", 0xffb2dfee },
- { "LightBlue3", 0xff9ac0cd },
- { "LightBlue4", 0xff68838b },
- { "LightCoral", 0xfff08080 },
- { "LightCyan", 0xffe0ffff },
- { "LightCyan1", 0xffe0ffff },
- { "LightCyan2", 0xffd1eeee },
- { "LightCyan3", 0xffb4cdcd },
- { "LightCyan4", 0xff7a8b8b },
- { "LightGoldenrod", 0xffeedd82 },
- { "LightGoldenrod1", 0xffffec8b },
- { "LightGoldenrod2", 0xffeedc82 },
- { "LightGoldenrod3", 0xffcdbe70 },
- { "LightGoldenrod4", 0xff8b814c },
- { "LightGoldenrodYellow", 0xfffafad2 },
- { "LightGray", 0xffd3d3d3 },
- { "LightGreen", 0xff90ee90 },
- { "LightGrey", 0xffd3d3d3 },
- { "LightPink", 0xffffb6c1 },
- { "LightPink1", 0xffffaeb9 },
- { "LightPink2", 0xffeea2ad },
- { "LightPink3", 0xffcd8c95 },
- { "LightPink4", 0xff8b5f65 },
- { "LightSalmon", 0xffffa07a },
- { "LightSalmon1", 0xffffa07a },
- { "LightSalmon2", 0xffee9572 },
- { "LightSalmon3", 0xffcd8162 },
- { "LightSalmon4", 0xff8b5742 },
- { "LightSeaGreen", 0xff20b2aa },
- { "LightSkyBlue", 0xff87cefa },
- { "LightSkyBlue1", 0xffb0e2ff },
- { "LightSkyBlue2", 0xffa4d3ee },
- { "LightSkyBlue3", 0xff8db6cd },
- { "LightSkyBlue4", 0xff607b8b },
- { "LightSlateBlue", 0xff8470ff },
- { "LightSlateGray", 0xff778899 },
- { "LightSlateGrey", 0xff778899 },
- { "LightSteelBlue", 0xffb0c4de },
- { "LightSteelBlue1", 0xffcae1ff },
- { "LightSteelBlue2", 0xffbcd2ee },
- { "LightSteelBlue3", 0xffa2b5cd },
- { "LightSteelBlue4", 0xff6e7b8b },
- { "LightYellow", 0xffffffe0 },
- { "LightYellow1", 0xffffffe0 },
- { "LightYellow2", 0xffeeeed1 },
- { "LightYellow3", 0xffcdcdb4 },
- { "LightYellow4", 0xff8b8b7a },
- { "lime green", 0xff32cd32 },
- { "LimeGreen", 0xff32cd32 },
- { "linen", 0xfffaf0e6 },
- { "magenta", 0xffff00ff },
- { "magenta1", 0xffff00ff },
- { "magenta2", 0xffee00ee },
- { "magenta3", 0xffcd00cd },
- { "magenta4", 0xff8b008b },
- { "maroon", 0xffb03060 },
- { "maroon1", 0xffff34b3 },
- { "maroon2", 0xffee30a7 },
- { "maroon3", 0xffcd2990 },
- { "maroon4", 0xff8b1c62 },
- { "medium aquamarine", 0xff66cdaa },
- { "medium blue", 0xff0000cd },
- { "medium orchid", 0xffba55d3 },
- { "medium purple", 0xff9370db },
- { "medium sea green", 0xff3cb371 },
- { "medium slate blue", 0xff7b68ee },
- { "medium spring green", 0xff00fa9a },
- { "medium turquoise", 0xff48d1cc },
- { "medium violet red", 0xffc71585 },
- { "MediumAquamarine", 0xff66cdaa },
- { "MediumBlue", 0xff0000cd },
- { "MediumOrchid", 0xffba55d3 },
- { "MediumOrchid1", 0xffe066ff },
- { "MediumOrchid2", 0xffd15fee },
- { "MediumOrchid3", 0xffb452cd },
- { "MediumOrchid4", 0xff7a378b },
- { "MediumPurple", 0xff9370db },
- { "MediumPurple1", 0xffab82ff },
- { "MediumPurple2", 0xff9f79ee },
- { "MediumPurple3", 0xff8968cd },
- { "MediumPurple4", 0xff5d478b },
- { "MediumSeaGreen", 0xff3cb371 },
- { "MediumSlateBlue", 0xff7b68ee },
- { "MediumSpringGreen", 0xff00fa9a },
- { "MediumTurquoise", 0xff48d1cc },
- { "MediumVioletRed", 0xffc71585 },
- { "midnight blue", 0xff191970 },
- { "MidnightBlue", 0xff191970 },
- { "mint cream", 0xfff5fffa },
- { "MintCream", 0xfff5fffa },
- { "misty rose", 0xffffe4e1 },
- { "MistyRose", 0xffffe4e1 },
- { "MistyRose1", 0xffffe4e1 },
- { "MistyRose2", 0xffeed5d2 },
- { "MistyRose3", 0xffcdb7b5 },
- { "MistyRose4", 0xff8b7d7b },
- { "moccasin", 0xffffe4b5 },
- { "navajo white", 0xffffdead },
- { "NavajoWhite", 0xffffdead },
- { "NavajoWhite1", 0xffffdead },
- { "NavajoWhite2", 0xffeecfa1 },
- { "NavajoWhite3", 0xffcdb38b },
- { "NavajoWhite4", 0xff8b795e },
- { "navy", 0xff000080 },
- { "navy blue", 0xff000080 },
- { "NavyBlue", 0xff000080 },
- { "old lace", 0xfffdf5e6 },
- { "OldLace", 0xfffdf5e6 },
- { "olive drab", 0xff6b8e23 },
- { "OliveDrab", 0xff6b8e23 },
- { "OliveDrab1", 0xffc0ff3e },
- { "OliveDrab2", 0xffb3ee3a },
- { "OliveDrab3", 0xff9acd32 },
- { "OliveDrab4", 0xff698b22 },
- { "orange", 0xffffa500 },
- { "orange red", 0xffff4500 },
- { "orange1", 0xffffa500 },
- { "orange2", 0xffee9a00 },
- { "orange3", 0xffcd8500 },
- { "orange4", 0xff8b5a00 },
- { "OrangeRed", 0xffff4500 },
- { "OrangeRed1", 0xffff4500 },
- { "OrangeRed2", 0xffee4000 },
- { "OrangeRed3", 0xffcd3700 },
- { "OrangeRed4", 0xff8b2500 },
- { "orchid", 0xffda70d6 },
- { "orchid1", 0xffff83fa },
- { "orchid2", 0xffee7ae9 },
- { "orchid3", 0xffcd69c9 },
- { "orchid4", 0xff8b4789 },
- { "pale goldenrod", 0xffeee8aa },
- { "pale green", 0xff98fb98 },
- { "pale turquoise", 0xffafeeee },
- { "pale violet red", 0xffdb7093 },
- { "PaleGoldenrod", 0xffeee8aa },
- { "PaleGreen", 0xff98fb98 },
- { "PaleGreen1", 0xff9aff9a },
- { "PaleGreen2", 0xff90ee90 },
- { "PaleGreen3", 0xff7ccd7c },
- { "PaleGreen4", 0xff548b54 },
- { "PaleTurquoise", 0xffafeeee },
- { "PaleTurquoise1", 0xffbbffff },
- { "PaleTurquoise2", 0xffaeeeee },
- { "PaleTurquoise3", 0xff96cdcd },
- { "PaleTurquoise4", 0xff668b8b },
- { "PaleVioletRed", 0xffdb7093 },
- { "PaleVioletRed1", 0xffff82ab },
- { "PaleVioletRed2", 0xffee799f },
- { "PaleVioletRed3", 0xffcd6889 },
- { "PaleVioletRed4", 0xff8b475d },
- { "papaya whip", 0xffffefd5 },
- { "PapayaWhip", 0xffffefd5 },
- { "peach puff", 0xffffdab9 },
- { "PeachPuff", 0xffffdab9 },
- { "PeachPuff1", 0xffffdab9 },
- { "PeachPuff2", 0xffeecbad },
- { "PeachPuff3", 0xffcdaf95 },
- { "PeachPuff4", 0xff8b7765 },
- { "peru", 0xffcd853f },
- { "pink", 0xffffc0cb },
- { "pink1", 0xffffb5c5 },
- { "pink2", 0xffeea9b8 },
- { "pink3", 0xffcd919e },
- { "pink4", 0xff8b636c },
- { "plum", 0xffdda0dd },
- { "plum1", 0xffffbbff },
- { "plum2", 0xffeeaeee },
- { "plum3", 0xffcd96cd },
- { "plum4", 0xff8b668b },
- { "powder blue", 0xffb0e0e6 },
- { "PowderBlue", 0xffb0e0e6 },
- { "purple", 0xffa020f0 },
- { "purple1", 0xff9b30ff },
- { "purple2", 0xff912cee },
- { "purple3", 0xff7d26cd },
- { "purple4", 0xff551a8b },
- { "red", 0xffff0000 },
- { "red1", 0xffff0000 },
- { "red2", 0xffee0000 },
- { "red3", 0xffcd0000 },
- { "red4", 0xff8b0000 },
- { "rosy brown", 0xffbc8f8f },
- { "RosyBrown", 0xffbc8f8f },
- { "RosyBrown1", 0xffffc1c1 },
- { "RosyBrown2", 0xffeeb4b4 },
- { "RosyBrown3", 0xffcd9b9b },
- { "RosyBrown4", 0xff8b6969 },
- { "royal blue", 0xff4169e1 },
- { "RoyalBlue", 0xff4169e1 },
- { "RoyalBlue1", 0xff4876ff },
- { "RoyalBlue2", 0xff436eee },
- { "RoyalBlue3", 0xff3a5fcd },
- { "RoyalBlue4", 0xff27408b },
- { "saddle brown", 0xff8b4513 },
- { "SaddleBrown", 0xff8b4513 },
- { "salmon", 0xfffa8072 },
- { "salmon1", 0xffff8c69 },
- { "salmon2", 0xffee8262 },
- { "salmon3", 0xffcd7054 },
- { "salmon4", 0xff8b4c39 },
- { "sandy brown", 0xfff4a460 },
- { "SandyBrown", 0xfff4a460 },
- { "sea green", 0xff2e8b57 },
- { "SeaGreen", 0xff2e8b57 },
- { "SeaGreen1", 0xff54ff9f },
- { "SeaGreen2", 0xff4eee94 },
- { "SeaGreen3", 0xff43cd80 },
- { "SeaGreen4", 0xff2e8b57 },
- { "seashell", 0xfffff5ee },
- { "seashell1", 0xfffff5ee },
- { "seashell2", 0xffeee5de },
- { "seashell3", 0xffcdc5bf },
- { "seashell4", 0xff8b8682 },
- { "sienna", 0xffa0522d },
- { "sienna1", 0xffff8247 },
- { "sienna2", 0xffee7942 },
- { "sienna3", 0xffcd6839 },
- { "sienna4", 0xff8b4726 },
- { "sky blue", 0xff87ceeb },
- { "SkyBlue", 0xff87ceeb },
- { "SkyBlue1", 0xff87ceff },
- { "SkyBlue2", 0xff7ec0ee },
- { "SkyBlue3", 0xff6ca6cd },
- { "SkyBlue4", 0xff4a708b },
- { "slate blue", 0xff6a5acd },
- { "slate gray", 0xff708090 },
- { "slate grey", 0xff708090 },
- { "SlateBlue", 0xff6a5acd },
- { "SlateBlue1", 0xff836fff },
- { "SlateBlue2", 0xff7a67ee },
- { "SlateBlue3", 0xff6959cd },
- { "SlateBlue4", 0xff473c8b },
- { "SlateGray", 0xff708090 },
- { "SlateGray1", 0xffc6e2ff },
- { "SlateGray2", 0xffb9d3ee },
- { "SlateGray3", 0xff9fb6cd },
- { "SlateGray4", 0xff6c7b8b },
- { "SlateGrey", 0xff708090 },
- { "snow", 0xfffffafa },
- { "snow1", 0xfffffafa },
- { "snow2", 0xffeee9e9 },
- { "snow3", 0xffcdc9c9 },
- { "snow4", 0xff8b8989 },
- { "spring green", 0xff00ff7f },
- { "SpringGreen", 0xff00ff7f },
- { "SpringGreen1", 0xff00ff7f },
- { "SpringGreen2", 0xff00ee76 },
- { "SpringGreen3", 0xff00cd66 },
- { "SpringGreen4", 0xff008b45 },
- { "steel blue", 0xff4682b4 },
- { "SteelBlue", 0xff4682b4 },
- { "SteelBlue1", 0xff63b8ff },
- { "SteelBlue2", 0xff5cacee },
- { "SteelBlue3", 0xff4f94cd },
- { "SteelBlue4", 0xff36648b },
- { "tan", 0xffd2b48c },
- { "tan1", 0xffffa54f },
- { "tan2", 0xffee9a49 },
- { "tan3", 0xffcd853f },
- { "tan4", 0xff8b5a2b },
- { "thistle", 0xffd8bfd8 },
- { "thistle1", 0xffffe1ff },
- { "thistle2", 0xffeed2ee },
- { "thistle3", 0xffcdb5cd },
- { "thistle4", 0xff8b7b8b },
- { "tomato", 0xffff6347 },
- { "tomato1", 0xffff6347 },
- { "tomato2", 0xffee5c42 },
- { "tomato3", 0xffcd4f39 },
- { "tomato4", 0xff8b3626 },
- { "turquoise", 0xff40e0d0 },
- { "turquoise1", 0xff00f5ff },
- { "turquoise2", 0xff00e5ee },
- { "turquoise3", 0xff00c5cd },
- { "turquoise4", 0xff00868b },
- { "violet", 0xffee82ee },
- { "violet red", 0xffd02090 },
- { "VioletRed", 0xffd02090 },
- { "VioletRed1", 0xffff3e96 },
- { "VioletRed2", 0xffee3a8c },
- { "VioletRed3", 0xffcd3278 },
- { "VioletRed4", 0xff8b2252 },
- { "wheat", 0xfff5deb3 },
- { "wheat1", 0xffffe7ba },
- { "wheat2", 0xffeed8ae },
- { "wheat3", 0xffcdba96 },
- { "wheat4", 0xff8b7e66 },
- { "white", 0xffffffff },
- { "white smoke", 0xfff5f5f5 },
- { "WhiteSmoke", 0xfff5f5f5 },
- { "yellow", 0xffffff00 },
- { "yellow green", 0xff9acd32 },
- { "yellow1", 0xffffff00 },
- { "yellow2", 0xffeeee00 },
- { "yellow3", 0xffcdcd00 },
- { "yellow4", 0xff8b8b00 },
- { "YellowGreen", 0xff9acd32 }
+ { "alice blue", 0xfff0f8ff },
+ { "AliceBlue", 0xfff0f8ff },
+ { "antique white", 0xfffaebd7 },
+ { "AntiqueWhite", 0xfffaebd7 },
+ { "AntiqueWhite1", 0xffffefdb },
+ { "AntiqueWhite2", 0xffeedfcc },
+ { "AntiqueWhite3", 0xffcdc0b0 },
+ { "AntiqueWhite4", 0xff8b8378 },
+ { "aquamarine", 0xff7fffd4 },
+ { "aquamarine1", 0xff7fffd4 },
+ { "aquamarine2", 0xff76eec6 },
+ { "aquamarine3", 0xff66cdaa },
+ { "aquamarine4", 0xff458b74 },
+ { "azure", 0xfff0ffff },
+ { "azure1", 0xfff0ffff },
+ { "azure2", 0xffe0eeee },
+ { "azure3", 0xffc1cdcd },
+ { "azure4", 0xff838b8b },
+ { "beige", 0xfff5f5dc },
+ { "bisque", 0xffffe4c4 },
+ { "bisque1", 0xffffe4c4 },
+ { "bisque2", 0xffeed5b7 },
+ { "bisque3", 0xffcdb79e },
+ { "bisque4", 0xff8b7d6b },
+ { "black", 0xff000000 },
+ { "blanched almond", 0xffffebcd },
+ { "BlanchedAlmond", 0xffffebcd },
+ { "blue", 0xff0000ff },
+ { "blue violet", 0xff8a2be2 },
+ { "blue1", 0xff0000ff },
+ { "blue2", 0xff0000ee },
+ { "blue3", 0xff0000cd },
+ { "blue4", 0xff00008b },
+ { "BlueViolet", 0xff8a2be2 },
+ { "brown", 0xffa52a2a },
+ { "brown1", 0xffff4040 },
+ { "brown2", 0xffee3b3b },
+ { "brown3", 0xffcd3333 },
+ { "brown4", 0xff8b2323 },
+ { "burlywood", 0xffdeb887 },
+ { "burlywood1", 0xffffd39b },
+ { "burlywood2", 0xffeec591 },
+ { "burlywood3", 0xffcdaa7d },
+ { "burlywood4", 0xff8b7355 },
+ { "cadet blue", 0xff5f9ea0 },
+ { "CadetBlue", 0xff5f9ea0 },
+ { "CadetBlue1", 0xff98f5ff },
+ { "CadetBlue2", 0xff8ee5ee },
+ { "CadetBlue3", 0xff7ac5cd },
+ { "CadetBlue4", 0xff53868b },
+ { "chartreuse", 0xff7fff00 },
+ { "chartreuse1", 0xff7fff00 },
+ { "chartreuse2", 0xff76ee00 },
+ { "chartreuse3", 0xff66cd00 },
+ { "chartreuse4", 0xff458b00 },
+ { "chocolate", 0xffd2691e },
+ { "chocolate1", 0xffff7f24 },
+ { "chocolate2", 0xffee7621 },
+ { "chocolate3", 0xffcd661d },
+ { "chocolate4", 0xff8b4513 },
+ { "coral", 0xffff7f50 },
+ { "coral1", 0xffff7256 },
+ { "coral2", 0xffee6a50 },
+ { "coral3", 0xffcd5b45 },
+ { "coral4", 0xff8b3e2f },
+ { "cornflower blue", 0xff6495ed },
+ { "CornflowerBlue", 0xff6495ed },
+ { "cornsilk", 0xfffff8dc },
+ { "cornsilk1", 0xfffff8dc },
+ { "cornsilk2", 0xffeee8cd },
+ { "cornsilk3", 0xffcdc8b1 },
+ { "cornsilk4", 0xff8b8878 },
+ { "cyan", 0xff00ffff },
+ { "cyan1", 0xff00ffff },
+ { "cyan2", 0xff00eeee },
+ { "cyan3", 0xff00cdcd },
+ { "cyan4", 0xff008b8b },
+ { "dark blue", 0xff00008b },
+ { "dark cyan", 0xff008b8b },
+ { "dark goldenrod", 0xffb8860b },
+ { "dark gray", 0xffa9a9a9 },
+ { "dark green", 0xff006400 },
+ { "dark grey", 0xffa9a9a9 },
+ { "dark khaki", 0xffbdb76b },
+ { "dark magenta", 0xff8b008b },
+ { "dark olive green", 0xff556b2f },
+ { "dark orange", 0xffff8c00 },
+ { "dark orchid", 0xff9932cc },
+ { "dark red", 0xff8b0000 },
+ { "dark salmon", 0xffe9967a },
+ { "dark sea green", 0xff8fbc8f },
+ { "dark slate blue", 0xff483d8b },
+ { "dark slate gray", 0xff2f4f4f },
+ { "dark slate grey", 0xff2f4f4f },
+ { "dark turquoise", 0xff00ced1 },
+ { "dark violet", 0xff9400d3 },
+ { "DarkBlue", 0xff00008b },
+ { "DarkCyan", 0xff008b8b },
+ { "DarkGoldenrod", 0xffb8860b },
+ { "DarkGoldenrod1", 0xffffb90f },
+ { "DarkGoldenrod2", 0xffeead0e },
+ { "DarkGoldenrod3", 0xffcd950c },
+ { "DarkGoldenrod4", 0xff8b6508 },
+ { "DarkGray", 0xffa9a9a9 },
+ { "DarkGreen", 0xff006400 },
+ { "DarkGrey", 0xffa9a9a9 },
+ { "DarkKhaki", 0xffbdb76b },
+ { "DarkMagenta", 0xff8b008b },
+ { "DarkOliveGreen", 0xff556b2f },
+ { "DarkOliveGreen1", 0xffcaff70 },
+ { "DarkOliveGreen2", 0xffbcee68 },
+ { "DarkOliveGreen3", 0xffa2cd5a },
+ { "DarkOliveGreen4", 0xff6e8b3d },
+ { "DarkOrange", 0xffff8c00 },
+ { "DarkOrange1", 0xffff7f00 },
+ { "DarkOrange2", 0xffee7600 },
+ { "DarkOrange3", 0xffcd6600 },
+ { "DarkOrange4", 0xff8b4500 },
+ { "DarkOrchid", 0xff9932cc },
+ { "DarkOrchid1", 0xffbf3eff },
+ { "DarkOrchid2", 0xffb23aee },
+ { "DarkOrchid3", 0xff9a32cd },
+ { "DarkOrchid4", 0xff68228b },
+ { "DarkRed", 0xff8b0000 },
+ { "DarkSalmon", 0xffe9967a },
+ { "DarkSeaGreen", 0xff8fbc8f },
+ { "DarkSeaGreen1", 0xffc1ffc1 },
+ { "DarkSeaGreen2", 0xffb4eeb4 },
+ { "DarkSeaGreen3", 0xff9bcd9b },
+ { "DarkSeaGreen4", 0xff698b69 },
+ { "DarkSlateBlue", 0xff483d8b },
+ { "DarkSlateGray", 0xff2f4f4f },
+ { "DarkSlateGray1", 0xff97ffff },
+ { "DarkSlateGray2", 0xff8deeee },
+ { "DarkSlateGray3", 0xff79cdcd },
+ { "DarkSlateGray4", 0xff528b8b },
+ { "DarkSlateGrey", 0xff2f4f4f },
+ { "DarkTurquoise", 0xff00ced1 },
+ { "DarkViolet", 0xff9400d3 },
+ { "deep pink", 0xffff1493 },
+ { "deep sky blue", 0xff00bfff },
+ { "DeepPink", 0xffff1493 },
+ { "DeepPink1", 0xffff1493 },
+ { "DeepPink2", 0xffee1289 },
+ { "DeepPink3", 0xffcd1076 },
+ { "DeepPink4", 0xff8b0a50 },
+ { "DeepSkyBlue", 0xff00bfff },
+ { "DeepSkyBlue1", 0xff00bfff },
+ { "DeepSkyBlue2", 0xff00b2ee },
+ { "DeepSkyBlue3", 0xff009acd },
+ { "DeepSkyBlue4", 0xff00688b },
+ { "dim gray", 0xff696969 },
+ { "dim grey", 0xff696969 },
+ { "DimGray", 0xff696969 },
+ { "DimGrey", 0xff696969 },
+ { "dodger blue", 0xff1e90ff },
+ { "DodgerBlue", 0xff1e90ff },
+ { "DodgerBlue1", 0xff1e90ff },
+ { "DodgerBlue2", 0xff1c86ee },
+ { "DodgerBlue3", 0xff1874cd },
+ { "DodgerBlue4", 0xff104e8b },
+ { "firebrick", 0xffb22222 },
+ { "firebrick1", 0xffff3030 },
+ { "firebrick2", 0xffee2c2c },
+ { "firebrick3", 0xffcd2626 },
+ { "firebrick4", 0xff8b1a1a },
+ { "floral white", 0xfffffaf0 },
+ { "FloralWhite", 0xfffffaf0 },
+ { "forest green", 0xff228b22 },
+ { "ForestGreen", 0xff228b22 },
+ { "gainsboro", 0xffdcdcdc },
+ { "ghost white", 0xfff8f8ff },
+ { "GhostWhite", 0xfff8f8ff },
+ { "gold", 0xffffd700 },
+ { "gold1", 0xffffd700 },
+ { "gold2", 0xffeec900 },
+ { "gold3", 0xffcdad00 },
+ { "gold4", 0xff8b7500 },
+ { "goldenrod", 0xffdaa520 },
+ { "goldenrod1", 0xffffc125 },
+ { "goldenrod2", 0xffeeb422 },
+ { "goldenrod3", 0xffcd9b1d },
+ { "goldenrod4", 0xff8b6914 },
+ { "gray", 0xffbebebe },
+ { "gray0", 0xff000000 },
+ { "gray1", 0xff030303 },
+ { "gray10", 0xff1a1a1a },
+ { "gray100", 0xffffffff },
+ { "gray11", 0xff1c1c1c },
+ { "gray12", 0xff1f1f1f },
+ { "gray13", 0xff212121 },
+ { "gray14", 0xff242424 },
+ { "gray15", 0xff262626 },
+ { "gray16", 0xff292929 },
+ { "gray17", 0xff2b2b2b },
+ { "gray18", 0xff2e2e2e },
+ { "gray19", 0xff303030 },
+ { "gray2", 0xff050505 },
+ { "gray20", 0xff333333 },
+ { "gray21", 0xff363636 },
+ { "gray22", 0xff383838 },
+ { "gray23", 0xff3b3b3b },
+ { "gray24", 0xff3d3d3d },
+ { "gray25", 0xff404040 },
+ { "gray26", 0xff424242 },
+ { "gray27", 0xff454545 },
+ { "gray28", 0xff474747 },
+ { "gray29", 0xff4a4a4a },
+ { "gray3", 0xff080808 },
+ { "gray30", 0xff4d4d4d },
+ { "gray31", 0xff4f4f4f },
+ { "gray32", 0xff525252 },
+ { "gray33", 0xff545454 },
+ { "gray34", 0xff575757 },
+ { "gray35", 0xff595959 },
+ { "gray36", 0xff5c5c5c },
+ { "gray37", 0xff5e5e5e },
+ { "gray38", 0xff616161 },
+ { "gray39", 0xff636363 },
+ { "gray4", 0xff0a0a0a },
+ { "gray40", 0xff666666 },
+ { "gray41", 0xff696969 },
+ { "gray42", 0xff6b6b6b },
+ { "gray43", 0xff6e6e6e },
+ { "gray44", 0xff707070 },
+ { "gray45", 0xff737373 },
+ { "gray46", 0xff757575 },
+ { "gray47", 0xff787878 },
+ { "gray48", 0xff7a7a7a },
+ { "gray49", 0xff7d7d7d },
+ { "gray5", 0xff0d0d0d },
+ { "gray50", 0xff7f7f7f },
+ { "gray51", 0xff828282 },
+ { "gray52", 0xff858585 },
+ { "gray53", 0xff878787 },
+ { "gray54", 0xff8a8a8a },
+ { "gray55", 0xff8c8c8c },
+ { "gray56", 0xff8f8f8f },
+ { "gray57", 0xff919191 },
+ { "gray58", 0xff949494 },
+ { "gray59", 0xff969696 },
+ { "gray6", 0xff0f0f0f },
+ { "gray60", 0xff999999 },
+ { "gray61", 0xff9c9c9c },
+ { "gray62", 0xff9e9e9e },
+ { "gray63", 0xffa1a1a1 },
+ { "gray64", 0xffa3a3a3 },
+ { "gray65", 0xffa6a6a6 },
+ { "gray66", 0xffa8a8a8 },
+ { "gray67", 0xffababab },
+ { "gray68", 0xffadadad },
+ { "gray69", 0xffb0b0b0 },
+ { "gray7", 0xff121212 },
+ { "gray70", 0xffb3b3b3 },
+ { "gray71", 0xffb5b5b5 },
+ { "gray72", 0xffb8b8b8 },
+ { "gray73", 0xffbababa },
+ { "gray74", 0xffbdbdbd },
+ { "gray75", 0xffbfbfbf },
+ { "gray76", 0xffc2c2c2 },
+ { "gray77", 0xffc4c4c4 },
+ { "gray78", 0xffc7c7c7 },
+ { "gray79", 0xffc9c9c9 },
+ { "gray8", 0xff141414 },
+ { "gray80", 0xffcccccc },
+ { "gray81", 0xffcfcfcf },
+ { "gray82", 0xffd1d1d1 },
+ { "gray83", 0xffd4d4d4 },
+ { "gray84", 0xffd6d6d6 },
+ { "gray85", 0xffd9d9d9 },
+ { "gray86", 0xffdbdbdb },
+ { "gray87", 0xffdedede },
+ { "gray88", 0xffe0e0e0 },
+ { "gray89", 0xffe3e3e3 },
+ { "gray9", 0xff171717 },
+ { "gray90", 0xffe5e5e5 },
+ { "gray91", 0xffe8e8e8 },
+ { "gray92", 0xffebebeb },
+ { "gray93", 0xffededed },
+ { "gray94", 0xfff0f0f0 },
+ { "gray95", 0xfff2f2f2 },
+ { "gray96", 0xfff5f5f5 },
+ { "gray97", 0xfff7f7f7 },
+ { "gray98", 0xfffafafa },
+ { "gray99", 0xfffcfcfc },
+ { "green", 0xff00ff00 },
+ { "green yellow", 0xffadff2f },
+ { "green1", 0xff00ff00 },
+ { "green2", 0xff00ee00 },
+ { "green3", 0xff00cd00 },
+ { "green4", 0xff008b00 },
+ { "GreenYellow", 0xffadff2f },
+ { "grey", 0xffbebebe },
+ { "grey0", 0xff000000 },
+ { "grey1", 0xff030303 },
+ { "grey10", 0xff1a1a1a },
+ { "grey100", 0xffffffff },
+ { "grey11", 0xff1c1c1c },
+ { "grey12", 0xff1f1f1f },
+ { "grey13", 0xff212121 },
+ { "grey14", 0xff242424 },
+ { "grey15", 0xff262626 },
+ { "grey16", 0xff292929 },
+ { "grey17", 0xff2b2b2b },
+ { "grey18", 0xff2e2e2e },
+ { "grey19", 0xff303030 },
+ { "grey2", 0xff050505 },
+ { "grey20", 0xff333333 },
+ { "grey21", 0xff363636 },
+ { "grey22", 0xff383838 },
+ { "grey23", 0xff3b3b3b },
+ { "grey24", 0xff3d3d3d },
+ { "grey25", 0xff404040 },
+ { "grey26", 0xff424242 },
+ { "grey27", 0xff454545 },
+ { "grey28", 0xff474747 },
+ { "grey29", 0xff4a4a4a },
+ { "grey3", 0xff080808 },
+ { "grey30", 0xff4d4d4d },
+ { "grey31", 0xff4f4f4f },
+ { "grey32", 0xff525252 },
+ { "grey33", 0xff545454 },
+ { "grey34", 0xff575757 },
+ { "grey35", 0xff595959 },
+ { "grey36", 0xff5c5c5c },
+ { "grey37", 0xff5e5e5e },
+ { "grey38", 0xff616161 },
+ { "grey39", 0xff636363 },
+ { "grey4", 0xff0a0a0a },
+ { "grey40", 0xff666666 },
+ { "grey41", 0xff696969 },
+ { "grey42", 0xff6b6b6b },
+ { "grey43", 0xff6e6e6e },
+ { "grey44", 0xff707070 },
+ { "grey45", 0xff737373 },
+ { "grey46", 0xff757575 },
+ { "grey47", 0xff787878 },
+ { "grey48", 0xff7a7a7a },
+ { "grey49", 0xff7d7d7d },
+ { "grey5", 0xff0d0d0d },
+ { "grey50", 0xff7f7f7f },
+ { "grey51", 0xff828282 },
+ { "grey52", 0xff858585 },
+ { "grey53", 0xff878787 },
+ { "grey54", 0xff8a8a8a },
+ { "grey55", 0xff8c8c8c },
+ { "grey56", 0xff8f8f8f },
+ { "grey57", 0xff919191 },
+ { "grey58", 0xff949494 },
+ { "grey59", 0xff969696 },
+ { "grey6", 0xff0f0f0f },
+ { "grey60", 0xff999999 },
+ { "grey61", 0xff9c9c9c },
+ { "grey62", 0xff9e9e9e },
+ { "grey63", 0xffa1a1a1 },
+ { "grey64", 0xffa3a3a3 },
+ { "grey65", 0xffa6a6a6 },
+ { "grey66", 0xffa8a8a8 },
+ { "grey67", 0xffababab },
+ { "grey68", 0xffadadad },
+ { "grey69", 0xffb0b0b0 },
+ { "grey7", 0xff121212 },
+ { "grey70", 0xffb3b3b3 },
+ { "grey71", 0xffb5b5b5 },
+ { "grey72", 0xffb8b8b8 },
+ { "grey73", 0xffbababa },
+ { "grey74", 0xffbdbdbd },
+ { "grey75", 0xffbfbfbf },
+ { "grey76", 0xffc2c2c2 },
+ { "grey77", 0xffc4c4c4 },
+ { "grey78", 0xffc7c7c7 },
+ { "grey79", 0xffc9c9c9 },
+ { "grey8", 0xff141414 },
+ { "grey80", 0xffcccccc },
+ { "grey81", 0xffcfcfcf },
+ { "grey82", 0xffd1d1d1 },
+ { "grey83", 0xffd4d4d4 },
+ { "grey84", 0xffd6d6d6 },
+ { "grey85", 0xffd9d9d9 },
+ { "grey86", 0xffdbdbdb },
+ { "grey87", 0xffdedede },
+ { "grey88", 0xffe0e0e0 },
+ { "grey89", 0xffe3e3e3 },
+ { "grey9", 0xff171717 },
+ { "grey90", 0xffe5e5e5 },
+ { "grey91", 0xffe8e8e8 },
+ { "grey92", 0xffebebeb },
+ { "grey93", 0xffededed },
+ { "grey94", 0xfff0f0f0 },
+ { "grey95", 0xfff2f2f2 },
+ { "grey96", 0xfff5f5f5 },
+ { "grey97", 0xfff7f7f7 },
+ { "grey98", 0xfffafafa },
+ { "grey99", 0xfffcfcfc },
+ { "honeydew", 0xfff0fff0 },
+ { "honeydew1", 0xfff0fff0 },
+ { "honeydew2", 0xffe0eee0 },
+ { "honeydew3", 0xffc1cdc1 },
+ { "honeydew4", 0xff838b83 },
+ { "hot pink", 0xffff69b4 },
+ { "HotPink", 0xffff69b4 },
+ { "HotPink1", 0xffff6eb4 },
+ { "HotPink2", 0xffee6aa7 },
+ { "HotPink3", 0xffcd6090 },
+ { "HotPink4", 0xff8b3a62 },
+ { "indian red", 0xffcd5c5c },
+ { "IndianRed", 0xffcd5c5c },
+ { "IndianRed1", 0xffff6a6a },
+ { "IndianRed2", 0xffee6363 },
+ { "IndianRed3", 0xffcd5555 },
+ { "IndianRed4", 0xff8b3a3a },
+ { "ivory", 0xfffffff0 },
+ { "ivory1", 0xfffffff0 },
+ { "ivory2", 0xffeeeee0 },
+ { "ivory3", 0xffcdcdc1 },
+ { "ivory4", 0xff8b8b83 },
+ { "khaki", 0xfff0e68c },
+ { "khaki1", 0xfffff68f },
+ { "khaki2", 0xffeee685 },
+ { "khaki3", 0xffcdc673 },
+ { "khaki4", 0xff8b864e },
+ { "lavender", 0xffe6e6fa },
+ { "lavender blush", 0xfffff0f5 },
+ { "LavenderBlush", 0xfffff0f5 },
+ { "LavenderBlush1", 0xfffff0f5 },
+ { "LavenderBlush2", 0xffeee0e5 },
+ { "LavenderBlush3", 0xffcdc1c5 },
+ { "LavenderBlush4", 0xff8b8386 },
+ { "lawn green", 0xff7cfc00 },
+ { "LawnGreen", 0xff7cfc00 },
+ { "lemon chiffon", 0xfffffacd },
+ { "LemonChiffon", 0xfffffacd },
+ { "LemonChiffon1", 0xfffffacd },
+ { "LemonChiffon2", 0xffeee9bf },
+ { "LemonChiffon3", 0xffcdc9a5 },
+ { "LemonChiffon4", 0xff8b8970 },
+ { "light blue", 0xffadd8e6 },
+ { "light coral", 0xfff08080 },
+ { "light cyan", 0xffe0ffff },
+ { "light goldenrod", 0xffeedd82 },
+ { "light goldenrod yellow", 0xfffafad2 },
+ { "light gray", 0xffd3d3d3 },
+ { "light green", 0xff90ee90 },
+ { "light grey", 0xffd3d3d3 },
+ { "light pink", 0xffffb6c1 },
+ { "light salmon", 0xffffa07a },
+ { "light sea green", 0xff20b2aa },
+ { "light sky blue", 0xff87cefa },
+ { "light slate blue", 0xff8470ff },
+ { "light slate gray", 0xff778899 },
+ { "light slate grey", 0xff778899 },
+ { "light steel blue", 0xffb0c4de },
+ { "light yellow", 0xffffffe0 },
+ { "LightBlue", 0xffadd8e6 },
+ { "LightBlue1", 0xffbfefff },
+ { "LightBlue2", 0xffb2dfee },
+ { "LightBlue3", 0xff9ac0cd },
+ { "LightBlue4", 0xff68838b },
+ { "LightCoral", 0xfff08080 },
+ { "LightCyan", 0xffe0ffff },
+ { "LightCyan1", 0xffe0ffff },
+ { "LightCyan2", 0xffd1eeee },
+ { "LightCyan3", 0xffb4cdcd },
+ { "LightCyan4", 0xff7a8b8b },
+ { "LightGoldenrod", 0xffeedd82 },
+ { "LightGoldenrod1", 0xffffec8b },
+ { "LightGoldenrod2", 0xffeedc82 },
+ { "LightGoldenrod3", 0xffcdbe70 },
+ { "LightGoldenrod4", 0xff8b814c },
+ { "LightGoldenrodYellow", 0xfffafad2 },
+ { "LightGray", 0xffd3d3d3 },
+ { "LightGreen", 0xff90ee90 },
+ { "LightGrey", 0xffd3d3d3 },
+ { "LightPink", 0xffffb6c1 },
+ { "LightPink1", 0xffffaeb9 },
+ { "LightPink2", 0xffeea2ad },
+ { "LightPink3", 0xffcd8c95 },
+ { "LightPink4", 0xff8b5f65 },
+ { "LightSalmon", 0xffffa07a },
+ { "LightSalmon1", 0xffffa07a },
+ { "LightSalmon2", 0xffee9572 },
+ { "LightSalmon3", 0xffcd8162 },
+ { "LightSalmon4", 0xff8b5742 },
+ { "LightSeaGreen", 0xff20b2aa },
+ { "LightSkyBlue", 0xff87cefa },
+ { "LightSkyBlue1", 0xffb0e2ff },
+ { "LightSkyBlue2", 0xffa4d3ee },
+ { "LightSkyBlue3", 0xff8db6cd },
+ { "LightSkyBlue4", 0xff607b8b },
+ { "LightSlateBlue", 0xff8470ff },
+ { "LightSlateGray", 0xff778899 },
+ { "LightSlateGrey", 0xff778899 },
+ { "LightSteelBlue", 0xffb0c4de },
+ { "LightSteelBlue1", 0xffcae1ff },
+ { "LightSteelBlue2", 0xffbcd2ee },
+ { "LightSteelBlue3", 0xffa2b5cd },
+ { "LightSteelBlue4", 0xff6e7b8b },
+ { "LightYellow", 0xffffffe0 },
+ { "LightYellow1", 0xffffffe0 },
+ { "LightYellow2", 0xffeeeed1 },
+ { "LightYellow3", 0xffcdcdb4 },
+ { "LightYellow4", 0xff8b8b7a },
+ { "lime green", 0xff32cd32 },
+ { "LimeGreen", 0xff32cd32 },
+ { "linen", 0xfffaf0e6 },
+ { "magenta", 0xffff00ff },
+ { "magenta1", 0xffff00ff },
+ { "magenta2", 0xffee00ee },
+ { "magenta3", 0xffcd00cd },
+ { "magenta4", 0xff8b008b },
+ { "maroon", 0xffb03060 },
+ { "maroon1", 0xffff34b3 },
+ { "maroon2", 0xffee30a7 },
+ { "maroon3", 0xffcd2990 },
+ { "maroon4", 0xff8b1c62 },
+ { "medium aquamarine", 0xff66cdaa },
+ { "medium blue", 0xff0000cd },
+ { "medium orchid", 0xffba55d3 },
+ { "medium purple", 0xff9370db },
+ { "medium sea green", 0xff3cb371 },
+ { "medium slate blue", 0xff7b68ee },
+ { "medium spring green", 0xff00fa9a },
+ { "medium turquoise", 0xff48d1cc },
+ { "medium violet red", 0xffc71585 },
+ { "MediumAquamarine", 0xff66cdaa },
+ { "MediumBlue", 0xff0000cd },
+ { "MediumOrchid", 0xffba55d3 },
+ { "MediumOrchid1", 0xffe066ff },
+ { "MediumOrchid2", 0xffd15fee },
+ { "MediumOrchid3", 0xffb452cd },
+ { "MediumOrchid4", 0xff7a378b },
+ { "MediumPurple", 0xff9370db },
+ { "MediumPurple1", 0xffab82ff },
+ { "MediumPurple2", 0xff9f79ee },
+ { "MediumPurple3", 0xff8968cd },
+ { "MediumPurple4", 0xff5d478b },
+ { "MediumSeaGreen", 0xff3cb371 },
+ { "MediumSlateBlue", 0xff7b68ee },
+ { "MediumSpringGreen", 0xff00fa9a },
+ { "MediumTurquoise", 0xff48d1cc },
+ { "MediumVioletRed", 0xffc71585 },
+ { "midnight blue", 0xff191970 },
+ { "MidnightBlue", 0xff191970 },
+ { "mint cream", 0xfff5fffa },
+ { "MintCream", 0xfff5fffa },
+ { "misty rose", 0xffffe4e1 },
+ { "MistyRose", 0xffffe4e1 },
+ { "MistyRose1", 0xffffe4e1 },
+ { "MistyRose2", 0xffeed5d2 },
+ { "MistyRose3", 0xffcdb7b5 },
+ { "MistyRose4", 0xff8b7d7b },
+ { "moccasin", 0xffffe4b5 },
+ { "navajo white", 0xffffdead },
+ { "NavajoWhite", 0xffffdead },
+ { "NavajoWhite1", 0xffffdead },
+ { "NavajoWhite2", 0xffeecfa1 },
+ { "NavajoWhite3", 0xffcdb38b },
+ { "NavajoWhite4", 0xff8b795e },
+ { "navy", 0xff000080 },
+ { "navy blue", 0xff000080 },
+ { "NavyBlue", 0xff000080 },
+ { "old lace", 0xfffdf5e6 },
+ { "OldLace", 0xfffdf5e6 },
+ { "olive drab", 0xff6b8e23 },
+ { "OliveDrab", 0xff6b8e23 },
+ { "OliveDrab1", 0xffc0ff3e },
+ { "OliveDrab2", 0xffb3ee3a },
+ { "OliveDrab3", 0xff9acd32 },
+ { "OliveDrab4", 0xff698b22 },
+ { "orange", 0xffffa500 },
+ { "orange red", 0xffff4500 },
+ { "orange1", 0xffffa500 },
+ { "orange2", 0xffee9a00 },
+ { "orange3", 0xffcd8500 },
+ { "orange4", 0xff8b5a00 },
+ { "OrangeRed", 0xffff4500 },
+ { "OrangeRed1", 0xffff4500 },
+ { "OrangeRed2", 0xffee4000 },
+ { "OrangeRed3", 0xffcd3700 },
+ { "OrangeRed4", 0xff8b2500 },
+ { "orchid", 0xffda70d6 },
+ { "orchid1", 0xffff83fa },
+ { "orchid2", 0xffee7ae9 },
+ { "orchid3", 0xffcd69c9 },
+ { "orchid4", 0xff8b4789 },
+ { "pale goldenrod", 0xffeee8aa },
+ { "pale green", 0xff98fb98 },
+ { "pale turquoise", 0xffafeeee },
+ { "pale violet red", 0xffdb7093 },
+ { "PaleGoldenrod", 0xffeee8aa },
+ { "PaleGreen", 0xff98fb98 },
+ { "PaleGreen1", 0xff9aff9a },
+ { "PaleGreen2", 0xff90ee90 },
+ { "PaleGreen3", 0xff7ccd7c },
+ { "PaleGreen4", 0xff548b54 },
+ { "PaleTurquoise", 0xffafeeee },
+ { "PaleTurquoise1", 0xffbbffff },
+ { "PaleTurquoise2", 0xffaeeeee },
+ { "PaleTurquoise3", 0xff96cdcd },
+ { "PaleTurquoise4", 0xff668b8b },
+ { "PaleVioletRed", 0xffdb7093 },
+ { "PaleVioletRed1", 0xffff82ab },
+ { "PaleVioletRed2", 0xffee799f },
+ { "PaleVioletRed3", 0xffcd6889 },
+ { "PaleVioletRed4", 0xff8b475d },
+ { "papaya whip", 0xffffefd5 },
+ { "PapayaWhip", 0xffffefd5 },
+ { "peach puff", 0xffffdab9 },
+ { "PeachPuff", 0xffffdab9 },
+ { "PeachPuff1", 0xffffdab9 },
+ { "PeachPuff2", 0xffeecbad },
+ { "PeachPuff3", 0xffcdaf95 },
+ { "PeachPuff4", 0xff8b7765 },
+ { "peru", 0xffcd853f },
+ { "pink", 0xffffc0cb },
+ { "pink1", 0xffffb5c5 },
+ { "pink2", 0xffeea9b8 },
+ { "pink3", 0xffcd919e },
+ { "pink4", 0xff8b636c },
+ { "plum", 0xffdda0dd },
+ { "plum1", 0xffffbbff },
+ { "plum2", 0xffeeaeee },
+ { "plum3", 0xffcd96cd },
+ { "plum4", 0xff8b668b },
+ { "powder blue", 0xffb0e0e6 },
+ { "PowderBlue", 0xffb0e0e6 },
+ { "purple", 0xffa020f0 },
+ { "purple1", 0xff9b30ff },
+ { "purple2", 0xff912cee },
+ { "purple3", 0xff7d26cd },
+ { "purple4", 0xff551a8b },
+ { "red", 0xffff0000 },
+ { "red1", 0xffff0000 },
+ { "red2", 0xffee0000 },
+ { "red3", 0xffcd0000 },
+ { "red4", 0xff8b0000 },
+ { "rosy brown", 0xffbc8f8f },
+ { "RosyBrown", 0xffbc8f8f },
+ { "RosyBrown1", 0xffffc1c1 },
+ { "RosyBrown2", 0xffeeb4b4 },
+ { "RosyBrown3", 0xffcd9b9b },
+ { "RosyBrown4", 0xff8b6969 },
+ { "royal blue", 0xff4169e1 },
+ { "RoyalBlue", 0xff4169e1 },
+ { "RoyalBlue1", 0xff4876ff },
+ { "RoyalBlue2", 0xff436eee },
+ { "RoyalBlue3", 0xff3a5fcd },
+ { "RoyalBlue4", 0xff27408b },
+ { "saddle brown", 0xff8b4513 },
+ { "SaddleBrown", 0xff8b4513 },
+ { "salmon", 0xfffa8072 },
+ { "salmon1", 0xffff8c69 },
+ { "salmon2", 0xffee8262 },
+ { "salmon3", 0xffcd7054 },
+ { "salmon4", 0xff8b4c39 },
+ { "sandy brown", 0xfff4a460 },
+ { "SandyBrown", 0xfff4a460 },
+ { "sea green", 0xff2e8b57 },
+ { "SeaGreen", 0xff2e8b57 },
+ { "SeaGreen1", 0xff54ff9f },
+ { "SeaGreen2", 0xff4eee94 },
+ { "SeaGreen3", 0xff43cd80 },
+ { "SeaGreen4", 0xff2e8b57 },
+ { "seashell", 0xfffff5ee },
+ { "seashell1", 0xfffff5ee },
+ { "seashell2", 0xffeee5de },
+ { "seashell3", 0xffcdc5bf },
+ { "seashell4", 0xff8b8682 },
+ { "sienna", 0xffa0522d },
+ { "sienna1", 0xffff8247 },
+ { "sienna2", 0xffee7942 },
+ { "sienna3", 0xffcd6839 },
+ { "sienna4", 0xff8b4726 },
+ { "sky blue", 0xff87ceeb },
+ { "SkyBlue", 0xff87ceeb },
+ { "SkyBlue1", 0xff87ceff },
+ { "SkyBlue2", 0xff7ec0ee },
+ { "SkyBlue3", 0xff6ca6cd },
+ { "SkyBlue4", 0xff4a708b },
+ { "slate blue", 0xff6a5acd },
+ { "slate gray", 0xff708090 },
+ { "slate grey", 0xff708090 },
+ { "SlateBlue", 0xff6a5acd },
+ { "SlateBlue1", 0xff836fff },
+ { "SlateBlue2", 0xff7a67ee },
+ { "SlateBlue3", 0xff6959cd },
+ { "SlateBlue4", 0xff473c8b },
+ { "SlateGray", 0xff708090 },
+ { "SlateGray1", 0xffc6e2ff },
+ { "SlateGray2", 0xffb9d3ee },
+ { "SlateGray3", 0xff9fb6cd },
+ { "SlateGray4", 0xff6c7b8b },
+ { "SlateGrey", 0xff708090 },
+ { "snow", 0xfffffafa },
+ { "snow1", 0xfffffafa },
+ { "snow2", 0xffeee9e9 },
+ { "snow3", 0xffcdc9c9 },
+ { "snow4", 0xff8b8989 },
+ { "spring green", 0xff00ff7f },
+ { "SpringGreen", 0xff00ff7f },
+ { "SpringGreen1", 0xff00ff7f },
+ { "SpringGreen2", 0xff00ee76 },
+ { "SpringGreen3", 0xff00cd66 },
+ { "SpringGreen4", 0xff008b45 },
+ { "steel blue", 0xff4682b4 },
+ { "SteelBlue", 0xff4682b4 },
+ { "SteelBlue1", 0xff63b8ff },
+ { "SteelBlue2", 0xff5cacee },
+ { "SteelBlue3", 0xff4f94cd },
+ { "SteelBlue4", 0xff36648b },
+ { "tan", 0xffd2b48c },
+ { "tan1", 0xffffa54f },
+ { "tan2", 0xffee9a49 },
+ { "tan3", 0xffcd853f },
+ { "tan4", 0xff8b5a2b },
+ { "thistle", 0xffd8bfd8 },
+ { "thistle1", 0xffffe1ff },
+ { "thistle2", 0xffeed2ee },
+ { "thistle3", 0xffcdb5cd },
+ { "thistle4", 0xff8b7b8b },
+ { "tomato", 0xffff6347 },
+ { "tomato1", 0xffff6347 },
+ { "tomato2", 0xffee5c42 },
+ { "tomato3", 0xffcd4f39 },
+ { "tomato4", 0xff8b3626 },
+ { "turquoise", 0xff40e0d0 },
+ { "turquoise1", 0xff00f5ff },
+ { "turquoise2", 0xff00e5ee },
+ { "turquoise3", 0xff00c5cd },
+ { "turquoise4", 0xff00868b },
+ { "violet", 0xffee82ee },
+ { "violet red", 0xffd02090 },
+ { "VioletRed", 0xffd02090 },
+ { "VioletRed1", 0xffff3e96 },
+ { "VioletRed2", 0xffee3a8c },
+ { "VioletRed3", 0xffcd3278 },
+ { "VioletRed4", 0xff8b2252 },
+ { "wheat", 0xfff5deb3 },
+ { "wheat1", 0xffffe7ba },
+ { "wheat2", 0xffeed8ae },
+ { "wheat3", 0xffcdba96 },
+ { "wheat4", 0xff8b7e66 },
+ { "white", 0xffffffff },
+ { "white smoke", 0xfff5f5f5 },
+ { "WhiteSmoke", 0xfff5f5f5 },
+ { "yellow", 0xffffff00 },
+ { "yellow green", 0xff9acd32 },
+ { "yellow1", 0xffffff00 },
+ { "yellow2", 0xffeeee00 },
+ { "yellow3", 0xffcdcd00 },
+ { "yellow4", 0xff8b8b00 },
+ { "YellowGreen", 0xff9acd32 }
};
EXPORT
-bool wld_lookup_named_color(const char * name, uint32_t * color)
+bool
+wld_lookup_named_color(const char *name, uint32_t *color)
{
- char * end;
- int low = 0, mid, high = ARRAY_LENGTH(named_colors);
- int r;
+ char *end;
+ int low = 0, mid, high = ARRAY_LENGTH(named_colors);
+ int r;
- if (name[0] == '#' && name[1] != '\0')
- {
- *color = strtoul(name + 1, &end, 16);
+ if (name[0] == '#' && name[1] != '\0') {
+ *color = strtoul(name + 1, &end, 16);
- /* Set alpha channel to opaque. */
- *color |= 0xff << 24;
+ /* Set alpha channel to opaque. */
+ *color |= 0xff << 24;
- if (*end == '\0')
- return true;
- }
+ if (*end == '\0')
+ return true;
+ }
- while (low <= high)
- {
- mid = (low + high) / 2;
- r = strcasecmp(named_colors[mid].name, name);
+ while (low <= high) {
+ mid = (low + high) / 2;
+ r = strcasecmp(named_colors[mid].name, name);
- if (r == 0)
- {
- *color = named_colors[mid].color;
- return true;
- }
- if (r < 0)
- low = mid + 1;
- else
- high = mid - 1;
- }
+ if (r == 0) {
+ *color = named_colors[mid].color;
+ return true;
+ }
+ if (r < 0)
+ low = mid + 1;
+ else
+ high = mid - 1;
+ }
- return false;
+ return false;
}
-
diff --git a/context.c b/context.c
@@ -23,48 +23,55 @@
#include "wld-private.h"
-void context_initialize(struct wld_context * context,
- const struct wld_context_impl * impl)
+void
+context_initialize(struct wld_context *context,
+ const struct wld_context_impl *impl)
{
- *((const struct wld_context_impl **) &context->impl) = impl;
+ *((const struct wld_context_impl **)&context->impl) = impl;
}
EXPORT
-struct wld_renderer * wld_create_renderer(struct wld_context * context)
+struct wld_renderer *
+wld_create_renderer(struct wld_context *context)
{
- return context->impl->create_renderer(context);
+ return context->impl->create_renderer(context);
}
EXPORT
-struct wld_buffer * wld_create_buffer(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
+struct wld_buffer *
+wld_create_buffer(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
{
- return &context->impl->create_buffer(context, width, height,
- format, flags)->base;
+ return &context->impl->create_buffer(context, width, height,
+ format, flags)
+ ->base;
}
EXPORT
-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)
+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_buffer(context, type, object,
- width, height, format, pitch)->base;
+ return &context->impl->import_buffer(context, type, object,
+ width, height, format, pitch)
+ ->base;
}
EXPORT
-struct wld_surface * wld_create_surface(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
+struct wld_surface *
+wld_create_surface(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
{
- return context->impl->create_surface(context, width, height, format, flags);
+ return context->impl->create_surface(context, width, height, format, flags);
}
EXPORT
-void wld_destroy_context(struct wld_context * context)
+void
+wld_destroy_context(struct wld_context *context)
{
- context->impl->destroy(context);
+ context->impl->destroy(context);
}
-
diff --git a/drm-private.h b/drm-private.h
@@ -26,11 +26,10 @@
#include "wld-private.h"
-struct drm_driver
-{
- const char * name;
- bool (* device_supported)(uint32_t vendor_id, uint32_t device_id);
- struct wld_context * (* create_context)(int drm_fd);
+struct drm_driver {
+ const char *name;
+ bool (*device_supported)(uint32_t vendor_id, uint32_t device_id);
+ struct wld_context *(*create_context)(int drm_fd);
};
#if WITH_DRM_INTEL
@@ -40,7 +39,6 @@ extern const struct drm_driver intel_drm_driver;
extern const struct drm_driver nouveau_drm_driver;
#endif
extern const struct drm_driver dumb_drm_driver;
-extern const struct wld_context_impl * dumb_context_impl;
+extern const struct wld_context_impl *dumb_context_impl;
#endif
-
diff --git a/drm.c b/drm.c
@@ -26,82 +26,83 @@
#include <sys/sysmacros.h>
-const static struct drm_driver * drivers[] = {
+const static struct drm_driver *drivers[] = {
#if WITH_DRM_INTEL
- &intel_drm_driver,
+ &intel_drm_driver,
#endif
#if WITH_DRM_NOUVEAU
- &nouveau_drm_driver,
+ &nouveau_drm_driver,
#endif
- &dumb_drm_driver
+ &dumb_drm_driver
};
-static const struct drm_driver * find_driver(int fd)
+static const struct drm_driver *
+find_driver(int fd)
{
- char path[64], id[32];
- uint32_t vendor_id, device_id;
- char * path_part;
- struct stat st;
- FILE * file;
- uint32_t index;
- int n;
-
- if (fstat(fd, &st) == -1)
- return NULL;
-
- if (getenv("WLD_DRM_DUMB"))
- goto dumb;
-
- n = snprintf(path, sizeof(path), "/sys/dev/char/%u:%u/device/", major(st.st_rdev), minor(st.st_rdev));
- if (n + 6 >= sizeof(path))
- return NULL;
- path_part = path + n;
-
- strcpy(path_part, "vendor");
- file = fopen(path, "r");
- if (!file)
- goto dumb;
- fgets(id, sizeof id, file);
- fclose(file);
- vendor_id = strtoul(id, NULL, 0);
-
- strcpy(path_part, "device");
- file = fopen(path, "r");
- if (!file)
- goto dumb;
- fgets(id, sizeof id, file);
- fclose(file);
- device_id = strtoul(id, NULL, 0);
-
- for (index = 0; index < ARRAY_LENGTH(drivers); ++index)
- {
- DEBUG("Trying DRM driver `%s'\n", drivers[index]->name);
- if (drivers[index]->device_supported(vendor_id, device_id))
- return drivers[index];
- }
-
- DEBUG("No DRM driver supports device 0x%x:0x%x\n", vendor_id, device_id);
-
- return NULL;
+ char path[64], id[32];
+ uint32_t vendor_id, device_id;
+ char *path_part;
+ struct stat st;
+ FILE *file;
+ uint32_t index;
+ int n;
+
+ if (fstat(fd, &st) == -1)
+ return NULL;
+
+ if (getenv("WLD_DRM_DUMB"))
+ goto dumb;
+
+ n = snprintf(path, sizeof(path), "/sys/dev/char/%u:%u/device/", major(st.st_rdev), minor(st.st_rdev));
+ if (n + 6 >= sizeof(path))
+ return NULL;
+ path_part = path + n;
+
+ strcpy(path_part, "vendor");
+ file = fopen(path, "r");
+ if (!file)
+ goto dumb;
+ fgets(id, sizeof id, file);
+ fclose(file);
+ vendor_id = strtoul(id, NULL, 0);
+
+ strcpy(path_part, "device");
+ file = fopen(path, "r");
+ if (!file)
+ goto dumb;
+ fgets(id, sizeof id, file);
+ fclose(file);
+ device_id = strtoul(id, NULL, 0);
+
+ for (index = 0; index < ARRAY_LENGTH(drivers); ++index) {
+ DEBUG("Trying DRM driver `%s'\n", drivers[index]->name);
+ if (drivers[index]->device_supported(vendor_id, device_id))
+ return drivers[index];
+ }
+
+ DEBUG("No DRM driver supports device 0x%x:0x%x\n", vendor_id, device_id);
+
+ return NULL;
dumb:
- return &dumb_drm_driver;
+ return &dumb_drm_driver;
}
EXPORT
-struct wld_context * wld_drm_create_context(int fd)
+struct wld_context *
+wld_drm_create_context(int fd)
{
- const struct drm_driver * driver;
+ const struct drm_driver *driver;
- if (!(driver = find_driver(fd)))
- return NULL;
+ if (!(driver = find_driver(fd)))
+ return NULL;
- return driver->create_context(fd);
+ return driver->create_context(fd);
}
EXPORT
-bool wld_drm_is_dumb(struct wld_context * context)
+bool
+wld_drm_is_dumb(struct wld_context *context)
{
- return context->impl == dumb_context_impl;
+ return context->impl == dumb_context_impl;
}
-
diff --git a/drm.h b/drm.h
@@ -29,24 +29,21 @@
#define WLD_DRM_ID (0x02 << 24)
-enum wld_drm_object_type
-{
- WLD_DRM_OBJECT_HANDLE = WLD_DRM_ID,
- WLD_DRM_OBJECT_PRIME_FD,
+enum wld_drm_object_type {
+ WLD_DRM_OBJECT_HANDLE = WLD_DRM_ID,
+ WLD_DRM_OBJECT_PRIME_FD,
};
-enum wld_drm_flags
-{
- WLD_DRM_FLAG_SCANOUT = 0x1,
- WLD_DRM_FLAG_TILED = 0x2
+enum wld_drm_flags {
+ WLD_DRM_FLAG_SCANOUT = 0x1,
+ WLD_DRM_FLAG_TILED = 0x2
};
/**
* Create a new WLD context from an opened DRM device file descriptor.
*/
-struct wld_context * wld_drm_create_context(int fd);
+struct wld_context *wld_drm_create_context(int fd);
-bool wld_drm_is_dumb(struct wld_context * context);
+bool wld_drm_is_dumb(struct wld_context *context);
#endif
-
diff --git a/dumb.c b/dumb.c
@@ -26,210 +26,216 @@
#include "pixman.h"
#include <fcntl.h>
-#include <unistd.h>
#include <sys/mman.h>
+#include <unistd.h>
#include <xf86drm.h>
#include <errno.h>
-struct dumb_context
-{
- struct wld_context base;
- int fd;
+struct dumb_context {
+ struct wld_context base;
+ int fd;
};
-struct dumb_buffer
-{
- struct buffer base;
- struct wld_exporter exporter;
- struct dumb_context * context;
- uint32_t handle;
+struct dumb_buffer {
+ struct buffer base;
+ struct wld_exporter exporter;
+ struct dumb_context *context;
+ uint32_t handle;
};
-#include "interface/context.h"
#include "interface/buffer.h"
+#include "interface/context.h"
#define DRM_DRIVER_NAME dumb
#include "interface/drm.h"
IMPL(dumb_context, wld_context)
IMPL(dumb_buffer, wld_buffer)
-const struct wld_context_impl * dumb_context_impl = &wld_context_impl;
+const struct wld_context_impl *dumb_context_impl = &wld_context_impl;
-bool driver_device_supported(uint32_t vendor_id, uint32_t device_id)
+bool
+driver_device_supported(uint32_t vendor_id, uint32_t device_id)
{
- return true;
+ return true;
}
-struct wld_context * driver_create_context(int drm_fd)
+struct wld_context *
+driver_create_context(int drm_fd)
{
- struct dumb_context * context;
+ struct dumb_context *context;
- if (!(context = malloc(sizeof *context)))
- return NULL;
+ if (!(context = malloc(sizeof *context)))
+ return NULL;
- context_initialize(&context->base, &wld_context_impl);
- context->fd = drm_fd;
+ context_initialize(&context->base, &wld_context_impl);
+ context->fd = drm_fd;
- return &context->base;
+ return &context->base;
}
-struct wld_renderer * context_create_renderer(struct wld_context * context)
+struct wld_renderer *
+context_create_renderer(struct wld_context *context)
{
- return wld_create_renderer(wld_pixman_context);
+ return wld_create_renderer(wld_pixman_context);
}
-static bool export(struct wld_exporter * exporter, struct wld_buffer * base,
- uint32_t type, union wld_object * object)
+static bool export(struct wld_exporter *exporter, struct wld_buffer *base,
+ uint32_t type, union wld_object *object)
{
- struct dumb_buffer * buffer = dumb_buffer(base);
-
- switch (type)
- {
- case WLD_DRM_OBJECT_HANDLE:
- object->u32 = buffer->handle;
- return true;
- case WLD_DRM_OBJECT_PRIME_FD:
- if (drmPrimeHandleToFD(buffer->context->fd, buffer->handle,
- DRM_CLOEXEC, &object->i) != 0)
- {
- return false;
- }
-
- return true;
- default:
- return false;
- }
+ struct dumb_buffer *buffer = dumb_buffer(base);
+
+ switch (type) {
+ case WLD_DRM_OBJECT_HANDLE:
+ object->u32 = buffer->handle;
+ return true;
+ case WLD_DRM_OBJECT_PRIME_FD:
+ if (drmPrimeHandleToFD(buffer->context->fd, buffer->handle,
+ DRM_CLOEXEC, &object->i)
+ != 0) {
+ return false;
+ }
+
+ return true;
+ default:
+ return false;
+ }
}
-static struct buffer * new_buffer(struct dumb_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t handle,
- unsigned long pitch)
+static struct buffer *
+new_buffer(struct dumb_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t handle,
+ unsigned long pitch)
{
- struct dumb_buffer * buffer;
+ struct dumb_buffer *buffer;
- if (!(buffer = malloc(sizeof *buffer)))
- return NULL;
+ if (!(buffer = malloc(sizeof *buffer)))
+ return NULL;
- buffer_initialize(&buffer->base, &wld_buffer_impl,
- width, height, format, pitch);
- buffer->context = context;
- buffer->handle = handle;
- buffer->exporter.export = &export;
- wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
+ buffer_initialize(&buffer->base, &wld_buffer_impl,
+ width, height, format, pitch);
+ buffer->context = context;
+ buffer->handle = handle;
+ buffer->exporter.export = &export;
+ wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
- return &buffer->base;
+ return &buffer->base;
}
-struct buffer * context_create_buffer(struct wld_context * base,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
+struct buffer *
+context_create_buffer(struct wld_context *base,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
{
- struct dumb_context * context = dumb_context(base);
- struct buffer * buffer;
- struct drm_mode_create_dumb create_dumb = {
- .height = height, .width = width,
- .bpp = format_bytes_per_pixel(format) * 8,
- };
-
- if (drmIoctl(context->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_dumb) != 0)
- goto error0;
-
- buffer = new_buffer(context, width, height, format,
- create_dumb.handle, create_dumb.pitch);
-
- if (!buffer)
- goto error1;
-
- return buffer;
-
- error1:
- {
- struct drm_mode_destroy_dumb destroy_dumb = {
- .handle = create_dumb.handle
- };
-
- drmIoctl(context->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
- }
- error0:
- return NULL;
+ struct dumb_context *context = dumb_context(base);
+ struct buffer *buffer;
+ struct drm_mode_create_dumb create_dumb = {
+ .height = height,
+ .width = width,
+ .bpp = format_bytes_per_pixel(format) * 8,
+ };
+
+ if (drmIoctl(context->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_dumb) != 0)
+ goto error0;
+
+ buffer = new_buffer(context, width, height, format,
+ create_dumb.handle, create_dumb.pitch);
+
+ if (!buffer)
+ goto error1;
+
+ return buffer;
+
+error1 : {
+ struct drm_mode_destroy_dumb destroy_dumb = {
+ .handle = create_dumb.handle
+ };
+
+ drmIoctl(context->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
+}
+error0:
+ return NULL;
}
-struct 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 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;
-
- switch (type)
- {
- case WLD_DRM_OBJECT_PRIME_FD:
- if (drmPrimeFDToHandle(context->fd, object.i, &handle) != 0)
- return NULL;
- break;
- default: return NULL;
- }
-
- return new_buffer(context, width, height, format, handle, pitch);
+ struct dumb_context *context = dumb_context(base);
+ uint32_t handle;
+
+ switch (type) {
+ case WLD_DRM_OBJECT_PRIME_FD:
+ if (drmPrimeFDToHandle(context->fd, object.i, &handle) != 0)
+ return NULL;
+ break;
+ default:
+ return NULL;
+ }
+
+ return new_buffer(context, width, height, format, handle, pitch);
}
-void context_destroy(struct wld_context * base)
+void
+context_destroy(struct wld_context *base)
{
- struct dumb_context * context = dumb_context(base);
+ struct dumb_context *context = dumb_context(base);
- close(context->fd);
- free(context);
+ close(context->fd);
+ free(context);
}
/**** Buffer ****/
-bool buffer_map(struct buffer * base)
+bool
+buffer_map(struct buffer *base)
{
- struct dumb_buffer * buffer = dumb_buffer(&base->base);
- struct drm_mode_map_dumb map_dumb = { .handle = buffer->handle };
- void * data;
+ struct dumb_buffer *buffer = dumb_buffer(&base->base);
+ struct drm_mode_map_dumb map_dumb = { .handle = buffer->handle };
+ void *data;
- if (drmIoctl(buffer->context->fd, DRM_IOCTL_MODE_MAP_DUMB,
- &map_dumb) != 0)
- {
- return false;
- }
+ if (drmIoctl(buffer->context->fd, DRM_IOCTL_MODE_MAP_DUMB,
+ &map_dumb)
+ != 0) {
+ return false;
+ }
- data = mmap(NULL, buffer->base.base.pitch * buffer->base.base.height,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- buffer->context->fd, map_dumb.offset);
+ data = mmap(NULL, buffer->base.base.pitch * buffer->base.base.height,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ buffer->context->fd, map_dumb.offset);
- if (data == MAP_FAILED)
- return false;
+ if (data == MAP_FAILED)
+ return false;
- buffer->base.base.map = data;
+ buffer->base.base.map = data;
- return true;
+ return true;
}
-bool buffer_unmap(struct buffer * buffer)
+bool
+buffer_unmap(struct buffer *buffer)
{
- if (munmap(buffer->base.map,
- buffer->base.pitch * buffer->base.height) == -1)
- {
- return false;
- }
+ if (munmap(buffer->base.map,
+ buffer->base.pitch * buffer->base.height)
+ == -1) {
+ return false;
+ }
- buffer->base.map = NULL;
+ buffer->base.map = NULL;
- return true;
+ return true;
}
-void buffer_destroy(struct buffer * base)
+void
+buffer_destroy(struct buffer *base)
{
- struct dumb_buffer * buffer = dumb_buffer(&base->base);
- struct drm_mode_destroy_dumb destroy_dumb = {
- .handle = buffer->handle
- };
+ struct dumb_buffer *buffer = dumb_buffer(&base->base);
+ struct drm_mode_destroy_dumb destroy_dumb = {
+ .handle = buffer->handle
+ };
- drmIoctl(buffer->context->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
- free(buffer);
+ drmIoctl(buffer->context->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
+ free(buffer);
}
-
diff --git a/font.c b/font.c
@@ -26,210 +26,207 @@
#include <fontconfig/fcfreetype.h>
EXPORT
-struct wld_font_context * wld_font_create_context()
+struct wld_font_context *
+wld_font_create_context()
{
- struct wld_font_context * context;
+ struct wld_font_context *context;
- context = malloc(sizeof *context);
+ context = malloc(sizeof *context);
- if (!context)
- goto error0;
+ if (!context)
+ goto error0;
- if (FT_Init_FreeType(&context->library) != 0)
- {
- DEBUG("Failed to initialize FreeType library\n");
+ if (FT_Init_FreeType(&context->library) != 0) {
+ DEBUG("Failed to initialize FreeType library\n");
- goto error1;
- }
+ goto error1;
+ }
- return context;
+ return context;
- error1:
- free(context);
- error0:
- return NULL;
+error1:
+ free(context);
+error0:
+ return NULL;
}
EXPORT
-void wld_font_destroy_context(struct wld_font_context * context)
+void
+wld_font_destroy_context(struct wld_font_context *context)
{
- FT_Done_FreeType(context->library);
- free(context);
+ FT_Done_FreeType(context->library);
+ free(context);
}
EXPORT
-struct wld_font * wld_font_open_name(struct wld_font_context * context,
- const char * name)
+struct wld_font *
+wld_font_open_name(struct wld_font_context *context,
+ const char *name)
{
- FcPattern * pattern, * match;
- FcResult result;
+ FcPattern *pattern, *match;
+ FcResult result;
- DEBUG("Opening font with name: %s\n", name);
+ DEBUG("Opening font with name: %s\n", name);
- pattern = FcNameParse((const FcChar8 *) name);
- FcConfigSubstitute(NULL, pattern, FcMatchPattern);
- FcDefaultSubstitute(pattern);
+ pattern = FcNameParse((const FcChar8 *)name);
+ FcConfigSubstitute(NULL, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
- match = FcFontMatch(NULL, pattern, &result);
+ match = FcFontMatch(NULL, pattern, &result);
- if (!match)
- return NULL;
+ if (!match)
+ return NULL;
- return wld_font_open_pattern(context, match);
+ return wld_font_open_pattern(context, match);
}
EXPORT
-struct wld_font * wld_font_open_pattern(struct wld_font_context * context,
- FcPattern * match)
+struct wld_font *
+wld_font_open_pattern(struct wld_font_context *context,
+ FcPattern *match)
{
- char * filename;
- struct font * font;
- FcResult result;
- double pixel_size, aspect;
+ char *filename;
+ struct font *font;
+ FcResult result;
+ double pixel_size, aspect;
- font = malloc(sizeof *font);
+ font = malloc(sizeof *font);
- if (!font)
- goto error0;
+ if (!font)
+ goto error0;
- font->context = context;
+ font->context = context;
- result = FcPatternGetString(match, FC_FILE, 0, (FcChar8 **) &filename);
+ result = FcPatternGetString(match, FC_FILE, 0, (FcChar8 **)&filename);
- if (result == FcResultMatch)
- {
- FT_Error error;
+ if (result == FcResultMatch) {
+ FT_Error error;
- DEBUG("Loading font file: %s\n", filename);
+ DEBUG("Loading font file: %s\n", filename);
- error = FT_New_Face(context->library, filename, 0, &font->face);
+ error = FT_New_Face(context->library, filename, 0, &font->face);
- if (error == 0)
- goto load_face;
- }
+ if (error == 0)
+ goto load_face;
+ }
- result = FcPatternGetFTFace(match, FC_FT_FACE, 0, &font->face);
+ result = FcPatternGetFTFace(match, FC_FT_FACE, 0, &font->face);
- if (result != FcResultMatch)
- {
- DEBUG("Couldn't determine font filename or FreeType face\n");
- goto error1;
- }
+ if (result != FcResultMatch) {
+ DEBUG("Couldn't determine font filename or FreeType face\n");
+ goto error1;
+ }
- load_face:
- result = FcPatternGetDouble(match, FC_PIXEL_SIZE, 0, &pixel_size);
+load_face:
+ result = FcPatternGetDouble(match, FC_PIXEL_SIZE, 0, &pixel_size);
- result = FcPatternGetDouble(match, FC_ASPECT, 0, &aspect);
+ result = FcPatternGetDouble(match, FC_ASPECT, 0, &aspect);
- if (result == FcResultNoMatch)
- aspect = 1.0;
+ if (result == FcResultNoMatch)
+ aspect = 1.0;
- if (font->face->face_flags & FT_FACE_FLAG_SCALABLE)
- {
- FT_F26Dot6 width, height;
+ if (font->face->face_flags & FT_FACE_FLAG_SCALABLE) {
+ FT_F26Dot6 width, height;
- width = ((unsigned int) pixel_size) << 6;
- height = ((unsigned int) (pixel_size * aspect)) << 6;
+ width = ((unsigned int)pixel_size) << 6;
+ height = ((unsigned int)(pixel_size * aspect)) << 6;
- FT_Set_Char_Size(font->face, width, height, 0, 0);
- }
- else
- {
- FT_Set_Pixel_Sizes(font->face, (unsigned int) pixel_size,
- (unsigned int) (pixel_size * aspect));
- }
+ FT_Set_Char_Size(font->face, width, height, 0, 0);
+ } else {
+ FT_Set_Pixel_Sizes(font->face, (unsigned int)pixel_size,
+ (unsigned int)(pixel_size * aspect));
+ }
- font->base.ascent = font->face->size->metrics.ascender >> 6;
- font->base.descent = -font->face->size->metrics.descender >> 6;
- font->base.height = font->base.ascent + font->base.descent;
- font->base.max_advance = font->face->size->metrics.max_advance >> 6;
+ font->base.ascent = font->face->size->metrics.ascender >> 6;
+ font->base.descent = -font->face->size->metrics.descender >> 6;
+ font->base.height = font->base.ascent + font->base.descent;
+ font->base.max_advance = font->face->size->metrics.max_advance >> 6;
- font->glyphs = calloc(font->face->num_glyphs, sizeof(struct glyph *));
+ font->glyphs = calloc(font->face->num_glyphs, sizeof(struct glyph *));
- return &font->base;
+ return &font->base;
- error1:
- free(font);
- error0:
- return NULL;
+error1:
+ free(font);
+error0:
+ return NULL;
}
EXPORT
-void wld_font_close(struct wld_font * font_base)
+void
+wld_font_close(struct wld_font *font_base)
{
- struct font * font = (void *) font_base;
+ struct font *font = (void *)font_base;
- FT_Done_Face(font->face);
- free(font);
+ FT_Done_Face(font->face);
+ free(font);
}
-bool font_ensure_glyph(struct font * font, FT_UInt glyph_index)
+bool
+font_ensure_glyph(struct font *font, FT_UInt glyph_index)
{
- if (glyph_index)
- {
- if (!font->glyphs[glyph_index])
- {
- struct glyph * glyph;
+ if (glyph_index) {
+ if (!font->glyphs[glyph_index]) {
+ struct glyph *glyph;
- glyph = malloc(sizeof *glyph);
+ glyph = malloc(sizeof *glyph);
- if (!glyph)
- return false;
+ if (!glyph)
+ return false;
- FT_Load_Glyph(font->face, glyph_index, FT_LOAD_RENDER
- | FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO);
+ FT_Load_Glyph(font->face, glyph_index, FT_LOAD_RENDER | FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO);
- FT_Bitmap_New(&glyph->bitmap);
+ FT_Bitmap_New(&glyph->bitmap);
- FT_Bitmap_Copy(font->context->library,
- &font->face->glyph->bitmap, &glyph->bitmap);
+ FT_Bitmap_Copy(font->context->library,
+ &font->face->glyph->bitmap, &glyph->bitmap);
- glyph->advance = font->face->glyph->metrics.horiAdvance >> 6;
- glyph->x = font->face->glyph->bitmap_left;
- glyph->y = -font->face->glyph->bitmap_top;
+ glyph->advance = font->face->glyph->metrics.horiAdvance >> 6;
+ glyph->x = font->face->glyph->bitmap_left;
+ glyph->y = -font->face->glyph->bitmap_top;
- font->glyphs[glyph_index] = glyph;
- }
+ font->glyphs[glyph_index] = glyph;
+ }
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
EXPORT
-bool wld_font_ensure_char(struct wld_font * font_base, uint32_t character)
+bool
+wld_font_ensure_char(struct wld_font *font_base, uint32_t character)
{
- struct font * font = (void *) font_base;
- FT_UInt glyph_index;
+ struct font *font = (void *)font_base;
+ FT_UInt glyph_index;
- glyph_index = FT_Get_Char_Index(font->face, character);
+ glyph_index = FT_Get_Char_Index(font->face, character);
- return font_ensure_glyph(font, glyph_index);
+ return font_ensure_glyph(font, glyph_index);
}
EXPORT
-void wld_font_text_extents_n(struct wld_font * font_base,
- const char * text, int32_t length,
- struct wld_extents * extents)
+void
+wld_font_text_extents_n(struct wld_font *font_base,
+ const char *text, int32_t length,
+ struct wld_extents *extents)
{
- struct font * font = (void *) font_base;
- int ret;
- uint32_t c;
- FT_UInt glyph_index;
+ struct font *font = (void *)font_base;
+ int ret;
+ uint32_t c;
+ FT_UInt glyph_index;
- extents->advance = 0;
+ extents->advance = 0;
- while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length) > 0) && c != '\0')
- {
- length -= ret;
- text += ret;
- glyph_index = FT_Get_Char_Index(font->face, c);
+ while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length) > 0) && c != '\0') {
+ length -= ret;
+ text += ret;
+ glyph_index = FT_Get_Char_Index(font->face, c);
- if (!font_ensure_glyph(font, glyph_index))
- continue;
+ if (!font_ensure_glyph(font, glyph_index))
+ continue;
- extents->advance += font->glyphs[glyph_index]->advance;
- }
+ extents->advance += font->glyphs[glyph_index]->advance;
+ }
}
-
diff --git a/intel.c b/intel.c
@@ -27,33 +27,30 @@
#include "intel/blt.h"
#include "wld-private.h"
-#include <unistd.h>
-#include <intel_bufmgr.h>
#include <i915_drm.h>
+#include <intel_bufmgr.h>
+#include <unistd.h>
-struct intel_context
-{
- struct wld_context base;
- drm_intel_bufmgr * bufmgr;
+struct intel_context {
+ struct wld_context base;
+ drm_intel_bufmgr *bufmgr;
};
-struct intel_renderer
-{
- struct wld_renderer base;
- struct intel_batch batch;
- struct intel_buffer * target;
+struct intel_renderer {
+ struct wld_renderer base;
+ struct intel_batch batch;
+ struct intel_buffer *target;
};
-struct intel_buffer
-{
- struct buffer base;
- struct wld_exporter exporter;
- drm_intel_bo * bo;
+struct intel_buffer {
+ struct buffer base;
+ struct wld_exporter exporter;
+ drm_intel_bo *bo;
};
+#include "interface/buffer.h"
#include "interface/context.h"
#include "interface/renderer.h"
-#include "interface/buffer.h"
#define DRM_DRIVER_NAME intel
#include "interface/drm.h"
IMPL(intel_context, wld_context)
@@ -61,330 +58,341 @@ IMPL(intel_renderer, wld_renderer)
IMPL(intel_buffer, wld_buffer)
/**** DRM driver ****/
-bool driver_device_supported(uint32_t vendor_id, uint32_t device_id)
+bool
+driver_device_supported(uint32_t vendor_id, uint32_t device_id)
{
- return vendor_id == 0x8086;
+ return vendor_id == 0x8086;
}
-struct wld_context * driver_create_context(int drm_fd)
+struct wld_context *
+driver_create_context(int drm_fd)
{
- struct intel_context * context;
+ struct intel_context *context;
- context = malloc(sizeof *context);
+ context = malloc(sizeof *context);
- if (!context)
- goto error0;
+ if (!context)
+ goto error0;
- context_initialize(&context->base, &wld_context_impl);
- context->bufmgr = drm_intel_bufmgr_gem_init(drm_fd, INTEL_BATCH_SIZE);
+ context_initialize(&context->base, &wld_context_impl);
+ context->bufmgr = drm_intel_bufmgr_gem_init(drm_fd, INTEL_BATCH_SIZE);
- if (!context->bufmgr)
- goto error1;
+ if (!context->bufmgr)
+ goto error1;
- return &context->base;
+ return &context->base;
- error1:
- free(context);
- error0:
- return NULL;
+error1:
+ free(context);
+error0:
+ return NULL;
}
/**** Context ****/
-struct wld_renderer * context_create_renderer(struct wld_context * base)
+struct wld_renderer *
+context_create_renderer(struct wld_context *base)
{
- struct intel_context * context = intel_context(base);
- struct intel_renderer * renderer;
+ struct intel_context *context = intel_context(base);
+ struct intel_renderer *renderer;
- if (!(renderer = malloc(sizeof *renderer)))
- goto error0;
+ if (!(renderer = malloc(sizeof *renderer)))
+ goto error0;
- if (!(intel_batch_initialize(&renderer->batch, context->bufmgr)))
- goto error1;
+ if (!(intel_batch_initialize(&renderer->batch, context->bufmgr)))
+ goto error1;
- renderer_initialize(&renderer->base, &wld_renderer_impl);
+ renderer_initialize(&renderer->base, &wld_renderer_impl);
- return &renderer->base;
+ return &renderer->base;
- error1:
- free(renderer);
- error0:
- return NULL;
+error1:
+ free(renderer);
+error0:
+ return NULL;
}
-static bool export(struct wld_exporter * exporter, struct wld_buffer * base,
- uint32_t type, union wld_object * object)
+static bool export(struct wld_exporter *exporter, struct wld_buffer *base,
+ uint32_t type, union wld_object *object)
{
- struct intel_buffer * buffer = intel_buffer(base);
-
- switch (type)
- {
- case WLD_DRM_OBJECT_HANDLE:
- object->u32 = buffer->bo->handle;
- return true;
- case WLD_DRM_OBJECT_PRIME_FD:
- if (drm_intel_bo_gem_export_to_prime(buffer->bo, &object->i) != 0)
- return false;
- return true;
- default:
- return false;
- }
+ struct intel_buffer *buffer = intel_buffer(base);
+
+ switch (type) {
+ case WLD_DRM_OBJECT_HANDLE:
+ object->u32 = buffer->bo->handle;
+ return true;
+ case WLD_DRM_OBJECT_PRIME_FD:
+ if (drm_intel_bo_gem_export_to_prime(buffer->bo, &object->i) != 0)
+ return false;
+ return true;
+ default:
+ return false;
+ }
}
-static struct buffer * new_buffer(uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch,
- drm_intel_bo * bo)
+static struct buffer *
+new_buffer(uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch,
+ drm_intel_bo *bo)
{
- struct intel_buffer * buffer;
+ struct intel_buffer *buffer;
- if (!(buffer = malloc(sizeof *buffer)))
- return NULL;
+ if (!(buffer = malloc(sizeof *buffer)))
+ return NULL;
- buffer_initialize(&buffer->base, &wld_buffer_impl,
- width, height, format, pitch);
- buffer->bo = bo;
- buffer->exporter.export = &export;
- wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
+ buffer_initialize(&buffer->base, &wld_buffer_impl,
+ width, height, format, pitch);
+ buffer->bo = bo;
+ buffer->exporter.export = &export;
+ wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
- return &buffer->base;
+ return &buffer->base;
}
-struct buffer * context_create_buffer(struct wld_context * base,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
+struct buffer *
+context_create_buffer(struct wld_context *base,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
{
- struct intel_context * context = intel_context(base);
- struct buffer * buffer;
- drm_intel_bo * bo;
- uint32_t tiling_mode = width >= 128 && !(flags & WLD_FLAG_CURSOR) ? I915_TILING_X : I915_TILING_NONE;
- unsigned long pitch;
+ struct intel_context *context = intel_context(base);
+ struct buffer *buffer;
+ drm_intel_bo *bo;
+ uint32_t tiling_mode = width >= 128 && !(flags & WLD_FLAG_CURSOR) ? I915_TILING_X : I915_TILING_NONE;
+ unsigned long pitch;
- bo = drm_intel_bo_alloc_tiled(context->bufmgr, "buffer", width, height, 4,
- &tiling_mode, &pitch, 0);
+ bo = drm_intel_bo_alloc_tiled(context->bufmgr, "buffer", width, height, 4,
+ &tiling_mode, &pitch, 0);
- if (!bo)
- goto error0;
+ if (!bo)
+ goto error0;
- if (!(buffer = new_buffer(width, height, format, pitch, bo)))
- goto error1;
+ if (!(buffer = new_buffer(width, height, format, pitch, bo)))
+ goto error1;
- return buffer;
+ return buffer;
- error1:
- drm_intel_bo_unreference(bo);
- error0:
- return NULL;
+error1:
+ drm_intel_bo_unreference(bo);
+error0:
+ return NULL;
}
-struct 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 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 buffer * buffer;
- drm_intel_bo * bo;
-
- switch (type)
- {
- case WLD_DRM_OBJECT_PRIME_FD:
- {
- uint32_t size = width * height * format_bytes_per_pixel(format);
- bo = drm_intel_bo_gem_create_from_prime(context->bufmgr,
- object.i, size);
- break;
- }
- default: bo = NULL;
- };
-
- if (!bo)
- goto error0;
-
- if (!(buffer = new_buffer(width, height, format, pitch, bo)))
- goto error1;
-
- return buffer;
-
- error1:
- drm_intel_bo_unreference(bo);
- error0:
- return NULL;
+ struct intel_context *context = intel_context(base);
+ struct buffer *buffer;
+ drm_intel_bo *bo;
+
+ switch (type) {
+ case WLD_DRM_OBJECT_PRIME_FD: {
+ uint32_t size = width * height * format_bytes_per_pixel(format);
+ bo = drm_intel_bo_gem_create_from_prime(context->bufmgr,
+ object.i, size);
+ break;
+ }
+ default:
+ bo = NULL;
+ };
+
+ if (!bo)
+ goto error0;
+
+ if (!(buffer = new_buffer(width, height, format, pitch, bo)))
+ goto error1;
+
+ return buffer;
+
+error1:
+ drm_intel_bo_unreference(bo);
+error0:
+ return NULL;
}
-void context_destroy(struct wld_context * base)
+void
+context_destroy(struct wld_context *base)
{
- struct intel_context * context = intel_context(base);
+ struct intel_context *context = intel_context(base);
- drm_intel_bufmgr_destroy(context->bufmgr);
- free(context);
+ drm_intel_bufmgr_destroy(context->bufmgr);
+ free(context);
}
/**** Renderer ****/
-uint32_t renderer_capabilities(struct wld_renderer * renderer,
- struct buffer * buffer)
+uint32_t
+renderer_capabilities(struct wld_renderer *renderer,
+ struct buffer *buffer)
{
- if (buffer->base.impl == &wld_buffer_impl)
- return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
+ if (buffer->base.impl == &wld_buffer_impl)
+ return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
- return 0;
+ return 0;
}
-bool renderer_set_target(struct wld_renderer * base, struct buffer * buffer)
+bool
+renderer_set_target(struct wld_renderer *base, struct buffer *buffer)
{
- struct intel_renderer * renderer = intel_renderer(base);
+ struct intel_renderer *renderer = intel_renderer(base);
- if (buffer && buffer->base.impl != &wld_buffer_impl)
- return false;
+ if (buffer && buffer->base.impl != &wld_buffer_impl)
+ return false;
- renderer->target = buffer ? intel_buffer(&buffer->base) : NULL;
+ renderer->target = buffer ? intel_buffer(&buffer->base) : NULL;
- return true;
+ return true;
}
-void renderer_fill_rectangle(struct wld_renderer * base, uint32_t color,
- int32_t x, int32_t y,
- uint32_t width, uint32_t height)
+void
+renderer_fill_rectangle(struct wld_renderer *base, uint32_t color,
+ int32_t x, int32_t y,
+ uint32_t width, uint32_t height)
{
- struct intel_renderer * renderer = intel_renderer(base);
- struct intel_buffer * dst = renderer->target;
+ struct intel_renderer *renderer = intel_renderer(base);
+ struct intel_buffer *dst = renderer->target;
- xy_color_blt(&renderer->batch, dst->bo, dst->base.base.pitch,
- x, y, x + width, y + height, color);
+ xy_color_blt(&renderer->batch, dst->bo, dst->base.base.pitch,
+ x, y, x + width, y + height, color);
}
-void renderer_copy_rectangle(struct wld_renderer * base,
- struct 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)
+void
+renderer_copy_rectangle(struct wld_renderer *base,
+ struct 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);
+ struct intel_renderer *renderer = intel_renderer(base);
- if (buffer_base->base.impl != &wld_buffer_impl)
- return;
+ if (buffer_base->base.impl != &wld_buffer_impl)
+ return;
- struct intel_buffer * src = intel_buffer(&buffer_base->base),
- * dst = renderer->target;
+ struct intel_buffer *src = intel_buffer(&buffer_base->base),
+ *dst = renderer->target;
- xy_src_copy_blt(&renderer->batch,
- src->bo, src->base.base.pitch, src_x, src_y,
- dst->bo, dst->base.base.pitch, dst_x, dst_y, width, height);
+ xy_src_copy_blt(&renderer->batch,
+ src->bo, src->base.base.pitch, src_x, src_y,
+ dst->bo, dst->base.base.pitch, dst_x, dst_y, width, height);
}
-void renderer_draw_text(struct wld_renderer * base,
- struct font * font, uint32_t color,
- int32_t x, int32_t y, const char * text,
- uint32_t length, struct wld_extents * extents)
+void
+renderer_draw_text(struct wld_renderer *base,
+ struct font *font, uint32_t color,
+ int32_t x, int32_t y, const char *text,
+ uint32_t length, struct wld_extents *extents)
{
- struct intel_renderer * renderer = intel_renderer(base);
- struct intel_buffer * dst = renderer->target;
- int ret;
- struct glyph * glyph;
- uint32_t row;
- FT_UInt glyph_index;
- uint32_t c;
- uint8_t immediate[512];
- uint8_t * byte;
- int32_t origin_x = x;
-
- xy_setup_blt(&renderer->batch, true, BLT_RASTER_OPERATION_SRC,
- 0, color, dst->bo, dst->base.base.pitch);
-
- if (length == -1)
- length = strlen(text);
-
- while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length)) > 0 && c != '\0')
- {
- text += ret;
- length -= ret;
- glyph_index = FT_Get_Char_Index(font->face, c);
-
- if (!font_ensure_glyph(font, glyph_index))
- continue;
-
- glyph = font->glyphs[glyph_index];
-
- if (glyph->bitmap.width == 0 || glyph->bitmap.rows == 0)
- goto advance;
-
- byte = immediate;
-
- /* XY_TEXT_IMMEDIATE requires a pitch with no extra bytes */
- for (row = 0; row < glyph->bitmap.rows; ++row)
- {
- memcpy(byte, glyph->bitmap.buffer + (row * glyph->bitmap.pitch),
- (glyph->bitmap.width + 7) / 8);
- byte += (glyph->bitmap.width + 7) / 8;
- }
-
- retry:
- ret = xy_text_immediate_blt(&renderer->batch, dst->bo,
- origin_x + glyph->x, y + glyph->y,
- origin_x + glyph->x + glyph->bitmap.width,
- y + glyph->y + glyph->bitmap.rows,
- (byte - immediate + 3) / 4,
- (uint32_t *) immediate);
-
- if (ret == INTEL_BATCH_NO_SPACE)
- {
- intel_batch_flush(&renderer->batch);
- xy_setup_blt(&renderer->batch, true, BLT_RASTER_OPERATION_SRC,
- 0, color, dst->bo, dst->base.base.pitch);
- goto retry;
- }
-
- advance:
- origin_x += glyph->advance;
- }
-
- if (extents)
- extents->advance = origin_x - x;
+ struct intel_renderer *renderer = intel_renderer(base);
+ struct intel_buffer *dst = renderer->target;
+ int ret;
+ struct glyph *glyph;
+ uint32_t row;
+ FT_UInt glyph_index;
+ uint32_t c;
+ uint8_t immediate[512];
+ uint8_t *byte;
+ int32_t origin_x = x;
+
+ xy_setup_blt(&renderer->batch, true, BLT_RASTER_OPERATION_SRC,
+ 0, color, dst->bo, dst->base.base.pitch);
+
+ if (length == -1)
+ length = strlen(text);
+
+ while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length)) > 0 && c != '\0') {
+ text += ret;
+ length -= ret;
+ glyph_index = FT_Get_Char_Index(font->face, c);
+
+ if (!font_ensure_glyph(font, glyph_index))
+ continue;
+
+ glyph = font->glyphs[glyph_index];
+
+ if (glyph->bitmap.width == 0 || glyph->bitmap.rows == 0)
+ goto advance;
+
+ byte = immediate;
+
+ /* XY_TEXT_IMMEDIATE requires a pitch with no extra bytes */
+ for (row = 0; row < glyph->bitmap.rows; ++row) {
+ memcpy(byte, glyph->bitmap.buffer + (row * glyph->bitmap.pitch),
+ (glyph->bitmap.width + 7) / 8);
+ byte += (glyph->bitmap.width + 7) / 8;
+ }
+
+ retry:
+ ret = xy_text_immediate_blt(&renderer->batch, dst->bo,
+ origin_x + glyph->x, y + glyph->y,
+ origin_x + glyph->x + glyph->bitmap.width,
+ y + glyph->y + glyph->bitmap.rows,
+ (byte - immediate + 3) / 4,
+ (uint32_t *)immediate);
+
+ if (ret == INTEL_BATCH_NO_SPACE) {
+ intel_batch_flush(&renderer->batch);
+ xy_setup_blt(&renderer->batch, true, BLT_RASTER_OPERATION_SRC,
+ 0, color, dst->bo, dst->base.base.pitch);
+ goto retry;
+ }
+
+ advance:
+ origin_x += glyph->advance;
+ }
+
+ if (extents)
+ extents->advance = origin_x - x;
}
-void renderer_flush(struct wld_renderer * base)
+void
+renderer_flush(struct wld_renderer *base)
{
- struct intel_renderer * renderer = intel_renderer(base);
+ struct intel_renderer *renderer = intel_renderer(base);
- intel_batch_flush(&renderer->batch);
+ intel_batch_flush(&renderer->batch);
}
-void renderer_destroy(struct wld_renderer * base)
+void
+renderer_destroy(struct wld_renderer *base)
{
- struct intel_renderer * renderer = intel_renderer(base);
+ struct intel_renderer *renderer = intel_renderer(base);
- intel_batch_finalize(&renderer->batch);
- free(renderer);
+ intel_batch_finalize(&renderer->batch);
+ free(renderer);
}
/**** Buffer ****/
-bool buffer_map(struct buffer * base)
+bool
+buffer_map(struct buffer *base)
{
- struct intel_buffer * buffer = intel_buffer(&base->base);
+ struct intel_buffer *buffer = intel_buffer(&base->base);
- if (drm_intel_gem_bo_map_gtt(buffer->bo) != 0)
- return false;
+ if (drm_intel_gem_bo_map_gtt(buffer->bo) != 0)
+ return false;
- buffer->base.base.map = buffer->bo->virtual;
+ buffer->base.base.map = buffer->bo->virtual;
- return true;
+ return true;
}
-bool buffer_unmap(struct buffer * base)
+bool
+buffer_unmap(struct buffer *base)
{
- struct intel_buffer * buffer = intel_buffer(&base->base);
+ struct intel_buffer *buffer = intel_buffer(&base->base);
- if (drm_intel_gem_bo_unmap_gtt(buffer->bo) != 0)
- return false;
+ if (drm_intel_gem_bo_unmap_gtt(buffer->bo) != 0)
+ return false;
- buffer->base.base.map = NULL;
+ buffer->base.base.map = NULL;
- return true;
+ return true;
}
-void buffer_destroy(struct buffer * base)
+void
+buffer_destroy(struct buffer *base)
{
- struct intel_buffer * buffer = intel_buffer(&base->base);
+ struct intel_buffer *buffer = intel_buffer(&base->base);
- drm_intel_bo_unreference(buffer->bo);
- free(buffer);
+ drm_intel_bo_unreference(buffer->bo);
+ free(buffer);
}
-
diff --git a/intel/batch.c b/intel/batch.c
@@ -27,97 +27,101 @@
#include <i915_drm.h>
#include <stdlib.h>
-static const struct intel_device_info device_info_i965 = { .gen = 4 };
-static const struct intel_device_info device_info_g4x = { .gen = 4 };
-static const struct intel_device_info device_info_ilk = { .gen = 5 };
-static const struct intel_device_info device_info_snb_gt1 = { .gen = 6 };
-static const struct intel_device_info device_info_snb_gt2 = { .gen = 6 };
-static const struct intel_device_info device_info_ivb_gt1 = { .gen = 7 };
-static const struct intel_device_info device_info_ivb_gt2 = { .gen = 7 };
-static const struct intel_device_info device_info_byt = { .gen = 7 };
-static const struct intel_device_info device_info_hsw_gt1 = { .gen = 7 };
-static const struct intel_device_info device_info_hsw_gt2 = { .gen = 7 };
-static const struct intel_device_info device_info_hsw_gt3 = { .gen = 7 };
-static const struct intel_device_info device_info_bdw_gt1 = { .gen = 8 };
-static const struct intel_device_info device_info_bdw_gt2 = { .gen = 8 };
-static const struct intel_device_info device_info_bdw_gt3 = { .gen = 8 };
-static const struct intel_device_info device_info_chv = { .gen = 8 };
-static const struct intel_device_info device_info_skl_gt1 = { .gen = 9 };
-static const struct intel_device_info device_info_skl_gt2 = { .gen = 9 };
-static const struct intel_device_info device_info_skl_gt3 = { .gen = 9 };
-static const struct intel_device_info device_info_skl_gt4 = { .gen = 9 };
-static const struct intel_device_info device_info_bxt = { .gen = 9 };
-static const struct intel_device_info device_info_bxt_2x6 = { .gen = 9 };
-static const struct intel_device_info device_info_kbl_gt1 = { .gen = 9 };
+static const struct intel_device_info device_info_i965 = { .gen = 4 };
+static const struct intel_device_info device_info_g4x = { .gen = 4 };
+static const struct intel_device_info device_info_ilk = { .gen = 5 };
+static const struct intel_device_info device_info_snb_gt1 = { .gen = 6 };
+static const struct intel_device_info device_info_snb_gt2 = { .gen = 6 };
+static const struct intel_device_info device_info_ivb_gt1 = { .gen = 7 };
+static const struct intel_device_info device_info_ivb_gt2 = { .gen = 7 };
+static const struct intel_device_info device_info_byt = { .gen = 7 };
+static const struct intel_device_info device_info_hsw_gt1 = { .gen = 7 };
+static const struct intel_device_info device_info_hsw_gt2 = { .gen = 7 };
+static const struct intel_device_info device_info_hsw_gt3 = { .gen = 7 };
+static const struct intel_device_info device_info_bdw_gt1 = { .gen = 8 };
+static const struct intel_device_info device_info_bdw_gt2 = { .gen = 8 };
+static const struct intel_device_info device_info_bdw_gt3 = { .gen = 8 };
+static const struct intel_device_info device_info_chv = { .gen = 8 };
+static const struct intel_device_info device_info_skl_gt1 = { .gen = 9 };
+static const struct intel_device_info device_info_skl_gt2 = { .gen = 9 };
+static const struct intel_device_info device_info_skl_gt3 = { .gen = 9 };
+static const struct intel_device_info device_info_skl_gt4 = { .gen = 9 };
+static const struct intel_device_info device_info_bxt = { .gen = 9 };
+static const struct intel_device_info device_info_bxt_2x6 = { .gen = 9 };
+static const struct intel_device_info device_info_kbl_gt1 = { .gen = 9 };
static const struct intel_device_info device_info_kbl_gt1_5 = { .gen = 9 };
-static const struct intel_device_info device_info_kbl_gt2 = { .gen = 9 };
-static const struct intel_device_info device_info_kbl_gt3 = { .gen = 9 };
-static const struct intel_device_info device_info_kbl_gt4 = { .gen = 9 };
-static const struct intel_device_info device_info_glk = { .gen = 9 };
-static const struct intel_device_info device_info_glk_2x6 = { .gen = 9 };
-static const struct intel_device_info device_info_cfl_gt1 = { .gen = 9 };
-static const struct intel_device_info device_info_cfl_gt2 = { .gen = 9 };
-static const struct intel_device_info device_info_cfl_gt3 = { .gen = 9 };
-static const struct intel_device_info device_info_cnl_2x8 = { .gen = 10 };
-static const struct intel_device_info device_info_cnl_3x8 = { .gen = 10 };
-static const struct intel_device_info device_info_cnl_4x8 = { .gen = 10 };
-static const struct intel_device_info device_info_cnl_5x8 = { .gen = 10 };
-
-static const struct intel_device_info * device_info(int device_id)
+static const struct intel_device_info device_info_kbl_gt2 = { .gen = 9 };
+static const struct intel_device_info device_info_kbl_gt3 = { .gen = 9 };
+static const struct intel_device_info device_info_kbl_gt4 = { .gen = 9 };
+static const struct intel_device_info device_info_glk = { .gen = 9 };
+static const struct intel_device_info device_info_glk_2x6 = { .gen = 9 };
+static const struct intel_device_info device_info_cfl_gt1 = { .gen = 9 };
+static const struct intel_device_info device_info_cfl_gt2 = { .gen = 9 };
+static const struct intel_device_info device_info_cfl_gt3 = { .gen = 9 };
+static const struct intel_device_info device_info_cnl_2x8 = { .gen = 10 };
+static const struct intel_device_info device_info_cnl_3x8 = { .gen = 10 };
+static const struct intel_device_info device_info_cnl_4x8 = { .gen = 10 };
+static const struct intel_device_info device_info_cnl_5x8 = { .gen = 10 };
+
+static const struct intel_device_info *
+device_info(int device_id)
{
- switch (device_id)
- {
+ switch (device_id) {
#define CHIPSET(device_id, type, name) \
- case device_id: return &device_info_ ## type;
+ case device_id: \
+ return &device_info_##type;
#include "i965_pci_ids.h"
#undef CHIPSET
- default: return NULL;
- }
+ default:
+ return NULL;
+ }
}
-bool intel_batch_initialize(struct intel_batch * batch,
- drm_intel_bufmgr * bufmgr)
+bool
+intel_batch_initialize(struct intel_batch *batch,
+ drm_intel_bufmgr *bufmgr)
{
- int device_id = drm_intel_bufmgr_gem_get_devid(bufmgr);
+ int device_id = drm_intel_bufmgr_gem_get_devid(bufmgr);
- batch->command_count = 0;
- batch->device_info = device_info(device_id);
+ batch->command_count = 0;
+ batch->device_info = device_info(device_id);
- if (!batch->device_info)
- return false;
+ if (!batch->device_info)
+ return false;
- /* Alignment argument (4096) is not used */
- batch->bo = drm_intel_bo_alloc(bufmgr, "batchbuffer",
- sizeof batch->commands, 4096);
+ /* Alignment argument (4096) is not used */
+ batch->bo = drm_intel_bo_alloc(bufmgr, "batchbuffer",
+ sizeof batch->commands, 4096);
- if (!batch->bo)
- return false;
+ if (!batch->bo)
+ return false;
- return true;
+ return true;
}
-void intel_batch_finalize(struct intel_batch * batch)
+void
+intel_batch_finalize(struct intel_batch *batch)
{
- drm_intel_bo_unreference(batch->bo);
+ drm_intel_bo_unreference(batch->bo);
}
-void intel_batch_flush(struct intel_batch * batch)
+void
+intel_batch_flush(struct intel_batch *batch)
{
- if (batch->command_count == 0)
- return;
-
- intel_batch_add_dword(batch, MI_BATCH_BUFFER_END);
-
- /* Pad the batch buffer to the next quad-word. */
- if (batch->command_count & 1)
- intel_batch_add_dword(batch, MI_NOOP);
-
- drm_intel_bo_subdata(batch->bo, 0, batch->command_count << 2,
- batch->commands);
- drm_intel_bo_mrb_exec(batch->bo, batch->command_count << 2, NULL, 0, 0,
- GEN(batch, 6) ? I915_EXEC_BLT
- : I915_EXEC_DEFAULT);
- drm_intel_gem_bo_clear_relocs(batch->bo, 0);
- batch->command_count = 0;
+ if (batch->command_count == 0)
+ return;
+
+ intel_batch_add_dword(batch, MI_BATCH_BUFFER_END);
+
+ /* Pad the batch buffer to the next quad-word. */
+ if (batch->command_count & 1)
+ intel_batch_add_dword(batch, MI_NOOP);
+
+ drm_intel_bo_subdata(batch->bo, 0, batch->command_count << 2,
+ batch->commands);
+ drm_intel_bo_mrb_exec(batch->bo, batch->command_count << 2, NULL, 0, 0,
+ GEN(batch, 6) ? I915_EXEC_BLT
+ : I915_EXEC_DEFAULT);
+ drm_intel_gem_bo_clear_relocs(batch->bo, 0);
+ batch->command_count = 0;
}
-
diff --git a/intel/batch.h b/intel/batch.h
@@ -24,83 +24,86 @@
#ifndef WLD_INTEL_BATCH_H
#define WLD_INTEL_BATCH_H
+#include <intel_bufmgr.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
-#include <intel_bufmgr.h>
#define INTEL_BATCH_MAX_COMMANDS (1 << 13)
#define INTEL_BATCH_RESERVED_COMMANDS 2
#define INTEL_BATCH_SIZE (INTEL_BATCH_MAX_COMMANDS << 2)
-enum intel_batch_result
-{
- INTEL_BATCH_SUCCESS,
- INTEL_BATCH_NO_SPACE
+enum intel_batch_result {
+ INTEL_BATCH_SUCCESS,
+ INTEL_BATCH_NO_SPACE
};
-struct intel_device_info
-{
- int gen;
+struct intel_device_info {
+ int gen;
};
#define GEN(b, m) ((b)->device_info->gen >= (m))
-struct intel_batch
-{
- const struct intel_device_info * device_info;
- drm_intel_bo * bo;
- uint32_t commands[INTEL_BATCH_MAX_COMMANDS];
- uint32_t command_count;
+struct intel_batch {
+ const struct intel_device_info *device_info;
+ drm_intel_bo *bo;
+ uint32_t commands[INTEL_BATCH_MAX_COMMANDS];
+ uint32_t command_count;
};
-bool intel_batch_initialize(struct intel_batch * batch,
- drm_intel_bufmgr * bufmgr);
+bool intel_batch_initialize(struct intel_batch *batch,
+ drm_intel_bufmgr *bufmgr);
-void intel_batch_finalize(struct intel_batch * batch);
+void intel_batch_finalize(struct intel_batch *batch);
-void intel_batch_flush(struct intel_batch * batch);
+void intel_batch_flush(struct intel_batch *batch);
-static inline uint32_t intel_batch_check_space(struct intel_batch * batch,
- uint32_t size)
+static inline uint32_t
+intel_batch_check_space(struct intel_batch *batch,
+ uint32_t size)
{
- return (INTEL_BATCH_MAX_COMMANDS - INTEL_BATCH_RESERVED_COMMANDS
- - batch->command_count) >= size;
+ return (INTEL_BATCH_MAX_COMMANDS - INTEL_BATCH_RESERVED_COMMANDS
+ - batch->command_count)
+ >= size;
}
-static inline void intel_batch_ensure_space(struct intel_batch * batch, uint32_t size)
+static inline void
+intel_batch_ensure_space(struct intel_batch *batch, uint32_t size)
{
- if (!intel_batch_check_space(batch, size))
- intel_batch_flush(batch);
+ if (!intel_batch_check_space(batch, size))
+ intel_batch_flush(batch);
}
-static inline void intel_batch_add_dword(struct intel_batch * batch,
- uint32_t dword)
+static inline void
+intel_batch_add_dword(struct intel_batch *batch,
+ uint32_t dword)
{
- batch->commands[batch->command_count++] = dword;
+ batch->commands[batch->command_count++] = dword;
}
-static inline void intel_batch_add_dwords_va(struct intel_batch * batch,
- uint32_t count, va_list dwords)
+static inline void
+intel_batch_add_dwords_va(struct intel_batch *batch,
+ uint32_t count, va_list dwords)
{
- while (count--)
- intel_batch_add_dword(batch, va_arg(dwords, uint32_t));
+ while (count--)
+ intel_batch_add_dword(batch, va_arg(dwords, uint32_t));
}
-static inline void intel_batch_add_dwords(struct intel_batch * batch,
- uint32_t count, ...)
+static inline void
+intel_batch_add_dwords(struct intel_batch *batch,
+ uint32_t count, ...)
{
- va_list dwords;
- va_start(dwords, count);
- intel_batch_add_dwords_va(batch, count, dwords);
- va_end(dwords);
+ va_list dwords;
+ va_start(dwords, count);
+ intel_batch_add_dwords_va(batch, count, dwords);
+ va_end(dwords);
}
-static inline uint32_t intel_batch_offset(struct intel_batch * batch,
- uint32_t command_index)
+static inline uint32_t
+intel_batch_offset(struct intel_batch *batch,
+ uint32_t command_index)
{
- return (batch->command_count + command_index) << 2;
+ return (batch->command_count + command_index) << 2;
}
#endif
-
diff --git a/intel/blt.h b/intel/blt.h
@@ -29,360 +29,344 @@
#define INTEL_CLIENT_BLT 0x2
-enum blt_op
-{
- BLT_OP_XY_SETUP_BLT = 0x01,
- BLT_OP_XY_TEXT_BLT = 0x26,
- BLT_OP_XY_TEXT_IMMEDIATE_BLT = 0x31,
- BLT_OP_XY_COLOR_BLT = 0x50,
- BLT_OP_XY_SRC_COPY_BLT = 0x53
+enum blt_op {
+ BLT_OP_XY_SETUP_BLT = 0x01,
+ BLT_OP_XY_TEXT_BLT = 0x26,
+ BLT_OP_XY_TEXT_IMMEDIATE_BLT = 0x31,
+ BLT_OP_XY_COLOR_BLT = 0x50,
+ BLT_OP_XY_SRC_COPY_BLT = 0x53
};
-enum blt_32bpp_mask
-{
- BLT_32BPP_MASK_ALPHA = (1 << 0),
- BLT_32BPP_MASK_RGB = (1 << 1)
+enum blt_32bpp_mask {
+ BLT_32BPP_MASK_ALPHA = (1 << 0),
+ BLT_32BPP_MASK_RGB = (1 << 1)
};
-enum blt_packing
-{
- BLT_PACKING_BIT = 0,
- BLT_PACKING_BYTE = 1
+enum blt_packing {
+ BLT_PACKING_BIT = 0,
+ BLT_PACKING_BYTE = 1
};
-enum blt_color_depth
-{
- BLT_COLOR_DEPTH_8BIT = 0x0,
- BLT_COLOR_DEPTH_16BIT_565 = 0x1,
- BLT_COLOR_DEPTH_16BIT_1555 = 0x2,
- BLT_COLOR_DEPTH_32BIT = 0x3
+enum blt_color_depth {
+ BLT_COLOR_DEPTH_8BIT = 0x0,
+ BLT_COLOR_DEPTH_16BIT_565 = 0x1,
+ BLT_COLOR_DEPTH_16BIT_1555 = 0x2,
+ BLT_COLOR_DEPTH_32BIT = 0x3
};
-enum blt_raster_operation
-{
- BLT_RASTER_OPERATION_SRC = 0xcc,
- BLT_RASTER_OPERATION_PAT = 0xf0
+enum blt_raster_operation {
+ BLT_RASTER_OPERATION_SRC = 0xcc,
+ BLT_RASTER_OPERATION_PAT = 0xf0
};
/* BR00 : BLT Opcode & Control */
-#define BLT_BR00_CLIENT(x) ((x) << 29) /* 31:29 */
-#define BLT_BR00_OP(x) ((x) << 22) /* 28:22 */
-#define BLT_BR00_32BPP_MASK(x) ((x) << 20) /* 21:20 */
- /* 19:17 */
-#define BLT_BR00_PACKING(x) ((x) << 16) /* 16 */
-#define BLT_BR00_SRC_TILING_ENABLE(x) ((x) << 15) /* 15 */
- /* 14:12 */
-#define BLT_BR00_DST_TILING_ENABLE(x) ((x) << 11) /* 11 */
-#define BLT_BR00_DWORD_LENGTH(x) ((x) << 0) /* 7:0 */
+#define BLT_BR00_CLIENT(x) ((x) << 29) /* 31:29 */
+#define BLT_BR00_OP(x) ((x) << 22) /* 28:22 */
+#define BLT_BR00_32BPP_MASK(x) ((x) << 20) /* 21:20 */
+ /* 19:17 */
+#define BLT_BR00_PACKING(x) ((x) << 16) /* 16 */
+#define BLT_BR00_SRC_TILING_ENABLE(x) ((x) << 15) /* 15 */
+ /* 14:12 */
+#define BLT_BR00_DST_TILING_ENABLE(x) ((x) << 11) /* 11 */
+#define BLT_BR00_DWORD_LENGTH(x) ((x) << 0) /* 7:0 */
/* BR01 : Setup BLT Raster OP, Control, and Destination Offset */
-#define BLT_BR01_SOLID_PATTERN(x) ((x) << 31) /* 31 */
-#define BLT_BR01_CLIPPING_ENABLE(x) ((x) << 30) /* 30 */
-#define BLT_BR01_MONO_SRC_TRANSPARENCY(x) ((x) << 29) /* 29 */
-#define BLT_BR01_MONO_PAT_TRANSPARENCY(x) ((x) << 28) /* 28 */
-#define BLT_BR01_COLOR_DEPTH(x) ((x) << 24) /* 25:24 */
-#define BLT_BR01_RASTER_OPERATION(x) ((x) << 16) /* 23:16 */
-#define BLT_BR01_DST_PITCH(x) ((x) << 0) /* 15:0 */
+#define BLT_BR01_SOLID_PATTERN(x) ((x) << 31) /* 31 */
+#define BLT_BR01_CLIPPING_ENABLE(x) ((x) << 30) /* 30 */
+#define BLT_BR01_MONO_SRC_TRANSPARENCY(x) ((x) << 29) /* 29 */
+#define BLT_BR01_MONO_PAT_TRANSPARENCY(x) ((x) << 28) /* 28 */
+#define BLT_BR01_COLOR_DEPTH(x) ((x) << 24) /* 25:24 */
+#define BLT_BR01_RASTER_OPERATION(x) ((x) << 16) /* 23:16 */
+#define BLT_BR01_DST_PITCH(x) ((x) << 0) /* 15:0 */
/* BR05 : Setup Expansion Background Color */
-#define BLT_BR05_BACKGROUND_COLOR(x) ((x) << 0) /* 31:0 */
+#define BLT_BR05_BACKGROUND_COLOR(x) ((x) << 0) /* 31:0 */
/* BR06 : Setup Expansion Foreground Color */
-#define BLT_BR06_FOREGROUND_COLOR(x) ((x) << 0) /* 31:0 */
+#define BLT_BR06_FOREGROUND_COLOR(x) ((x) << 0) /* 31:0 */
/* BR07 : Setup Blit Color Pattern Address Low Bits */
- /* 31:29 */
-#define BLT_BR07_PAT_ADDRESS(x) ((x) << 6) /* 28:6 */
- /* 5:0 */
+/* 31:29 */
+#define BLT_BR07_PAT_ADDRESS(x) ((x) << 6) /* 28:6 */
+ /* 5:0 */
/* BR09 : Destination Address Low Bits */
- /* 31:29 */
-#define BLT_BR09_DST_ADDRESS(x) ((x) << 0) /* 28:0 */
+/* 31:29 */
+#define BLT_BR09_DST_ADDRESS(x) ((x) << 0) /* 28:0 */
/* BR11 : Source Pitch */
- /* 31:16 */
-#define BLT_BR11_SRC_PITCH(x) ((x) << 0) /* 15:0 */
+/* 31:16 */
+#define BLT_BR11_SRC_PITCH(x) ((x) << 0) /* 15:0 */
/* BR12 : Source Address Low Bits */
- /* 31:29 */
-#define BLT_BR12_SRC_ADDRESS(x) ((x) << 0) /* 28:0 */
+/* 31:29 */
+#define BLT_BR12_SRC_ADDRESS(x) ((x) << 0) /* 28:0 */
/* BR13 : BLT Raster OP, Control, and Destination Pitch */
-#define BLT_BR13_SOLID_PATTERN(x) ((x) << 31) /* 31 */
-#define BLT_BR13_CLIPPING_ENABLE(x) ((x) << 30) /* 30 */
-#define BLT_BR13_MONO_SRC_TRANSPARENT(x) ((x) << 29) /* 29 */
-#define BLT_BR13_MONO_PAT_TRANSPARENT(x) ((x) << 28) /* 28 */
-#define BLT_BR13_COLOR_DEPTH(x) ((x) << 24) /* 25:24 */
-#define BLT_BR13_RASTER_OPERATION(x) ((x) << 16) /* 23:16 */
-#define BLT_BR13_DST_PITCH(x) ((x) << 0) /* 15:0 */
+#define BLT_BR13_SOLID_PATTERN(x) ((x) << 31) /* 31 */
+#define BLT_BR13_CLIPPING_ENABLE(x) ((x) << 30) /* 30 */
+#define BLT_BR13_MONO_SRC_TRANSPARENT(x) ((x) << 29) /* 29 */
+#define BLT_BR13_MONO_PAT_TRANSPARENT(x) ((x) << 28) /* 28 */
+#define BLT_BR13_COLOR_DEPTH(x) ((x) << 24) /* 25:24 */
+#define BLT_BR13_RASTER_OPERATION(x) ((x) << 16) /* 23:16 */
+#define BLT_BR13_DST_PITCH(x) ((x) << 0) /* 15:0 */
/* BR16 : Pattern Expansion Background & Solid Pattern Color */
-#define BLT_BR16_COLOR(x) ((x) << 0) /* 31 : 0 */
+#define BLT_BR16_COLOR(x) ((x) << 0) /* 31 : 0 */
/* BR22 : Destination Top Left */
-#define BLT_BR22_DST_Y1(x) ((x) << 16) /* 31:16 */
-#define BLT_BR22_DST_X1(x) ((x) << 0) /* 16:0 */
+#define BLT_BR22_DST_Y1(x) ((x) << 16) /* 31:16 */
+#define BLT_BR22_DST_X1(x) ((x) << 0) /* 16:0 */
/* BR23 : Destination Bottom Right */
-#define BLT_BR23_DST_Y2(x) ((x) << 16) /* 31:16 */
-#define BLT_BR23_DST_X2(x) ((x) << 0) /* 16:0 */
+#define BLT_BR23_DST_Y2(x) ((x) << 16) /* 31:16 */
+#define BLT_BR23_DST_X2(x) ((x) << 0) /* 16:0 */
/* BR24 : Clip Rectangle Top Left */
- /* 31 */
-#define BLT_BR24_CLP_Y1(x) ((x) << 16) /* 30:16 */
- /* 15 */
-#define BLT_BR24_CLP_X1(x) ((x) << 0) /* 14:0 */
+/* 31 */
+#define BLT_BR24_CLP_Y1(x) ((x) << 16) /* 30:16 */
+ /* 15 */
+#define BLT_BR24_CLP_X1(x) ((x) << 0) /* 14:0 */
/* BR25 : Clip Rectangle Bottom Right */
- /* 31 */
-#define BLT_BR25_CLP_Y2(x) ((x) << 16) /* 30:16 */
- /* 15 */
-#define BLT_BR25_CLP_X2(x) ((x) << 0) /* 14:0 */
+/* 31 */
+#define BLT_BR25_CLP_Y2(x) ((x) << 16) /* 30:16 */
+ /* 15 */
+#define BLT_BR25_CLP_X2(x) ((x) << 0) /* 14:0 */
/* BR26 : Source Top Left */
-#define BLT_BR26_SRC_Y1(x) ((x) << 16) /* 31:16 */
-#define BLT_BR26_SRC_X1(x) ((x) << 0) /* 15:0 */
+#define BLT_BR26_SRC_Y1(x) ((x) << 16) /* 31:16 */
+#define BLT_BR26_SRC_X1(x) ((x) << 0) /* 15:0 */
/* BR27 : Destination Address High Bits */
- /* 31:16 */
-#define BLT_BR27_DST_ADDRESS_HI(x) ((x) << 0) /* 15:0 */
+/* 31:16 */
+#define BLT_BR27_DST_ADDRESS_HI(x) ((x) << 0) /* 15:0 */
/* BR28 : Source Address High Bits */
- /* 31:16 */
-#define BLT_BR28_SRC_ADDRESS_HI(x) ((x) << 0) /* 15:0 */
+/* 31:16 */
+#define BLT_BR28_SRC_ADDRESS_HI(x) ((x) << 0) /* 15:0 */
/* BR30 : Setup Blit Color Pattern Address High Bits */
- /* 31:16 */
-#define BLT_BR30_PAT_ADDRESS_HI(x) ((x) << 0) /* 15:0 */
-
-static inline void xy_setup_blt(struct intel_batch * batch,
- bool monochrome_source_transparency,
- uint8_t raster_operation,
- uint32_t background_color,
- uint32_t foreground_color,
- drm_intel_bo * dst, uint16_t dst_pitch)
+/* 31:16 */
+#define BLT_BR30_PAT_ADDRESS_HI(x) ((x) << 0) /* 15:0 */
+
+static inline void
+xy_setup_blt(struct intel_batch *batch,
+ bool monochrome_source_transparency,
+ uint8_t raster_operation,
+ uint32_t background_color,
+ uint32_t foreground_color,
+ drm_intel_bo *dst, uint16_t dst_pitch)
{
- uint32_t tiling_mode, swizzle_mode;
-
- intel_batch_ensure_space(batch, GEN(batch, 8) ? 10 : 8);
-
- drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
- drm_intel_bo_emit_reloc_fence
- (batch->bo, intel_batch_offset(batch, 4), dst, 0,
- I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
-
- intel_batch_add_dwords(batch, 4,
- BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
- | BLT_BR00_OP(BLT_OP_XY_SETUP_BLT)
- | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
- | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
- | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 8 : 6),
-
- BLT_BR01_CLIPPING_ENABLE(false)
- | BLT_BR01_MONO_SRC_TRANSPARENCY(monochrome_source_transparency)
- | BLT_BR01_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
- | BLT_BR01_RASTER_OPERATION(raster_operation)
- | BLT_BR01_DST_PITCH(tiling_mode == I915_TILING_NONE
- ? dst_pitch : dst_pitch >> 2),
-
- /* XXX: No clipping yet */
- BLT_BR24_CLP_Y1(0)
- | BLT_BR24_CLP_X1(0),
-
- BLT_BR25_CLP_Y2(0)
- | BLT_BR25_CLP_X2(0)
- );
-
- intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
- BLT_BR09_DST_ADDRESS(dst->offset64),
- /* if gen8 */
- BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32)
- );
-
- intel_batch_add_dwords(batch, 2,
- BLT_BR05_BACKGROUND_COLOR(background_color),
- BLT_BR06_FOREGROUND_COLOR(foreground_color)
- );
-
- intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
- BLT_BR07_PAT_ADDRESS(0),
- /* if gen8 */
- BLT_BR30_PAT_ADDRESS_HI(0)
- );
+ uint32_t tiling_mode, swizzle_mode;
+
+ intel_batch_ensure_space(batch, GEN(batch, 8) ? 10 : 8);
+
+ drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
+ drm_intel_bo_emit_reloc_fence(batch->bo, intel_batch_offset(batch, 4), dst, 0,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
+
+ intel_batch_add_dwords(batch, 4,
+ BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
+ | BLT_BR00_OP(BLT_OP_XY_SETUP_BLT)
+ | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
+ | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
+ | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 8 : 6),
+
+ BLT_BR01_CLIPPING_ENABLE(false)
+ | BLT_BR01_MONO_SRC_TRANSPARENCY(monochrome_source_transparency)
+ | BLT_BR01_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
+ | BLT_BR01_RASTER_OPERATION(raster_operation)
+ | BLT_BR01_DST_PITCH(tiling_mode == I915_TILING_NONE
+ ? dst_pitch
+ : dst_pitch >> 2),
+
+ /* XXX: No clipping yet */
+ BLT_BR24_CLP_Y1(0)
+ | BLT_BR24_CLP_X1(0),
+
+ BLT_BR25_CLP_Y2(0)
+ | BLT_BR25_CLP_X2(0));
+
+ intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
+ BLT_BR09_DST_ADDRESS(dst->offset64),
+ /* if gen8 */
+ BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32));
+
+ intel_batch_add_dwords(batch, 2,
+ BLT_BR05_BACKGROUND_COLOR(background_color),
+ BLT_BR06_FOREGROUND_COLOR(foreground_color));
+
+ intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
+ BLT_BR07_PAT_ADDRESS(0),
+ /* if gen8 */
+ BLT_BR30_PAT_ADDRESS_HI(0));
}
-static inline int xy_text_blt(struct intel_batch * batch,
- drm_intel_bo * src, uint32_t src_offset,
- drm_intel_bo * dst,
- int16_t dst_x1, int16_t dst_y1,
- int16_t dst_x2, int16_t dst_y2)
+static inline int
+xy_text_blt(struct intel_batch *batch,
+ drm_intel_bo *src, uint32_t src_offset,
+ drm_intel_bo *dst,
+ int16_t dst_x1, int16_t dst_y1,
+ int16_t dst_x2, int16_t dst_y2)
{
- uint32_t tiling_mode, swizzle_mode;
+ uint32_t tiling_mode, swizzle_mode;
- if (!intel_batch_check_space(batch, GEN(batch, 8) ? 5 : 4))
- return INTEL_BATCH_NO_SPACE;
+ if (!intel_batch_check_space(batch, GEN(batch, 8) ? 5 : 4))
+ return INTEL_BATCH_NO_SPACE;
- drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
+ drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
- drm_intel_bo_emit_reloc_fence
- (batch->bo, intel_batch_offset(batch, 3), src, src_offset,
- I915_GEM_DOMAIN_RENDER, 0);
+ drm_intel_bo_emit_reloc_fence(batch->bo, intel_batch_offset(batch, 3), src, src_offset,
+ I915_GEM_DOMAIN_RENDER, 0);
- intel_batch_add_dwords(batch, 3,
- BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
- | BLT_BR00_OP(BLT_OP_XY_TEXT_BLT)
- | BLT_BR00_PACKING(BLT_PACKING_BYTE)
- | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
- | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 3 : 2),
+ intel_batch_add_dwords(batch, 3,
+ BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
+ | BLT_BR00_OP(BLT_OP_XY_TEXT_BLT)
+ | BLT_BR00_PACKING(BLT_PACKING_BYTE)
+ | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
+ | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 3 : 2),
- BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
- BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2)
- );
+ BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
+ BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2));
- intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
- BLT_BR12_SRC_ADDRESS(src->offset64 + src_offset),
- /* if gen8 */
- BLT_BR28_SRC_ADDRESS_HI((src->offset64 + src_offset) >> 32)
- );
+ intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
+ BLT_BR12_SRC_ADDRESS(src->offset64 + src_offset),
+ /* if gen8 */
+ BLT_BR28_SRC_ADDRESS_HI((src->offset64 + src_offset) >> 32));
- return INTEL_BATCH_SUCCESS;
+ return INTEL_BATCH_SUCCESS;
}
-static inline int xy_text_immediate_blt(struct intel_batch * batch,
- drm_intel_bo * dst,
- int16_t dst_x1, int16_t dst_y1,
- int16_t dst_x2, int16_t dst_y2,
- uint16_t count, uint32_t * immediates)
+static inline int
+xy_text_immediate_blt(struct intel_batch *batch,
+ drm_intel_bo *dst,
+ int16_t dst_x1, int16_t dst_y1,
+ int16_t dst_x2, int16_t dst_y2,
+ uint16_t count, uint32_t *immediates)
{
- /* Round up to the next even number. */
- uint8_t dwords = (count + 1) & ~1;
- uint32_t index;
- uint32_t tiling_mode, swizzle_mode;
+ /* Round up to the next even number. */
+ uint8_t dwords = (count + 1) & ~1;
+ uint32_t index;
+ uint32_t tiling_mode, swizzle_mode;
- if (!intel_batch_check_space(batch, 3 + dwords))
- return INTEL_BATCH_NO_SPACE;
+ if (!intel_batch_check_space(batch, 3 + dwords))
+ return INTEL_BATCH_NO_SPACE;
- drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
+ drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
- intel_batch_add_dwords(batch, 3,
- BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
- | BLT_BR00_OP(BLT_OP_XY_TEXT_IMMEDIATE_BLT)
- | BLT_BR00_PACKING(BLT_PACKING_BYTE)
- | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
- | BLT_BR00_DWORD_LENGTH(1 + dwords),
+ intel_batch_add_dwords(batch, 3,
+ BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
+ | BLT_BR00_OP(BLT_OP_XY_TEXT_IMMEDIATE_BLT)
+ | BLT_BR00_PACKING(BLT_PACKING_BYTE)
+ | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
+ | BLT_BR00_DWORD_LENGTH(1 + dwords),
- BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
- BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2)
- );
+ BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
+ BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2));
- for (index = 0; index < count; ++index)
- intel_batch_add_dword(batch, *immediates++);
+ for (index = 0; index < count; ++index)
+ intel_batch_add_dword(batch, *immediates++);
- /* From BLT engine documentation:
+ /* From BLT engine documentation:
*
* The IMMEDIATE_BLT data MUST transfer an even number of doublewords. The
* BLT engine will hang if it does not get an even number of doublewords. */
- if (count & 1)
- intel_batch_add_dword(batch, 0);
+ if (count & 1)
+ intel_batch_add_dword(batch, 0);
- return INTEL_BATCH_SUCCESS;
+ return INTEL_BATCH_SUCCESS;
}
-static inline void xy_src_copy_blt(struct intel_batch * batch,
- drm_intel_bo * src, uint16_t src_pitch,
- uint16_t src_x, uint16_t src_y,
- drm_intel_bo * dst, uint16_t dst_pitch,
- uint16_t dst_x, uint16_t dst_y,
- uint16_t width, uint16_t height)
+static inline void
+xy_src_copy_blt(struct intel_batch *batch,
+ drm_intel_bo *src, uint16_t src_pitch,
+ uint16_t src_x, uint16_t src_y,
+ drm_intel_bo *dst, uint16_t dst_pitch,
+ uint16_t dst_x, uint16_t dst_y,
+ uint16_t width, uint16_t height)
{
- uint32_t src_tiling_mode, dst_tiling_mode, swizzle;
-
- intel_batch_ensure_space(batch, GEN(batch, 8) ? 10 : 8);
-
- drm_intel_bo_get_tiling(dst, &dst_tiling_mode, &swizzle);
- drm_intel_bo_get_tiling(src, &src_tiling_mode, &swizzle);
-
- drm_intel_bo_emit_reloc_fence
- (batch->bo, intel_batch_offset(batch, 4), dst, 0,
- I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
- drm_intel_bo_emit_reloc_fence
- (batch->bo, intel_batch_offset(batch, GEN(batch, 8) ? 8 : 7), src, 0,
- I915_GEM_DOMAIN_RENDER, 0);
-
- intel_batch_add_dwords(batch, 4,
- BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
- | BLT_BR00_OP(BLT_OP_XY_SRC_COPY_BLT)
- | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
- | BLT_BR00_SRC_TILING_ENABLE(src_tiling_mode != I915_TILING_NONE)
- | BLT_BR00_DST_TILING_ENABLE(dst_tiling_mode != I915_TILING_NONE)
- | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 8 : 6),
-
- BLT_BR13_CLIPPING_ENABLE(false)
- | BLT_BR13_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
- | BLT_BR13_RASTER_OPERATION(BLT_RASTER_OPERATION_SRC)
- | BLT_BR13_DST_PITCH(dst_tiling_mode == I915_TILING_NONE
- ? dst_pitch : dst_pitch >> 2),
-
- BLT_BR22_DST_Y1(dst_y) | BLT_BR22_DST_X1(dst_x),
-
- BLT_BR23_DST_Y2(dst_y + height)
- | BLT_BR23_DST_X2(dst_x + width)
- );
- intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
- BLT_BR09_DST_ADDRESS(dst->offset64),
- BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32)
- );
- intel_batch_add_dwords(batch, 2,
- BLT_BR26_SRC_Y1(src_y) | BLT_BR26_SRC_X1(src_x),
- BLT_BR11_SRC_PITCH(src_tiling_mode == I915_TILING_NONE
- ? src_pitch : src_pitch >> 2)
- );
- intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
- BLT_BR12_SRC_ADDRESS(src->offset64),
- BLT_BR28_SRC_ADDRESS_HI(src->offset64 >> 32)
- );
+ uint32_t src_tiling_mode, dst_tiling_mode, swizzle;
+
+ intel_batch_ensure_space(batch, GEN(batch, 8) ? 10 : 8);
+
+ drm_intel_bo_get_tiling(dst, &dst_tiling_mode, &swizzle);
+ drm_intel_bo_get_tiling(src, &src_tiling_mode, &swizzle);
+
+ drm_intel_bo_emit_reloc_fence(batch->bo, intel_batch_offset(batch, 4), dst, 0,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
+ drm_intel_bo_emit_reloc_fence(batch->bo, intel_batch_offset(batch, GEN(batch, 8) ? 8 : 7), src, 0,
+ I915_GEM_DOMAIN_RENDER, 0);
+
+ intel_batch_add_dwords(batch, 4,
+ BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
+ | BLT_BR00_OP(BLT_OP_XY_SRC_COPY_BLT)
+ | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
+ | BLT_BR00_SRC_TILING_ENABLE(src_tiling_mode != I915_TILING_NONE)
+ | BLT_BR00_DST_TILING_ENABLE(dst_tiling_mode != I915_TILING_NONE)
+ | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 8 : 6),
+
+ BLT_BR13_CLIPPING_ENABLE(false)
+ | BLT_BR13_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
+ | BLT_BR13_RASTER_OPERATION(BLT_RASTER_OPERATION_SRC)
+ | BLT_BR13_DST_PITCH(dst_tiling_mode == I915_TILING_NONE
+ ? dst_pitch
+ : dst_pitch >> 2),
+
+ BLT_BR22_DST_Y1(dst_y) | BLT_BR22_DST_X1(dst_x),
+
+ BLT_BR23_DST_Y2(dst_y + height)
+ | BLT_BR23_DST_X2(dst_x + width));
+ intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
+ BLT_BR09_DST_ADDRESS(dst->offset64),
+ BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32));
+ intel_batch_add_dwords(batch, 2,
+ BLT_BR26_SRC_Y1(src_y) | BLT_BR26_SRC_X1(src_x),
+ BLT_BR11_SRC_PITCH(src_tiling_mode == I915_TILING_NONE
+ ? src_pitch
+ : src_pitch >> 2));
+ intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
+ BLT_BR12_SRC_ADDRESS(src->offset64),
+ BLT_BR28_SRC_ADDRESS_HI(src->offset64 >> 32));
}
-static inline void xy_color_blt(struct intel_batch * batch,
- drm_intel_bo * dst, uint16_t dst_pitch,
- uint16_t dst_x1, uint16_t dst_y1,
- uint16_t dst_x2, uint16_t dst_y2,
- uint32_t color)
+static inline void
+xy_color_blt(struct intel_batch *batch,
+ drm_intel_bo *dst, uint16_t dst_pitch,
+ uint16_t dst_x1, uint16_t dst_y1,
+ uint16_t dst_x2, uint16_t dst_y2,
+ uint32_t color)
{
- uint32_t tiling_mode, swizzle_mode;
-
- intel_batch_ensure_space(batch, GEN(batch, 8) ? 7 : 6);
-
- drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
-
- drm_intel_bo_emit_reloc_fence
- (batch->bo, intel_batch_offset(batch, 4), dst, 0,
- I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
-
- intel_batch_add_dwords(batch, 4,
- BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
- | BLT_BR00_OP(BLT_OP_XY_COLOR_BLT)
- | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
- | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
- | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 5 : 4),
-
- BLT_BR13_CLIPPING_ENABLE(false)
- | BLT_BR13_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
- | BLT_BR13_RASTER_OPERATION(BLT_RASTER_OPERATION_PAT)
- | BLT_BR13_DST_PITCH(tiling_mode == I915_TILING_NONE
- ? dst_pitch : dst_pitch >> 2),
-
- BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
- BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2)
- );
- intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
- BLT_BR09_DST_ADDRESS(dst->offset64),
- BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32)
- );
- intel_batch_add_dword(batch,
- BLT_BR16_COLOR(color)
- );
+ uint32_t tiling_mode, swizzle_mode;
+
+ intel_batch_ensure_space(batch, GEN(batch, 8) ? 7 : 6);
+
+ drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
+
+ drm_intel_bo_emit_reloc_fence(batch->bo, intel_batch_offset(batch, 4), dst, 0,
+ I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
+
+ intel_batch_add_dwords(batch, 4,
+ BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
+ | BLT_BR00_OP(BLT_OP_XY_COLOR_BLT)
+ | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
+ | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
+ | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 5 : 4),
+
+ BLT_BR13_CLIPPING_ENABLE(false)
+ | BLT_BR13_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
+ | BLT_BR13_RASTER_OPERATION(BLT_RASTER_OPERATION_PAT)
+ | BLT_BR13_DST_PITCH(tiling_mode == I915_TILING_NONE
+ ? dst_pitch
+ : dst_pitch >> 2),
+
+ BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
+ BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2));
+ intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
+ BLT_BR09_DST_ADDRESS(dst->offset64),
+ BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32));
+ intel_batch_add_dword(batch,
+ BLT_BR16_COLOR(color));
}
#endif
-
diff --git a/intel/mi.h b/intel/mi.h
@@ -26,25 +26,24 @@
#define INTEL_CLIENT_MI 0x0
-#define MI_OP(opcode) ( \
- INTEL_CLIENT_MI << 29 /* 31:29 */ \
- | opcode << 23 /* 28:23 */ \
+#define MI_OP(opcode) ( \
+ INTEL_CLIENT_MI << 29 /* 31:29 */ \
+ | opcode << 23 /* 28:23 */ \
)
-#define MI_NOOP MI_OP(0x00)
-#define MI_FLUSH MI_OP(0x04)
-#define MI_BATCH_BUFFER_END MI_OP(0x0A)
+#define MI_NOOP MI_OP(0x00)
+#define MI_FLUSH MI_OP(0x04)
+#define MI_BATCH_BUFFER_END MI_OP(0x0A)
/* MI_NOOP */
-#define MI_NOOP_IDENTIFICATION_NUMBER(number) (1 << 22 | number)
+#define MI_NOOP_IDENTIFICATION_NUMBER(number) (1 << 22 | number)
/* MI_FLUSH */
-#define MI_FLUSH_ENABLE_PROTECTED_MEMORY (1 << 6)
-#define MI_FLUSH_DISABLE_INDIRECT_STATE_POINTERS (1 << 5)
-#define MI_FLUSH_CLEAR_GENERIC_MEDIA_STATE (1 << 4)
-#define MI_FLUSH_RESET_GLOBAL_SNAPSHOT_COUNT (1 << 3)
-#define MI_FLUSH_INHIBIT_RENDER_CACHE_FLUSH (1 << 2)
+#define MI_FLUSH_ENABLE_PROTECTED_MEMORY (1 << 6)
+#define MI_FLUSH_DISABLE_INDIRECT_STATE_POINTERS (1 << 5)
+#define MI_FLUSH_CLEAR_GENERIC_MEDIA_STATE (1 << 4)
+#define MI_FLUSH_RESET_GLOBAL_SNAPSHOT_COUNT (1 << 3)
+#define MI_FLUSH_INHIBIT_RENDER_CACHE_FLUSH (1 << 2)
#define MI_FLUSH_INVALIDATE_STATE_INSTRUCTION_CACHE (1 << 1)
#endif
-
diff --git a/interface/buffer.h b/interface/buffer.h
@@ -21,13 +21,12 @@
* SOFTWARE.
*/
-static bool buffer_map(struct buffer * drawable);
-static bool buffer_unmap(struct buffer * drawable);
-static void buffer_destroy(struct buffer * drawable);
+static bool buffer_map(struct buffer *drawable);
+static bool buffer_unmap(struct buffer *drawable);
+static void buffer_destroy(struct buffer *drawable);
static const struct wld_buffer_impl wld_buffer_impl = {
- .map = &buffer_map,
- .unmap = &buffer_unmap,
- .destroy = &buffer_destroy
+ .map = &buffer_map,
+ .unmap = &buffer_unmap,
+ .destroy = &buffer_destroy
};
-
diff --git a/interface/context.h b/interface/context.h
@@ -21,30 +21,25 @@
* SOFTWARE.
*/
-static struct wld_renderer * context_create_renderer
- (struct wld_context * context);
-static struct buffer * context_create_buffer
- (struct wld_context * context,
- uint32_t width, uint32_t height, uint32_t format, uint32_t flags);
-static struct 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 struct wld_renderer *context_create_renderer(struct wld_context *context);
+static struct buffer *context_create_buffer(struct wld_context *context,
+ uint32_t width, uint32_t height, uint32_t format, uint32_t flags);
+static struct 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);
#ifdef CONTEXT_IMPLEMENTS_CREATE_SURFACE
-static struct wld_surface * context_create_surface
- (struct wld_context * context,
- uint32_t width, uint32_t height, uint32_t format, uint32_t flags);
+static struct wld_surface *context_create_surface(struct wld_context *context,
+ uint32_t width, uint32_t height, uint32_t format, uint32_t flags);
#endif
-static void context_destroy(struct wld_context * context);
+static void context_destroy(struct wld_context *context);
static const struct wld_context_impl wld_context_impl = {
- .create_renderer = &context_create_renderer,
- .create_buffer = &context_create_buffer,
- .import_buffer = &context_import_buffer,
+ .create_renderer = &context_create_renderer,
+ .create_buffer = &context_create_buffer,
+ .import_buffer = &context_import_buffer,
#ifdef CONTEXT_IMPLEMENTS_CREATE_SURFACE
- .create_surface = &context_create_surface,
+ .create_surface = &context_create_surface,
#else
- .create_surface = &default_create_surface,
+ .create_surface = &default_create_surface,
#endif
- .destroy = &context_destroy
+ .destroy = &context_destroy
};
-
diff --git a/interface/drm.h b/interface/drm.h
@@ -22,22 +22,21 @@
*/
#ifndef DRM_DRIVER_NAME
-# error "You must define DRM_DRIVER_NAME before including interface/drm.h"
+#error "You must define DRM_DRIVER_NAME before including interface/drm.h"
#endif
/* DRM driver */
static bool driver_device_supported(uint32_t vendor_id, uint32_t device_id);
-static struct wld_context * driver_create_context(int drm_fd);
+static struct wld_context *driver_create_context(int drm_fd);
#define EXPAND(f, x) f(x)
-#define VAR(name) name ## _drm_driver
-#define STRING(name) # name
+#define VAR(name) name##_drm_driver
+#define STRING(name) #name
const struct drm_driver EXPAND(VAR, DRM_DRIVER_NAME) = {
- .name = EXPAND(STRING, DRM_DRIVER_NAME),
- .device_supported = &driver_device_supported,
- .create_context = &driver_create_context,
+ .name = EXPAND(STRING, DRM_DRIVER_NAME),
+ .device_supported = &driver_device_supported,
+ .create_context = &driver_create_context,
};
#undef VAR
#undef STRING
#undef EXPAND
-
diff --git a/interface/renderer.h b/interface/renderer.h
@@ -21,48 +21,47 @@
* SOFTWARE.
*/
-static uint32_t renderer_capabilities(struct wld_renderer * renderer,
- struct buffer * buffer);
-static bool renderer_set_target(struct wld_renderer * renderer,
- struct buffer * buffer);
-static void renderer_fill_rectangle(struct wld_renderer * renderer,
+static uint32_t renderer_capabilities(struct wld_renderer *renderer,
+ struct buffer *buffer);
+static bool renderer_set_target(struct wld_renderer *renderer,
+ struct 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 buffer * buffer,
+static void renderer_copy_rectangle(struct wld_renderer *renderer,
+ struct buffer *buffer,
int32_t dst_x, int32_t dst_y,
int32_t src_x, int32_t src_y,
uint32_t width, uint32_t height);
#ifdef RENDERER_IMPLEMENTS_REGION
-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 buffer * buffer,
+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 buffer *buffer,
int32_t dst_x, int32_t dst_y,
- pixman_region32_t * region);
+ pixman_region32_t *region);
#endif
-static void renderer_draw_text(struct wld_renderer * renderer,
- struct font * font, uint32_t color,
+static void renderer_draw_text(struct wld_renderer *renderer,
+ struct font *font, uint32_t color,
int32_t x, int32_t y,
- const char * text, uint32_t length,
- struct wld_extents * extents);
-static void renderer_flush(struct wld_renderer * renderer);
-static void renderer_destroy(struct wld_renderer * renderer);
+ const char *text, uint32_t length,
+ struct wld_extents *extents);
+static void renderer_flush(struct wld_renderer *renderer);
+static void renderer_destroy(struct wld_renderer *renderer);
static const struct wld_renderer_impl wld_renderer_impl = {
- .capabilities = &renderer_capabilities,
- .set_target = &renderer_set_target,
- .fill_rectangle = &renderer_fill_rectangle,
- .copy_rectangle = &renderer_copy_rectangle,
+ .capabilities = &renderer_capabilities,
+ .set_target = &renderer_set_target,
+ .fill_rectangle = &renderer_fill_rectangle,
+ .copy_rectangle = &renderer_copy_rectangle,
#ifdef RENDERER_IMPLEMENTS_REGION
- .fill_region = &renderer_fill_region,
- .copy_region = &renderer_copy_region,
+ .fill_region = &renderer_fill_region,
+ .copy_region = &renderer_copy_region,
#else
- .fill_region = &default_fill_region,
- .copy_region = &default_copy_region,
+ .fill_region = &default_fill_region,
+ .copy_region = &default_copy_region,
#endif
- .draw_text = &renderer_draw_text,
- .flush = &renderer_flush,
- .destroy = &renderer_destroy
+ .draw_text = &renderer_draw_text,
+ .flush = &renderer_flush,
+ .destroy = &renderer_destroy
};
-
diff --git a/interface/surface.h b/interface/surface.h
@@ -21,21 +21,20 @@
* SOFTWARE.
*/
-static pixman_region32_t * surface_damage(struct wld_surface * surface,
- pixman_region32_t * new_damage);
-static struct buffer * surface_back(struct wld_surface * surface);
-static struct buffer * surface_take(struct wld_surface * surface);
-static bool surface_release(struct wld_surface * surface,
- struct buffer * buffer);
-static bool surface_swap(struct wld_surface * surface);
-static void surface_destroy(struct wld_surface * surface);
+static pixman_region32_t *surface_damage(struct wld_surface *surface,
+ pixman_region32_t *new_damage);
+static struct buffer *surface_back(struct wld_surface *surface);
+static struct buffer *surface_take(struct wld_surface *surface);
+static bool surface_release(struct wld_surface *surface,
+ struct buffer *buffer);
+static bool surface_swap(struct wld_surface *surface);
+static void surface_destroy(struct wld_surface *surface);
static const struct wld_surface_impl wld_surface_impl = {
- .damage = &surface_damage,
- .back = &surface_back,
- .take = &surface_take,
- .release = &surface_release,
- .swap = &surface_swap,
- .destroy = &surface_destroy
+ .damage = &surface_damage,
+ .back = &surface_back,
+ .take = &surface_take,
+ .release = &surface_release,
+ .swap = &surface_swap,
+ .destroy = &surface_destroy
};
-
diff --git a/interface/wayland.h b/interface/wayland.h
@@ -22,20 +22,18 @@
*/
#ifndef WAYLAND_IMPL_NAME
-# error you must define WAYLAND_IMPL_NAME before including interface/wayland.h
+#error you must define WAYLAND_IMPL_NAME before including interface/wayland.h
#endif
-static struct wayland_context * wayland_create_context
- (struct wl_display * display, struct wl_event_queue * queue);
-static bool wayland_has_format(struct wld_context * context, uint32_t format);
+static struct wayland_context *wayland_create_context(struct wl_display *display, struct wl_event_queue *queue);
+static bool wayland_has_format(struct wld_context *context, uint32_t format);
#define EXPAND(f, x) f(x)
-#define VAR(name) name ## _wayland_impl
+#define VAR(name) name##_wayland_impl
const struct wayland_impl EXPAND(VAR, WAYLAND_IMPL_NAME) = {
- .create_context = &wayland_create_context,
- .has_format = &wayland_has_format,
- //.create_surface = &wayland_create_surface,
+ .create_context = &wayland_create_context,
+ .has_format = &wayland_has_format,
+ //.create_surface = &wayland_create_surface,
};
#undef VAR
#undef EXPAND
-
diff --git a/nouveau.c b/nouveau.c
@@ -28,51 +28,47 @@
#include "drm-private.h"
#include "drm.h"
-#include "pixman.h"
-#include "nouveau/nv_object.xml.h"
#include "nouveau/g80_2d.xml.h"
#include "nouveau/g80_defs.xml.h"
+#include "nouveau/nv_object.xml.h"
+#include "pixman.h"
#include <nouveau.h>
#include <sys/mman.h>
-enum nv_architecture
-{
- NV_ARCH_50 = 0x50,
- NV_ARCH_C0 = 0xc0,
- NV_ARCH_E0 = 0xe0
+enum nv_architecture {
+ NV_ARCH_50 = 0x50,
+ NV_ARCH_C0 = 0xc0,
+ NV_ARCH_E0 = 0xe0
};
-struct nouveau_context
-{
- struct wld_context base;
- struct nouveau_device * device;
- struct nouveau_client * client;
- enum nv_architecture architecture;
+struct nouveau_context {
+ struct wld_context base;
+ struct nouveau_device *device;
+ struct nouveau_client *client;
+ enum nv_architecture architecture;
};
-struct nouveau_renderer
-{
- struct wld_renderer base;
- struct nouveau_object * channel;
- struct nouveau_pushbuf * pushbuf;
- struct nouveau_bufctx * bufctx;
- struct nouveau_object * nvc0_2d;
+struct nouveau_renderer {
+ struct wld_renderer base;
+ struct nouveau_object *channel;
+ struct nouveau_pushbuf *pushbuf;
+ struct nouveau_bufctx *bufctx;
+ struct nouveau_object *nvc0_2d;
- struct nouveau_buffer * target;
+ struct nouveau_buffer *target;
};
-struct nouveau_buffer
-{
- struct buffer base;
- struct wld_exporter exporter;
- struct nouveau_context * context;
- struct nouveau_bo * bo;
+struct nouveau_buffer {
+ struct buffer base;
+ struct wld_exporter exporter;
+ struct nouveau_context *context;
+ struct nouveau_bo *bo;
};
+#include "interface/buffer.h"
#include "interface/context.h"
#include "interface/renderer.h"
-#include "interface/buffer.h"
#define DRM_DRIVER_NAME nouveau
#include "interface/drm.h"
IMPL(nouveau_context, wld_context)
@@ -80,24 +76,25 @@ IMPL(nouveau_renderer, wld_renderer)
IMPL(nouveau_buffer, wld_buffer)
/**** DRM driver ****/
-bool driver_device_supported(uint32_t vendor_id, uint32_t device_id)
+bool
+driver_device_supported(uint32_t vendor_id, uint32_t device_id)
{
- return vendor_id == 0x10de;
+ return vendor_id == 0x10de;
}
-struct wld_context * driver_create_context(int drm_fd)
+struct wld_context *
+driver_create_context(int drm_fd)
{
- struct nouveau_context * context;
+ struct nouveau_context *context;
- if (!(context = malloc(sizeof *context)))
- goto error0;
+ if (!(context = malloc(sizeof *context)))
+ goto error0;
- if (nouveau_device_wrap(drm_fd, 0, &context->device) != 0)
- goto error1;
+ if (nouveau_device_wrap(drm_fd, 0, &context->device) != 0)
+ goto error1;
- switch (context->device->chipset & ~0xf)
- {
- /* TODO: Support NV50
+ switch (context->device->chipset & ~0xf) {
+ /* TODO: Support NV50
case 0x50:
case 0x80:
case 0x90:
@@ -105,574 +102,590 @@ struct wld_context * driver_create_context(int drm_fd)
context->architecture = NV_ARCH_50;
break;
*/
- case 0xc0:
- case 0xd0:
- context->architecture = NV_ARCH_C0;
- break;
- /* TODO: Support NVE0
+ case 0xc0:
+ case 0xd0:
+ context->architecture = NV_ARCH_C0;
+ break;
+ /* TODO: Support NVE0
case 0xe0:
case 0xf0:
case 0x100:
context->architecture = NV_ARCH_E0;
break;
*/
- default:
- return NULL;
- }
+ default:
+ return NULL;
+ }
- if (nouveau_client_new(context->device, &context->client) != 0)
- goto error2;
+ if (nouveau_client_new(context->device, &context->client) != 0)
+ goto error2;
- context_initialize(&context->base, &wld_context_impl);
+ context_initialize(&context->base, &wld_context_impl);
- return &context->base;
+ return &context->base;
- error2:
- nouveau_device_del(&context->device);
- error1:
- free(context);
- error0:
- return NULL;
+error2:
+ nouveau_device_del(&context->device);
+error1:
+ free(context);
+error0:
+ return NULL;
}
/**** Context ****/
-static inline bool ensure_space(struct nouveau_pushbuf * push, uint32_t count)
+static inline bool
+ensure_space(struct nouveau_pushbuf *push, uint32_t count)
{
- if (push->end - push->cur > count)
- return true;
+ if (push->end - push->cur > count)
+ return true;
- return nouveau_pushbuf_space(push, count, 0, 0) == 0;
+ return nouveau_pushbuf_space(push, count, 0, 0) == 0;
}
-static inline void nv_add_dword(struct nouveau_pushbuf * push, uint32_t dword)
+static inline void
+nv_add_dword(struct nouveau_pushbuf *push, uint32_t dword)
{
- *push->cur++ = dword;
+ *push->cur++ = dword;
}
-static inline void nv_add_dwords_va(struct nouveau_pushbuf * push,
- uint16_t count, va_list dwords)
+static inline void
+nv_add_dwords_va(struct nouveau_pushbuf *push,
+ uint16_t count, va_list dwords)
{
- while (count--)
- nv_add_dword(push, va_arg(dwords, uint32_t));
+ while (count--)
+ nv_add_dword(push, va_arg(dwords, uint32_t));
}
-static inline void nv_add_data(struct nouveau_pushbuf * push,
- void * data, uint32_t count)
+static inline void
+nv_add_data(struct nouveau_pushbuf *push,
+ void *data, uint32_t count)
{
- memcpy(push->cur, data, count * 4);
- push->cur += count;
+ memcpy(push->cur, data, count * 4);
+ push->cur += count;
}
-static inline uint32_t nvc0_format(uint32_t format)
+static inline uint32_t
+nvc0_format(uint32_t format)
{
- switch (format)
- {
- case WLD_FORMAT_XRGB8888:
- return G80_SURFACE_FORMAT_BGRX8_UNORM;
- case WLD_FORMAT_ARGB8888:
- return G80_SURFACE_FORMAT_BGRA8_UNORM;
- }
-
- return 0;
+ switch (format) {
+ case WLD_FORMAT_XRGB8888:
+ return G80_SURFACE_FORMAT_BGRX8_UNORM;
+ case WLD_FORMAT_ARGB8888:
+ return G80_SURFACE_FORMAT_BGRA8_UNORM;
+ }
+
+ return 0;
}
-enum
-{
- GF100_COMMAND_TYPE_INCREASING = 1,
- GF100_COMMAND_TYPE_NON_INCREASING = 3,
- GF100_COMMAND_TYPE_INLINE = 4
+enum {
+ GF100_COMMAND_TYPE_INCREASING = 1,
+ GF100_COMMAND_TYPE_NON_INCREASING = 3,
+ GF100_COMMAND_TYPE_INLINE = 4
};
-enum
-{
- GF100_SUBCHANNEL_2D = 3,
+enum {
+ GF100_SUBCHANNEL_2D = 3,
};
-static inline uint32_t nvc0_command(uint8_t type, uint8_t subchannel,
- uint16_t method, uint16_t count_or_value)
+static inline uint32_t
+nvc0_command(uint8_t type, uint8_t subchannel,
+ uint16_t method, uint16_t count_or_value)
{
- return type << 29 | count_or_value << 16 | subchannel << 13 | method >> 2;
+ return type << 29 | count_or_value << 16 | subchannel << 13 | method >> 2;
}
-static inline void nvc0_inline(struct nouveau_pushbuf * push,
- uint8_t subchannel, uint16_t method,
- uint16_t value)
+static inline void
+nvc0_inline(struct nouveau_pushbuf *push,
+ uint8_t subchannel, uint16_t method,
+ uint16_t value)
{
- nv_add_dword(push, nvc0_command(GF100_COMMAND_TYPE_INLINE,
- subchannel, method, value));
+ nv_add_dword(push, nvc0_command(GF100_COMMAND_TYPE_INLINE,
+ subchannel, method, value));
}
-static inline void nvc0_methods(struct nouveau_pushbuf * push,
- uint8_t subchannel, uint16_t start_method,
- uint16_t count, ...)
-{
- va_list dwords;
- nv_add_dword(push, nvc0_command(GF100_COMMAND_TYPE_INCREASING,
- subchannel, start_method, count));
- va_start(dwords, count);
- nv_add_dwords_va(push, count, dwords);
- va_end(dwords);
+static inline void
+nvc0_methods(struct nouveau_pushbuf *push,
+ uint8_t subchannel, uint16_t start_method,
+ uint16_t count, ...)
+{
+ va_list dwords;
+ nv_add_dword(push, nvc0_command(GF100_COMMAND_TYPE_INCREASING,
+ subchannel, start_method, count));
+ va_start(dwords, count);
+ nv_add_dwords_va(push, count, dwords);
+ va_end(dwords);
}
#define nvc0_2d(push, method, count, ...) \
- nvc0_methods(push, GF100_SUBCHANNEL_2D, method, count, __VA_ARGS__)
+ nvc0_methods(push, GF100_SUBCHANNEL_2D, method, count, __VA_ARGS__)
#define nvc0_2d_inline(push, method, value) \
- nvc0_inline(push, GF100_SUBCHANNEL_2D, method, value)
+ nvc0_inline(push, GF100_SUBCHANNEL_2D, method, value)
-static bool nvc0_2d_initialize(struct nouveau_renderer * renderer)
+static bool
+nvc0_2d_initialize(struct nouveau_renderer *renderer)
{
- int ret;
+ int ret;
- ret = nouveau_object_new(renderer->channel, GF100_2D, GF100_2D, NULL, 0,
- &renderer->nvc0_2d);
+ ret = nouveau_object_new(renderer->channel, GF100_2D, GF100_2D, NULL, 0,
+ &renderer->nvc0_2d);
- if (ret != 0)
- goto error0;
+ if (ret != 0)
+ goto error0;
- if (!ensure_space(renderer->pushbuf, 5))
- goto error1;
+ if (!ensure_space(renderer->pushbuf, 5))
+ goto error1;
- nvc0_2d(renderer->pushbuf, NV1_SUBCHAN_OBJECT, 1,
- renderer->nvc0_2d->handle);
- nvc0_2d_inline(renderer->pushbuf, G80_2D_OPERATION,
- G80_2D_OPERATION_SRCCOPY_AND);
- nvc0_2d_inline(renderer->pushbuf, G80_2D_UNK0884, 0x3f);
- nvc0_2d_inline(renderer->pushbuf, G80_2D_UNK0888, 1);
+ nvc0_2d(renderer->pushbuf, NV1_SUBCHAN_OBJECT, 1,
+ renderer->nvc0_2d->handle);
+ nvc0_2d_inline(renderer->pushbuf, G80_2D_OPERATION,
+ G80_2D_OPERATION_SRCCOPY_AND);
+ nvc0_2d_inline(renderer->pushbuf, G80_2D_UNK0884, 0x3f);
+ nvc0_2d_inline(renderer->pushbuf, G80_2D_UNK0888, 1);
- return true;
+ return true;
- error1:
- nouveau_object_del(&renderer->nvc0_2d);
- error0:
- return false;
+error1:
+ nouveau_object_del(&renderer->nvc0_2d);
+error0:
+ return false;
}
-static void nvc0_2d_finalize(struct nouveau_renderer * renderer)
+static void
+nvc0_2d_finalize(struct nouveau_renderer *renderer)
{
- nouveau_object_del(&renderer->nvc0_2d);
+ nouveau_object_del(&renderer->nvc0_2d);
}
-struct wld_renderer * context_create_renderer(struct wld_context * base)
+struct wld_renderer *
+context_create_renderer(struct wld_context *base)
{
- struct nouveau_context * context = nouveau_context(base);
- struct nouveau_renderer * renderer;
- struct nvc0_fifo fifo = { };
- int ret;
+ struct nouveau_context *context = nouveau_context(base);
+ struct nouveau_renderer *renderer;
+ struct nvc0_fifo fifo = {};
+ int ret;
- if (!(renderer = malloc(sizeof *renderer)))
- goto error0;
+ if (!(renderer = malloc(sizeof *renderer)))
+ goto error0;
- ret = nouveau_object_new(&context->device->object, 0,
- NOUVEAU_FIFO_CHANNEL_CLASS, &fifo, sizeof fifo,
- &renderer->channel);
+ ret = nouveau_object_new(&context->device->object, 0,
+ NOUVEAU_FIFO_CHANNEL_CLASS, &fifo, sizeof fifo,
+ &renderer->channel);
- if (ret != 0)
- goto error1;
+ if (ret != 0)
+ goto error1;
- ret = nouveau_pushbuf_new(context->client, renderer->channel, 4, 32 * 1024,
- true, &renderer->pushbuf);
+ ret = nouveau_pushbuf_new(context->client, renderer->channel, 4, 32 * 1024,
+ true, &renderer->pushbuf);
- if (ret != 0)
- goto error2;
+ if (ret != 0)
+ goto error2;
- if (nouveau_bufctx_new(context->client, 1, &renderer->bufctx) != 0)
- goto error3;
+ if (nouveau_bufctx_new(context->client, 1, &renderer->bufctx) != 0)
+ goto error3;
- if (!nvc0_2d_initialize(renderer))
- goto error4;
+ if (!nvc0_2d_initialize(renderer))
+ goto error4;
- renderer_initialize(&renderer->base, &wld_renderer_impl);
- renderer->target = NULL;
+ renderer_initialize(&renderer->base, &wld_renderer_impl);
+ renderer->target = NULL;
- return &renderer->base;
+ return &renderer->base;
- error4:
- nouveau_bufctx_del(&renderer->bufctx);
- error3:
- nouveau_pushbuf_del(&renderer->pushbuf);
- error2:
- nouveau_object_del(&renderer->channel);
- error1:
- free(renderer);
- error0:
- return NULL;
+error4:
+ nouveau_bufctx_del(&renderer->bufctx);
+error3:
+ nouveau_pushbuf_del(&renderer->pushbuf);
+error2:
+ nouveau_object_del(&renderer->channel);
+error1:
+ free(renderer);
+error0:
+ return NULL;
}
-static bool export(struct wld_exporter * exporter, struct wld_buffer * base,
- uint32_t type, union wld_object * object)
-{
- struct nouveau_buffer * buffer = nouveau_buffer(base);
-
- switch (type)
- {
- case WLD_DRM_OBJECT_HANDLE:
- object->u32 = buffer->bo->handle;
- return true;
- case WLD_DRM_OBJECT_PRIME_FD:
- if (nouveau_bo_set_prime(buffer->bo, &object->i) != 0)
- return false;
- return true;
- default:
- return false;
- }
+static bool export(struct wld_exporter *exporter, struct wld_buffer *base,
+ uint32_t type, union wld_object *object)
+{
+ struct nouveau_buffer *buffer = nouveau_buffer(base);
+
+ switch (type) {
+ case WLD_DRM_OBJECT_HANDLE:
+ object->u32 = buffer->bo->handle;
+ return true;
+ case WLD_DRM_OBJECT_PRIME_FD:
+ if (nouveau_bo_set_prime(buffer->bo, &object->i) != 0)
+ return false;
+ return true;
+ default:
+ return false;
+ }
}
-static struct nouveau_buffer * new_buffer(struct nouveau_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t pitch)
+static struct nouveau_buffer *
+new_buffer(struct nouveau_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t pitch)
{
- struct nouveau_buffer * buffer;
+ struct nouveau_buffer *buffer;
- if (!(buffer = malloc(sizeof *buffer)))
- return NULL;
+ if (!(buffer = malloc(sizeof *buffer)))
+ return NULL;
- buffer_initialize(&buffer->base, &wld_buffer_impl,
- width, height, format, pitch);
- buffer->context = context;
- buffer->exporter.export = &export;
- wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
+ buffer_initialize(&buffer->base, &wld_buffer_impl,
+ width, height, format, pitch);
+ buffer->context = context;
+ buffer->exporter.export = &export;
+ wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
- return buffer;
+ return buffer;
}
-static inline uint32_t roundup(uint32_t value, uint32_t alignment)
+static inline uint32_t
+roundup(uint32_t value, uint32_t alignment)
{
- return (value + alignment - 1) & ~(alignment - 1);
+ return (value + alignment - 1) & ~(alignment - 1);
}
-struct buffer * context_create_buffer(struct wld_context * base,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
+struct buffer *
+context_create_buffer(struct wld_context *base,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
{
- struct nouveau_context * context = nouveau_context(base);
- struct nouveau_buffer * buffer;
- uint32_t bpp = format_bytes_per_pixel(format),
- pitch = roundup(width * bpp, 64), bo_flags;
- union nouveau_bo_config config = { };
-
- if (!(buffer = new_buffer(context, width, height, format, pitch)))
- goto error0;
-
- bo_flags = NOUVEAU_BO_VRAM;
-
- if (flags & WLD_DRM_FLAG_SCANOUT)
- bo_flags |= NOUVEAU_BO_CONTIG;
-
- if (height > 0x40 && !(flags & WLD_FLAG_MAP))
- {
- config.nvc0.tile_mode = 0x40;
- config.nvc0.memtype = 0xfe;
- height = roundup(height, 0x80);
- }
- else
- bo_flags |= NOUVEAU_BO_MAP;
-
- if (nouveau_bo_new(context->device, bo_flags, 0, pitch * height,
- &config, &buffer->bo) != 0)
- {
- goto error1;
- }
-
- return &buffer->base;
-
- error1:
- free(buffer);
- error0:
- return NULL;
-}
+ struct nouveau_context *context = nouveau_context(base);
+ struct nouveau_buffer *buffer;
+ uint32_t bpp = format_bytes_per_pixel(format),
+ pitch = roundup(width * bpp, 64), bo_flags;
+ union nouveau_bo_config config = {};
-struct 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 nouveau_context * context = (void *) base;
- struct nouveau_buffer * buffer;
- struct nouveau_bo * bo = NULL;
-
- switch (type)
- {
- case WLD_DRM_OBJECT_PRIME_FD:
- if (nouveau_bo_prime_handle_ref(context->device,
- object.i, &bo) != 0)
- {
- goto error0;
- }
- break;
- default: goto error0;
- }
+ if (!(buffer = new_buffer(context, width, height, format, pitch)))
+ goto error0;
- if (!(buffer = new_buffer(context, width, height, format, pitch)))
- goto error1;
+ bo_flags = NOUVEAU_BO_VRAM;
- buffer->bo = bo;
+ if (flags & WLD_DRM_FLAG_SCANOUT)
+ bo_flags |= NOUVEAU_BO_CONTIG;
- return &buffer->base;
+ if (height > 0x40 && !(flags & WLD_FLAG_MAP)) {
+ config.nvc0.tile_mode = 0x40;
+ config.nvc0.memtype = 0xfe;
+ height = roundup(height, 0x80);
+ } else
+ bo_flags |= NOUVEAU_BO_MAP;
- error1:
- nouveau_bo_ref(NULL, &buffer->bo);
- error0:
- return NULL;
+ if (nouveau_bo_new(context->device, bo_flags, 0, pitch * height,
+ &config, &buffer->bo)
+ != 0) {
+ goto error1;
+ }
+
+ return &buffer->base;
+
+error1:
+ free(buffer);
+error0:
+ return NULL;
}
-void context_destroy(struct wld_context * base)
+struct 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 nouveau_context *context = (void *)base;
+ struct nouveau_buffer *buffer;
+ struct nouveau_bo *bo = NULL;
+
+ switch (type) {
+ case WLD_DRM_OBJECT_PRIME_FD:
+ if (nouveau_bo_prime_handle_ref(context->device,
+ object.i, &bo)
+ != 0) {
+ goto error0;
+ }
+ break;
+ default:
+ goto error0;
+ }
+
+ if (!(buffer = new_buffer(context, width, height, format, pitch)))
+ goto error1;
+
+ buffer->bo = bo;
+
+ return &buffer->base;
+
+error1:
+ nouveau_bo_ref(NULL, &buffer->bo);
+error0:
+ return NULL;
+}
+
+void
+context_destroy(struct wld_context *base)
{
- struct nouveau_context * context = nouveau_context(base);
+ struct nouveau_context *context = nouveau_context(base);
- nouveau_client_del(&context->client);
- nouveau_device_del(&context->device);
- free(context);
+ nouveau_client_del(&context->client);
+ nouveau_device_del(&context->device);
+ free(context);
}
/**** Renderer ****/
-uint32_t renderer_capabilities(struct wld_renderer * renderer,
- struct buffer * buffer)
+uint32_t
+renderer_capabilities(struct wld_renderer *renderer,
+ struct buffer *buffer)
{
- if (buffer->base.impl == &wld_buffer_impl)
- return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
+ if (buffer->base.impl == &wld_buffer_impl)
+ return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
- return 0;
+ return 0;
}
-bool renderer_set_target(struct wld_renderer * base, struct buffer * buffer)
+bool
+renderer_set_target(struct wld_renderer *base, struct buffer *buffer)
{
- struct nouveau_renderer * renderer = nouveau_renderer(base);
+ struct nouveau_renderer *renderer = nouveau_renderer(base);
- if (buffer && buffer->base.impl != &wld_buffer_impl)
- return false;
+ if (buffer && buffer->base.impl != &wld_buffer_impl)
+ return false;
- renderer->target = buffer ? nouveau_buffer(&buffer->base) : NULL;
+ renderer->target = buffer ? nouveau_buffer(&buffer->base) : NULL;
- return true;
+ return true;
}
-static inline void nvc0_2d_use_buffer(struct nouveau_renderer * renderer,
- struct nouveau_buffer * buffer,
- uint16_t format_method, uint16_t format)
-{
- uint32_t access = format == G80_2D_SRC_FORMAT ? NOUVEAU_BO_RD
- : NOUVEAU_BO_WR;
-
- nvc0_2d_inline(renderer->pushbuf, format_method, format);
-
- if (buffer->bo->config.nvc0.memtype)
- {
- nvc0_2d(renderer->pushbuf, format_method + 0x04, 2,
- 0, buffer->bo->config.nvc0.tile_mode);
- }
- else
- {
- nvc0_2d_inline(renderer->pushbuf, format_method + 0x04, 1);
- nvc0_2d(renderer->pushbuf, format_method + 0x14, 1,
- buffer->base.base.pitch);
- }
-
- nvc0_2d(renderer->pushbuf, format_method + 0x18, 4,
- buffer->base.base.width, buffer->base.base.height,
- buffer->bo->offset >> 32, buffer->bo->offset);
- nouveau_bufctx_refn(renderer->bufctx, 0, buffer->bo,
- NOUVEAU_BO_VRAM | access);
+static inline void
+nvc0_2d_use_buffer(struct nouveau_renderer *renderer,
+ struct nouveau_buffer *buffer,
+ uint16_t format_method, uint16_t format)
+{
+ uint32_t access = format == G80_2D_SRC_FORMAT ? NOUVEAU_BO_RD
+ : NOUVEAU_BO_WR;
+
+ nvc0_2d_inline(renderer->pushbuf, format_method, format);
+
+ if (buffer->bo->config.nvc0.memtype) {
+ nvc0_2d(renderer->pushbuf, format_method + 0x04, 2,
+ 0, buffer->bo->config.nvc0.tile_mode);
+ } else {
+ nvc0_2d_inline(renderer->pushbuf, format_method + 0x04, 1);
+ nvc0_2d(renderer->pushbuf, format_method + 0x14, 1,
+ buffer->base.base.pitch);
+ }
+
+ nvc0_2d(renderer->pushbuf, format_method + 0x18, 4,
+ buffer->base.base.width, buffer->base.base.height,
+ buffer->bo->offset >> 32, buffer->bo->offset);
+ nouveau_bufctx_refn(renderer->bufctx, 0, buffer->bo,
+ NOUVEAU_BO_VRAM | access);
}
-void renderer_fill_rectangle(struct wld_renderer * base, uint32_t color,
- int32_t x, int32_t y,
- uint32_t width, uint32_t height)
+void
+renderer_fill_rectangle(struct wld_renderer *base, uint32_t color,
+ int32_t x, int32_t y,
+ uint32_t width, uint32_t height)
{
- struct nouveau_renderer * renderer = nouveau_renderer(base);
- struct nouveau_buffer * dst = renderer->target;
- uint32_t format;
+ struct nouveau_renderer *renderer = nouveau_renderer(base);
+ struct nouveau_buffer *dst = renderer->target;
+ uint32_t format;
- if (!ensure_space(renderer->pushbuf, 18))
- return;
+ if (!ensure_space(renderer->pushbuf, 18))
+ return;
- format = nvc0_format(dst->base.base.format);
+ format = nvc0_format(dst->base.base.format);
- nouveau_bufctx_reset(renderer->bufctx, 0);
- nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, format);
- nvc0_2d(renderer->pushbuf, G80_2D_DRAW_SHAPE, 3,
- G80_2D_DRAW_SHAPE_RECTANGLES, format, color);
- nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
+ nouveau_bufctx_reset(renderer->bufctx, 0);
+ nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, format);
+ nvc0_2d(renderer->pushbuf, G80_2D_DRAW_SHAPE, 3,
+ G80_2D_DRAW_SHAPE_RECTANGLES, format, color);
+ nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
- if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
- return;
+ if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
+ return;
- nvc0_2d(renderer->pushbuf, G80_2D_DRAW_POINT32_X(0), 4,
- x, y, x + width, y + height);
+ nvc0_2d(renderer->pushbuf, G80_2D_DRAW_POINT32_X(0), 4,
+ x, y, x + width, y + height);
}
-void renderer_copy_rectangle(struct wld_renderer * base,
- struct 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)
+void
+renderer_copy_rectangle(struct wld_renderer *base,
+ struct 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 nouveau_renderer * renderer = nouveau_renderer(base);
+ struct nouveau_renderer *renderer = nouveau_renderer(base);
- if (buffer_base->base.impl != &wld_buffer_impl)
- return;
+ if (buffer_base->base.impl != &wld_buffer_impl)
+ return;
- struct nouveau_buffer * src = nouveau_buffer(&buffer_base->base),
- * dst = renderer->target;
- uint32_t src_format, dst_format;
+ struct nouveau_buffer *src = nouveau_buffer(&buffer_base->base),
+ *dst = renderer->target;
+ uint32_t src_format, dst_format;
- if (!ensure_space(renderer->pushbuf, 33))
- return;
+ if (!ensure_space(renderer->pushbuf, 33))
+ return;
- src_format = nvc0_format(src->base.base.format);
- dst_format = nvc0_format(dst->base.base.format);
+ src_format = nvc0_format(src->base.base.format);
+ dst_format = nvc0_format(dst->base.base.format);
- nouveau_bufctx_reset(renderer->bufctx, 0);
- nvc0_2d_use_buffer(renderer, src, G80_2D_SRC_FORMAT, src_format);
- nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, dst_format);
- nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
+ nouveau_bufctx_reset(renderer->bufctx, 0);
+ nvc0_2d_use_buffer(renderer, src, G80_2D_SRC_FORMAT, src_format);
+ nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, dst_format);
+ nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
- if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
- return;
+ if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
+ return;
- nvc0_2d_inline(renderer->pushbuf, G80_GRAPH_SERIALIZE, 0);
- nvc0_2d_inline(renderer->pushbuf, G80_2D_BLIT_CONTROL,
- G80_2D_BLIT_CONTROL_ORIGIN_CENTER
- | G80_2D_BLIT_CONTROL_FILTER_POINT_SAMPLE);
- nvc0_2d(renderer->pushbuf, G80_2D_BLIT_DST_X, 12,
- dst_x, dst_y, width, height, 0, 1, 0, 1, 0, src_x, 0, src_y);
+ nvc0_2d_inline(renderer->pushbuf, G80_GRAPH_SERIALIZE, 0);
+ nvc0_2d_inline(renderer->pushbuf, G80_2D_BLIT_CONTROL,
+ G80_2D_BLIT_CONTROL_ORIGIN_CENTER
+ | G80_2D_BLIT_CONTROL_FILTER_POINT_SAMPLE);
+ nvc0_2d(renderer->pushbuf, G80_2D_BLIT_DST_X, 12,
+ dst_x, dst_y, width, height, 0, 1, 0, 1, 0, src_x, 0, src_y);
- renderer_flush(base);
+ renderer_flush(base);
}
-void renderer_draw_text(struct wld_renderer * base,
- struct font * font, uint32_t color,
- int32_t x, int32_t y, const char * text,
- uint32_t length, struct wld_extents * extents)
+void
+renderer_draw_text(struct wld_renderer *base,
+ struct font *font, uint32_t color,
+ int32_t x, int32_t y, const char *text,
+ uint32_t length, struct wld_extents *extents)
{
- struct nouveau_renderer * renderer = nouveau_renderer(base);
- struct nouveau_buffer * dst = renderer->target;
- uint32_t format;
- int ret;
- struct glyph * glyph;
- FT_UInt glyph_index;
- uint32_t c, count;
- int32_t origin_x = x;
-
- if (!ensure_space(renderer->pushbuf, 17))
- return;
-
- format = nvc0_format(dst->base.base.format);
-
- nouveau_bufctx_reset(renderer->bufctx, 0);
- nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, format);
- nvc0_2d_inline(renderer->pushbuf, G80_2D_SIFC_BITMAP_ENABLE, 1);
- nvc0_2d(renderer->pushbuf, G80_2D_SIFC_BITMAP_FORMAT, 6,
- G80_2D_SIFC_BITMAP_FORMAT_I1,
- 0, /* SIFC_FORMAT */
- G80_2D_SIFC_BITMAP_LINE_PACK_MODE_ALIGN_BYTE,
- 0, color, /* SIFC_BITMAP_COLOR_BIT0, SIFC_BITMAP_COLOR_BIT1 */
- 0 /* SIFC_BITMAP_WRITE_BIT0_ENABLE */
- );
- nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
-
- if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
- return;
-
- if (length == -1)
- length = strlen(text);
-
- while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length)) > 0 && c != '\0')
- {
- text += ret;
- length -= ret;
- glyph_index = FT_Get_Char_Index(font->face, c);
-
- if (!font_ensure_glyph(font, glyph_index))
- continue;
-
- glyph = font->glyphs[glyph_index];
-
- if (glyph->bitmap.width == 0 || glyph->bitmap.rows == 0)
- goto advance;
-
- count = (glyph->bitmap.pitch * glyph->bitmap.rows + 3) / 4;
-
- if (!ensure_space(renderer->pushbuf, 12 + count))
- return;
-
- nvc0_2d(renderer->pushbuf, G80_2D_SIFC_WIDTH, 10,
- /* Use the pitch instead of width to ensure the correct
+ struct nouveau_renderer *renderer = nouveau_renderer(base);
+ struct nouveau_buffer *dst = renderer->target;
+ uint32_t format;
+ int ret;
+ struct glyph *glyph;
+ FT_UInt glyph_index;
+ uint32_t c, count;
+ int32_t origin_x = x;
+
+ if (!ensure_space(renderer->pushbuf, 17))
+ return;
+
+ format = nvc0_format(dst->base.base.format);
+
+ nouveau_bufctx_reset(renderer->bufctx, 0);
+ nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, format);
+ nvc0_2d_inline(renderer->pushbuf, G80_2D_SIFC_BITMAP_ENABLE, 1);
+ nvc0_2d(renderer->pushbuf, G80_2D_SIFC_BITMAP_FORMAT, 6,
+ G80_2D_SIFC_BITMAP_FORMAT_I1,
+ 0, /* SIFC_FORMAT */
+ G80_2D_SIFC_BITMAP_LINE_PACK_MODE_ALIGN_BYTE,
+ 0, color, /* SIFC_BITMAP_COLOR_BIT0, SIFC_BITMAP_COLOR_BIT1 */
+ 0 /* SIFC_BITMAP_WRITE_BIT0_ENABLE */
+ );
+ nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
+
+ if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
+ return;
+
+ if (length == -1)
+ length = strlen(text);
+
+ while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length)) > 0 && c != '\0') {
+ text += ret;
+ length -= ret;
+ glyph_index = FT_Get_Char_Index(font->face, c);
+
+ if (!font_ensure_glyph(font, glyph_index))
+ continue;
+
+ glyph = font->glyphs[glyph_index];
+
+ if (glyph->bitmap.width == 0 || glyph->bitmap.rows == 0)
+ goto advance;
+
+ count = (glyph->bitmap.pitch * glyph->bitmap.rows + 3) / 4;
+
+ if (!ensure_space(renderer->pushbuf, 12 + count))
+ return;
+
+ nvc0_2d(renderer->pushbuf, G80_2D_SIFC_WIDTH, 10,
+ /* Use the pitch instead of width to ensure the correct
* alignment is used. */
- glyph->bitmap.pitch * 8, glyph->bitmap.rows,
- 0, 1, 0, 1,
- 0, origin_x + glyph->x, 0, y + glyph->y);
- nv_add_dword(renderer->pushbuf,
- nvc0_command(GF100_COMMAND_TYPE_NON_INCREASING,
- GF100_SUBCHANNEL_2D,
- G80_2D_SIFC_DATA, count));
- nv_add_data(renderer->pushbuf, glyph->bitmap.buffer, count);
-
- advance:
- origin_x += glyph->advance;
- }
-
- if (extents)
- extents->advance = origin_x - x;
+ glyph->bitmap.pitch * 8, glyph->bitmap.rows,
+ 0, 1, 0, 1,
+ 0, origin_x + glyph->x, 0, y + glyph->y);
+ nv_add_dword(renderer->pushbuf,
+ nvc0_command(GF100_COMMAND_TYPE_NON_INCREASING,
+ GF100_SUBCHANNEL_2D,
+ G80_2D_SIFC_DATA, count));
+ nv_add_data(renderer->pushbuf, glyph->bitmap.buffer, count);
+
+ advance:
+ origin_x += glyph->advance;
+ }
+
+ if (extents)
+ extents->advance = origin_x - x;
}
-void renderer_flush(struct wld_renderer * base)
+void
+renderer_flush(struct wld_renderer *base)
{
- struct nouveau_renderer * renderer = nouveau_renderer(base);
+ struct nouveau_renderer *renderer = nouveau_renderer(base);
- nouveau_pushbuf_kick(renderer->pushbuf, renderer->channel);
- nouveau_pushbuf_bufctx(renderer->pushbuf, NULL);
+ nouveau_pushbuf_kick(renderer->pushbuf, renderer->channel);
+ nouveau_pushbuf_bufctx(renderer->pushbuf, NULL);
}
-void renderer_destroy(struct wld_renderer * base)
+void
+renderer_destroy(struct wld_renderer *base)
{
- struct nouveau_renderer * renderer = nouveau_renderer(base);
+ struct nouveau_renderer *renderer = nouveau_renderer(base);
- nvc0_2d_finalize(renderer);
- nouveau_bufctx_del(&renderer->bufctx);
- nouveau_pushbuf_del(&renderer->pushbuf);
- nouveau_object_del(&renderer->channel);
- free(renderer);
+ nvc0_2d_finalize(renderer);
+ nouveau_bufctx_del(&renderer->bufctx);
+ nouveau_pushbuf_del(&renderer->pushbuf);
+ nouveau_object_del(&renderer->channel);
+ free(renderer);
}
/**** Buffer ****/
-bool buffer_map(struct buffer * base)
+bool
+buffer_map(struct buffer *base)
{
- struct nouveau_buffer * buffer = nouveau_buffer(&base->base);
+ struct nouveau_buffer *buffer = nouveau_buffer(&base->base);
- /* If the buffer is tiled, it cannot be mapped into virtual memory in order
+ /* If the buffer is tiled, it cannot be mapped into virtual memory in order
* to appear linear like intel can do with map_gtt. */
- if (buffer->bo->config.nvc0.tile_mode)
- return false;
+ if (buffer->bo->config.nvc0.tile_mode)
+ return false;
- if (nouveau_bo_map(buffer->bo, NOUVEAU_BO_WR,
- buffer->context->client) != 0)
- {
- return false;
- }
+ if (nouveau_bo_map(buffer->bo, NOUVEAU_BO_WR,
+ buffer->context->client)
+ != 0) {
+ return false;
+ }
- buffer->base.base.map = buffer->bo->map;
+ buffer->base.base.map = buffer->bo->map;
- return true;
+ return true;
}
-bool buffer_unmap(struct buffer * base)
+bool
+buffer_unmap(struct buffer *base)
{
- struct nouveau_buffer * buffer = nouveau_buffer(&base->base);
+ struct nouveau_buffer *buffer = nouveau_buffer(&base->base);
- if (munmap(buffer->bo->map, buffer->bo->size) == -1)
- return false;
+ if (munmap(buffer->bo->map, buffer->bo->size) == -1)
+ return false;
- buffer->bo->map = NULL;
- base->base.map = NULL;
+ buffer->bo->map = NULL;
+ base->base.map = NULL;
- return true;
+ return true;
}
-void buffer_destroy(struct buffer * base)
+void
+buffer_destroy(struct buffer *base)
{
- struct nouveau_buffer * buffer = nouveau_buffer(&base->base);
+ struct nouveau_buffer *buffer = nouveau_buffer(&base->base);
- nouveau_bo_ref(NULL, &buffer->bo);
- free(buffer);
+ nouveau_bo_ref(NULL, &buffer->bo);
+ free(buffer);
}
-
diff --git a/pixman.c b/pixman.c
@@ -24,427 +24,439 @@
#include "pixman.h"
#include "wld-private.h"
-#define PIXMAN_COLOR(c) { \
- .alpha = ((c >> 24) & 0xff) * 0x101, \
- .red = ((c >> 16) & 0xff) * 0x101, \
- .green = ((c >> 8) & 0xff) * 0x101, \
- .blue = ((c >> 0) & 0xff) * 0x101, \
-}
-
-struct pixman_renderer
-{
- struct wld_renderer base;
- pixman_image_t * target;
- pixman_glyph_cache_t * glyph_cache;
+#define PIXMAN_COLOR(c) \
+ { \
+ .alpha = ((c >> 24) & 0xff) * 0x101, \
+ .red = ((c >> 16) & 0xff) * 0x101, \
+ .green = ((c >> 8) & 0xff) * 0x101, \
+ .blue = ((c >> 0) & 0xff) * 0x101, \
+ }
+
+struct pixman_renderer {
+ struct wld_renderer base;
+ pixman_image_t *target;
+ pixman_glyph_cache_t *glyph_cache;
};
-struct pixman_buffer
-{
- struct buffer base;
- pixman_image_t * image;
+struct pixman_buffer {
+ struct buffer base;
+ pixman_image_t *image;
};
-struct pixman_map
-{
- struct wld_exporter exporter;
- struct wld_destructor destructor;
- pixman_image_t * image;
+struct pixman_map {
+ struct wld_exporter exporter;
+ struct wld_destructor destructor;
+ pixman_image_t *image;
};
#include "interface/context.h"
#define RENDERER_IMPLEMENTS_REGION
-#include "interface/renderer.h"
#include "interface/buffer.h"
+#include "interface/renderer.h"
IMPL(pixman_renderer, wld_renderer)
IMPL(pixman_buffer, wld_buffer)
static struct wld_context context = { .impl = &wld_context_impl };
EXPORT
-struct wld_context * wld_pixman_context = &context;
+struct wld_context *wld_pixman_context = &context;
-struct wld_renderer * context_create_renderer(struct wld_context * context)
+struct wld_renderer *
+context_create_renderer(struct wld_context *context)
{
- struct pixman_renderer * renderer;
+ struct pixman_renderer *renderer;
- if (!(renderer = malloc(sizeof *renderer)))
- goto error0;
+ if (!(renderer = malloc(sizeof *renderer)))
+ goto error0;
- if (!(renderer->glyph_cache = pixman_glyph_cache_create()))
- goto error1;
+ if (!(renderer->glyph_cache = pixman_glyph_cache_create()))
+ goto error1;
- renderer_initialize(&renderer->base, &wld_renderer_impl);
- renderer->target = NULL;
+ renderer_initialize(&renderer->base, &wld_renderer_impl);
+ renderer->target = NULL;
- return &renderer->base;
+ return &renderer->base;
- error1:
- free(renderer);
- error0:
- return NULL;
+error1:
+ free(renderer);
+error0:
+ return NULL;
}
-static struct buffer * new_buffer(pixman_image_t * image)
+static struct buffer *
+new_buffer(pixman_image_t *image)
{
- struct pixman_buffer * buffer;
+ struct pixman_buffer *buffer;
- if (!(buffer = malloc(sizeof *buffer)))
- return NULL;
+ if (!(buffer = malloc(sizeof *buffer)))
+ return NULL;
- buffer_initialize(&buffer->base, &wld_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.base.map = pixman_image_get_data(image);
- buffer->image = image;
+ buffer_initialize(&buffer->base, &wld_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.base.map = pixman_image_get_data(image);
+ buffer->image = image;
- return &buffer->base;
+ return &buffer->base;
}
-struct buffer * context_create_buffer(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
+struct buffer *
+context_create_buffer(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
{
- struct buffer * buffer;
- pixman_image_t * image;
+ struct buffer *buffer;
+ pixman_image_t *image;
- image = pixman_image_create_bits(format_wld_to_pixman(format),
- width, height, NULL, 0);
+ image = pixman_image_create_bits(format_wld_to_pixman(format),
+ width, height, NULL, 0);
- if (!image)
- goto error0;
+ if (!image)
+ goto error0;
- if (!(buffer = new_buffer(image)))
- goto error1;
+ if (!(buffer = new_buffer(image)))
+ goto error1;
- return buffer;
+ return buffer;
- error1:
- pixman_image_unref(image);
- error0:
- return NULL;
+error1:
+ pixman_image_unref(image);
+error0:
+ return NULL;
}
-struct 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 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 buffer * buffer;
- pixman_image_t * image;
-
- switch (type)
- {
- case WLD_OBJECT_DATA:
- image = pixman_image_create_bits(format_wld_to_pixman(format),
- width, height, object.ptr, pitch);
- break;
- default: image = NULL;
- }
-
- if (!image)
- goto error0;
-
- if (!(buffer = new_buffer(image)))
- goto error1;
-
- return buffer;
-
- error1:
- pixman_image_unref(image);
- error0:
- return NULL;
-
+ struct buffer *buffer;
+ pixman_image_t *image;
+
+ switch (type) {
+ case WLD_OBJECT_DATA:
+ image = pixman_image_create_bits(format_wld_to_pixman(format),
+ width, height, object.ptr, pitch);
+ break;
+ default:
+ image = NULL;
+ }
+
+ if (!image)
+ goto error0;
+
+ if (!(buffer = new_buffer(image)))
+ goto error1;
+
+ return buffer;
+
+error1:
+ pixman_image_unref(image);
+error0:
+ return NULL;
}
-void context_destroy(struct wld_context * context)
+void
+context_destroy(struct wld_context *context)
{
}
-uint32_t renderer_capabilities(struct wld_renderer * renderer,
- struct buffer * buffer)
+uint32_t
+renderer_capabilities(struct wld_renderer *renderer,
+ struct buffer *buffer)
{
- /* The pixman renderer can read and write to any buffer 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;
+ return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
}
-static void destroy_image(pixman_image_t * image, void * data)
+static void
+destroy_image(pixman_image_t *image, void *data)
{
- struct buffer * buffer = data;
+ struct buffer *buffer = data;
- wld_unmap(&buffer->base);
+ wld_unmap(&buffer->base);
}
-bool map_export(struct wld_exporter * exporter, struct wld_buffer * buffer,
- uint32_t type, union wld_object * object)
+bool
+map_export(struct wld_exporter *exporter, struct wld_buffer *buffer,
+ uint32_t type, union wld_object *object)
{
- struct pixman_map * map
- = CONTAINER_OF(exporter, struct pixman_map, exporter);
-
- switch (type)
- {
- case WLD_PIXMAN_OBJECT_IMAGE:
- object->ptr = pixman_image_ref(map->image);
- return true;
- default:
- return false;
- }
+ struct pixman_map *map = CONTAINER_OF(exporter, struct pixman_map, exporter);
+
+ switch (type) {
+ case WLD_PIXMAN_OBJECT_IMAGE:
+ object->ptr = pixman_image_ref(map->image);
+ return true;
+ default:
+ return false;
+ }
}
-void map_destroy(struct wld_destructor * destructor)
+void
+map_destroy(struct wld_destructor *destructor)
{
- struct pixman_map * map
- = CONTAINER_OF(destructor, struct pixman_map, destructor);
+ struct pixman_map *map = CONTAINER_OF(destructor, struct pixman_map, destructor);
- pixman_image_unref(map->image);
- free(map);
+ pixman_image_unref(map->image);
+ free(map);
}
-static pixman_image_t * pixman_image(struct buffer * buffer)
+static pixman_image_t *
+pixman_image(struct buffer *buffer)
{
- if (buffer->base.impl == &wld_buffer_impl)
- return pixman_image_ref(pixman_buffer(&buffer->base)->image);
+ if (buffer->base.impl == &wld_buffer_impl)
+ return pixman_image_ref(pixman_buffer(&buffer->base)->image);
- union wld_object object;
+ union wld_object object;
- if (wld_export(&buffer->base, WLD_PIXMAN_OBJECT_IMAGE, &object))
- return object.ptr;
+ if (wld_export(&buffer->base, WLD_PIXMAN_OBJECT_IMAGE, &object))
+ return object.ptr;
- struct pixman_map * map;
- pixman_image_t * image;
+ struct pixman_map *map;
+ pixman_image_t *image;
- if (!wld_map(&buffer->base))
- goto error0;
+ if (!wld_map(&buffer->base))
+ goto error0;
- image = pixman_image_create_bits(format_wld_to_pixman(buffer->base.format),
- buffer->base.width, buffer->base.height,
- buffer->base.map, buffer->base.pitch);
+ image = pixman_image_create_bits(format_wld_to_pixman(buffer->base.format),
+ buffer->base.width, buffer->base.height,
+ buffer->base.map, buffer->base.pitch);
- if (!image)
- goto error1;
+ if (!image)
+ goto error1;
- if (!(map = malloc(sizeof *map)))
- goto error2;
+ if (!(map = malloc(sizeof *map)))
+ goto error2;
- map->image = image;
- map->exporter.export = &map_export;
- wld_buffer_add_exporter(&buffer->base, &map->exporter);
- map->destructor.destroy = &map_destroy;
- wld_buffer_add_destructor(&buffer->base, &map->destructor);
- pixman_image_set_destroy_function(image, &destroy_image, buffer);
+ map->image = image;
+ map->exporter.export = &map_export;
+ wld_buffer_add_exporter(&buffer->base, &map->exporter);
+ map->destructor.destroy = &map_destroy;
+ wld_buffer_add_destructor(&buffer->base, &map->destructor);
+ pixman_image_set_destroy_function(image, &destroy_image, buffer);
- return pixman_image_ref(image);
+ return pixman_image_ref(image);
- error2:
- pixman_image_unref(image);
- error1:
- wld_unmap(&buffer->base);
- error0:
- return NULL;
+error2:
+ pixman_image_unref(image);
+error1:
+ wld_unmap(&buffer->base);
+error0:
+ return NULL;
}
-bool renderer_set_target(struct wld_renderer * base, struct buffer * buffer)
+bool
+renderer_set_target(struct wld_renderer *base, struct buffer *buffer)
{
- struct pixman_renderer * renderer = pixman_renderer(base);
+ struct pixman_renderer *renderer = pixman_renderer(base);
- if (renderer->target)
- pixman_image_unref(renderer->target);
+ if (renderer->target)
+ pixman_image_unref(renderer->target);
- if (buffer)
- return (renderer->target = pixman_image(buffer));
+ if (buffer)
+ return (renderer->target = pixman_image(buffer));
- renderer->target = NULL;
- return true;
+ renderer->target = NULL;
+ return true;
}
-void renderer_fill_rectangle(struct wld_renderer * base, uint32_t color,
- int32_t x, int32_t y,
- uint32_t width, uint32_t height)
+void
+renderer_fill_rectangle(struct wld_renderer *base, uint32_t color,
+ int32_t x, int32_t y,
+ uint32_t width, uint32_t height)
{
- struct pixman_renderer * renderer = pixman_renderer(base);
- pixman_color_t pixman_color = PIXMAN_COLOR(color);
- pixman_box32_t box = { x, y, x + width, y + height };
+ struct pixman_renderer *renderer = pixman_renderer(base);
+ pixman_color_t pixman_color = PIXMAN_COLOR(color);
+ pixman_box32_t box = { x, y, x + width, y + height };
- pixman_image_fill_boxes(PIXMAN_OP_SRC, renderer->target,
- &pixman_color, 1, &box);
+ pixman_image_fill_boxes(PIXMAN_OP_SRC, renderer->target,
+ &pixman_color, 1, &box);
}
-void renderer_fill_region(struct wld_renderer * base, uint32_t color,
- pixman_region32_t * region)
+void
+renderer_fill_region(struct wld_renderer *base, uint32_t color,
+ pixman_region32_t *region)
{
- struct pixman_renderer * renderer = pixman_renderer(base);
- pixman_color_t pixman_color = PIXMAN_COLOR(color);
- pixman_box32_t * boxes;
- int num_boxes;
-
- boxes = pixman_region32_rectangles(region, &num_boxes);
- pixman_image_fill_boxes(PIXMAN_OP_SRC, renderer->target,
- &pixman_color, num_boxes, boxes);
+ struct pixman_renderer *renderer = pixman_renderer(base);
+ pixman_color_t pixman_color = PIXMAN_COLOR(color);
+ pixman_box32_t *boxes;
+ int num_boxes;
+
+ boxes = pixman_region32_rectangles(region, &num_boxes);
+ pixman_image_fill_boxes(PIXMAN_OP_SRC, renderer->target,
+ &pixman_color, num_boxes, boxes);
}
-void renderer_copy_rectangle(struct wld_renderer * base, struct 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
+renderer_copy_rectangle(struct wld_renderer *base, struct 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(buffer), * dst = renderer->target;
+ struct pixman_renderer *renderer = pixman_renderer(base);
+ pixman_image_t *src = pixman_image(buffer), *dst = renderer->target;
- if (!src) return;
+ if (!src)
+ return;
- pixman_image_composite32(PIXMAN_OP_SRC, src, NULL, dst,
- src_x, src_y, 0, 0, dst_x, dst_y, width, height);
+ pixman_image_composite32(PIXMAN_OP_SRC, src, NULL, dst,
+ src_x, src_y, 0, 0, dst_x, dst_y, width, height);
}
-void renderer_copy_region(struct wld_renderer * base, struct buffer * buffer,
- int32_t dst_x, int32_t dst_y,
- pixman_region32_t * region)
+void
+renderer_copy_region(struct wld_renderer *base, struct 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(buffer), * dst = renderer->target;
-
- if (!src) return;
-
- pixman_image_set_clip_region32(src, region);
- pixman_image_composite32(PIXMAN_OP_SRC, src, NULL, dst,
- region->extents.x1, region->extents.y1, 0, 0,
- region->extents.x1 + dst_x,
- region->extents.y1 + dst_y,
- region->extents.x2 - region->extents.x1,
- region->extents.y2 - region->extents.y1);
- pixman_image_set_clip_region32(src, NULL);
+ struct pixman_renderer *renderer = pixman_renderer(base);
+ pixman_image_t *src = pixman_image(buffer), *dst = renderer->target;
+
+ if (!src)
+ return;
+
+ pixman_image_set_clip_region32(src, region);
+ pixman_image_composite32(PIXMAN_OP_SRC, src, NULL, dst,
+ region->extents.x1, region->extents.y1, 0, 0,
+ region->extents.x1 + dst_x,
+ region->extents.y1 + dst_y,
+ region->extents.x2 - region->extents.x1,
+ region->extents.y2 - region->extents.y1);
+ pixman_image_set_clip_region32(src, NULL);
}
-static inline uint8_t reverse(uint8_t byte)
+static inline uint8_t
+reverse(uint8_t byte)
{
- byte = ((byte << 1) & 0xaa) | ((byte >> 1) & 0x55);
- byte = ((byte << 2) & 0xcc) | ((byte >> 2) & 0x33);
- byte = ((byte << 4) & 0xf0) | ((byte >> 4) & 0x0f);
+ byte = ((byte << 1) & 0xaa) | ((byte >> 1) & 0x55);
+ byte = ((byte << 2) & 0xcc) | ((byte >> 2) & 0x33);
+ byte = ((byte << 4) & 0xf0) | ((byte >> 4) & 0x0f);
- return byte;
+ return byte;
}
-void renderer_draw_text(struct wld_renderer * base,
- struct font * font, uint32_t color,
- int32_t x, int32_t y, const char * text,
- uint32_t length, struct wld_extents * extents)
+void
+renderer_draw_text(struct wld_renderer *base,
+ struct font *font, uint32_t color,
+ int32_t x, int32_t y, const char *text,
+ uint32_t length, struct wld_extents *extents)
{
- struct pixman_renderer * renderer = pixman_renderer(base);
- int ret;
- uint32_t c;
- struct glyph * glyph;
- FT_UInt glyph_index;
- pixman_glyph_t glyphs[length == -1 ? (length = strlen(text)) : length];
- uint32_t index = 0, origin_x = 0;
- pixman_color_t pixman_color = PIXMAN_COLOR(color);
- pixman_image_t * solid;
-
- solid = pixman_image_create_solid_fill(&pixman_color);
-
- while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length)) > 0 && c != '\0')
- {
- text += ret;
- length -= ret;
- glyph_index = FT_Get_Char_Index(font->face, c);
-
- if (!font_ensure_glyph(font, glyph_index))
- continue;
-
- glyph = font->glyphs[glyph_index];
-
- glyphs[index].x = origin_x;
- glyphs[index].y = 0;
- glyphs[index].glyph = pixman_glyph_cache_lookup(renderer->glyph_cache,
- font, glyph);
-
- /* If we don't have the glyph in our cache, do some conversions to make
+ struct pixman_renderer *renderer = pixman_renderer(base);
+ int ret;
+ uint32_t c;
+ struct glyph *glyph;
+ FT_UInt glyph_index;
+ pixman_glyph_t glyphs[length == -1 ? (length = strlen(text)) : length];
+ uint32_t index = 0, origin_x = 0;
+ pixman_color_t pixman_color = PIXMAN_COLOR(color);
+ pixman_image_t *solid;
+
+ solid = pixman_image_create_solid_fill(&pixman_color);
+
+ while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length)) > 0 && c != '\0') {
+ text += ret;
+ length -= ret;
+ glyph_index = FT_Get_Char_Index(font->face, c);
+
+ if (!font_ensure_glyph(font, glyph_index))
+ continue;
+
+ glyph = font->glyphs[glyph_index];
+
+ glyphs[index].x = origin_x;
+ glyphs[index].y = 0;
+ glyphs[index].glyph = pixman_glyph_cache_lookup(renderer->glyph_cache,
+ font, glyph);
+
+ /* If we don't have the glyph in our cache, do some conversions to make
* pixman happy, and then insert it. */
- if (!glyphs[index].glyph)
- {
- uint8_t * src, * dst;
- uint32_t row, byte_index, bytes_per_row, pitch;
- pixman_image_t * image;
- FT_Bitmap * bitmap;
-
- bitmap = &glyph->bitmap;
- image = pixman_image_create_bits
- (PIXMAN_a1, bitmap->width, bitmap->rows, NULL, bitmap->pitch);
-
- if (!image)
- goto advance;
-
- pitch = pixman_image_get_stride(image);
- bytes_per_row = (bitmap->width + 7) / 8;
- src = bitmap->buffer;
- dst = (uint8_t *) pixman_image_get_data(image);
-
- for (row = 0; row < bitmap->rows; ++row)
- {
- /* Pixman's A1 format expects the bits in the opposite order
+ if (!glyphs[index].glyph) {
+ uint8_t *src, *dst;
+ uint32_t row, byte_index, bytes_per_row, pitch;
+ pixman_image_t *image;
+ FT_Bitmap *bitmap;
+
+ bitmap = &glyph->bitmap;
+ image = pixman_image_create_bits(PIXMAN_a1, bitmap->width, bitmap->rows, NULL, bitmap->pitch);
+
+ if (!image)
+ goto advance;
+
+ pitch = pixman_image_get_stride(image);
+ bytes_per_row = (bitmap->width + 7) / 8;
+ src = bitmap->buffer;
+ dst = (uint8_t *)pixman_image_get_data(image);
+
+ for (row = 0; row < bitmap->rows; ++row) {
+ /* Pixman's A1 format expects the bits in the opposite order
* that Freetype gives us. Sigh... */
- for (byte_index = 0; byte_index < bytes_per_row; ++byte_index)
- dst[byte_index] = reverse(src[byte_index]);
+ for (byte_index = 0; byte_index < bytes_per_row; ++byte_index)
+ dst[byte_index] = reverse(src[byte_index]);
- dst += pitch;
- src += bitmap->pitch;
- }
+ dst += pitch;
+ src += bitmap->pitch;
+ }
- /* Insert the glyph into the cache. */
- pixman_glyph_cache_freeze(renderer->glyph_cache);
- glyphs[index].glyph = pixman_glyph_cache_insert
- (renderer->glyph_cache, font, glyph,
- -glyph->x, -glyph->y, image);
- pixman_glyph_cache_thaw(renderer->glyph_cache);
+ /* Insert the glyph into the cache. */
+ pixman_glyph_cache_freeze(renderer->glyph_cache);
+ glyphs[index].glyph = pixman_glyph_cache_insert(renderer->glyph_cache, font, glyph,
+ -glyph->x, -glyph->y, image);
+ pixman_glyph_cache_thaw(renderer->glyph_cache);
- /* The glyph cache copies the contents of the glyph bitmap. */
- pixman_image_unref(image);
- }
+ /* The glyph cache copies the contents of the glyph bitmap. */
+ pixman_image_unref(image);
+ }
- ++index;
+ ++index;
- advance:
- origin_x += glyph->advance;
- }
+ advance:
+ origin_x += glyph->advance;
+ }
- pixman_composite_glyphs_no_mask(PIXMAN_OP_OVER, solid, renderer->target,
- 0, 0, x, y, renderer->glyph_cache,
- index, glyphs);
+ pixman_composite_glyphs_no_mask(PIXMAN_OP_OVER, solid, renderer->target,
+ 0, 0, x, y, renderer->glyph_cache,
+ index, glyphs);
- pixman_image_unref(solid);
+ pixman_image_unref(solid);
- if (extents)
- extents->advance = origin_x;
+ if (extents)
+ extents->advance = origin_x;
}
-void renderer_flush(struct wld_renderer * renderer)
+void
+renderer_flush(struct wld_renderer *renderer)
{
}
-void renderer_destroy(struct wld_renderer * base)
+void
+renderer_destroy(struct wld_renderer *base)
{
- struct pixman_renderer * renderer = pixman_renderer(base);
+ struct pixman_renderer *renderer = pixman_renderer(base);
- pixman_glyph_cache_destroy(renderer->glyph_cache);
- free(renderer);
+ pixman_glyph_cache_destroy(renderer->glyph_cache);
+ free(renderer);
}
-bool buffer_map(struct buffer * buffer)
+bool
+buffer_map(struct buffer *buffer)
{
- return true;
+ return true;
}
-bool buffer_unmap(struct buffer * buffer)
+bool
+buffer_unmap(struct buffer *buffer)
{
- return true;
+ return true;
}
-void buffer_destroy(struct buffer * base)
+void
+buffer_destroy(struct buffer *base)
{
- struct pixman_buffer * buffer = pixman_buffer(&base->base);
+ struct pixman_buffer *buffer = pixman_buffer(&base->base);
- pixman_image_unref(buffer->image);
- free(buffer);
+ pixman_image_unref(buffer->image);
+ free(buffer);
}
-
diff --git a/pixman.h b/pixman.h
@@ -28,17 +28,16 @@
#define WLD_PIXMAN_ID (0x01 << 24)
-enum wld_pixman_object_type
-{
- WLD_PIXMAN_OBJECT_IMAGE = WLD_PIXMAN_ID
+enum wld_pixman_object_type {
+ WLD_PIXMAN_OBJECT_IMAGE = WLD_PIXMAN_ID
};
-extern struct wld_context * wld_pixman_context;
+extern struct wld_context *wld_pixman_context;
-static inline struct wld_context * wld_pixman_create_context()
+static inline struct wld_context *
+wld_pixman_create_context()
{
- return wld_pixman_context;
+ return wld_pixman_context;
}
#endif
-
diff --git a/renderer.c b/renderer.c
@@ -23,135 +23,145 @@
#include "wld-private.h"
-void default_fill_region(struct wld_renderer * renderer, uint32_t color,
- pixman_region32_t * region)
+void
+default_fill_region(struct wld_renderer *renderer, uint32_t color,
+ pixman_region32_t *region)
{
- pixman_box32_t * box;
- int num_boxes;
+ pixman_box32_t *box;
+ int num_boxes;
- box = pixman_region32_rectangles(region, &num_boxes);
+ box = pixman_region32_rectangles(region, &num_boxes);
- while (num_boxes--)
- {
- renderer->impl->fill_rectangle(renderer, color, box->x1, box->y1,
- box->x2 - box->x1, box->y2 - box->y1);
- ++box;
- }
+ while (num_boxes--) {
+ renderer->impl->fill_rectangle(renderer, color, box->x1, box->y1,
+ box->x2 - box->x1, box->y2 - box->y1);
+ ++box;
+ }
}
-void default_copy_region(struct wld_renderer * renderer, struct buffer * buffer,
- int32_t dst_x, int32_t dst_y,
- pixman_region32_t * region)
+void
+default_copy_region(struct wld_renderer *renderer, struct buffer *buffer,
+ int32_t dst_x, int32_t dst_y,
+ pixman_region32_t *region)
{
- pixman_box32_t * box;
- int num_boxes;
-
- box = pixman_region32_rectangles(region, &num_boxes);
-
- while (num_boxes--)
- {
- 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);
- ++box;
- }
+ pixman_box32_t *box;
+ int num_boxes;
+
+ box = pixman_region32_rectangles(region, &num_boxes);
+
+ while (num_boxes--) {
+ 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);
+ ++box;
+ }
}
-void renderer_initialize(struct wld_renderer * renderer,
- const struct wld_renderer_impl * impl)
+void
+renderer_initialize(struct wld_renderer *renderer,
+ const struct wld_renderer_impl *impl)
{
- *((const struct wld_renderer_impl **) &renderer->impl) = impl;
- renderer->target = NULL;
+ *((const struct wld_renderer_impl **)&renderer->impl) = impl;
+ renderer->target = NULL;
}
EXPORT
-void wld_destroy_renderer(struct wld_renderer * renderer)
+void
+wld_destroy_renderer(struct wld_renderer *renderer)
{
- renderer->impl->destroy(renderer);
+ renderer->impl->destroy(renderer);
}
EXPORT
-uint32_t wld_capabilities(struct wld_renderer * renderer,
- struct wld_buffer * buffer)
+uint32_t
+wld_capabilities(struct wld_renderer *renderer,
+ struct wld_buffer *buffer)
{
- return renderer->impl->capabilities(renderer, (struct buffer *) buffer);
+ return renderer->impl->capabilities(renderer, (struct buffer *)buffer);
}
EXPORT
-bool wld_set_target_buffer(struct wld_renderer * renderer,
- struct wld_buffer * buffer)
+bool
+wld_set_target_buffer(struct wld_renderer *renderer,
+ struct wld_buffer *buffer)
{
- if (!renderer->impl->set_target(renderer, (struct buffer *) buffer))
- return false;
+ if (!renderer->impl->set_target(renderer, (struct buffer *)buffer))
+ return false;
- renderer->target = buffer;
+ renderer->target = buffer;
- return true;
+ return true;
}
EXPORT
-bool wld_set_target_surface(struct wld_renderer * renderer,
- struct wld_surface * surface)
+bool
+wld_set_target_surface(struct wld_renderer *renderer,
+ struct wld_surface *surface)
{
- struct buffer * back_buffer;
+ struct buffer *back_buffer;
- if (!(back_buffer = surface->impl->back(surface)))
- return false;
+ if (!(back_buffer = surface->impl->back(surface)))
+ return false;
- return renderer->impl->set_target(renderer, back_buffer);
+ return renderer->impl->set_target(renderer, back_buffer);
}
EXPORT
-void wld_fill_rectangle(struct wld_renderer * renderer, uint32_t color,
- int32_t x, int32_t y, uint32_t width, uint32_t height)
+void
+wld_fill_rectangle(struct wld_renderer *renderer, uint32_t color,
+ int32_t x, int32_t y, uint32_t width, uint32_t height)
{
- renderer->impl->fill_rectangle(renderer, color, x, y, width, height);
+ renderer->impl->fill_rectangle(renderer, color, x, y, width, height);
}
EXPORT
-void wld_fill_region(struct wld_renderer * renderer, uint32_t color,
- pixman_region32_t * region)
+void
+wld_fill_region(struct wld_renderer *renderer, uint32_t color,
+ pixman_region32_t *region)
{
- renderer->impl->fill_region(renderer, color, region);
+ renderer->impl->fill_region(renderer, color, region);
}
EXPORT
-void wld_copy_rectangle(struct wld_renderer * renderer,
- 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_rectangle(struct wld_renderer *renderer,
+ 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, (struct buffer *) buffer,
- dst_x, dst_y, src_x, src_y, width, height);
+ renderer->impl->copy_rectangle(renderer, (struct buffer *)buffer,
+ dst_x, dst_y, src_x, src_y, width, height);
}
EXPORT
-void wld_copy_region(struct wld_renderer * renderer,
- struct wld_buffer * buffer,
- int32_t dst_x, int32_t dst_y, pixman_region32_t * region)
+void
+wld_copy_region(struct wld_renderer *renderer,
+ struct wld_buffer *buffer,
+ int32_t dst_x, int32_t dst_y, pixman_region32_t *region)
{
- renderer->impl->copy_region(renderer, (struct buffer *) buffer,
- dst_x, dst_y, region);
+ renderer->impl->copy_region(renderer, (struct buffer *)buffer,
+ dst_x, dst_y, region);
}
EXPORT
-void wld_draw_text(struct wld_renderer * renderer,
- struct wld_font * font_base, uint32_t color,
- int32_t x, int32_t y, const char * text, uint32_t length,
- struct wld_extents * extents)
+void
+wld_draw_text(struct wld_renderer *renderer,
+ struct wld_font *font_base, uint32_t color,
+ int32_t x, int32_t y, const char *text, uint32_t length,
+ struct wld_extents *extents)
{
- struct font * font = (void *) font_base;
+ struct font *font = (void *)font_base;
- renderer->impl->draw_text(renderer, font, color, x, y, text, length,
- extents);
+ renderer->impl->draw_text(renderer, font, color, x, y, text, length,
+ extents);
}
EXPORT
-void wld_flush(struct wld_renderer * renderer)
+void
+wld_flush(struct wld_renderer *renderer)
{
- renderer->impl->flush(renderer);
- renderer->impl->set_target(renderer, NULL);
+ renderer->impl->flush(renderer);
+ renderer->impl->set_target(renderer, NULL);
}
-
diff --git a/surface.c b/surface.c
@@ -23,48 +23,54 @@
#include "wld-private.h"
-struct wld_surface * default_create_surface(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
+struct wld_surface *
+default_create_surface(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
{
- return buffered_surface_create(context, width, height, format, flags, NULL);
+ return buffered_surface_create(context, width, height, format, flags, NULL);
}
-void surface_initialize(struct wld_surface * surface,
- const struct wld_surface_impl * impl)
+void
+surface_initialize(struct wld_surface *surface,
+ const struct wld_surface_impl *impl)
{
- *((const struct wld_surface_impl **) &surface->impl) = impl;
+ *((const struct wld_surface_impl **)&surface->impl) = impl;
}
EXPORT
-pixman_region32_t * wld_surface_damage(struct wld_surface * surface,
- pixman_region32_t * new_damage)
+pixman_region32_t *
+wld_surface_damage(struct wld_surface *surface,
+ pixman_region32_t *new_damage)
{
- return surface->impl->damage(surface, new_damage);
+ return surface->impl->damage(surface, new_damage);
}
EXPORT
-struct wld_buffer * wld_surface_take(struct wld_surface * surface)
+struct wld_buffer *
+wld_surface_take(struct wld_surface *surface)
{
- return &surface->impl->take(surface)->base;
+ return &surface->impl->take(surface)->base;
}
EXPORT
-void wld_surface_release(struct wld_surface * surface,
- struct wld_buffer * buffer)
+void
+wld_surface_release(struct wld_surface *surface,
+ struct wld_buffer *buffer)
{
- surface->impl->release(surface, (struct buffer *) buffer);
+ surface->impl->release(surface, (struct buffer *)buffer);
}
EXPORT
-bool wld_swap(struct wld_surface * surface)
+bool
+wld_swap(struct wld_surface *surface)
{
- return surface->impl->swap(surface);
+ return surface->impl->swap(surface);
}
EXPORT
-void wld_destroy_surface(struct wld_surface * surface)
+void
+wld_destroy_surface(struct wld_surface *surface)
{
- surface->impl->destroy(surface);
+ surface->impl->destroy(surface);
}
-
diff --git a/wayland-drm.c b/wayland-drm.c
@@ -21,29 +21,28 @@
* SOFTWARE.
*/
-#include "wayland.h"
+#include "drm-private.h"
#include "drm.h"
#include "protocol/wayland-drm-client-protocol.h"
#include "wayland-private.h"
+#include "wayland.h"
#include "wld-private.h"
-#include "drm-private.h"
+#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <fcntl.h>
#include <xf86drm.h>
-struct drm_context
-{
- struct wayland_context base;
- struct wld_context * driver_context;
- struct wl_drm * wl;
- struct wl_registry * registry;
- struct wl_array formats;
- uint32_t capabilities;
- int fd;
- bool authenticated;
+struct drm_context {
+ struct wayland_context base;
+ struct wld_context *driver_context;
+ struct wl_drm *wl;
+ struct wl_registry *registry;
+ struct wl_array formats;
+ uint32_t capabilities;
+ int fd;
+ bool authenticated;
};
#define WAYLAND_IMPL_NAME drm
@@ -51,246 +50,250 @@ struct drm_context
#include "interface/wayland.h"
IMPL(drm_context, wld_context)
-static void registry_global(void * data, struct wl_registry * registry,
- uint32_t name, const char * interface,
+static void registry_global(void *data, struct wl_registry *registry,
+ uint32_t name, const char *interface,
uint32_t version);
-static void registry_global_remove(void * data, struct wl_registry * registry,
+static void registry_global_remove(void *data, struct wl_registry *registry,
uint32_t name);
-static void drm_device(void * data, struct wl_drm * wl, const char * name);
-static void drm_format(void * data, struct wl_drm * wl, uint32_t format);
-static void drm_authenticated(void * data, struct wl_drm * wl);
-static void drm_capabilities(void * data, struct wl_drm * wl,
+static void drm_device(void *data, struct wl_drm *wl, const char *name);
+static void drm_format(void *data, struct wl_drm *wl, uint32_t format);
+static void drm_authenticated(void *data, struct wl_drm *wl);
+static void drm_capabilities(void *data, struct wl_drm *wl,
uint32_t capabilities);
const static struct wl_registry_listener registry_listener = {
- .global = ®istry_global,
- .global_remove = ®istry_global_remove
+ .global = ®istry_global,
+ .global_remove = ®istry_global_remove
};
const static struct wl_drm_listener drm_listener = {
- .device = &drm_device,
- .format = &drm_format,
- .authenticated = &drm_authenticated,
- .capabilities = &drm_capabilities
+ .device = &drm_device,
+ .format = &drm_format,
+ .authenticated = &drm_authenticated,
+ .capabilities = &drm_capabilities
};
-struct wayland_context * wayland_create_context(struct wl_display * display,
- struct wl_event_queue * queue)
+struct wayland_context *
+wayland_create_context(struct wl_display *display,
+ struct wl_event_queue *queue)
{
- struct drm_context * context;
-
- if (!(context = malloc(sizeof *context)))
- goto error0;
-
- context_initialize(&context->base.base, &wld_context_impl);
- context->wl = NULL;
- context->fd = -1;
- context->capabilities = 0;
- wl_array_init(&context->formats);
-
- if (!(context->registry = wl_display_get_registry(display)))
- goto error1;
-
- wl_registry_add_listener(context->registry, ®istry_listener, context);
- wl_proxy_set_queue((struct wl_proxy *) context->registry, queue);
-
- /* Wait for wl_drm global. */
- wl_display_roundtrip_queue(display, queue);
-
- if (!context->wl)
- {
- DEBUG("No wl_drm global\n");
- goto error2;
- }
-
- wl_drm_add_listener(context->wl, &drm_listener, context);
-
- /* Wait for DRM capabilities and device. */
- wl_display_roundtrip_queue(display, queue);
-
- if (!(context->capabilities & WL_DRM_CAPABILITY_PRIME))
- {
- DEBUG("No PRIME support\n");
- goto error3;
- }
-
- if (context->fd == -1)
- {
- DEBUG("No DRM device\n");
- goto error3;
- }
-
- /* Wait for DRM authentication. */
- wl_display_roundtrip_queue(display, queue);
-
- if (!context->authenticated)
- {
- DEBUG("DRM authentication failed\n");
- goto error4;
- }
-
- if (!(context->driver_context = wld_drm_create_context(context->fd)))
- {
- DEBUG("Couldn't initialize context for DRM device\n");
- goto error4;
- }
-
- return &context->base;
-
- error4:
- close(context->fd);
- error3:
- wl_drm_destroy(context->wl);
- error2:
- wl_registry_destroy(context->registry);
- error1:
- wl_array_release(&context->formats);
- free(context);
- error0:
- return NULL;
+ struct drm_context *context;
+
+ if (!(context = malloc(sizeof *context)))
+ goto error0;
+
+ context_initialize(&context->base.base, &wld_context_impl);
+ context->wl = NULL;
+ context->fd = -1;
+ context->capabilities = 0;
+ wl_array_init(&context->formats);
+
+ if (!(context->registry = wl_display_get_registry(display)))
+ goto error1;
+
+ wl_registry_add_listener(context->registry, ®istry_listener, context);
+ wl_proxy_set_queue((struct wl_proxy *)context->registry, queue);
+
+ /* Wait for wl_drm global. */
+ wl_display_roundtrip_queue(display, queue);
+
+ if (!context->wl) {
+ DEBUG("No wl_drm global\n");
+ goto error2;
+ }
+
+ wl_drm_add_listener(context->wl, &drm_listener, context);
+
+ /* Wait for DRM capabilities and device. */
+ wl_display_roundtrip_queue(display, queue);
+
+ if (!(context->capabilities & WL_DRM_CAPABILITY_PRIME)) {
+ DEBUG("No PRIME support\n");
+ goto error3;
+ }
+
+ if (context->fd == -1) {
+ DEBUG("No DRM device\n");
+ goto error3;
+ }
+
+ /* Wait for DRM authentication. */
+ wl_display_roundtrip_queue(display, queue);
+
+ if (!context->authenticated) {
+ DEBUG("DRM authentication failed\n");
+ goto error4;
+ }
+
+ if (!(context->driver_context = wld_drm_create_context(context->fd))) {
+ DEBUG("Couldn't initialize context for DRM device\n");
+ goto error4;
+ }
+
+ return &context->base;
+
+error4:
+ close(context->fd);
+error3:
+ wl_drm_destroy(context->wl);
+error2:
+ wl_registry_destroy(context->registry);
+error1:
+ wl_array_release(&context->formats);
+ free(context);
+error0:
+ return NULL;
}
-bool wayland_has_format(struct wld_context * base, uint32_t format)
+bool
+wayland_has_format(struct wld_context *base, uint32_t format)
{
- struct drm_context * context = drm_context(base);
- uint32_t * supported_format;
+ struct drm_context *context = drm_context(base);
+ uint32_t *supported_format;
- wl_array_for_each(supported_format, &context->formats)
- {
- if (*supported_format == format)
- return true;
- }
+ wl_array_for_each (supported_format, &context->formats) {
+ if (*supported_format == format)
+ return true;
+ }
- return false;
+ return false;
}
EXPORT
-int wld_wayland_drm_get_fd(struct wld_context * base)
+int
+wld_wayland_drm_get_fd(struct wld_context *base)
{
- struct drm_context * context = drm_context(base);
+ struct drm_context *context = drm_context(base);
- return context->authenticated ? context->fd : -1;
+ return context->authenticated ? context->fd : -1;
}
-struct wld_renderer * context_create_renderer(struct wld_context * base)
+struct wld_renderer *
+context_create_renderer(struct wld_context *base)
{
- struct drm_context * context = drm_context(base);
+ struct drm_context *context = drm_context(base);
- return wld_create_renderer(context->driver_context);
+ return wld_create_renderer(context->driver_context);
}
-struct buffer * context_create_buffer(struct wld_context * base,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
+struct buffer *
+context_create_buffer(struct wld_context *base,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
{
- struct drm_context * context = drm_context(base);
- struct buffer * buffer;
- union wld_object object;
- struct wl_buffer * wl;
+ struct drm_context *context = drm_context(base);
+ struct buffer *buffer;
+ union wld_object object;
+ struct wl_buffer *wl;
- if (!wayland_has_format(base, format))
- goto error0;
+ if (!wayland_has_format(base, format))
+ goto error0;
- buffer = context->driver_context->impl->create_buffer
- (context->driver_context, width, height, format, flags);
+ buffer = context->driver_context->impl->create_buffer(context->driver_context, width, height, format, flags);
- if (!buffer)
- goto error0;
+ if (!buffer)
+ goto error0;
- if (!wld_export(&buffer->base, WLD_DRM_OBJECT_PRIME_FD, &object))
- goto error1;
+ if (!wld_export(&buffer->base, WLD_DRM_OBJECT_PRIME_FD, &object))
+ goto error1;
- wl = wl_drm_create_prime_buffer(context->wl, object.i, width, height,
- format, 0, buffer->base.pitch, 0, 0, 0, 0);
- close(object.i);
+ wl = wl_drm_create_prime_buffer(context->wl, object.i, width, height,
+ format, 0, buffer->base.pitch, 0, 0, 0, 0);
+ close(object.i);
- if (!wl)
- goto error1;
+ if (!wl)
+ goto error1;
- if (!wayland_buffer_add_exporter(buffer, wl))
- goto error2;
+ if (!wayland_buffer_add_exporter(buffer, wl))
+ goto error2;
- return buffer;
+ return buffer;
- error2:
- wl_buffer_destroy(wl);
- error1:
- wld_buffer_unreference(&buffer->base);
- error0:
- return NULL;
+error2:
+ wl_buffer_destroy(wl);
+error1:
+ wld_buffer_unreference(&buffer->base);
+error0:
+ return NULL;
}
-struct 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 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;
+ return NULL;
}
-void context_destroy(struct wld_context * base)
+void
+context_destroy(struct wld_context *base)
{
- struct drm_context * context = drm_context(base);
-
- wld_destroy_context(context->driver_context);
- close(context->fd);
- wl_drm_destroy(context->wl);
- wl_registry_destroy(context->registry);
- wl_array_release(&context->formats);
- wl_event_queue_destroy(context->base.queue);
- free(context);
+ struct drm_context *context = drm_context(base);
+
+ wld_destroy_context(context->driver_context);
+ close(context->fd);
+ wl_drm_destroy(context->wl);
+ wl_registry_destroy(context->registry);
+ wl_array_release(&context->formats);
+ wl_event_queue_destroy(context->base.queue);
+ free(context);
}
-void registry_global(void * data, struct wl_registry * registry, uint32_t name,
- const char * interface, uint32_t version)
+void
+registry_global(void *data, struct wl_registry *registry, uint32_t name,
+ const char *interface, uint32_t version)
{
- struct drm_context * context = data;
+ struct drm_context *context = data;
- if (strcmp(interface, "wl_drm") == 0 && version >= 2)
- context->wl = wl_registry_bind(registry, name, &wl_drm_interface, 2);
+ if (strcmp(interface, "wl_drm") == 0 && version >= 2)
+ context->wl = wl_registry_bind(registry, name, &wl_drm_interface, 2);
}
-void registry_global_remove(void * data, struct wl_registry * registry,
- uint32_t name)
+void
+registry_global_remove(void *data, struct wl_registry *registry,
+ uint32_t name)
{
}
-void drm_device(void * data, struct wl_drm * wl, const char * name)
+void
+drm_device(void *data, struct wl_drm *wl, const char *name)
{
- struct drm_context * context = data;
- drm_magic_t magic;
+ struct drm_context *context = data;
+ drm_magic_t magic;
- context->fd = open(name, O_RDWR);
+ context->fd = open(name, O_RDWR);
- if (context->fd == -1)
- {
- DEBUG("Couldn't open DRM device '%s'\n", name);
- return;
- }
+ if (context->fd == -1) {
+ DEBUG("Couldn't open DRM device '%s'\n", name);
+ return;
+ }
- drmGetMagic(context->fd, &magic);
- wl_drm_authenticate(wl, magic);
+ drmGetMagic(context->fd, &magic);
+ wl_drm_authenticate(wl, magic);
}
-void drm_format(void * data, struct wl_drm * wl, uint32_t format)
+void
+drm_format(void *data, struct wl_drm *wl, uint32_t format)
{
- struct drm_context * context = data;
+ struct drm_context *context = data;
- *((uint32_t *) wl_array_add(&context->formats, sizeof format)) = format;
+ *((uint32_t *)wl_array_add(&context->formats, sizeof format)) = format;
}
-void drm_authenticated(void * data, struct wl_drm * wl)
+void
+drm_authenticated(void *data, struct wl_drm *wl)
{
- struct drm_context * context = data;
+ struct drm_context *context = data;
- context->authenticated = true;
+ context->authenticated = true;
}
-void drm_capabilities(void * data, struct wl_drm * wl, uint32_t capabilities)
+void
+drm_capabilities(void *data, struct wl_drm *wl, uint32_t capabilities)
{
- struct drm_context * context = data;
+ struct drm_context *context = data;
- context->capabilities = capabilities;
+ context->capabilities = capabilities;
}
-
diff --git a/wayland-private.h b/wayland-private.h
@@ -31,19 +31,17 @@ struct wl_display;
struct wl_event_queue;
struct wl_buffer;
-struct wayland_context
-{
- struct wld_context base;
- const struct wayland_impl * impl;
- struct wl_display * display;
- struct wl_event_queue * queue;
+struct wayland_context {
+ struct wld_context base;
+ const struct wayland_impl *impl;
+ struct wl_display *display;
+ struct wl_event_queue *queue;
};
-struct wayland_impl
-{
- struct wayland_context * (* create_context)(struct wl_display * display,
- struct wl_event_queue * queue);
- bool (* has_format)(struct wld_context * context, uint32_t format);
+struct wayland_impl {
+ struct wayland_context *(*create_context)(struct wl_display *display,
+ struct wl_event_queue *queue);
+ bool (*has_format)(struct wld_context *context, uint32_t format);
};
#if WITH_WAYLAND_DRM
@@ -54,7 +52,6 @@ extern const struct wayland_impl drm_wayland_impl;
extern const struct wayland_impl shm_wayland_impl;
#endif
-bool wayland_buffer_add_exporter(struct buffer * buffer, struct wl_buffer * wl);
+bool wayland_buffer_add_exporter(struct buffer *buffer, struct wl_buffer *wl);
#endif
-
diff --git a/wayland-shm.c b/wayland-shm.c
@@ -23,10 +23,10 @@
#define _GNU_SOURCE /* Required for mkostemp */
-#include "wayland.h"
+#include "pixman.h"
#include "wayland-private.h"
+#include "wayland.h"
#include "wld-private.h"
-#include "pixman.h"
#include <fcntl.h>
#include <stdlib.h>
@@ -35,260 +35,266 @@
#include <unistd.h>
#include <wayland-client.h>
-struct shm_context
-{
- struct wayland_context base;
- struct wl_registry * registry;
- struct wl_shm * wl;
- struct wl_array formats;
+struct shm_context {
+ struct wayland_context base;
+ struct wl_registry *registry;
+ struct wl_shm *wl;
+ struct wl_array formats;
};
-struct shm_buffer
-{
- struct buffer base;
- int fd;
+struct shm_buffer {
+ struct buffer base;
+ int fd;
};
#define WAYLAND_IMPL_NAME shm
-#include "interface/context.h"
#include "interface/buffer.h"
+#include "interface/context.h"
#include "interface/wayland.h"
IMPL(shm_context, wld_context)
IMPL(shm_buffer, wld_buffer)
-static void registry_global(void * data, struct wl_registry * registry,
- uint32_t name, const char * interface,
+static void registry_global(void *data, struct wl_registry *registry,
+ uint32_t name, const char *interface,
uint32_t version);
-static void registry_global_remove(void * data, struct wl_registry * registry,
+static void registry_global_remove(void *data, struct wl_registry *registry,
uint32_t name);
-static void shm_format(void * data, struct wl_shm * wl, uint32_t format);
+static void shm_format(void *data, struct wl_shm *wl, uint32_t format);
const static struct wl_registry_listener registry_listener = {
- .global = ®istry_global,
- .global_remove = ®istry_global_remove
+ .global = ®istry_global,
+ .global_remove = ®istry_global_remove
};
const static struct wl_shm_listener shm_listener = {
- .format = &shm_format,
+ .format = &shm_format,
};
-static inline uint32_t format_wld_to_shm(uint32_t format)
+static inline uint32_t
+format_wld_to_shm(uint32_t format)
{
- switch (format)
- {
- case WLD_FORMAT_ARGB8888:
- return WL_SHM_FORMAT_ARGB8888;
- case WLD_FORMAT_XRGB8888:
- return WL_SHM_FORMAT_XRGB8888;
- default:
- return 0;
- }
+ switch (format) {
+ case WLD_FORMAT_ARGB8888:
+ return WL_SHM_FORMAT_ARGB8888;
+ case WLD_FORMAT_XRGB8888:
+ return WL_SHM_FORMAT_XRGB8888;
+ default:
+ return 0;
+ }
}
-struct wayland_context * wayland_create_context(struct wl_display * display,
- struct wl_event_queue * queue)
+struct wayland_context *
+wayland_create_context(struct wl_display *display,
+ struct wl_event_queue *queue)
{
- struct shm_context * context;
+ struct shm_context *context;
- if (!(context = malloc(sizeof *context)))
- goto error0;
+ if (!(context = malloc(sizeof *context)))
+ goto error0;
- context_initialize(&context->base.base, &wld_context_impl);
- context->wl = NULL;
- wl_array_init(&context->formats);
+ context_initialize(&context->base.base, &wld_context_impl);
+ context->wl = NULL;
+ wl_array_init(&context->formats);
- if (!(context->registry = wl_display_get_registry(display)))
- {
- DEBUG("Couldn't get registry\n");
- goto error1;
- }
+ if (!(context->registry = wl_display_get_registry(display))) {
+ DEBUG("Couldn't get registry\n");
+ goto error1;
+ }
- wl_registry_add_listener(context->registry, ®istry_listener, context);
- wl_proxy_set_queue((struct wl_proxy *) context->registry, queue);
+ wl_registry_add_listener(context->registry, ®istry_listener, context);
+ wl_proxy_set_queue((struct wl_proxy *)context->registry, queue);
- /* Wait for wl_shm global. */
- wl_display_roundtrip_queue(display, queue);
+ /* Wait for wl_shm global. */
+ wl_display_roundtrip_queue(display, queue);
- if (!context->wl)
- {
- DEBUG("No wl_shm global\n");
- goto error2;
- }
+ if (!context->wl) {
+ DEBUG("No wl_shm global\n");
+ goto error2;
+ }
- wl_shm_add_listener(context->wl, &shm_listener, context);
+ wl_shm_add_listener(context->wl, &shm_listener, context);
- /* Wait for SHM formats. */
- wl_display_roundtrip_queue(display, queue);
+ /* Wait for SHM formats. */
+ wl_display_roundtrip_queue(display, queue);
- return &context->base;
+ return &context->base;
- error2:
- wl_registry_destroy(context->registry);
- error1:
- wl_array_release(&context->formats);
- free(context);
- error0:
- return NULL;
+error2:
+ wl_registry_destroy(context->registry);
+error1:
+ wl_array_release(&context->formats);
+ free(context);
+error0:
+ return NULL;
}
-bool wayland_has_format(struct wld_context * base, uint32_t format)
+bool
+wayland_has_format(struct wld_context *base, uint32_t format)
{
- struct shm_context * context = shm_context(base);
- uint32_t * supported_format;
- uint32_t shm_format = format_wld_to_shm(format);
+ struct shm_context *context = shm_context(base);
+ uint32_t *supported_format;
+ uint32_t shm_format = format_wld_to_shm(format);
- wl_array_for_each(supported_format, &context->formats)
- {
- if (*supported_format == shm_format)
- return true;
- }
+ wl_array_for_each (supported_format, &context->formats) {
+ if (*supported_format == shm_format)
+ return true;
+ }
- return false;
+ return false;
}
-struct wld_renderer * context_create_renderer(struct wld_context * context)
+struct wld_renderer *
+context_create_renderer(struct wld_context *context)
{
- return wld_create_renderer(wld_pixman_context);
+ return wld_create_renderer(wld_pixman_context);
}
-struct buffer * context_create_buffer(struct wld_context * base,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags)
+struct buffer *
+context_create_buffer(struct wld_context *base,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
{
- struct shm_context * context = shm_context(base);
- struct shm_buffer * buffer;
- char name[] = "/tmp/wld-XXXXXX";
- uint32_t pitch = width * format_bytes_per_pixel(format);
- size_t size = pitch * height;
- int fd;
- struct wl_shm_pool * pool;
- struct wl_buffer * wl;
+ struct shm_context *context = shm_context(base);
+ struct shm_buffer *buffer;
+ char name[] = "/tmp/wld-XXXXXX";
+ uint32_t pitch = width * format_bytes_per_pixel(format);
+ size_t size = pitch * height;
+ int fd;
+ struct wl_shm_pool *pool;
+ struct wl_buffer *wl;
- if (!wayland_has_format(base, format))
- goto error0;
+ if (!wayland_has_format(base, format))
+ goto error0;
- if (!(buffer = malloc(sizeof *buffer)))
- goto error0;
+ if (!(buffer = malloc(sizeof *buffer)))
+ goto error0;
- fd = mkostemp(name, O_CLOEXEC);
+ fd = mkostemp(name, O_CLOEXEC);
- if (fd < 0)
- goto error1;
+ if (fd < 0)
+ goto error1;
- unlink(name);
+ unlink(name);
- if (posix_fallocate(fd, 0, size) != 0)
- goto error2;
+ if (posix_fallocate(fd, 0, size) != 0)
+ goto error2;
- if (!(pool = wl_shm_create_pool(context->wl, fd, size)))
- goto error2;
+ if (!(pool = wl_shm_create_pool(context->wl, fd, size)))
+ goto error2;
- wl = wl_shm_pool_create_buffer(pool, 0, width, height, pitch,
- format_wld_to_shm(format));
- wl_shm_pool_destroy(pool);
+ wl = wl_shm_pool_create_buffer(pool, 0, width, height, pitch,
+ format_wld_to_shm(format));
+ wl_shm_pool_destroy(pool);
- if (!wl)
- goto error2;
+ if (!wl)
+ goto error2;
- buffer_initialize(&buffer->base, &wld_buffer_impl,
- width, height, format, pitch);
- buffer->fd = fd;
+ buffer_initialize(&buffer->base, &wld_buffer_impl,
+ width, height, format, pitch);
+ buffer->fd = fd;
- if (!(wayland_buffer_add_exporter(&buffer->base, wl)))
- goto error3;
+ if (!(wayland_buffer_add_exporter(&buffer->base, wl)))
+ goto error3;
- return &buffer->base;
+ return &buffer->base;
- error3:
- wl_buffer_destroy(wl);
- error2:
- close(fd);
- error1:
- free(buffer);
- error0:
- return NULL;
+error3:
+ wl_buffer_destroy(wl);
+error2:
+ close(fd);
+error1:
+ free(buffer);
+error0:
+ return NULL;
}
-struct 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 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;
+ return NULL;
}
-void context_destroy(struct wld_context * base)
+void
+context_destroy(struct wld_context *base)
{
- struct shm_context * context = shm_context(base);
+ struct shm_context *context = shm_context(base);
- wl_shm_destroy(context->wl);
- wl_registry_destroy(context->registry);
- wl_array_release(&context->formats);
- wl_event_queue_destroy(context->base.queue);
- free(context);
+ wl_shm_destroy(context->wl);
+ wl_registry_destroy(context->registry);
+ wl_array_release(&context->formats);
+ wl_event_queue_destroy(context->base.queue);
+ free(context);
}
/**** Buffer ****/
-bool buffer_map(struct buffer * base)
+bool
+buffer_map(struct buffer *base)
{
- struct shm_buffer * buffer = shm_buffer(&base->base);
- void * data;
+ struct shm_buffer *buffer = shm_buffer(&base->base);
+ void *data;
- data = mmap(NULL, buffer->base.base.pitch * buffer->base.base.height,
- PROT_READ | PROT_WRITE, MAP_SHARED, buffer->fd, 0);
+ data = mmap(NULL, buffer->base.base.pitch * buffer->base.base.height,
+ PROT_READ | PROT_WRITE, MAP_SHARED, buffer->fd, 0);
- if (data == MAP_FAILED)
- return false;
+ if (data == MAP_FAILED)
+ return false;
- buffer->base.base.map = data;
+ buffer->base.base.map = data;
- return true;
+ return true;
}
-bool buffer_unmap(struct buffer * buffer)
+bool
+buffer_unmap(struct buffer *buffer)
{
- if (munmap(buffer->base.map,
- buffer->base.pitch * buffer->base.height) == -1)
- {
- return false;
- }
+ if (munmap(buffer->base.map,
+ buffer->base.pitch * buffer->base.height)
+ == -1) {
+ return false;
+ }
- buffer->base.map = NULL;
+ buffer->base.map = NULL;
- return true;
+ return true;
}
-void buffer_destroy(struct buffer * base)
+void
+buffer_destroy(struct buffer *base)
{
- struct shm_buffer * buffer = shm_buffer(&base->base);
+ struct shm_buffer *buffer = shm_buffer(&base->base);
- close(buffer->fd);
- free(buffer);
+ close(buffer->fd);
+ free(buffer);
}
-void registry_global(void * data, struct wl_registry * registry, uint32_t name,
- const char * interface, uint32_t version)
+void
+registry_global(void *data, struct wl_registry *registry, uint32_t name,
+ const char *interface, uint32_t version)
{
- struct shm_context * context = data;
+ struct shm_context *context = data;
- if (strcmp(interface, "wl_shm") == 0)
- context->wl = wl_registry_bind(registry, name, &wl_shm_interface, 1);
+ if (strcmp(interface, "wl_shm") == 0)
+ context->wl = wl_registry_bind(registry, name, &wl_shm_interface, 1);
}
-void registry_global_remove(void * data, struct wl_registry * registry,
- uint32_t name)
+void
+registry_global_remove(void *data, struct wl_registry *registry,
+ uint32_t name)
{
}
-void shm_format(void * data, struct wl_shm * wl, uint32_t format)
+void
+shm_format(void *data, struct wl_shm *wl, uint32_t format)
{
- struct shm_context * context = data;
- uint32_t * added_format;
+ struct shm_context *context = data;
+ uint32_t *added_format;
- if (!(added_format = wl_array_add(&context->formats, sizeof format)))
- return;
- *added_format = format;
+ if (!(added_format = wl_array_add(&context->formats, sizeof format)))
+ return;
+ *added_format = format;
}
-
diff --git a/wayland.c b/wayland.c
@@ -28,281 +28,278 @@
#include <stdlib.h>
#include <wayland-client.h>
-struct wayland_buffer
-{
- struct wld_exporter exporter;
- struct wld_destructor destructor;
- struct wl_buffer * wl;
+struct wayland_buffer {
+ struct wld_exporter exporter;
+ struct wld_destructor destructor;
+ struct wl_buffer *wl;
};
-struct wayland_buffer_socket
-{
- struct buffer_socket base;
- struct wl_buffer_listener listener;
- struct wld_surface * surface;
- struct wl_surface * wl;
- struct wl_display * display;
- struct wl_event_queue * queue;
+struct wayland_buffer_socket {
+ struct buffer_socket base;
+ struct wl_buffer_listener listener;
+ struct wld_surface *surface;
+ struct wl_surface *wl;
+ struct wl_display *display;
+ struct wl_event_queue *queue;
};
-static bool buffer_socket_attach(struct buffer_socket * socket,
- struct buffer * buffer);
-static void buffer_socket_process(struct buffer_socket * socket);
-static void buffer_socket_destroy(struct buffer_socket * socket);
+static bool buffer_socket_attach(struct buffer_socket *socket,
+ struct buffer *buffer);
+static void buffer_socket_process(struct buffer_socket *socket);
+static void buffer_socket_destroy(struct buffer_socket *socket);
static const struct buffer_socket_impl buffer_socket_impl = {
- .attach = &buffer_socket_attach,
- .process = &buffer_socket_process,
- .destroy = &buffer_socket_destroy
+ .attach = &buffer_socket_attach,
+ .process = &buffer_socket_process,
+ .destroy = &buffer_socket_destroy
};
IMPL(wayland_buffer_socket, buffer_socket)
-static void sync_done(void * data, struct wl_callback * callback,
+static void sync_done(void *data, struct wl_callback *callback,
uint32_t msecs);
static const struct wl_callback_listener sync_listener = {
- .done = &sync_done
+ .done = &sync_done
};
-static void buffer_release(void * data, struct wl_buffer * buffer);
+static void buffer_release(void *data, struct wl_buffer *buffer);
-const static struct wayland_impl * impls[] = {
+const static struct wayland_impl *impls[] = {
#if WITH_WAYLAND_DRM
- [WLD_DRM] = &drm_wayland_impl,
+ [WLD_DRM] = &drm_wayland_impl,
#endif
#if WITH_WAYLAND_SHM
- [WLD_SHM] = &shm_wayland_impl,
+ [WLD_SHM] = &shm_wayland_impl,
#endif
};
-enum wld_wayland_interface_id interface_id(const char * string)
+enum wld_wayland_interface_id
+interface_id(const char *string)
{
- if (strcmp(string, "drm") == 0)
- return WLD_DRM;
- if (strcmp(string, "shm") == 0)
- return WLD_SHM;
+ if (strcmp(string, "drm") == 0)
+ return WLD_DRM;
+ if (strcmp(string, "shm") == 0)
+ return WLD_SHM;
- fprintf(stderr, "Unknown Wayland interface specified: '%s'\n", string);
+ fprintf(stderr, "Unknown Wayland interface specified: '%s'\n", string);
- return WLD_NONE;
+ return WLD_NONE;
}
EXPORT
-struct wld_context * wld_wayland_create_context
- (struct wl_display * display, enum wld_wayland_interface_id id, ...)
+struct wld_context *
+wld_wayland_create_context(struct wl_display *display, enum wld_wayland_interface_id id, ...)
{
- struct wayland_context * context = NULL;
- struct wl_event_queue * queue;
- va_list requested_impls;
- bool impls_tried[ARRAY_LENGTH(impls)] = {0};
- const char * interface_string;
+ struct wayland_context *context = NULL;
+ struct wl_event_queue *queue;
+ va_list requested_impls;
+ bool impls_tried[ARRAY_LENGTH(impls)] = { 0 };
+ const char *interface_string;
- if (!(queue = wl_display_create_queue(display)))
- return NULL;
+ if (!(queue = wl_display_create_queue(display)))
+ return NULL;
- if ((interface_string = getenv("WLD_WAYLAND_INTERFACE")))
- {
- id = interface_id(interface_string);
+ if ((interface_string = getenv("WLD_WAYLAND_INTERFACE"))) {
+ id = interface_id(interface_string);
- if ((context = impls[id]->create_context(display, queue)))
- return &context->base;
+ if ((context = impls[id]->create_context(display, queue)))
+ return &context->base;
- fprintf(stderr, "Could not create context for Wayland interface '%s'\n",
- interface_string);
+ fprintf(stderr, "Could not create context for Wayland interface '%s'\n",
+ interface_string);
- return NULL;
- }
+ return NULL;
+ }
- va_start(requested_impls, id);
+ va_start(requested_impls, id);
- while (id >= 0)
- {
- if (impls_tried[id] || !impls[id])
- continue;
+ while (id >= 0) {
+ if (impls_tried[id] || !impls[id])
+ continue;
- if ((context = impls[id]->create_context(display, queue)))
- goto done;
+ if ((context = impls[id]->create_context(display, queue)))
+ goto done;
- impls_tried[id] = true;
- id = va_arg(requested_impls, enum wld_wayland_interface_id);
- }
+ impls_tried[id] = true;
+ id = va_arg(requested_impls, enum wld_wayland_interface_id);
+ }
- va_end(requested_impls);
+ va_end(requested_impls);
- /* If the user specified WLD_ANY, try any remaining implementations. */
- if (!context && id == WLD_ANY)
- {
- for (id = 0; id < ARRAY_LENGTH(impls); ++id)
- {
- if (impls_tried[id] || !impls[id])
- continue;
+ /* If the user specified WLD_ANY, try any remaining implementations. */
+ if (!context && id == WLD_ANY) {
+ for (id = 0; id < ARRAY_LENGTH(impls); ++id) {
+ if (impls_tried[id] || !impls[id])
+ continue;
- if ((context = impls[id]->create_context(display, queue)))
- break;
- }
- }
+ if ((context = impls[id]->create_context(display, queue)))
+ break;
+ }
+ }
- if (!context)
- {
- DEBUG("Could not initialize any of the specified implementations\n");
- return NULL;
- }
+ if (!context) {
+ DEBUG("Could not initialize any of the specified implementations\n");
+ return NULL;
+ }
- done:
- context->impl = impls[id];
- context->display = display;
- context->queue = queue;
+done:
+ context->impl = impls[id];
+ context->display = display;
+ context->queue = queue;
- return &context->base;
+ return &context->base;
}
EXPORT
-struct wld_surface * wld_wayland_create_surface(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags,
- struct wl_surface * wl)
+struct wld_surface *
+wld_wayland_create_surface(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags,
+ struct wl_surface *wl)
{
- struct wayland_buffer_socket * socket;
+ struct wayland_buffer_socket *socket;
- if (!(socket = malloc(sizeof *socket)))
- goto error0;
+ if (!(socket = malloc(sizeof *socket)))
+ goto error0;
- socket->base.impl = &buffer_socket_impl;
- socket->listener.release = &buffer_release;
- socket->wl = wl;
- socket->queue = ((struct wayland_context *) context)->queue;
- socket->display = ((struct wayland_context *) context)->display;
- socket->surface = buffered_surface_create(context, width, height, format,
- flags, &socket->base);
+ socket->base.impl = &buffer_socket_impl;
+ socket->listener.release = &buffer_release;
+ socket->wl = wl;
+ socket->queue = ((struct wayland_context *)context)->queue;
+ socket->display = ((struct wayland_context *)context)->display;
+ socket->surface = buffered_surface_create(context, width, height, format,
+ flags, &socket->base);
- if (!socket->surface)
- goto error1;
+ if (!socket->surface)
+ goto error1;
- return socket->surface;
+ return socket->surface;
- error1:
- free(socket);
- error0:
- return NULL;
+error1:
+ free(socket);
+error0:
+ return NULL;
}
EXPORT
-bool wld_wayland_has_format(struct wld_context * base, uint32_t format)
+bool
+wld_wayland_has_format(struct wld_context *base, uint32_t format)
{
- struct wayland_context * context = (void *) base;
+ struct wayland_context *context = (void *)base;
- return context->impl->has_format(base, format);
+ return context->impl->has_format(base, format);
}
-static bool buffer_export(struct wld_exporter * exporter,
- struct wld_buffer * buffer,
- uint32_t type, union wld_object * object)
+static bool
+buffer_export(struct wld_exporter *exporter,
+ struct wld_buffer *buffer,
+ uint32_t type, union wld_object *object)
{
- struct wayland_buffer * wayland_buffer
- = CONTAINER_OF(exporter, struct wayland_buffer, exporter);
-
- switch (type)
- {
- case WLD_WAYLAND_OBJECT_BUFFER:
- object->ptr = wayland_buffer->wl;
- return true;
- default: return false;
- }
+ struct wayland_buffer *wayland_buffer = CONTAINER_OF(exporter, struct wayland_buffer, exporter);
+
+ switch (type) {
+ case WLD_WAYLAND_OBJECT_BUFFER:
+ object->ptr = wayland_buffer->wl;
+ return true;
+ default:
+ return false;
+ }
}
-static void buffer_destroy(struct wld_destructor * destructor)
+static void
+buffer_destroy(struct wld_destructor *destructor)
{
- struct wayland_buffer * wayland_buffer
- = CONTAINER_OF(destructor, struct wayland_buffer, destructor);
+ struct wayland_buffer *wayland_buffer = CONTAINER_OF(destructor, struct wayland_buffer, destructor);
- wl_buffer_destroy(wayland_buffer->wl);
- free(wayland_buffer);
+ wl_buffer_destroy(wayland_buffer->wl);
+ free(wayland_buffer);
}
-bool wayland_buffer_add_exporter(struct buffer * buffer, struct wl_buffer * wl)
+bool
+wayland_buffer_add_exporter(struct buffer *buffer, struct wl_buffer *wl)
{
- struct wayland_buffer * wayland_buffer;
+ struct wayland_buffer *wayland_buffer;
- if (!(wayland_buffer = malloc(sizeof *wayland_buffer)))
- return false;
+ if (!(wayland_buffer = malloc(sizeof *wayland_buffer)))
+ return false;
- wayland_buffer->wl = wl;
- wayland_buffer->exporter.export = &buffer_export;
- wld_buffer_add_exporter(&buffer->base, &wayland_buffer->exporter);
- wayland_buffer->destructor.destroy = &buffer_destroy;
- wld_buffer_add_destructor(&buffer->base, &wayland_buffer->destructor);
+ wayland_buffer->wl = wl;
+ wayland_buffer->exporter.export = &buffer_export;
+ wld_buffer_add_exporter(&buffer->base, &wayland_buffer->exporter);
+ wayland_buffer->destructor.destroy = &buffer_destroy;
+ wld_buffer_add_destructor(&buffer->base, &wayland_buffer->destructor);
- return true;
+ return true;
}
-bool buffer_socket_attach(struct buffer_socket * base, struct buffer * buffer)
+bool
+buffer_socket_attach(struct buffer_socket *base, struct buffer *buffer)
{
- struct wayland_buffer_socket * socket = wayland_buffer_socket(base);
- struct wl_buffer * wl;
- union wld_object object;
+ struct wayland_buffer_socket *socket = wayland_buffer_socket(base);
+ struct wl_buffer *wl;
+ union wld_object object;
- if (!wld_export(&buffer->base, WLD_WAYLAND_OBJECT_BUFFER, &object))
- return false;
+ if (!wld_export(&buffer->base, WLD_WAYLAND_OBJECT_BUFFER, &object))
+ return false;
- wl = object.ptr;
+ wl = object.ptr;
- if (!wl_proxy_get_listener((struct wl_proxy *) wl))
- wl_buffer_add_listener(wl, &socket->listener, buffer);
+ if (!wl_proxy_get_listener((struct wl_proxy *)wl))
+ wl_buffer_add_listener(wl, &socket->listener, buffer);
- wl_surface_attach(socket->wl, wl, 0, 0);
+ wl_surface_attach(socket->wl, wl, 0, 0);
- if (pixman_region32_not_empty(&buffer->base.damage))
- {
- pixman_box32_t * box;
- int num_boxes;
+ if (pixman_region32_not_empty(&buffer->base.damage)) {
+ pixman_box32_t *box;
+ int num_boxes;
- box = pixman_region32_rectangles(&buffer->base.damage, &num_boxes);
+ box = pixman_region32_rectangles(&buffer->base.damage, &num_boxes);
- while (num_boxes--)
- {
- wl_surface_damage(socket->wl, box->x1, box->y1,
- box->x2 - box->x1, box->y2 - box->y1);
- }
- }
+ while (num_boxes--) {
+ wl_surface_damage(socket->wl, box->x1, box->y1,
+ box->x2 - box->x1, box->y2 - box->y1);
+ }
+ }
- wl_surface_commit(socket->wl);
+ wl_surface_commit(socket->wl);
- return true;
+ return true;
}
-void buffer_socket_process(struct buffer_socket * base)
+void
+buffer_socket_process(struct buffer_socket *base)
{
- struct wayland_buffer_socket * socket = wayland_buffer_socket(base);
+ struct wayland_buffer_socket *socket = wayland_buffer_socket(base);
- /* Since events for our wl_buffers lie in a special queue used by WLD, we
+ /* Since events for our wl_buffers lie in a special queue used by WLD, we
* must dispatch these events here so that we see any release events before
* the next back buffer is chosen. */
- wl_display_dispatch_queue_pending(socket->display, socket->queue);
+ wl_display_dispatch_queue_pending(socket->display, socket->queue);
}
-void buffer_socket_destroy(struct buffer_socket * socket)
+void
+buffer_socket_destroy(struct buffer_socket *socket)
{
- free(socket);
+ free(socket);
}
-void sync_done(void * data, struct wl_callback * callback, uint32_t msecs)
+void
+sync_done(void *data, struct wl_callback *callback, uint32_t msecs)
{
- bool * done = data;
+ bool *done = data;
- *done = true;
- wl_callback_destroy(callback);
+ *done = true;
+ wl_callback_destroy(callback);
}
-void buffer_release(void * data, struct wl_buffer * wl)
+void
+buffer_release(void *data, struct wl_buffer *wl)
{
- struct wld_buffer * buffer = data;
- const struct wl_buffer_listener * listener
- = wl_proxy_get_listener((struct wl_proxy *) wl);
- struct wayland_buffer_socket * socket
- = CONTAINER_OF(listener, struct wayland_buffer_socket, listener);
+ struct wld_buffer *buffer = data;
+ const struct wl_buffer_listener *listener = wl_proxy_get_listener((struct wl_proxy *)wl);
+ struct wayland_buffer_socket *socket = CONTAINER_OF(listener, struct wayland_buffer_socket, listener);
- wld_surface_release(socket->surface, buffer);
+ wld_surface_release(socket->surface, buffer);
}
-
diff --git a/wayland.h b/wayland.h
@@ -32,25 +32,23 @@ struct wl_surface;
#define WLD_WAYLAND_ID (0x3 << 24)
-enum wld_wayland_interface_id
-{
- /**
+enum wld_wayland_interface_id {
+ /**
* Give up on trying any new interfaces. This can be considered as a
* sentinel for wld_wayland_create_context.
*/
- WLD_NONE = -2,
+ WLD_NONE = -2,
- /**
+ /**
* Try any available interface.
*/
- WLD_ANY = -1,
- WLD_DRM,
- WLD_SHM
+ WLD_ANY = -1,
+ WLD_DRM,
+ WLD_SHM
};
-enum wld_wayland_object_type
-{
- WLD_WAYLAND_OBJECT_BUFFER = WLD_WAYLAND_ID
+enum wld_wayland_object_type {
+ WLD_WAYLAND_OBJECT_BUFFER = WLD_WAYLAND_ID
};
/**
@@ -65,20 +63,18 @@ enum wld_wayland_object_type
*
* @see enum wld_wayland_interface_id
*/
-struct wld_context * wld_wayland_create_context
- (struct wl_display * display, enum wld_wayland_interface_id id, ...);
+struct wld_context *wld_wayland_create_context(struct wl_display *display, enum wld_wayland_interface_id id, ...);
-struct wld_surface * wld_wayland_create_surface(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags,
- struct wl_surface * surface);
+struct wld_surface *wld_wayland_create_surface(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags,
+ struct wl_surface *surface);
/**
* Check if the wayland implementation supports a particular pixel format.
*
* @see enum wld_format
*/
-bool wld_wayland_has_format(struct wld_context * context, uint32_t format);
+bool wld_wayland_has_format(struct wld_context *context, uint32_t format);
#endif
-
diff --git a/wld-private.h b/wld-private.h
@@ -27,217 +27,206 @@
#include "wld.h"
#include <assert.h>
+#include <ft2build.h>
#include <stdbool.h>
#include <stdint.h>
-#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_BITMAP_H
-#define ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0])
+#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array)[0])
#if ENABLE_DEBUG
-# define DEBUG(format, ...) \
- fprintf(stderr, "# %s: " format, __func__, ## __VA_ARGS__)
+#define DEBUG(format, ...) \
+ fprintf(stderr, "# %s: " format, __func__, ##__VA_ARGS__)
#else
-# define DEBUG(format, ...)
+#define DEBUG(format, ...)
#endif
#define EXPORT __attribute__((visibility("default")))
#define CONTAINER_OF(ptr, type, member) \
- ((type *)((uintptr_t) ptr - offsetof(type, member)))
+ ((type *)((uintptr_t)ptr - offsetof(type, member)))
#define IMPL(impl_type, base_type) \
- static inline struct impl_type * impl_type(struct base_type * object) \
- { \
- assert(object->impl == &base_type ## _impl); \
- return (struct impl_type *) object; \
- }
-
-struct wld_font_context
-{
- FT_Library library;
+ static inline struct impl_type *impl_type(struct base_type *object) \
+ { \
+ assert(object->impl == &base_type##_impl); \
+ return (struct impl_type *)object; \
+ }
+
+struct wld_font_context {
+ FT_Library library;
};
-struct glyph
-{
- FT_Bitmap bitmap;
+struct glyph {
+ FT_Bitmap bitmap;
- /**
+ /**
* The offset from the origin to the top left corner of the bitmap.
*/
- int16_t x, y;
+ int16_t x, y;
- /**
+ /**
* The width to advance to the origin of the next character.
*/
- uint16_t advance;
+ uint16_t advance;
};
-struct font
-{
- struct wld_font base;
+struct font {
+ struct wld_font base;
- struct wld_font_context * context;
- FT_Face face;
- struct glyph ** glyphs;
+ struct wld_font_context *context;
+ FT_Face face;
+ struct glyph **glyphs;
};
-struct wld_context_impl
-{
- struct wld_renderer * (* create_renderer)(struct wld_context * context);
- struct buffer * (* create_buffer)(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags);
- struct 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);
- struct wld_surface * (* create_surface)(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags);
- void (* destroy)(struct wld_context * context);
+struct wld_context_impl {
+ struct wld_renderer *(*create_renderer)(struct wld_context *context);
+ struct buffer *(*create_buffer)(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags);
+ struct 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);
+ struct wld_surface *(*create_surface)(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags);
+ void (*destroy)(struct wld_context *context);
};
-struct wld_renderer_impl
-{
- uint32_t (* capabilities)(struct wld_renderer * renderer,
- struct buffer * buffer);
- bool (* set_target)(struct wld_renderer * renderer, struct 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 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 buffer * src,
- int32_t dst_x, int32_t dst_y,
- pixman_region32_t * region);
- void (* draw_text)(struct wld_renderer * renderer,
- struct font * font, uint32_t color,
- int32_t x, int32_t y, const char * text, uint32_t length,
- struct wld_extents * extents);
- void (* flush)(struct wld_renderer * renderer);
- void (* destroy)(struct wld_renderer * renderer);
+struct wld_renderer_impl {
+ uint32_t (*capabilities)(struct wld_renderer *renderer,
+ struct buffer *buffer);
+ bool (*set_target)(struct wld_renderer *renderer, struct 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 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 buffer *src,
+ int32_t dst_x, int32_t dst_y,
+ pixman_region32_t *region);
+ void (*draw_text)(struct wld_renderer *renderer,
+ struct font *font, uint32_t color,
+ int32_t x, int32_t y, const char *text, uint32_t length,
+ struct wld_extents *extents);
+ void (*flush)(struct wld_renderer *renderer);
+ void (*destroy)(struct wld_renderer *renderer);
};
-struct buffer
-{
- struct wld_buffer base;
+struct buffer {
+ struct wld_buffer base;
- unsigned references, map_references;
- struct wld_exporter * exporters;
- struct wld_destructor * destructors;
+ unsigned references, map_references;
+ struct wld_exporter *exporters;
+ struct wld_destructor *destructors;
};
-struct wld_buffer_impl
-{
- bool (* map)(struct buffer * buffer);
- bool (* unmap)(struct buffer * buffer);
- void (* destroy)(struct buffer * buffer);
+struct wld_buffer_impl {
+ bool (*map)(struct buffer *buffer);
+ bool (*unmap)(struct buffer *buffer);
+ void (*destroy)(struct buffer *buffer);
};
-struct wld_surface_impl
-{
- pixman_region32_t * (* damage)(struct wld_surface * surface,
- pixman_region32_t * damage);
- struct buffer * (* back)(struct wld_surface * surface);
- struct buffer * (* take)(struct wld_surface * surface);
- bool (* release)(struct wld_surface * surface, struct buffer * buffer);
- bool (* swap)(struct wld_surface * surface);
- void (* destroy)(struct wld_surface * surface);
+struct wld_surface_impl {
+ pixman_region32_t *(*damage)(struct wld_surface *surface,
+ pixman_region32_t *damage);
+ struct buffer *(*back)(struct wld_surface *surface);
+ struct buffer *(*take)(struct wld_surface *surface);
+ bool (*release)(struct wld_surface *surface, struct buffer *buffer);
+ bool (*swap)(struct wld_surface *surface);
+ void (*destroy)(struct wld_surface *surface);
};
-struct buffer_socket
-{
- const struct buffer_socket_impl * impl;
+struct buffer_socket {
+ const struct buffer_socket_impl *impl;
};
-struct buffer_socket_impl
-{
- bool (* attach)(struct buffer_socket * socket, struct buffer * buffer);
- void (* process)(struct buffer_socket * socket);
- void (* destroy)(struct buffer_socket * socket);
+struct buffer_socket_impl {
+ bool (*attach)(struct buffer_socket *socket, struct buffer *buffer);
+ void (*process)(struct buffer_socket *socket);
+ void (*destroy)(struct buffer_socket *socket);
};
-bool font_ensure_glyph(struct font * font, FT_UInt glyph_index);
+bool font_ensure_glyph(struct font *font, FT_UInt glyph_index);
/**
* Returns the number of bytes per pixel for the given format.
*/
-static inline uint8_t format_bytes_per_pixel(enum wld_format format)
+static inline uint8_t
+format_bytes_per_pixel(enum wld_format format)
{
- switch (format)
- {
- case WLD_FORMAT_ARGB8888:
- case WLD_FORMAT_XRGB8888:
- return 4;
- default:
- return 0;
- }
+ switch (format) {
+ case WLD_FORMAT_ARGB8888:
+ case WLD_FORMAT_XRGB8888:
+ return 4;
+ default:
+ return 0;
+ }
}
-static inline pixman_format_code_t format_wld_to_pixman(uint32_t format)
+static inline pixman_format_code_t
+format_wld_to_pixman(uint32_t format)
{
- switch (format)
- {
- case WLD_FORMAT_ARGB8888:
- return PIXMAN_a8r8g8b8;
- case WLD_FORMAT_XRGB8888:
- return PIXMAN_x8r8g8b8;
- default:
- return 0;
- }
+ switch (format) {
+ case WLD_FORMAT_ARGB8888:
+ return PIXMAN_a8r8g8b8;
+ case WLD_FORMAT_XRGB8888:
+ return PIXMAN_x8r8g8b8;
+ default:
+ return 0;
+ }
}
-static inline uint32_t format_pixman_to_wld(pixman_format_code_t format)
+static inline uint32_t
+format_pixman_to_wld(pixman_format_code_t format)
{
- switch (format)
- {
- case PIXMAN_a8r8g8b8:
- return WLD_FORMAT_ARGB8888;
- case PIXMAN_x8r8g8b8:
- return WLD_FORMAT_XRGB8888;
- default:
- return 0;
- }
+ switch (format) {
+ case PIXMAN_a8r8g8b8:
+ return WLD_FORMAT_ARGB8888;
+ case PIXMAN_x8r8g8b8:
+ return WLD_FORMAT_XRGB8888;
+ default:
+ return 0;
+ }
}
/**
* This default fill_region method is implemented in terms of fill_rectangle.
*/
-void default_fill_region(struct wld_renderer * renderer, uint32_t color,
- pixman_region32_t * region);
+void default_fill_region(struct wld_renderer *renderer, uint32_t color,
+ pixman_region32_t *region);
/**
* This default copy_region method is implemented in terms of copy_rectangle.
*/
-void default_copy_region(struct wld_renderer * renderer, struct buffer * buffer,
+void default_copy_region(struct wld_renderer *renderer, struct buffer *buffer,
int32_t dst_x, int32_t dst_y,
- pixman_region32_t * region);
+ pixman_region32_t *region);
-struct wld_surface * default_create_surface(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags);
+struct wld_surface *default_create_surface(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags);
-struct wld_surface * buffered_surface_create(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags,
- struct buffer_socket * socket);
+struct wld_surface *buffered_surface_create(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags,
+ struct buffer_socket *socket);
-void context_initialize(struct wld_context * context,
- const struct wld_context_impl * impl);
+void context_initialize(struct wld_context *context,
+ const struct wld_context_impl *impl);
-void renderer_initialize(struct wld_renderer * renderer,
- const struct wld_renderer_impl * impl);
+void renderer_initialize(struct wld_renderer *renderer,
+ const struct wld_renderer_impl *impl);
-void buffer_initialize(struct buffer * buffer,
- const struct wld_buffer_impl * impl,
+void buffer_initialize(struct buffer *buffer,
+ const struct wld_buffer_impl *impl,
uint32_t width, uint32_t height,
uint32_t format, uint32_t pitch);
-void surface_initialize(struct wld_surface * surface,
- const struct wld_surface_impl * impl);
+void surface_initialize(struct wld_surface *surface,
+ const struct wld_surface_impl *impl);
#endif
-
diff --git a/wld.h b/wld.h
@@ -24,85 +24,78 @@
#ifndef WLD_H
#define WLD_H
+#include <fontconfig/fontconfig.h>
+#include <pixman.h>
#include <stdbool.h>
#include <stdint.h>
-#include <pixman.h>
-#include <fontconfig/fontconfig.h>
#define WLD_USER_ID (0xff << 24)
-#define __WLD_FOURCC(a, b, c, d) ( (a) \
- | ((b) << 8) \
- | ((c) << 16) \
- | ((d) << 24) )
+#define __WLD_FOURCC(a, b, c, d) ((a) \
+ | ((b) << 8) \
+ | ((c) << 16) \
+ | ((d) << 24))
/**
* Supported pixel formats.
*
* These formats can safely be interchanged with GBM and wl_drm formats.
*/
-enum wld_format
-{
- WLD_FORMAT_XRGB8888 = __WLD_FOURCC('X', 'R', '2', '4'),
- WLD_FORMAT_ARGB8888 = __WLD_FOURCC('A', 'R', '2', '4')
+enum wld_format {
+ WLD_FORMAT_XRGB8888 = __WLD_FOURCC('X', 'R', '2', '4'),
+ WLD_FORMAT_ARGB8888 = __WLD_FOURCC('A', 'R', '2', '4')
};
-enum wld_flags
-{
- WLD_FLAG_MAP = 1 << 16,
- WLD_FLAG_CURSOR = 1 << 17,
+enum wld_flags {
+ WLD_FLAG_MAP = 1 << 16,
+ WLD_FLAG_CURSOR = 1 << 17,
};
-bool wld_lookup_named_color(const char * name, uint32_t * color);
+bool wld_lookup_named_color(const char *name, uint32_t *color);
/**** WLD Context ****/
-enum wld_object_type
-{
- WLD_OBJECT_DATA
+enum wld_object_type {
+ WLD_OBJECT_DATA
};
-union wld_object
-{
- void * ptr;
- uint32_t u32;
- int i;
+union wld_object {
+ void *ptr;
+ uint32_t u32;
+ int i;
};
-struct wld_context
-{
- const struct wld_context_impl * const impl;
+struct wld_context {
+ const struct wld_context_impl *const impl;
};
-struct wld_renderer * wld_create_renderer(struct wld_context * context);
+struct wld_renderer *wld_create_renderer(struct wld_context *context);
-struct wld_buffer * wld_create_buffer(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags);
+struct wld_buffer *wld_create_buffer(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags);
-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);
+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);
-struct wld_surface * wld_create_surface(struct wld_context * context,
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t flags);
+struct wld_surface *wld_create_surface(struct wld_context *context,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags);
-void wld_destroy_context(struct wld_context * context);
+void wld_destroy_context(struct wld_context *context);
/**** Font Handling ****/
-struct wld_extents
-{
- uint32_t advance;
+struct wld_extents {
+ uint32_t advance;
};
-struct wld_font
-{
- uint32_t ascent, descent;
- uint32_t height;
- uint32_t max_advance;
+struct wld_font {
+ uint32_t ascent, descent;
+ uint32_t height;
+ uint32_t max_advance;
};
/**
@@ -110,160 +103,155 @@ struct wld_font
*
* This sets up the underlying FreeType library.
*/
-struct wld_font_context * wld_font_create_context();
+struct wld_font_context *wld_font_create_context();
/**
* Destroy a font context.
*/
-void wld_font_destroy_context(struct wld_font_context * context);
+void wld_font_destroy_context(struct wld_font_context *context);
/**
* Open a new font from the given fontconfig match.
*/
-struct wld_font * wld_font_open_pattern(struct wld_font_context * context,
- FcPattern * match);
+struct wld_font *wld_font_open_pattern(struct wld_font_context *context,
+ FcPattern *match);
/**
* Open a new font from a fontconfig pattern string.
*/
-struct wld_font * wld_font_open_name(struct wld_font_context * context,
- const char * name);
+struct wld_font *wld_font_open_name(struct wld_font_context *context,
+ const char *name);
/**
* Close a font.
*/
-void wld_font_close(struct wld_font * font);
+void wld_font_close(struct wld_font *font);
/**
* Check if the given font has a particular character (in UTF-32), and if so,
* load the glyph.
*/
-bool wld_font_ensure_char(struct wld_font * font, uint32_t character);
+bool wld_font_ensure_char(struct wld_font *font, uint32_t character);
/**
* Calculate the text extents of the given UTF-8 string.
*
* @param length The maximum number of bytes in the string to process
*/
-void wld_font_text_extents_n(struct wld_font * font,
- const char * text, int32_t length,
- struct wld_extents * extents);
-
-static inline void wld_font_text_extents(struct wld_font * font,
- const char * text,
- struct wld_extents * extents)
+void wld_font_text_extents_n(struct wld_font *font,
+ const char *text, int32_t length,
+ struct wld_extents *extents);
+
+static inline void
+wld_font_text_extents(struct wld_font *font,
+ const char *text,
+ struct wld_extents *extents)
{
- wld_font_text_extents_n(font, text, INT32_MAX, extents);
+ wld_font_text_extents_n(font, text, INT32_MAX, extents);
}
/**** Buffers ****/
-struct wld_exporter
-{
- bool (* export)(struct wld_exporter * exporter, struct wld_buffer * buffer,
- uint32_t type, union wld_object * object);
- struct wld_exporter * next;
+struct wld_exporter {
+ bool (*export)(struct wld_exporter *exporter, struct wld_buffer *buffer,
+ uint32_t type, union wld_object *object);
+ struct wld_exporter *next;
};
-struct wld_destructor
-{
- void (* destroy)(struct wld_destructor * destructor);
- struct wld_destructor * next;
+struct wld_destructor {
+ void (*destroy)(struct wld_destructor *destructor);
+ struct wld_destructor *next;
};
-struct wld_buffer
-{
- const struct wld_buffer_impl * const impl;
+struct wld_buffer {
+ const struct wld_buffer_impl *const impl;
- uint32_t width, height, pitch;
- enum wld_format format;
- pixman_region32_t damage;
- void * map;
+ uint32_t width, height, pitch;
+ enum wld_format format;
+ pixman_region32_t damage;
+ void *map;
};
-bool wld_map(struct wld_buffer * buffer);
-bool wld_unmap(struct wld_buffer * buffer);
+bool wld_map(struct wld_buffer *buffer);
+bool wld_unmap(struct wld_buffer *buffer);
-bool wld_export(struct wld_buffer * buffer,
- uint32_t type, union wld_object * object);
+bool wld_export(struct wld_buffer *buffer,
+ uint32_t type, union wld_object *object);
-void wld_buffer_add_exporter(struct wld_buffer * buffer,
- struct wld_exporter * exporter);
+void wld_buffer_add_exporter(struct wld_buffer *buffer,
+ struct wld_exporter *exporter);
-void wld_buffer_add_destructor(struct wld_buffer * buffer,
- struct wld_destructor * destructor);
+void wld_buffer_add_destructor(struct wld_buffer *buffer,
+ struct wld_destructor *destructor);
/**
* Increase the reference count of a buffer.
*/
-void wld_buffer_reference(struct wld_buffer * buffer);
+void wld_buffer_reference(struct wld_buffer *buffer);
/**
* Decrease the reference count of a buffer.
*
* When the reference count drops to zero, the buffer will be destroyed.
*/
-void wld_buffer_unreference(struct wld_buffer * buffer);
+void wld_buffer_unreference(struct wld_buffer *buffer);
/**** Surfaces ****/
-struct wld_surface
-{
- const struct wld_surface_impl * const impl;
+struct wld_surface {
+ const struct wld_surface_impl *const impl;
};
-pixman_region32_t * wld_surface_damage(struct wld_surface * surface,
- pixman_region32_t * new_damage);
+pixman_region32_t *wld_surface_damage(struct wld_surface *surface,
+ pixman_region32_t *new_damage);
-struct wld_buffer * wld_surface_take(struct wld_surface * surface);
+struct wld_buffer *wld_surface_take(struct wld_surface *surface);
-void wld_surface_release(struct wld_surface * surface,
- struct wld_buffer * buffer);
+void wld_surface_release(struct wld_surface *surface,
+ struct wld_buffer *buffer);
-bool wld_swap(struct wld_surface * surface);
+bool wld_swap(struct wld_surface *surface);
-void wld_destroy_surface(struct wld_surface * surface);
+void wld_destroy_surface(struct wld_surface *surface);
/**** Renderers ****/
-struct wld_renderer
-{
- const struct wld_renderer_impl * const impl;
- struct wld_buffer * target;
+struct wld_renderer {
+ const struct wld_renderer_impl *const impl;
+ struct wld_buffer *target;
};
-enum wld_capability
-{
- WLD_CAPABILITY_READ = 1<<0,
- WLD_CAPABILITY_WRITE = 1<<1,
+enum wld_capability {
+ WLD_CAPABILITY_READ = 1 << 0,
+ WLD_CAPABILITY_WRITE = 1 << 1,
};
-void wld_destroy_renderer(struct wld_renderer * renderer);
+void wld_destroy_renderer(struct wld_renderer *renderer);
-uint32_t wld_capabilities(struct wld_renderer * renderer,
- struct wld_buffer * buffer);
+uint32_t wld_capabilities(struct wld_renderer *renderer,
+ struct wld_buffer *buffer);
-bool wld_set_target_buffer(struct wld_renderer * renderer,
- struct wld_buffer * buffer);
+bool wld_set_target_buffer(struct wld_renderer *renderer,
+ struct wld_buffer *buffer);
-bool wld_set_target_surface(struct wld_renderer * renderer,
- struct wld_surface * surface);
+bool wld_set_target_surface(struct wld_renderer *renderer,
+ struct wld_surface *surface);
-void wld_fill_rectangle(struct wld_renderer * renderer, uint32_t color,
+void wld_fill_rectangle(struct wld_renderer *renderer, uint32_t color,
int32_t x, int32_t y, uint32_t width, uint32_t height);
-void wld_fill_region(struct wld_renderer * renderer, uint32_t color,
- pixman_region32_t * region);
+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_buffer * buffer,
+void wld_copy_rectangle(struct wld_renderer *renderer,
+ 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_buffer * buffer,
- int32_t dst_x, int32_t dst_y, pixman_region32_t * region);
+void wld_copy_region(struct wld_renderer *renderer,
+ 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 buffer.
@@ -273,12 +261,11 @@ void wld_copy_region(struct wld_renderer * renderer,
* @param extents If not NULL, will be initialized to the extents of the
* drawn text
*/
-void wld_draw_text(struct wld_renderer * renderer,
- struct wld_font * font, uint32_t color,
- int32_t x, int32_t y, const char * text, uint32_t length,
- struct wld_extents * extents);
+void wld_draw_text(struct wld_renderer *renderer,
+ struct wld_font *font, uint32_t color,
+ int32_t x, int32_t y, const char *text, uint32_t length,
+ struct wld_extents *extents);
-void wld_flush(struct wld_renderer * renderer);
+void wld_flush(struct wld_renderer *renderer);
#endif
-