commit 81232b2

Michael Forney  ·  2019-07-11 03:55:25 +0000 UTC
parent 0da359a
Reformat with clang-format
32 files changed,  +3819, -3816
M drm.c
M drm.h
M dumb.c
M font.c
M wld.h
+72, -68
  1@@ -23,115 +23,119 @@
  2 
  3 #include "wld-private.h"
  4 
  5-void buffer_initialize(struct buffer * buffer,
  6-                       const struct wld_buffer_impl * impl,
  7-                       uint32_t width, uint32_t height,
  8-                       uint32_t format, uint32_t pitch)
  9+void
 10+buffer_initialize(struct buffer *buffer,
 11+                  const struct wld_buffer_impl *impl,
 12+                  uint32_t width, uint32_t height,
 13+                  uint32_t format, uint32_t pitch)
 14 {
 15-    *((const struct wld_buffer_impl **) &buffer->base.impl) = impl;
 16-    buffer->base.width = width;
 17-    buffer->base.height = height;
 18-    buffer->base.format = format;
 19-    buffer->base.pitch = pitch;
 20-    buffer->base.map = NULL;
 21-    buffer->references = 1;
 22-    buffer->map_references = 0;
 23-    buffer->exporters = NULL;
 24-    buffer->destructors = NULL;
 25-    pixman_region32_init_rect(&buffer->base.damage, 0, 0, width, height);
 26+	*((const struct wld_buffer_impl **)&buffer->base.impl) = impl;
 27+	buffer->base.width = width;
 28+	buffer->base.height = height;
 29+	buffer->base.format = format;
 30+	buffer->base.pitch = pitch;
 31+	buffer->base.map = NULL;
 32+	buffer->references = 1;
 33+	buffer->map_references = 0;
 34+	buffer->exporters = NULL;
 35+	buffer->destructors = NULL;
 36+	pixman_region32_init_rect(&buffer->base.damage, 0, 0, width, height);
 37 }
 38 
 39 EXPORT
 40-bool wld_map(struct wld_buffer * base)
 41+bool
 42+wld_map(struct wld_buffer *base)
 43 {
 44-    struct buffer * buffer = (void *) base;
 45+	struct buffer *buffer = (void *)base;
 46 
 47-    if (buffer->map_references == 0 && !buffer->base.impl->map(buffer))
 48-        return false;
 49+	if (buffer->map_references == 0 && !buffer->base.impl->map(buffer))
 50+		return false;
 51 
 52-    ++buffer->map_references;
 53-    return true;
 54+	++buffer->map_references;
 55+	return true;
 56 }
 57 
 58 EXPORT
 59-bool wld_unmap(struct wld_buffer * base)
 60+bool
 61+wld_unmap(struct wld_buffer *base)
 62 {
 63-    struct buffer * buffer = (void *) base;
 64+	struct buffer *buffer = (void *)base;
 65 
 66-    if (buffer->map_references == 0
 67-        || (buffer->map_references == 1 && !buffer->base.impl->unmap(buffer)))
 68-    {
 69-        return false;
 70-    }
 71+	if (buffer->map_references == 0
 72+	    || (buffer->map_references == 1 && !buffer->base.impl->unmap(buffer))) {
 73+		return false;
 74+	}
 75 
 76-    --buffer->map_references;
 77-    return true;
 78+	--buffer->map_references;
 79+	return true;
 80 }
 81 
 82 EXPORT
 83-bool wld_export(struct wld_buffer * base,
 84-                uint32_t type, union wld_object * object)
 85+bool
 86+wld_export(struct wld_buffer *base,
 87+           uint32_t type, union wld_object *object)
 88 {
 89-    struct buffer * buffer = (void *) base;
 90-    struct wld_exporter * exporter;
 91+	struct buffer *buffer = (void *)base;
 92+	struct wld_exporter *exporter;
 93 
 94-    for (exporter = buffer->exporters; exporter; exporter = exporter->next)
 95-    {
 96-        if (exporter->export(exporter, &buffer->base, type, object))
 97-            return true;
 98-    }
 99+	for (exporter = buffer->exporters; exporter; exporter = exporter->next) {
100+		if (exporter->export(exporter, &buffer->base, type, object))
101+			return true;
102+	}
103 
104-    return false;
105+	return false;
106 }
107 
108 EXPORT
109-void wld_buffer_add_exporter(struct wld_buffer * base,
110-                             struct wld_exporter * exporter)
111+void
112+wld_buffer_add_exporter(struct wld_buffer *base,
113+                        struct wld_exporter *exporter)
114 {
115-    struct buffer * buffer = (void *) base;
116+	struct buffer *buffer = (void *)base;
117 
118-    exporter->next = buffer->exporters;
119-    buffer->exporters = exporter;
120+	exporter->next = buffer->exporters;
121+	buffer->exporters = exporter;
122 }
123 
124 EXPORT
125-void wld_buffer_add_destructor(struct wld_buffer * base,
126-                               struct wld_destructor * destructor)
127+void
128+wld_buffer_add_destructor(struct wld_buffer *base,
129+                          struct wld_destructor *destructor)
130 {
131-    struct buffer * buffer = (void *) base;
132+	struct buffer *buffer = (void *)base;
133 
134-    destructor->next = buffer->destructors;
135-    buffer->destructors = destructor;
136+	destructor->next = buffer->destructors;
137+	buffer->destructors = destructor;
138 }
139 
140 EXPORT
141-void wld_buffer_reference(struct wld_buffer * base)
142+void
143+wld_buffer_reference(struct wld_buffer *base)
144 {
145-    struct buffer * buffer = (void *) base;
146+	struct buffer *buffer = (void *)base;
147 
148-    ++buffer->references;
149+	++buffer->references;
150 }
151 
152 EXPORT
153-void wld_buffer_unreference(struct wld_buffer * base)
154+void
155+wld_buffer_unreference(struct wld_buffer *base)
156 {
157-    struct buffer * buffer = (void *) base;
158-    struct wld_destructor * destructor, * next;
159+	struct buffer *buffer = (void *)base;
160+	struct wld_destructor *destructor, *next;
161 
162-    if (--buffer->references > 0)
163-        return;
164+	if (--buffer->references > 0)
165+		return;
166 
167-    pixman_region32_fini(&buffer->base.damage);
168+	pixman_region32_fini(&buffer->base.damage);
169 
170-    for (destructor = buffer->destructors; destructor; destructor = next)
171-    {
172-        next = destructor->next;
173-        destructor->destroy(destructor);
174-    }
175+	for (destructor = buffer->destructors; destructor; destructor = next) {
176+		next = destructor->next;
177+		destructor->destroy(destructor);
178+	}
179 
180-    if (buffer->map_references > 0)
181-        buffer->base.impl->unmap(buffer);
182+	if (buffer->map_references > 0)
183+		buffer->base.impl->unmap(buffer);
184 
185-    buffer->base.impl->destroy(buffer);
186+	buffer->base.impl->destroy(buffer);
187 }
188-
+153, -158
  1@@ -26,199 +26,194 @@
  2 #include "interface/surface.h"
  3 IMPL(buffered_surface, wld_surface)
  4 
  5-struct buffer_entry
  6-{
  7-    struct buffer * buffer;
  8-    bool busy;
  9+struct buffer_entry {
 10+	struct buffer *buffer;
 11+	bool busy;
 12 };
 13 
 14-struct buffered_surface
 15-{
 16-    struct wld_surface base;
 17+struct buffered_surface {
 18+	struct wld_surface base;
 19 
 20-    struct wld_context * context;
 21-    struct buffer_entry * entries, * back;
 22-    unsigned entries_size, entries_capacity;
 23+	struct wld_context *context;
 24+	struct buffer_entry *entries, *back;
 25+	unsigned entries_size, entries_capacity;
 26 
 27-    struct buffer_socket * buffer_socket;
 28+	struct buffer_socket *buffer_socket;
 29 
 30-    uint32_t width, height;
 31-    enum wld_format format;
 32-    uint32_t flags;
 33+	uint32_t width, height;
 34+	enum wld_format format;
 35+	uint32_t flags;
 36 };
 37 
 38-struct wld_surface * buffered_surface_create
 39-    (struct wld_context * context, uint32_t width, uint32_t height,
 40-     uint32_t format, uint32_t flags, struct buffer_socket * buffer_socket)
 41+struct wld_surface *
 42+buffered_surface_create(struct wld_context *context, uint32_t width, uint32_t height,
 43+                        uint32_t format, uint32_t flags, struct buffer_socket *buffer_socket)
 44 {
 45-    struct buffered_surface * surface;
 46-
 47-    if (!(surface = malloc(sizeof *surface)))
 48-        return NULL;
 49-
 50-    surface_initialize(&surface->base, &wld_surface_impl);
 51-    surface->context = context;
 52-    surface->entries = NULL;
 53-    surface->back = NULL;
 54-    surface->entries_size = 0;
 55-    surface->entries_capacity = 0;
 56-    surface->buffer_socket = buffer_socket;
 57-    surface->width = width;
 58-    surface->height = height;
 59-    surface->format = format;
 60-    surface->flags = flags;
 61-
 62-    return &surface->base;
 63+	struct buffered_surface *surface;
 64+
 65+	if (!(surface = malloc(sizeof *surface)))
 66+		return NULL;
 67+
 68+	surface_initialize(&surface->base, &wld_surface_impl);
 69+	surface->context = context;
 70+	surface->entries = NULL;
 71+	surface->back = NULL;
 72+	surface->entries_size = 0;
 73+	surface->entries_capacity = 0;
 74+	surface->buffer_socket = buffer_socket;
 75+	surface->width = width;
 76+	surface->height = height;
 77+	surface->format = format;
 78+	surface->flags = flags;
 79+
 80+	return &surface->base;
 81 }
 82 
 83-pixman_region32_t * surface_damage(struct wld_surface * base,
 84-                                   pixman_region32_t * new_damage)
 85+pixman_region32_t *
 86+surface_damage(struct wld_surface *base,
 87+               pixman_region32_t *new_damage)
 88 {
 89-    struct buffered_surface * surface = buffered_surface(base);
 90-    struct buffer * back_buffer;
 91-    unsigned index;
 92-
 93-    if (pixman_region32_not_empty(new_damage))
 94-    {
 95-        for (index = 0; index < surface->entries_size; ++index)
 96-        {
 97-            pixman_region32_union(&surface->entries[index].buffer->base.damage,
 98-                                  &surface->entries[index].buffer->base.damage,
 99-                                  new_damage);
100-        }
101-    }
102-
103-    if (!(back_buffer = surface_back(base)))
104-        return NULL;
105-
106-    return &back_buffer->base.damage;
107+	struct buffered_surface *surface = buffered_surface(base);
108+	struct buffer *back_buffer;
109+	unsigned index;
110+
111+	if (pixman_region32_not_empty(new_damage)) {
112+		for (index = 0; index < surface->entries_size; ++index) {
113+			pixman_region32_union(&surface->entries[index].buffer->base.damage,
114+			                      &surface->entries[index].buffer->base.damage,
115+			                      new_damage);
116+		}
117+	}
118+
119+	if (!(back_buffer = surface_back(base)))
120+		return NULL;
121+
122+	return &back_buffer->base.damage;
123 }
124 
125-struct buffer * surface_back(struct wld_surface * base)
126+struct buffer *
127+surface_back(struct wld_surface *base)
128 {
129-    struct buffered_surface * surface = buffered_surface(base);
130-    unsigned index;
131-
132-    if (surface->back)
133-        return surface->back->buffer;
134-
135-    /* The buffer socket may need to process any incoming buffer releases. */
136-    if (surface->buffer_socket)
137-        surface->buffer_socket->impl->process(surface->buffer_socket);
138-
139-    for (index = 0; index < surface->entries_size; ++index)
140-    {
141-        if (!surface->entries[index].busy)
142-        {
143-            surface->back = &surface->entries[index];
144-            return surface->back->buffer;
145-        }
146-    }
147-
148-    /* If there are no free buffers, we need to allocate another one. */
149-    struct buffer * buffer;
150-
151-    buffer = surface->context->impl->create_buffer
152-        (surface->context, surface->width, surface->height,
153-         surface->format, surface->flags);
154-
155-    if (!buffer)
156-        goto error0;
157-
158-    if (surface->entries_size == surface->entries_capacity)
159-    {
160-        struct buffer_entry * new_entries;
161-        size_t new_capacity = surface->entries_capacity * 2 + 1;
162-
163-        new_entries = realloc(surface->entries,
164-                              new_capacity * sizeof surface->entries[0]);
165-
166-        if (!new_entries)
167-            goto error1;
168-
169-        surface->entries = new_entries;
170-        surface->entries_capacity = new_capacity;
171-    }
172-
173-    surface->back = &surface->entries[surface->entries_size++];
174-    *surface->back = (struct buffer_entry) {
175-        .buffer = buffer,
176-        .busy = false
177-    };
178-
179-    return buffer;
180-
181-  error1:
182-    wld_buffer_unreference(&buffer->base);
183-  error0:
184-    return NULL;
185+	struct buffered_surface *surface = buffered_surface(base);
186+	unsigned index;
187+
188+	if (surface->back)
189+		return surface->back->buffer;
190+
191+	/* The buffer socket may need to process any incoming buffer releases. */
192+	if (surface->buffer_socket)
193+		surface->buffer_socket->impl->process(surface->buffer_socket);
194+
195+	for (index = 0; index < surface->entries_size; ++index) {
196+		if (!surface->entries[index].busy) {
197+			surface->back = &surface->entries[index];
198+			return surface->back->buffer;
199+		}
200+	}
201+
202+	/* If there are no free buffers, we need to allocate another one. */
203+	struct buffer *buffer;
204+
205+	buffer = surface->context->impl->create_buffer(surface->context, surface->width, surface->height,
206+	                                               surface->format, surface->flags);
207+
208+	if (!buffer)
209+		goto error0;
210+
211+	if (surface->entries_size == surface->entries_capacity) {
212+		struct buffer_entry *new_entries;
213+		size_t new_capacity = surface->entries_capacity * 2 + 1;
214+
215+		new_entries = realloc(surface->entries,
216+		                      new_capacity * sizeof surface->entries[0]);
217+
218+		if (!new_entries)
219+			goto error1;
220+
221+		surface->entries = new_entries;
222+		surface->entries_capacity = new_capacity;
223+	}
224+
225+	surface->back = &surface->entries[surface->entries_size++];
226+	*surface->back = (struct buffer_entry){
227+		.buffer = buffer,
228+		.busy = false
229+	};
230+
231+	return buffer;
232+
233+error1:
234+	wld_buffer_unreference(&buffer->base);
235+error0:
236+	return NULL;
237 }
238 
239-struct buffer * surface_take(struct wld_surface * base)
240+struct buffer *
241+surface_take(struct wld_surface *base)
242 {
243-    struct buffered_surface * surface = buffered_surface(base);
244-    struct buffer * buffer;
245+	struct buffered_surface *surface = buffered_surface(base);
246+	struct buffer *buffer;
247 
248-    if (!(buffer = surface_back(base)))
249-        return NULL;
250+	if (!(buffer = surface_back(base)))
251+		return NULL;
252 
253-    surface->back->busy = true;
254-    surface->back = NULL;
255-    pixman_region32_clear(&buffer->base.damage);
256+	surface->back->busy = true;
257+	surface->back = NULL;
258+	pixman_region32_clear(&buffer->base.damage);
259 
260-    return buffer;
261+	return buffer;
262 }
263 
264-bool surface_release(struct wld_surface * base, struct buffer * buffer)
265+bool
266+surface_release(struct wld_surface *base, struct buffer *buffer)
267 {
268-    struct buffered_surface * surface = buffered_surface(base);
269-    unsigned index;
270-
271-    for (index = 0; index < surface->entries_size; ++index)
272-    {
273-        if (surface->entries[index].buffer == buffer)
274-        {
275-            surface->entries[index].busy = false;
276-            return true;
277-        }
278-    }
279-
280-    return false;
281+	struct buffered_surface *surface = buffered_surface(base);
282+	unsigned index;
283+
284+	for (index = 0; index < surface->entries_size; ++index) {
285+		if (surface->entries[index].buffer == buffer) {
286+			surface->entries[index].busy = false;
287+			return true;
288+		}
289+	}
290+
291+	return false;
292 }
293 
294-bool surface_swap(struct wld_surface * base)
295+bool
296+surface_swap(struct wld_surface *base)
297 {
298-    struct buffered_surface * surface = buffered_surface(base);
299-    struct buffer * buffer;
300+	struct buffered_surface *surface = buffered_surface(base);
301+	struct buffer *buffer;
302 
303-    if (!surface->buffer_socket)
304-        return false;
305+	if (!surface->buffer_socket)
306+		return false;
307 
308-    if (!(buffer = surface_back(base)))
309-        return false;
310+	if (!(buffer = surface_back(base)))
311+		return false;
312 
313-    if (!surface->buffer_socket->impl->attach(surface->buffer_socket, buffer))
314-        return false;
315+	if (!surface->buffer_socket->impl->attach(surface->buffer_socket, buffer))
316+		return false;
317 
318-    surface->back->busy = true;
319-    surface->back = NULL;
320-    pixman_region32_clear(&buffer->base.damage);
321+	surface->back->busy = true;
322+	surface->back = NULL;
323+	pixman_region32_clear(&buffer->base.damage);
324 
325-    return true;
326+	return true;
327 }
328 
329-void surface_destroy(struct wld_surface * base)
330+void
331+surface_destroy(struct wld_surface *base)
332 {
333-    struct buffered_surface * surface = buffered_surface(base);
334-    unsigned index;
335+	struct buffered_surface *surface = buffered_surface(base);
336+	unsigned index;
337 
338-    if (surface->buffer_socket)
339-        surface->buffer_socket->impl->destroy(surface->buffer_socket);
340+	if (surface->buffer_socket)
341+		surface->buffer_socket->impl->destroy(surface->buffer_socket);
342 
343-    for (index = 0; index < surface->entries_size; ++index)
344-        wld_buffer_unreference(&surface->entries[index].buffer->base);
345+	for (index = 0; index < surface->entries_size; ++index)
346+		wld_buffer_unreference(&surface->entries[index].buffer->base);
347 
348-    free(surface->entries);
349-    free(surface);
350+	free(surface->entries);
351+	free(surface);
352 }
353-
+780, -784
   1@@ -50,801 +50,797 @@ SOFTWARE.
   2 
   3 #include <strings.h>
   4 
   5-struct named_color
   6-{
   7-    const char * name;
   8-    uint32_t color;
   9+struct named_color {
  10+	const char *name;
  11+	uint32_t color;
  12 };
  13 
  14 static const struct named_color named_colors[] = {
  15-    { "alice blue",             0xfff0f8ff },
  16-    { "AliceBlue",              0xfff0f8ff },
  17-    { "antique white",          0xfffaebd7 },
  18-    { "AntiqueWhite",           0xfffaebd7 },
  19-    { "AntiqueWhite1",          0xffffefdb },
  20-    { "AntiqueWhite2",          0xffeedfcc },
  21-    { "AntiqueWhite3",          0xffcdc0b0 },
  22-    { "AntiqueWhite4",          0xff8b8378 },
  23-    { "aquamarine",             0xff7fffd4 },
  24-    { "aquamarine1",            0xff7fffd4 },
  25-    { "aquamarine2",            0xff76eec6 },
  26-    { "aquamarine3",            0xff66cdaa },
  27-    { "aquamarine4",            0xff458b74 },
  28-    { "azure",                  0xfff0ffff },
  29-    { "azure1",                 0xfff0ffff },
  30-    { "azure2",                 0xffe0eeee },
  31-    { "azure3",                 0xffc1cdcd },
  32-    { "azure4",                 0xff838b8b },
  33-    { "beige",                  0xfff5f5dc },
  34-    { "bisque",                 0xffffe4c4 },
  35-    { "bisque1",                0xffffe4c4 },
  36-    { "bisque2",                0xffeed5b7 },
  37-    { "bisque3",                0xffcdb79e },
  38-    { "bisque4",                0xff8b7d6b },
  39-    { "black",                  0xff000000 },
  40-    { "blanched almond",        0xffffebcd },
  41-    { "BlanchedAlmond",         0xffffebcd },
  42-    { "blue",                   0xff0000ff },
  43-    { "blue violet",            0xff8a2be2 },
  44-    { "blue1",                  0xff0000ff },
  45-    { "blue2",                  0xff0000ee },
  46-    { "blue3",                  0xff0000cd },
  47-    { "blue4",                  0xff00008b },
  48-    { "BlueViolet",             0xff8a2be2 },
  49-    { "brown",                  0xffa52a2a },
  50-    { "brown1",                 0xffff4040 },
  51-    { "brown2",                 0xffee3b3b },
  52-    { "brown3",                 0xffcd3333 },
  53-    { "brown4",                 0xff8b2323 },
  54-    { "burlywood",              0xffdeb887 },
  55-    { "burlywood1",             0xffffd39b },
  56-    { "burlywood2",             0xffeec591 },
  57-    { "burlywood3",             0xffcdaa7d },
  58-    { "burlywood4",             0xff8b7355 },
  59-    { "cadet blue",             0xff5f9ea0 },
  60-    { "CadetBlue",              0xff5f9ea0 },
  61-    { "CadetBlue1",             0xff98f5ff },
  62-    { "CadetBlue2",             0xff8ee5ee },
  63-    { "CadetBlue3",             0xff7ac5cd },
  64-    { "CadetBlue4",             0xff53868b },
  65-    { "chartreuse",             0xff7fff00 },
  66-    { "chartreuse1",            0xff7fff00 },
  67-    { "chartreuse2",            0xff76ee00 },
  68-    { "chartreuse3",            0xff66cd00 },
  69-    { "chartreuse4",            0xff458b00 },
  70-    { "chocolate",              0xffd2691e },
  71-    { "chocolate1",             0xffff7f24 },
  72-    { "chocolate2",             0xffee7621 },
  73-    { "chocolate3",             0xffcd661d },
  74-    { "chocolate4",             0xff8b4513 },
  75-    { "coral",                  0xffff7f50 },
  76-    { "coral1",                 0xffff7256 },
  77-    { "coral2",                 0xffee6a50 },
  78-    { "coral3",                 0xffcd5b45 },
  79-    { "coral4",                 0xff8b3e2f },
  80-    { "cornflower blue",        0xff6495ed },
  81-    { "CornflowerBlue",         0xff6495ed },
  82-    { "cornsilk",               0xfffff8dc },
  83-    { "cornsilk1",              0xfffff8dc },
  84-    { "cornsilk2",              0xffeee8cd },
  85-    { "cornsilk3",              0xffcdc8b1 },
  86-    { "cornsilk4",              0xff8b8878 },
  87-    { "cyan",                   0xff00ffff },
  88-    { "cyan1",                  0xff00ffff },
  89-    { "cyan2",                  0xff00eeee },
  90-    { "cyan3",                  0xff00cdcd },
  91-    { "cyan4",                  0xff008b8b },
  92-    { "dark blue",              0xff00008b },
  93-    { "dark cyan",              0xff008b8b },
  94-    { "dark goldenrod",         0xffb8860b },
  95-    { "dark gray",              0xffa9a9a9 },
  96-    { "dark green",             0xff006400 },
  97-    { "dark grey",              0xffa9a9a9 },
  98-    { "dark khaki",             0xffbdb76b },
  99-    { "dark magenta",           0xff8b008b },
 100-    { "dark olive green",       0xff556b2f },
 101-    { "dark orange",            0xffff8c00 },
 102-    { "dark orchid",            0xff9932cc },
 103-    { "dark red",               0xff8b0000 },
 104-    { "dark salmon",            0xffe9967a },
 105-    { "dark sea green",         0xff8fbc8f },
 106-    { "dark slate blue",        0xff483d8b },
 107-    { "dark slate gray",        0xff2f4f4f },
 108-    { "dark slate grey",        0xff2f4f4f },
 109-    { "dark turquoise",         0xff00ced1 },
 110-    { "dark violet",            0xff9400d3 },
 111-    { "DarkBlue",               0xff00008b },
 112-    { "DarkCyan",               0xff008b8b },
 113-    { "DarkGoldenrod",          0xffb8860b },
 114-    { "DarkGoldenrod1",         0xffffb90f },
 115-    { "DarkGoldenrod2",         0xffeead0e },
 116-    { "DarkGoldenrod3",         0xffcd950c },
 117-    { "DarkGoldenrod4",         0xff8b6508 },
 118-    { "DarkGray",               0xffa9a9a9 },
 119-    { "DarkGreen",              0xff006400 },
 120-    { "DarkGrey",               0xffa9a9a9 },
 121-    { "DarkKhaki",              0xffbdb76b },
 122-    { "DarkMagenta",            0xff8b008b },
 123-    { "DarkOliveGreen",         0xff556b2f },
 124-    { "DarkOliveGreen1",        0xffcaff70 },
 125-    { "DarkOliveGreen2",        0xffbcee68 },
 126-    { "DarkOliveGreen3",        0xffa2cd5a },
 127-    { "DarkOliveGreen4",        0xff6e8b3d },
 128-    { "DarkOrange",             0xffff8c00 },
 129-    { "DarkOrange1",            0xffff7f00 },
 130-    { "DarkOrange2",            0xffee7600 },
 131-    { "DarkOrange3",            0xffcd6600 },
 132-    { "DarkOrange4",            0xff8b4500 },
 133-    { "DarkOrchid",             0xff9932cc },
 134-    { "DarkOrchid1",            0xffbf3eff },
 135-    { "DarkOrchid2",            0xffb23aee },
 136-    { "DarkOrchid3",            0xff9a32cd },
 137-    { "DarkOrchid4",            0xff68228b },
 138-    { "DarkRed",                0xff8b0000 },
 139-    { "DarkSalmon",             0xffe9967a },
 140-    { "DarkSeaGreen",           0xff8fbc8f },
 141-    { "DarkSeaGreen1",          0xffc1ffc1 },
 142-    { "DarkSeaGreen2",          0xffb4eeb4 },
 143-    { "DarkSeaGreen3",          0xff9bcd9b },
 144-    { "DarkSeaGreen4",          0xff698b69 },
 145-    { "DarkSlateBlue",          0xff483d8b },
 146-    { "DarkSlateGray",          0xff2f4f4f },
 147-    { "DarkSlateGray1",         0xff97ffff },
 148-    { "DarkSlateGray2",         0xff8deeee },
 149-    { "DarkSlateGray3",         0xff79cdcd },
 150-    { "DarkSlateGray4",         0xff528b8b },
 151-    { "DarkSlateGrey",          0xff2f4f4f },
 152-    { "DarkTurquoise",          0xff00ced1 },
 153-    { "DarkViolet",             0xff9400d3 },
 154-    { "deep pink",              0xffff1493 },
 155-    { "deep sky blue",          0xff00bfff },
 156-    { "DeepPink",               0xffff1493 },
 157-    { "DeepPink1",              0xffff1493 },
 158-    { "DeepPink2",              0xffee1289 },
 159-    { "DeepPink3",              0xffcd1076 },
 160-    { "DeepPink4",              0xff8b0a50 },
 161-    { "DeepSkyBlue",            0xff00bfff },
 162-    { "DeepSkyBlue1",           0xff00bfff },
 163-    { "DeepSkyBlue2",           0xff00b2ee },
 164-    { "DeepSkyBlue3",           0xff009acd },
 165-    { "DeepSkyBlue4",           0xff00688b },
 166-    { "dim gray",               0xff696969 },
 167-    { "dim grey",               0xff696969 },
 168-    { "DimGray",                0xff696969 },
 169-    { "DimGrey",                0xff696969 },
 170-    { "dodger blue",            0xff1e90ff },
 171-    { "DodgerBlue",             0xff1e90ff },
 172-    { "DodgerBlue1",            0xff1e90ff },
 173-    { "DodgerBlue2",            0xff1c86ee },
 174-    { "DodgerBlue3",            0xff1874cd },
 175-    { "DodgerBlue4",            0xff104e8b },
 176-    { "firebrick",              0xffb22222 },
 177-    { "firebrick1",             0xffff3030 },
 178-    { "firebrick2",             0xffee2c2c },
 179-    { "firebrick3",             0xffcd2626 },
 180-    { "firebrick4",             0xff8b1a1a },
 181-    { "floral white",           0xfffffaf0 },
 182-    { "FloralWhite",            0xfffffaf0 },
 183-    { "forest green",           0xff228b22 },
 184-    { "ForestGreen",            0xff228b22 },
 185-    { "gainsboro",              0xffdcdcdc },
 186-    { "ghost white",            0xfff8f8ff },
 187-    { "GhostWhite",             0xfff8f8ff },
 188-    { "gold",                   0xffffd700 },
 189-    { "gold1",                  0xffffd700 },
 190-    { "gold2",                  0xffeec900 },
 191-    { "gold3",                  0xffcdad00 },
 192-    { "gold4",                  0xff8b7500 },
 193-    { "goldenrod",              0xffdaa520 },
 194-    { "goldenrod1",             0xffffc125 },
 195-    { "goldenrod2",             0xffeeb422 },
 196-    { "goldenrod3",             0xffcd9b1d },
 197-    { "goldenrod4",             0xff8b6914 },
 198-    { "gray",                   0xffbebebe },
 199-    { "gray0",                  0xff000000 },
 200-    { "gray1",                  0xff030303 },
 201-    { "gray10",                 0xff1a1a1a },
 202-    { "gray100",                0xffffffff },
 203-    { "gray11",                 0xff1c1c1c },
 204-    { "gray12",                 0xff1f1f1f },
 205-    { "gray13",                 0xff212121 },
 206-    { "gray14",                 0xff242424 },
 207-    { "gray15",                 0xff262626 },
 208-    { "gray16",                 0xff292929 },
 209-    { "gray17",                 0xff2b2b2b },
 210-    { "gray18",                 0xff2e2e2e },
 211-    { "gray19",                 0xff303030 },
 212-    { "gray2",                  0xff050505 },
 213-    { "gray20",                 0xff333333 },
 214-    { "gray21",                 0xff363636 },
 215-    { "gray22",                 0xff383838 },
 216-    { "gray23",                 0xff3b3b3b },
 217-    { "gray24",                 0xff3d3d3d },
 218-    { "gray25",                 0xff404040 },
 219-    { "gray26",                 0xff424242 },
 220-    { "gray27",                 0xff454545 },
 221-    { "gray28",                 0xff474747 },
 222-    { "gray29",                 0xff4a4a4a },
 223-    { "gray3",                  0xff080808 },
 224-    { "gray30",                 0xff4d4d4d },
 225-    { "gray31",                 0xff4f4f4f },
 226-    { "gray32",                 0xff525252 },
 227-    { "gray33",                 0xff545454 },
 228-    { "gray34",                 0xff575757 },
 229-    { "gray35",                 0xff595959 },
 230-    { "gray36",                 0xff5c5c5c },
 231-    { "gray37",                 0xff5e5e5e },
 232-    { "gray38",                 0xff616161 },
 233-    { "gray39",                 0xff636363 },
 234-    { "gray4",                  0xff0a0a0a },
 235-    { "gray40",                 0xff666666 },
 236-    { "gray41",                 0xff696969 },
 237-    { "gray42",                 0xff6b6b6b },
 238-    { "gray43",                 0xff6e6e6e },
 239-    { "gray44",                 0xff707070 },
 240-    { "gray45",                 0xff737373 },
 241-    { "gray46",                 0xff757575 },
 242-    { "gray47",                 0xff787878 },
 243-    { "gray48",                 0xff7a7a7a },
 244-    { "gray49",                 0xff7d7d7d },
 245-    { "gray5",                  0xff0d0d0d },
 246-    { "gray50",                 0xff7f7f7f },
 247-    { "gray51",                 0xff828282 },
 248-    { "gray52",                 0xff858585 },
 249-    { "gray53",                 0xff878787 },
 250-    { "gray54",                 0xff8a8a8a },
 251-    { "gray55",                 0xff8c8c8c },
 252-    { "gray56",                 0xff8f8f8f },
 253-    { "gray57",                 0xff919191 },
 254-    { "gray58",                 0xff949494 },
 255-    { "gray59",                 0xff969696 },
 256-    { "gray6",                  0xff0f0f0f },
 257-    { "gray60",                 0xff999999 },
 258-    { "gray61",                 0xff9c9c9c },
 259-    { "gray62",                 0xff9e9e9e },
 260-    { "gray63",                 0xffa1a1a1 },
 261-    { "gray64",                 0xffa3a3a3 },
 262-    { "gray65",                 0xffa6a6a6 },
 263-    { "gray66",                 0xffa8a8a8 },
 264-    { "gray67",                 0xffababab },
 265-    { "gray68",                 0xffadadad },
 266-    { "gray69",                 0xffb0b0b0 },
 267-    { "gray7",                  0xff121212 },
 268-    { "gray70",                 0xffb3b3b3 },
 269-    { "gray71",                 0xffb5b5b5 },
 270-    { "gray72",                 0xffb8b8b8 },
 271-    { "gray73",                 0xffbababa },
 272-    { "gray74",                 0xffbdbdbd },
 273-    { "gray75",                 0xffbfbfbf },
 274-    { "gray76",                 0xffc2c2c2 },
 275-    { "gray77",                 0xffc4c4c4 },
 276-    { "gray78",                 0xffc7c7c7 },
 277-    { "gray79",                 0xffc9c9c9 },
 278-    { "gray8",                  0xff141414 },
 279-    { "gray80",                 0xffcccccc },
 280-    { "gray81",                 0xffcfcfcf },
 281-    { "gray82",                 0xffd1d1d1 },
 282-    { "gray83",                 0xffd4d4d4 },
 283-    { "gray84",                 0xffd6d6d6 },
 284-    { "gray85",                 0xffd9d9d9 },
 285-    { "gray86",                 0xffdbdbdb },
 286-    { "gray87",                 0xffdedede },
 287-    { "gray88",                 0xffe0e0e0 },
 288-    { "gray89",                 0xffe3e3e3 },
 289-    { "gray9",                  0xff171717 },
 290-    { "gray90",                 0xffe5e5e5 },
 291-    { "gray91",                 0xffe8e8e8 },
 292-    { "gray92",                 0xffebebeb },
 293-    { "gray93",                 0xffededed },
 294-    { "gray94",                 0xfff0f0f0 },
 295-    { "gray95",                 0xfff2f2f2 },
 296-    { "gray96",                 0xfff5f5f5 },
 297-    { "gray97",                 0xfff7f7f7 },
 298-    { "gray98",                 0xfffafafa },
 299-    { "gray99",                 0xfffcfcfc },
 300-    { "green",                  0xff00ff00 },
 301-    { "green yellow",           0xffadff2f },
 302-    { "green1",                 0xff00ff00 },
 303-    { "green2",                 0xff00ee00 },
 304-    { "green3",                 0xff00cd00 },
 305-    { "green4",                 0xff008b00 },
 306-    { "GreenYellow",            0xffadff2f },
 307-    { "grey",                   0xffbebebe },
 308-    { "grey0",                  0xff000000 },
 309-    { "grey1",                  0xff030303 },
 310-    { "grey10",                 0xff1a1a1a },
 311-    { "grey100",                0xffffffff },
 312-    { "grey11",                 0xff1c1c1c },
 313-    { "grey12",                 0xff1f1f1f },
 314-    { "grey13",                 0xff212121 },
 315-    { "grey14",                 0xff242424 },
 316-    { "grey15",                 0xff262626 },
 317-    { "grey16",                 0xff292929 },
 318-    { "grey17",                 0xff2b2b2b },
 319-    { "grey18",                 0xff2e2e2e },
 320-    { "grey19",                 0xff303030 },
 321-    { "grey2",                  0xff050505 },
 322-    { "grey20",                 0xff333333 },
 323-    { "grey21",                 0xff363636 },
 324-    { "grey22",                 0xff383838 },
 325-    { "grey23",                 0xff3b3b3b },
 326-    { "grey24",                 0xff3d3d3d },
 327-    { "grey25",                 0xff404040 },
 328-    { "grey26",                 0xff424242 },
 329-    { "grey27",                 0xff454545 },
 330-    { "grey28",                 0xff474747 },
 331-    { "grey29",                 0xff4a4a4a },
 332-    { "grey3",                  0xff080808 },
 333-    { "grey30",                 0xff4d4d4d },
 334-    { "grey31",                 0xff4f4f4f },
 335-    { "grey32",                 0xff525252 },
 336-    { "grey33",                 0xff545454 },
 337-    { "grey34",                 0xff575757 },
 338-    { "grey35",                 0xff595959 },
 339-    { "grey36",                 0xff5c5c5c },
 340-    { "grey37",                 0xff5e5e5e },
 341-    { "grey38",                 0xff616161 },
 342-    { "grey39",                 0xff636363 },
 343-    { "grey4",                  0xff0a0a0a },
 344-    { "grey40",                 0xff666666 },
 345-    { "grey41",                 0xff696969 },
 346-    { "grey42",                 0xff6b6b6b },
 347-    { "grey43",                 0xff6e6e6e },
 348-    { "grey44",                 0xff707070 },
 349-    { "grey45",                 0xff737373 },
 350-    { "grey46",                 0xff757575 },
 351-    { "grey47",                 0xff787878 },
 352-    { "grey48",                 0xff7a7a7a },
 353-    { "grey49",                 0xff7d7d7d },
 354-    { "grey5",                  0xff0d0d0d },
 355-    { "grey50",                 0xff7f7f7f },
 356-    { "grey51",                 0xff828282 },
 357-    { "grey52",                 0xff858585 },
 358-    { "grey53",                 0xff878787 },
 359-    { "grey54",                 0xff8a8a8a },
 360-    { "grey55",                 0xff8c8c8c },
 361-    { "grey56",                 0xff8f8f8f },
 362-    { "grey57",                 0xff919191 },
 363-    { "grey58",                 0xff949494 },
 364-    { "grey59",                 0xff969696 },
 365-    { "grey6",                  0xff0f0f0f },
 366-    { "grey60",                 0xff999999 },
 367-    { "grey61",                 0xff9c9c9c },
 368-    { "grey62",                 0xff9e9e9e },
 369-    { "grey63",                 0xffa1a1a1 },
 370-    { "grey64",                 0xffa3a3a3 },
 371-    { "grey65",                 0xffa6a6a6 },
 372-    { "grey66",                 0xffa8a8a8 },
 373-    { "grey67",                 0xffababab },
 374-    { "grey68",                 0xffadadad },
 375-    { "grey69",                 0xffb0b0b0 },
 376-    { "grey7",                  0xff121212 },
 377-    { "grey70",                 0xffb3b3b3 },
 378-    { "grey71",                 0xffb5b5b5 },
 379-    { "grey72",                 0xffb8b8b8 },
 380-    { "grey73",                 0xffbababa },
 381-    { "grey74",                 0xffbdbdbd },
 382-    { "grey75",                 0xffbfbfbf },
 383-    { "grey76",                 0xffc2c2c2 },
 384-    { "grey77",                 0xffc4c4c4 },
 385-    { "grey78",                 0xffc7c7c7 },
 386-    { "grey79",                 0xffc9c9c9 },
 387-    { "grey8",                  0xff141414 },
 388-    { "grey80",                 0xffcccccc },
 389-    { "grey81",                 0xffcfcfcf },
 390-    { "grey82",                 0xffd1d1d1 },
 391-    { "grey83",                 0xffd4d4d4 },
 392-    { "grey84",                 0xffd6d6d6 },
 393-    { "grey85",                 0xffd9d9d9 },
 394-    { "grey86",                 0xffdbdbdb },
 395-    { "grey87",                 0xffdedede },
 396-    { "grey88",                 0xffe0e0e0 },
 397-    { "grey89",                 0xffe3e3e3 },
 398-    { "grey9",                  0xff171717 },
 399-    { "grey90",                 0xffe5e5e5 },
 400-    { "grey91",                 0xffe8e8e8 },
 401-    { "grey92",                 0xffebebeb },
 402-    { "grey93",                 0xffededed },
 403-    { "grey94",                 0xfff0f0f0 },
 404-    { "grey95",                 0xfff2f2f2 },
 405-    { "grey96",                 0xfff5f5f5 },
 406-    { "grey97",                 0xfff7f7f7 },
 407-    { "grey98",                 0xfffafafa },
 408-    { "grey99",                 0xfffcfcfc },
 409-    { "honeydew",               0xfff0fff0 },
 410-    { "honeydew1",              0xfff0fff0 },
 411-    { "honeydew2",              0xffe0eee0 },
 412-    { "honeydew3",              0xffc1cdc1 },
 413-    { "honeydew4",              0xff838b83 },
 414-    { "hot pink",               0xffff69b4 },
 415-    { "HotPink",                0xffff69b4 },
 416-    { "HotPink1",               0xffff6eb4 },
 417-    { "HotPink2",               0xffee6aa7 },
 418-    { "HotPink3",               0xffcd6090 },
 419-    { "HotPink4",               0xff8b3a62 },
 420-    { "indian red",             0xffcd5c5c },
 421-    { "IndianRed",              0xffcd5c5c },
 422-    { "IndianRed1",             0xffff6a6a },
 423-    { "IndianRed2",             0xffee6363 },
 424-    { "IndianRed3",             0xffcd5555 },
 425-    { "IndianRed4",             0xff8b3a3a },
 426-    { "ivory",                  0xfffffff0 },
 427-    { "ivory1",                 0xfffffff0 },
 428-    { "ivory2",                 0xffeeeee0 },
 429-    { "ivory3",                 0xffcdcdc1 },
 430-    { "ivory4",                 0xff8b8b83 },
 431-    { "khaki",                  0xfff0e68c },
 432-    { "khaki1",                 0xfffff68f },
 433-    { "khaki2",                 0xffeee685 },
 434-    { "khaki3",                 0xffcdc673 },
 435-    { "khaki4",                 0xff8b864e },
 436-    { "lavender",               0xffe6e6fa },
 437-    { "lavender blush",         0xfffff0f5 },
 438-    { "LavenderBlush",          0xfffff0f5 },
 439-    { "LavenderBlush1",         0xfffff0f5 },
 440-    { "LavenderBlush2",         0xffeee0e5 },
 441-    { "LavenderBlush3",         0xffcdc1c5 },
 442-    { "LavenderBlush4",         0xff8b8386 },
 443-    { "lawn green",             0xff7cfc00 },
 444-    { "LawnGreen",              0xff7cfc00 },
 445-    { "lemon chiffon",          0xfffffacd },
 446-    { "LemonChiffon",           0xfffffacd },
 447-    { "LemonChiffon1",          0xfffffacd },
 448-    { "LemonChiffon2",          0xffeee9bf },
 449-    { "LemonChiffon3",          0xffcdc9a5 },
 450-    { "LemonChiffon4",          0xff8b8970 },
 451-    { "light blue",             0xffadd8e6 },
 452-    { "light coral",            0xfff08080 },
 453-    { "light cyan",             0xffe0ffff },
 454-    { "light goldenrod",        0xffeedd82 },
 455-    { "light goldenrod yellow", 0xfffafad2 },
 456-    { "light gray",             0xffd3d3d3 },
 457-    { "light green",            0xff90ee90 },
 458-    { "light grey",             0xffd3d3d3 },
 459-    { "light pink",             0xffffb6c1 },
 460-    { "light salmon",           0xffffa07a },
 461-    { "light sea green",        0xff20b2aa },
 462-    { "light sky blue",         0xff87cefa },
 463-    { "light slate blue",       0xff8470ff },
 464-    { "light slate gray",       0xff778899 },
 465-    { "light slate grey",       0xff778899 },
 466-    { "light steel blue",       0xffb0c4de },
 467-    { "light yellow",           0xffffffe0 },
 468-    { "LightBlue",              0xffadd8e6 },
 469-    { "LightBlue1",             0xffbfefff },
 470-    { "LightBlue2",             0xffb2dfee },
 471-    { "LightBlue3",             0xff9ac0cd },
 472-    { "LightBlue4",             0xff68838b },
 473-    { "LightCoral",             0xfff08080 },
 474-    { "LightCyan",              0xffe0ffff },
 475-    { "LightCyan1",             0xffe0ffff },
 476-    { "LightCyan2",             0xffd1eeee },
 477-    { "LightCyan3",             0xffb4cdcd },
 478-    { "LightCyan4",             0xff7a8b8b },
 479-    { "LightGoldenrod",         0xffeedd82 },
 480-    { "LightGoldenrod1",        0xffffec8b },
 481-    { "LightGoldenrod2",        0xffeedc82 },
 482-    { "LightGoldenrod3",        0xffcdbe70 },
 483-    { "LightGoldenrod4",        0xff8b814c },
 484-    { "LightGoldenrodYellow",   0xfffafad2 },
 485-    { "LightGray",              0xffd3d3d3 },
 486-    { "LightGreen",             0xff90ee90 },
 487-    { "LightGrey",              0xffd3d3d3 },
 488-    { "LightPink",              0xffffb6c1 },
 489-    { "LightPink1",             0xffffaeb9 },
 490-    { "LightPink2",             0xffeea2ad },
 491-    { "LightPink3",             0xffcd8c95 },
 492-    { "LightPink4",             0xff8b5f65 },
 493-    { "LightSalmon",            0xffffa07a },
 494-    { "LightSalmon1",           0xffffa07a },
 495-    { "LightSalmon2",           0xffee9572 },
 496-    { "LightSalmon3",           0xffcd8162 },
 497-    { "LightSalmon4",           0xff8b5742 },
 498-    { "LightSeaGreen",          0xff20b2aa },
 499-    { "LightSkyBlue",           0xff87cefa },
 500-    { "LightSkyBlue1",          0xffb0e2ff },
 501-    { "LightSkyBlue2",          0xffa4d3ee },
 502-    { "LightSkyBlue3",          0xff8db6cd },
 503-    { "LightSkyBlue4",          0xff607b8b },
 504-    { "LightSlateBlue",         0xff8470ff },
 505-    { "LightSlateGray",         0xff778899 },
 506-    { "LightSlateGrey",         0xff778899 },
 507-    { "LightSteelBlue",         0xffb0c4de },
 508-    { "LightSteelBlue1",        0xffcae1ff },
 509-    { "LightSteelBlue2",        0xffbcd2ee },
 510-    { "LightSteelBlue3",        0xffa2b5cd },
 511-    { "LightSteelBlue4",        0xff6e7b8b },
 512-    { "LightYellow",            0xffffffe0 },
 513-    { "LightYellow1",           0xffffffe0 },
 514-    { "LightYellow2",           0xffeeeed1 },
 515-    { "LightYellow3",           0xffcdcdb4 },
 516-    { "LightYellow4",           0xff8b8b7a },
 517-    { "lime green",             0xff32cd32 },
 518-    { "LimeGreen",              0xff32cd32 },
 519-    { "linen",                  0xfffaf0e6 },
 520-    { "magenta",                0xffff00ff },
 521-    { "magenta1",               0xffff00ff },
 522-    { "magenta2",               0xffee00ee },
 523-    { "magenta3",               0xffcd00cd },
 524-    { "magenta4",               0xff8b008b },
 525-    { "maroon",                 0xffb03060 },
 526-    { "maroon1",                0xffff34b3 },
 527-    { "maroon2",                0xffee30a7 },
 528-    { "maroon3",                0xffcd2990 },
 529-    { "maroon4",                0xff8b1c62 },
 530-    { "medium aquamarine",      0xff66cdaa },
 531-    { "medium blue",            0xff0000cd },
 532-    { "medium orchid",          0xffba55d3 },
 533-    { "medium purple",          0xff9370db },
 534-    { "medium sea green",       0xff3cb371 },
 535-    { "medium slate blue",      0xff7b68ee },
 536-    { "medium spring green",    0xff00fa9a },
 537-    { "medium turquoise",       0xff48d1cc },
 538-    { "medium violet red",      0xffc71585 },
 539-    { "MediumAquamarine",       0xff66cdaa },
 540-    { "MediumBlue",             0xff0000cd },
 541-    { "MediumOrchid",           0xffba55d3 },
 542-    { "MediumOrchid1",          0xffe066ff },
 543-    { "MediumOrchid2",          0xffd15fee },
 544-    { "MediumOrchid3",          0xffb452cd },
 545-    { "MediumOrchid4",          0xff7a378b },
 546-    { "MediumPurple",           0xff9370db },
 547-    { "MediumPurple1",          0xffab82ff },
 548-    { "MediumPurple2",          0xff9f79ee },
 549-    { "MediumPurple3",          0xff8968cd },
 550-    { "MediumPurple4",          0xff5d478b },
 551-    { "MediumSeaGreen",         0xff3cb371 },
 552-    { "MediumSlateBlue",        0xff7b68ee },
 553-    { "MediumSpringGreen",      0xff00fa9a },
 554-    { "MediumTurquoise",        0xff48d1cc },
 555-    { "MediumVioletRed",        0xffc71585 },
 556-    { "midnight blue",          0xff191970 },
 557-    { "MidnightBlue",           0xff191970 },
 558-    { "mint cream",             0xfff5fffa },
 559-    { "MintCream",              0xfff5fffa },
 560-    { "misty rose",             0xffffe4e1 },
 561-    { "MistyRose",              0xffffe4e1 },
 562-    { "MistyRose1",             0xffffe4e1 },
 563-    { "MistyRose2",             0xffeed5d2 },
 564-    { "MistyRose3",             0xffcdb7b5 },
 565-    { "MistyRose4",             0xff8b7d7b },
 566-    { "moccasin",               0xffffe4b5 },
 567-    { "navajo white",           0xffffdead },
 568-    { "NavajoWhite",            0xffffdead },
 569-    { "NavajoWhite1",           0xffffdead },
 570-    { "NavajoWhite2",           0xffeecfa1 },
 571-    { "NavajoWhite3",           0xffcdb38b },
 572-    { "NavajoWhite4",           0xff8b795e },
 573-    { "navy",                   0xff000080 },
 574-    { "navy blue",              0xff000080 },
 575-    { "NavyBlue",               0xff000080 },
 576-    { "old lace",               0xfffdf5e6 },
 577-    { "OldLace",                0xfffdf5e6 },
 578-    { "olive drab",             0xff6b8e23 },
 579-    { "OliveDrab",              0xff6b8e23 },
 580-    { "OliveDrab1",             0xffc0ff3e },
 581-    { "OliveDrab2",             0xffb3ee3a },
 582-    { "OliveDrab3",             0xff9acd32 },
 583-    { "OliveDrab4",             0xff698b22 },
 584-    { "orange",                 0xffffa500 },
 585-    { "orange red",             0xffff4500 },
 586-    { "orange1",                0xffffa500 },
 587-    { "orange2",                0xffee9a00 },
 588-    { "orange3",                0xffcd8500 },
 589-    { "orange4",                0xff8b5a00 },
 590-    { "OrangeRed",              0xffff4500 },
 591-    { "OrangeRed1",             0xffff4500 },
 592-    { "OrangeRed2",             0xffee4000 },
 593-    { "OrangeRed3",             0xffcd3700 },
 594-    { "OrangeRed4",             0xff8b2500 },
 595-    { "orchid",                 0xffda70d6 },
 596-    { "orchid1",                0xffff83fa },
 597-    { "orchid2",                0xffee7ae9 },
 598-    { "orchid3",                0xffcd69c9 },
 599-    { "orchid4",                0xff8b4789 },
 600-    { "pale goldenrod",         0xffeee8aa },
 601-    { "pale green",             0xff98fb98 },
 602-    { "pale turquoise",         0xffafeeee },
 603-    { "pale violet red",        0xffdb7093 },
 604-    { "PaleGoldenrod",          0xffeee8aa },
 605-    { "PaleGreen",              0xff98fb98 },
 606-    { "PaleGreen1",             0xff9aff9a },
 607-    { "PaleGreen2",             0xff90ee90 },
 608-    { "PaleGreen3",             0xff7ccd7c },
 609-    { "PaleGreen4",             0xff548b54 },
 610-    { "PaleTurquoise",          0xffafeeee },
 611-    { "PaleTurquoise1",         0xffbbffff },
 612-    { "PaleTurquoise2",         0xffaeeeee },
 613-    { "PaleTurquoise3",         0xff96cdcd },
 614-    { "PaleTurquoise4",         0xff668b8b },
 615-    { "PaleVioletRed",          0xffdb7093 },
 616-    { "PaleVioletRed1",         0xffff82ab },
 617-    { "PaleVioletRed2",         0xffee799f },
 618-    { "PaleVioletRed3",         0xffcd6889 },
 619-    { "PaleVioletRed4",         0xff8b475d },
 620-    { "papaya whip",            0xffffefd5 },
 621-    { "PapayaWhip",             0xffffefd5 },
 622-    { "peach puff",             0xffffdab9 },
 623-    { "PeachPuff",              0xffffdab9 },
 624-    { "PeachPuff1",             0xffffdab9 },
 625-    { "PeachPuff2",             0xffeecbad },
 626-    { "PeachPuff3",             0xffcdaf95 },
 627-    { "PeachPuff4",             0xff8b7765 },
 628-    { "peru",                   0xffcd853f },
 629-    { "pink",                   0xffffc0cb },
 630-    { "pink1",                  0xffffb5c5 },
 631-    { "pink2",                  0xffeea9b8 },
 632-    { "pink3",                  0xffcd919e },
 633-    { "pink4",                  0xff8b636c },
 634-    { "plum",                   0xffdda0dd },
 635-    { "plum1",                  0xffffbbff },
 636-    { "plum2",                  0xffeeaeee },
 637-    { "plum3",                  0xffcd96cd },
 638-    { "plum4",                  0xff8b668b },
 639-    { "powder blue",            0xffb0e0e6 },
 640-    { "PowderBlue",             0xffb0e0e6 },
 641-    { "purple",                 0xffa020f0 },
 642-    { "purple1",                0xff9b30ff },
 643-    { "purple2",                0xff912cee },
 644-    { "purple3",                0xff7d26cd },
 645-    { "purple4",                0xff551a8b },
 646-    { "red",                    0xffff0000 },
 647-    { "red1",                   0xffff0000 },
 648-    { "red2",                   0xffee0000 },
 649-    { "red3",                   0xffcd0000 },
 650-    { "red4",                   0xff8b0000 },
 651-    { "rosy brown",             0xffbc8f8f },
 652-    { "RosyBrown",              0xffbc8f8f },
 653-    { "RosyBrown1",             0xffffc1c1 },
 654-    { "RosyBrown2",             0xffeeb4b4 },
 655-    { "RosyBrown3",             0xffcd9b9b },
 656-    { "RosyBrown4",             0xff8b6969 },
 657-    { "royal blue",             0xff4169e1 },
 658-    { "RoyalBlue",              0xff4169e1 },
 659-    { "RoyalBlue1",             0xff4876ff },
 660-    { "RoyalBlue2",             0xff436eee },
 661-    { "RoyalBlue3",             0xff3a5fcd },
 662-    { "RoyalBlue4",             0xff27408b },
 663-    { "saddle brown",           0xff8b4513 },
 664-    { "SaddleBrown",            0xff8b4513 },
 665-    { "salmon",                 0xfffa8072 },
 666-    { "salmon1",                0xffff8c69 },
 667-    { "salmon2",                0xffee8262 },
 668-    { "salmon3",                0xffcd7054 },
 669-    { "salmon4",                0xff8b4c39 },
 670-    { "sandy brown",            0xfff4a460 },
 671-    { "SandyBrown",             0xfff4a460 },
 672-    { "sea green",              0xff2e8b57 },
 673-    { "SeaGreen",               0xff2e8b57 },
 674-    { "SeaGreen1",              0xff54ff9f },
 675-    { "SeaGreen2",              0xff4eee94 },
 676-    { "SeaGreen3",              0xff43cd80 },
 677-    { "SeaGreen4",              0xff2e8b57 },
 678-    { "seashell",               0xfffff5ee },
 679-    { "seashell1",              0xfffff5ee },
 680-    { "seashell2",              0xffeee5de },
 681-    { "seashell3",              0xffcdc5bf },
 682-    { "seashell4",              0xff8b8682 },
 683-    { "sienna",                 0xffa0522d },
 684-    { "sienna1",                0xffff8247 },
 685-    { "sienna2",                0xffee7942 },
 686-    { "sienna3",                0xffcd6839 },
 687-    { "sienna4",                0xff8b4726 },
 688-    { "sky blue",               0xff87ceeb },
 689-    { "SkyBlue",                0xff87ceeb },
 690-    { "SkyBlue1",               0xff87ceff },
 691-    { "SkyBlue2",               0xff7ec0ee },
 692-    { "SkyBlue3",               0xff6ca6cd },
 693-    { "SkyBlue4",               0xff4a708b },
 694-    { "slate blue",             0xff6a5acd },
 695-    { "slate gray",             0xff708090 },
 696-    { "slate grey",             0xff708090 },
 697-    { "SlateBlue",              0xff6a5acd },
 698-    { "SlateBlue1",             0xff836fff },
 699-    { "SlateBlue2",             0xff7a67ee },
 700-    { "SlateBlue3",             0xff6959cd },
 701-    { "SlateBlue4",             0xff473c8b },
 702-    { "SlateGray",              0xff708090 },
 703-    { "SlateGray1",             0xffc6e2ff },
 704-    { "SlateGray2",             0xffb9d3ee },
 705-    { "SlateGray3",             0xff9fb6cd },
 706-    { "SlateGray4",             0xff6c7b8b },
 707-    { "SlateGrey",              0xff708090 },
 708-    { "snow",                   0xfffffafa },
 709-    { "snow1",                  0xfffffafa },
 710-    { "snow2",                  0xffeee9e9 },
 711-    { "snow3",                  0xffcdc9c9 },
 712-    { "snow4",                  0xff8b8989 },
 713-    { "spring green",           0xff00ff7f },
 714-    { "SpringGreen",            0xff00ff7f },
 715-    { "SpringGreen1",           0xff00ff7f },
 716-    { "SpringGreen2",           0xff00ee76 },
 717-    { "SpringGreen3",           0xff00cd66 },
 718-    { "SpringGreen4",           0xff008b45 },
 719-    { "steel blue",             0xff4682b4 },
 720-    { "SteelBlue",              0xff4682b4 },
 721-    { "SteelBlue1",             0xff63b8ff },
 722-    { "SteelBlue2",             0xff5cacee },
 723-    { "SteelBlue3",             0xff4f94cd },
 724-    { "SteelBlue4",             0xff36648b },
 725-    { "tan",                    0xffd2b48c },
 726-    { "tan1",                   0xffffa54f },
 727-    { "tan2",                   0xffee9a49 },
 728-    { "tan3",                   0xffcd853f },
 729-    { "tan4",                   0xff8b5a2b },
 730-    { "thistle",                0xffd8bfd8 },
 731-    { "thistle1",               0xffffe1ff },
 732-    { "thistle2",               0xffeed2ee },
 733-    { "thistle3",               0xffcdb5cd },
 734-    { "thistle4",               0xff8b7b8b },
 735-    { "tomato",                 0xffff6347 },
 736-    { "tomato1",                0xffff6347 },
 737-    { "tomato2",                0xffee5c42 },
 738-    { "tomato3",                0xffcd4f39 },
 739-    { "tomato4",                0xff8b3626 },
 740-    { "turquoise",              0xff40e0d0 },
 741-    { "turquoise1",             0xff00f5ff },
 742-    { "turquoise2",             0xff00e5ee },
 743-    { "turquoise3",             0xff00c5cd },
 744-    { "turquoise4",             0xff00868b },
 745-    { "violet",                 0xffee82ee },
 746-    { "violet red",             0xffd02090 },
 747-    { "VioletRed",              0xffd02090 },
 748-    { "VioletRed1",             0xffff3e96 },
 749-    { "VioletRed2",             0xffee3a8c },
 750-    { "VioletRed3",             0xffcd3278 },
 751-    { "VioletRed4",             0xff8b2252 },
 752-    { "wheat",                  0xfff5deb3 },
 753-    { "wheat1",                 0xffffe7ba },
 754-    { "wheat2",                 0xffeed8ae },
 755-    { "wheat3",                 0xffcdba96 },
 756-    { "wheat4",                 0xff8b7e66 },
 757-    { "white",                  0xffffffff },
 758-    { "white smoke",            0xfff5f5f5 },
 759-    { "WhiteSmoke",             0xfff5f5f5 },
 760-    { "yellow",                 0xffffff00 },
 761-    { "yellow green",           0xff9acd32 },
 762-    { "yellow1",                0xffffff00 },
 763-    { "yellow2",                0xffeeee00 },
 764-    { "yellow3",                0xffcdcd00 },
 765-    { "yellow4",                0xff8b8b00 },
 766-    { "YellowGreen",            0xff9acd32 }
 767+	{ "alice blue", 0xfff0f8ff },
 768+	{ "AliceBlue", 0xfff0f8ff },
 769+	{ "antique white", 0xfffaebd7 },
 770+	{ "AntiqueWhite", 0xfffaebd7 },
 771+	{ "AntiqueWhite1", 0xffffefdb },
 772+	{ "AntiqueWhite2", 0xffeedfcc },
 773+	{ "AntiqueWhite3", 0xffcdc0b0 },
 774+	{ "AntiqueWhite4", 0xff8b8378 },
 775+	{ "aquamarine", 0xff7fffd4 },
 776+	{ "aquamarine1", 0xff7fffd4 },
 777+	{ "aquamarine2", 0xff76eec6 },
 778+	{ "aquamarine3", 0xff66cdaa },
 779+	{ "aquamarine4", 0xff458b74 },
 780+	{ "azure", 0xfff0ffff },
 781+	{ "azure1", 0xfff0ffff },
 782+	{ "azure2", 0xffe0eeee },
 783+	{ "azure3", 0xffc1cdcd },
 784+	{ "azure4", 0xff838b8b },
 785+	{ "beige", 0xfff5f5dc },
 786+	{ "bisque", 0xffffe4c4 },
 787+	{ "bisque1", 0xffffe4c4 },
 788+	{ "bisque2", 0xffeed5b7 },
 789+	{ "bisque3", 0xffcdb79e },
 790+	{ "bisque4", 0xff8b7d6b },
 791+	{ "black", 0xff000000 },
 792+	{ "blanched almond", 0xffffebcd },
 793+	{ "BlanchedAlmond", 0xffffebcd },
 794+	{ "blue", 0xff0000ff },
 795+	{ "blue violet", 0xff8a2be2 },
 796+	{ "blue1", 0xff0000ff },
 797+	{ "blue2", 0xff0000ee },
 798+	{ "blue3", 0xff0000cd },
 799+	{ "blue4", 0xff00008b },
 800+	{ "BlueViolet", 0xff8a2be2 },
 801+	{ "brown", 0xffa52a2a },
 802+	{ "brown1", 0xffff4040 },
 803+	{ "brown2", 0xffee3b3b },
 804+	{ "brown3", 0xffcd3333 },
 805+	{ "brown4", 0xff8b2323 },
 806+	{ "burlywood", 0xffdeb887 },
 807+	{ "burlywood1", 0xffffd39b },
 808+	{ "burlywood2", 0xffeec591 },
 809+	{ "burlywood3", 0xffcdaa7d },
 810+	{ "burlywood4", 0xff8b7355 },
 811+	{ "cadet blue", 0xff5f9ea0 },
 812+	{ "CadetBlue", 0xff5f9ea0 },
 813+	{ "CadetBlue1", 0xff98f5ff },
 814+	{ "CadetBlue2", 0xff8ee5ee },
 815+	{ "CadetBlue3", 0xff7ac5cd },
 816+	{ "CadetBlue4", 0xff53868b },
 817+	{ "chartreuse", 0xff7fff00 },
 818+	{ "chartreuse1", 0xff7fff00 },
 819+	{ "chartreuse2", 0xff76ee00 },
 820+	{ "chartreuse3", 0xff66cd00 },
 821+	{ "chartreuse4", 0xff458b00 },
 822+	{ "chocolate", 0xffd2691e },
 823+	{ "chocolate1", 0xffff7f24 },
 824+	{ "chocolate2", 0xffee7621 },
 825+	{ "chocolate3", 0xffcd661d },
 826+	{ "chocolate4", 0xff8b4513 },
 827+	{ "coral", 0xffff7f50 },
 828+	{ "coral1", 0xffff7256 },
 829+	{ "coral2", 0xffee6a50 },
 830+	{ "coral3", 0xffcd5b45 },
 831+	{ "coral4", 0xff8b3e2f },
 832+	{ "cornflower blue", 0xff6495ed },
 833+	{ "CornflowerBlue", 0xff6495ed },
 834+	{ "cornsilk", 0xfffff8dc },
 835+	{ "cornsilk1", 0xfffff8dc },
 836+	{ "cornsilk2", 0xffeee8cd },
 837+	{ "cornsilk3", 0xffcdc8b1 },
 838+	{ "cornsilk4", 0xff8b8878 },
 839+	{ "cyan", 0xff00ffff },
 840+	{ "cyan1", 0xff00ffff },
 841+	{ "cyan2", 0xff00eeee },
 842+	{ "cyan3", 0xff00cdcd },
 843+	{ "cyan4", 0xff008b8b },
 844+	{ "dark blue", 0xff00008b },
 845+	{ "dark cyan", 0xff008b8b },
 846+	{ "dark goldenrod", 0xffb8860b },
 847+	{ "dark gray", 0xffa9a9a9 },
 848+	{ "dark green", 0xff006400 },
 849+	{ "dark grey", 0xffa9a9a9 },
 850+	{ "dark khaki", 0xffbdb76b },
 851+	{ "dark magenta", 0xff8b008b },
 852+	{ "dark olive green", 0xff556b2f },
 853+	{ "dark orange", 0xffff8c00 },
 854+	{ "dark orchid", 0xff9932cc },
 855+	{ "dark red", 0xff8b0000 },
 856+	{ "dark salmon", 0xffe9967a },
 857+	{ "dark sea green", 0xff8fbc8f },
 858+	{ "dark slate blue", 0xff483d8b },
 859+	{ "dark slate gray", 0xff2f4f4f },
 860+	{ "dark slate grey", 0xff2f4f4f },
 861+	{ "dark turquoise", 0xff00ced1 },
 862+	{ "dark violet", 0xff9400d3 },
 863+	{ "DarkBlue", 0xff00008b },
 864+	{ "DarkCyan", 0xff008b8b },
 865+	{ "DarkGoldenrod", 0xffb8860b },
 866+	{ "DarkGoldenrod1", 0xffffb90f },
 867+	{ "DarkGoldenrod2", 0xffeead0e },
 868+	{ "DarkGoldenrod3", 0xffcd950c },
 869+	{ "DarkGoldenrod4", 0xff8b6508 },
 870+	{ "DarkGray", 0xffa9a9a9 },
 871+	{ "DarkGreen", 0xff006400 },
 872+	{ "DarkGrey", 0xffa9a9a9 },
 873+	{ "DarkKhaki", 0xffbdb76b },
 874+	{ "DarkMagenta", 0xff8b008b },
 875+	{ "DarkOliveGreen", 0xff556b2f },
 876+	{ "DarkOliveGreen1", 0xffcaff70 },
 877+	{ "DarkOliveGreen2", 0xffbcee68 },
 878+	{ "DarkOliveGreen3", 0xffa2cd5a },
 879+	{ "DarkOliveGreen4", 0xff6e8b3d },
 880+	{ "DarkOrange", 0xffff8c00 },
 881+	{ "DarkOrange1", 0xffff7f00 },
 882+	{ "DarkOrange2", 0xffee7600 },
 883+	{ "DarkOrange3", 0xffcd6600 },
 884+	{ "DarkOrange4", 0xff8b4500 },
 885+	{ "DarkOrchid", 0xff9932cc },
 886+	{ "DarkOrchid1", 0xffbf3eff },
 887+	{ "DarkOrchid2", 0xffb23aee },
 888+	{ "DarkOrchid3", 0xff9a32cd },
 889+	{ "DarkOrchid4", 0xff68228b },
 890+	{ "DarkRed", 0xff8b0000 },
 891+	{ "DarkSalmon", 0xffe9967a },
 892+	{ "DarkSeaGreen", 0xff8fbc8f },
 893+	{ "DarkSeaGreen1", 0xffc1ffc1 },
 894+	{ "DarkSeaGreen2", 0xffb4eeb4 },
 895+	{ "DarkSeaGreen3", 0xff9bcd9b },
 896+	{ "DarkSeaGreen4", 0xff698b69 },
 897+	{ "DarkSlateBlue", 0xff483d8b },
 898+	{ "DarkSlateGray", 0xff2f4f4f },
 899+	{ "DarkSlateGray1", 0xff97ffff },
 900+	{ "DarkSlateGray2", 0xff8deeee },
 901+	{ "DarkSlateGray3", 0xff79cdcd },
 902+	{ "DarkSlateGray4", 0xff528b8b },
 903+	{ "DarkSlateGrey", 0xff2f4f4f },
 904+	{ "DarkTurquoise", 0xff00ced1 },
 905+	{ "DarkViolet", 0xff9400d3 },
 906+	{ "deep pink", 0xffff1493 },
 907+	{ "deep sky blue", 0xff00bfff },
 908+	{ "DeepPink", 0xffff1493 },
 909+	{ "DeepPink1", 0xffff1493 },
 910+	{ "DeepPink2", 0xffee1289 },
 911+	{ "DeepPink3", 0xffcd1076 },
 912+	{ "DeepPink4", 0xff8b0a50 },
 913+	{ "DeepSkyBlue", 0xff00bfff },
 914+	{ "DeepSkyBlue1", 0xff00bfff },
 915+	{ "DeepSkyBlue2", 0xff00b2ee },
 916+	{ "DeepSkyBlue3", 0xff009acd },
 917+	{ "DeepSkyBlue4", 0xff00688b },
 918+	{ "dim gray", 0xff696969 },
 919+	{ "dim grey", 0xff696969 },
 920+	{ "DimGray", 0xff696969 },
 921+	{ "DimGrey", 0xff696969 },
 922+	{ "dodger blue", 0xff1e90ff },
 923+	{ "DodgerBlue", 0xff1e90ff },
 924+	{ "DodgerBlue1", 0xff1e90ff },
 925+	{ "DodgerBlue2", 0xff1c86ee },
 926+	{ "DodgerBlue3", 0xff1874cd },
 927+	{ "DodgerBlue4", 0xff104e8b },
 928+	{ "firebrick", 0xffb22222 },
 929+	{ "firebrick1", 0xffff3030 },
 930+	{ "firebrick2", 0xffee2c2c },
 931+	{ "firebrick3", 0xffcd2626 },
 932+	{ "firebrick4", 0xff8b1a1a },
 933+	{ "floral white", 0xfffffaf0 },
 934+	{ "FloralWhite", 0xfffffaf0 },
 935+	{ "forest green", 0xff228b22 },
 936+	{ "ForestGreen", 0xff228b22 },
 937+	{ "gainsboro", 0xffdcdcdc },
 938+	{ "ghost white", 0xfff8f8ff },
 939+	{ "GhostWhite", 0xfff8f8ff },
 940+	{ "gold", 0xffffd700 },
 941+	{ "gold1", 0xffffd700 },
 942+	{ "gold2", 0xffeec900 },
 943+	{ "gold3", 0xffcdad00 },
 944+	{ "gold4", 0xff8b7500 },
 945+	{ "goldenrod", 0xffdaa520 },
 946+	{ "goldenrod1", 0xffffc125 },
 947+	{ "goldenrod2", 0xffeeb422 },
 948+	{ "goldenrod3", 0xffcd9b1d },
 949+	{ "goldenrod4", 0xff8b6914 },
 950+	{ "gray", 0xffbebebe },
 951+	{ "gray0", 0xff000000 },
 952+	{ "gray1", 0xff030303 },
 953+	{ "gray10", 0xff1a1a1a },
 954+	{ "gray100", 0xffffffff },
 955+	{ "gray11", 0xff1c1c1c },
 956+	{ "gray12", 0xff1f1f1f },
 957+	{ "gray13", 0xff212121 },
 958+	{ "gray14", 0xff242424 },
 959+	{ "gray15", 0xff262626 },
 960+	{ "gray16", 0xff292929 },
 961+	{ "gray17", 0xff2b2b2b },
 962+	{ "gray18", 0xff2e2e2e },
 963+	{ "gray19", 0xff303030 },
 964+	{ "gray2", 0xff050505 },
 965+	{ "gray20", 0xff333333 },
 966+	{ "gray21", 0xff363636 },
 967+	{ "gray22", 0xff383838 },
 968+	{ "gray23", 0xff3b3b3b },
 969+	{ "gray24", 0xff3d3d3d },
 970+	{ "gray25", 0xff404040 },
 971+	{ "gray26", 0xff424242 },
 972+	{ "gray27", 0xff454545 },
 973+	{ "gray28", 0xff474747 },
 974+	{ "gray29", 0xff4a4a4a },
 975+	{ "gray3", 0xff080808 },
 976+	{ "gray30", 0xff4d4d4d },
 977+	{ "gray31", 0xff4f4f4f },
 978+	{ "gray32", 0xff525252 },
 979+	{ "gray33", 0xff545454 },
 980+	{ "gray34", 0xff575757 },
 981+	{ "gray35", 0xff595959 },
 982+	{ "gray36", 0xff5c5c5c },
 983+	{ "gray37", 0xff5e5e5e },
 984+	{ "gray38", 0xff616161 },
 985+	{ "gray39", 0xff636363 },
 986+	{ "gray4", 0xff0a0a0a },
 987+	{ "gray40", 0xff666666 },
 988+	{ "gray41", 0xff696969 },
 989+	{ "gray42", 0xff6b6b6b },
 990+	{ "gray43", 0xff6e6e6e },
 991+	{ "gray44", 0xff707070 },
 992+	{ "gray45", 0xff737373 },
 993+	{ "gray46", 0xff757575 },
 994+	{ "gray47", 0xff787878 },
 995+	{ "gray48", 0xff7a7a7a },
 996+	{ "gray49", 0xff7d7d7d },
 997+	{ "gray5", 0xff0d0d0d },
 998+	{ "gray50", 0xff7f7f7f },
 999+	{ "gray51", 0xff828282 },
1000+	{ "gray52", 0xff858585 },
1001+	{ "gray53", 0xff878787 },
1002+	{ "gray54", 0xff8a8a8a },
1003+	{ "gray55", 0xff8c8c8c },
1004+	{ "gray56", 0xff8f8f8f },
1005+	{ "gray57", 0xff919191 },
1006+	{ "gray58", 0xff949494 },
1007+	{ "gray59", 0xff969696 },
1008+	{ "gray6", 0xff0f0f0f },
1009+	{ "gray60", 0xff999999 },
1010+	{ "gray61", 0xff9c9c9c },
1011+	{ "gray62", 0xff9e9e9e },
1012+	{ "gray63", 0xffa1a1a1 },
1013+	{ "gray64", 0xffa3a3a3 },
1014+	{ "gray65", 0xffa6a6a6 },
1015+	{ "gray66", 0xffa8a8a8 },
1016+	{ "gray67", 0xffababab },
1017+	{ "gray68", 0xffadadad },
1018+	{ "gray69", 0xffb0b0b0 },
1019+	{ "gray7", 0xff121212 },
1020+	{ "gray70", 0xffb3b3b3 },
1021+	{ "gray71", 0xffb5b5b5 },
1022+	{ "gray72", 0xffb8b8b8 },
1023+	{ "gray73", 0xffbababa },
1024+	{ "gray74", 0xffbdbdbd },
1025+	{ "gray75", 0xffbfbfbf },
1026+	{ "gray76", 0xffc2c2c2 },
1027+	{ "gray77", 0xffc4c4c4 },
1028+	{ "gray78", 0xffc7c7c7 },
1029+	{ "gray79", 0xffc9c9c9 },
1030+	{ "gray8", 0xff141414 },
1031+	{ "gray80", 0xffcccccc },
1032+	{ "gray81", 0xffcfcfcf },
1033+	{ "gray82", 0xffd1d1d1 },
1034+	{ "gray83", 0xffd4d4d4 },
1035+	{ "gray84", 0xffd6d6d6 },
1036+	{ "gray85", 0xffd9d9d9 },
1037+	{ "gray86", 0xffdbdbdb },
1038+	{ "gray87", 0xffdedede },
1039+	{ "gray88", 0xffe0e0e0 },
1040+	{ "gray89", 0xffe3e3e3 },
1041+	{ "gray9", 0xff171717 },
1042+	{ "gray90", 0xffe5e5e5 },
1043+	{ "gray91", 0xffe8e8e8 },
1044+	{ "gray92", 0xffebebeb },
1045+	{ "gray93", 0xffededed },
1046+	{ "gray94", 0xfff0f0f0 },
1047+	{ "gray95", 0xfff2f2f2 },
1048+	{ "gray96", 0xfff5f5f5 },
1049+	{ "gray97", 0xfff7f7f7 },
1050+	{ "gray98", 0xfffafafa },
1051+	{ "gray99", 0xfffcfcfc },
1052+	{ "green", 0xff00ff00 },
1053+	{ "green yellow", 0xffadff2f },
1054+	{ "green1", 0xff00ff00 },
1055+	{ "green2", 0xff00ee00 },
1056+	{ "green3", 0xff00cd00 },
1057+	{ "green4", 0xff008b00 },
1058+	{ "GreenYellow", 0xffadff2f },
1059+	{ "grey", 0xffbebebe },
1060+	{ "grey0", 0xff000000 },
1061+	{ "grey1", 0xff030303 },
1062+	{ "grey10", 0xff1a1a1a },
1063+	{ "grey100", 0xffffffff },
1064+	{ "grey11", 0xff1c1c1c },
1065+	{ "grey12", 0xff1f1f1f },
1066+	{ "grey13", 0xff212121 },
1067+	{ "grey14", 0xff242424 },
1068+	{ "grey15", 0xff262626 },
1069+	{ "grey16", 0xff292929 },
1070+	{ "grey17", 0xff2b2b2b },
1071+	{ "grey18", 0xff2e2e2e },
1072+	{ "grey19", 0xff303030 },
1073+	{ "grey2", 0xff050505 },
1074+	{ "grey20", 0xff333333 },
1075+	{ "grey21", 0xff363636 },
1076+	{ "grey22", 0xff383838 },
1077+	{ "grey23", 0xff3b3b3b },
1078+	{ "grey24", 0xff3d3d3d },
1079+	{ "grey25", 0xff404040 },
1080+	{ "grey26", 0xff424242 },
1081+	{ "grey27", 0xff454545 },
1082+	{ "grey28", 0xff474747 },
1083+	{ "grey29", 0xff4a4a4a },
1084+	{ "grey3", 0xff080808 },
1085+	{ "grey30", 0xff4d4d4d },
1086+	{ "grey31", 0xff4f4f4f },
1087+	{ "grey32", 0xff525252 },
1088+	{ "grey33", 0xff545454 },
1089+	{ "grey34", 0xff575757 },
1090+	{ "grey35", 0xff595959 },
1091+	{ "grey36", 0xff5c5c5c },
1092+	{ "grey37", 0xff5e5e5e },
1093+	{ "grey38", 0xff616161 },
1094+	{ "grey39", 0xff636363 },
1095+	{ "grey4", 0xff0a0a0a },
1096+	{ "grey40", 0xff666666 },
1097+	{ "grey41", 0xff696969 },
1098+	{ "grey42", 0xff6b6b6b },
1099+	{ "grey43", 0xff6e6e6e },
1100+	{ "grey44", 0xff707070 },
1101+	{ "grey45", 0xff737373 },
1102+	{ "grey46", 0xff757575 },
1103+	{ "grey47", 0xff787878 },
1104+	{ "grey48", 0xff7a7a7a },
1105+	{ "grey49", 0xff7d7d7d },
1106+	{ "grey5", 0xff0d0d0d },
1107+	{ "grey50", 0xff7f7f7f },
1108+	{ "grey51", 0xff828282 },
1109+	{ "grey52", 0xff858585 },
1110+	{ "grey53", 0xff878787 },
1111+	{ "grey54", 0xff8a8a8a },
1112+	{ "grey55", 0xff8c8c8c },
1113+	{ "grey56", 0xff8f8f8f },
1114+	{ "grey57", 0xff919191 },
1115+	{ "grey58", 0xff949494 },
1116+	{ "grey59", 0xff969696 },
1117+	{ "grey6", 0xff0f0f0f },
1118+	{ "grey60", 0xff999999 },
1119+	{ "grey61", 0xff9c9c9c },
1120+	{ "grey62", 0xff9e9e9e },
1121+	{ "grey63", 0xffa1a1a1 },
1122+	{ "grey64", 0xffa3a3a3 },
1123+	{ "grey65", 0xffa6a6a6 },
1124+	{ "grey66", 0xffa8a8a8 },
1125+	{ "grey67", 0xffababab },
1126+	{ "grey68", 0xffadadad },
1127+	{ "grey69", 0xffb0b0b0 },
1128+	{ "grey7", 0xff121212 },
1129+	{ "grey70", 0xffb3b3b3 },
1130+	{ "grey71", 0xffb5b5b5 },
1131+	{ "grey72", 0xffb8b8b8 },
1132+	{ "grey73", 0xffbababa },
1133+	{ "grey74", 0xffbdbdbd },
1134+	{ "grey75", 0xffbfbfbf },
1135+	{ "grey76", 0xffc2c2c2 },
1136+	{ "grey77", 0xffc4c4c4 },
1137+	{ "grey78", 0xffc7c7c7 },
1138+	{ "grey79", 0xffc9c9c9 },
1139+	{ "grey8", 0xff141414 },
1140+	{ "grey80", 0xffcccccc },
1141+	{ "grey81", 0xffcfcfcf },
1142+	{ "grey82", 0xffd1d1d1 },
1143+	{ "grey83", 0xffd4d4d4 },
1144+	{ "grey84", 0xffd6d6d6 },
1145+	{ "grey85", 0xffd9d9d9 },
1146+	{ "grey86", 0xffdbdbdb },
1147+	{ "grey87", 0xffdedede },
1148+	{ "grey88", 0xffe0e0e0 },
1149+	{ "grey89", 0xffe3e3e3 },
1150+	{ "grey9", 0xff171717 },
1151+	{ "grey90", 0xffe5e5e5 },
1152+	{ "grey91", 0xffe8e8e8 },
1153+	{ "grey92", 0xffebebeb },
1154+	{ "grey93", 0xffededed },
1155+	{ "grey94", 0xfff0f0f0 },
1156+	{ "grey95", 0xfff2f2f2 },
1157+	{ "grey96", 0xfff5f5f5 },
1158+	{ "grey97", 0xfff7f7f7 },
1159+	{ "grey98", 0xfffafafa },
1160+	{ "grey99", 0xfffcfcfc },
1161+	{ "honeydew", 0xfff0fff0 },
1162+	{ "honeydew1", 0xfff0fff0 },
1163+	{ "honeydew2", 0xffe0eee0 },
1164+	{ "honeydew3", 0xffc1cdc1 },
1165+	{ "honeydew4", 0xff838b83 },
1166+	{ "hot pink", 0xffff69b4 },
1167+	{ "HotPink", 0xffff69b4 },
1168+	{ "HotPink1", 0xffff6eb4 },
1169+	{ "HotPink2", 0xffee6aa7 },
1170+	{ "HotPink3", 0xffcd6090 },
1171+	{ "HotPink4", 0xff8b3a62 },
1172+	{ "indian red", 0xffcd5c5c },
1173+	{ "IndianRed", 0xffcd5c5c },
1174+	{ "IndianRed1", 0xffff6a6a },
1175+	{ "IndianRed2", 0xffee6363 },
1176+	{ "IndianRed3", 0xffcd5555 },
1177+	{ "IndianRed4", 0xff8b3a3a },
1178+	{ "ivory", 0xfffffff0 },
1179+	{ "ivory1", 0xfffffff0 },
1180+	{ "ivory2", 0xffeeeee0 },
1181+	{ "ivory3", 0xffcdcdc1 },
1182+	{ "ivory4", 0xff8b8b83 },
1183+	{ "khaki", 0xfff0e68c },
1184+	{ "khaki1", 0xfffff68f },
1185+	{ "khaki2", 0xffeee685 },
1186+	{ "khaki3", 0xffcdc673 },
1187+	{ "khaki4", 0xff8b864e },
1188+	{ "lavender", 0xffe6e6fa },
1189+	{ "lavender blush", 0xfffff0f5 },
1190+	{ "LavenderBlush", 0xfffff0f5 },
1191+	{ "LavenderBlush1", 0xfffff0f5 },
1192+	{ "LavenderBlush2", 0xffeee0e5 },
1193+	{ "LavenderBlush3", 0xffcdc1c5 },
1194+	{ "LavenderBlush4", 0xff8b8386 },
1195+	{ "lawn green", 0xff7cfc00 },
1196+	{ "LawnGreen", 0xff7cfc00 },
1197+	{ "lemon chiffon", 0xfffffacd },
1198+	{ "LemonChiffon", 0xfffffacd },
1199+	{ "LemonChiffon1", 0xfffffacd },
1200+	{ "LemonChiffon2", 0xffeee9bf },
1201+	{ "LemonChiffon3", 0xffcdc9a5 },
1202+	{ "LemonChiffon4", 0xff8b8970 },
1203+	{ "light blue", 0xffadd8e6 },
1204+	{ "light coral", 0xfff08080 },
1205+	{ "light cyan", 0xffe0ffff },
1206+	{ "light goldenrod", 0xffeedd82 },
1207+	{ "light goldenrod yellow", 0xfffafad2 },
1208+	{ "light gray", 0xffd3d3d3 },
1209+	{ "light green", 0xff90ee90 },
1210+	{ "light grey", 0xffd3d3d3 },
1211+	{ "light pink", 0xffffb6c1 },
1212+	{ "light salmon", 0xffffa07a },
1213+	{ "light sea green", 0xff20b2aa },
1214+	{ "light sky blue", 0xff87cefa },
1215+	{ "light slate blue", 0xff8470ff },
1216+	{ "light slate gray", 0xff778899 },
1217+	{ "light slate grey", 0xff778899 },
1218+	{ "light steel blue", 0xffb0c4de },
1219+	{ "light yellow", 0xffffffe0 },
1220+	{ "LightBlue", 0xffadd8e6 },
1221+	{ "LightBlue1", 0xffbfefff },
1222+	{ "LightBlue2", 0xffb2dfee },
1223+	{ "LightBlue3", 0xff9ac0cd },
1224+	{ "LightBlue4", 0xff68838b },
1225+	{ "LightCoral", 0xfff08080 },
1226+	{ "LightCyan", 0xffe0ffff },
1227+	{ "LightCyan1", 0xffe0ffff },
1228+	{ "LightCyan2", 0xffd1eeee },
1229+	{ "LightCyan3", 0xffb4cdcd },
1230+	{ "LightCyan4", 0xff7a8b8b },
1231+	{ "LightGoldenrod", 0xffeedd82 },
1232+	{ "LightGoldenrod1", 0xffffec8b },
1233+	{ "LightGoldenrod2", 0xffeedc82 },
1234+	{ "LightGoldenrod3", 0xffcdbe70 },
1235+	{ "LightGoldenrod4", 0xff8b814c },
1236+	{ "LightGoldenrodYellow", 0xfffafad2 },
1237+	{ "LightGray", 0xffd3d3d3 },
1238+	{ "LightGreen", 0xff90ee90 },
1239+	{ "LightGrey", 0xffd3d3d3 },
1240+	{ "LightPink", 0xffffb6c1 },
1241+	{ "LightPink1", 0xffffaeb9 },
1242+	{ "LightPink2", 0xffeea2ad },
1243+	{ "LightPink3", 0xffcd8c95 },
1244+	{ "LightPink4", 0xff8b5f65 },
1245+	{ "LightSalmon", 0xffffa07a },
1246+	{ "LightSalmon1", 0xffffa07a },
1247+	{ "LightSalmon2", 0xffee9572 },
1248+	{ "LightSalmon3", 0xffcd8162 },
1249+	{ "LightSalmon4", 0xff8b5742 },
1250+	{ "LightSeaGreen", 0xff20b2aa },
1251+	{ "LightSkyBlue", 0xff87cefa },
1252+	{ "LightSkyBlue1", 0xffb0e2ff },
1253+	{ "LightSkyBlue2", 0xffa4d3ee },
1254+	{ "LightSkyBlue3", 0xff8db6cd },
1255+	{ "LightSkyBlue4", 0xff607b8b },
1256+	{ "LightSlateBlue", 0xff8470ff },
1257+	{ "LightSlateGray", 0xff778899 },
1258+	{ "LightSlateGrey", 0xff778899 },
1259+	{ "LightSteelBlue", 0xffb0c4de },
1260+	{ "LightSteelBlue1", 0xffcae1ff },
1261+	{ "LightSteelBlue2", 0xffbcd2ee },
1262+	{ "LightSteelBlue3", 0xffa2b5cd },
1263+	{ "LightSteelBlue4", 0xff6e7b8b },
1264+	{ "LightYellow", 0xffffffe0 },
1265+	{ "LightYellow1", 0xffffffe0 },
1266+	{ "LightYellow2", 0xffeeeed1 },
1267+	{ "LightYellow3", 0xffcdcdb4 },
1268+	{ "LightYellow4", 0xff8b8b7a },
1269+	{ "lime green", 0xff32cd32 },
1270+	{ "LimeGreen", 0xff32cd32 },
1271+	{ "linen", 0xfffaf0e6 },
1272+	{ "magenta", 0xffff00ff },
1273+	{ "magenta1", 0xffff00ff },
1274+	{ "magenta2", 0xffee00ee },
1275+	{ "magenta3", 0xffcd00cd },
1276+	{ "magenta4", 0xff8b008b },
1277+	{ "maroon", 0xffb03060 },
1278+	{ "maroon1", 0xffff34b3 },
1279+	{ "maroon2", 0xffee30a7 },
1280+	{ "maroon3", 0xffcd2990 },
1281+	{ "maroon4", 0xff8b1c62 },
1282+	{ "medium aquamarine", 0xff66cdaa },
1283+	{ "medium blue", 0xff0000cd },
1284+	{ "medium orchid", 0xffba55d3 },
1285+	{ "medium purple", 0xff9370db },
1286+	{ "medium sea green", 0xff3cb371 },
1287+	{ "medium slate blue", 0xff7b68ee },
1288+	{ "medium spring green", 0xff00fa9a },
1289+	{ "medium turquoise", 0xff48d1cc },
1290+	{ "medium violet red", 0xffc71585 },
1291+	{ "MediumAquamarine", 0xff66cdaa },
1292+	{ "MediumBlue", 0xff0000cd },
1293+	{ "MediumOrchid", 0xffba55d3 },
1294+	{ "MediumOrchid1", 0xffe066ff },
1295+	{ "MediumOrchid2", 0xffd15fee },
1296+	{ "MediumOrchid3", 0xffb452cd },
1297+	{ "MediumOrchid4", 0xff7a378b },
1298+	{ "MediumPurple", 0xff9370db },
1299+	{ "MediumPurple1", 0xffab82ff },
1300+	{ "MediumPurple2", 0xff9f79ee },
1301+	{ "MediumPurple3", 0xff8968cd },
1302+	{ "MediumPurple4", 0xff5d478b },
1303+	{ "MediumSeaGreen", 0xff3cb371 },
1304+	{ "MediumSlateBlue", 0xff7b68ee },
1305+	{ "MediumSpringGreen", 0xff00fa9a },
1306+	{ "MediumTurquoise", 0xff48d1cc },
1307+	{ "MediumVioletRed", 0xffc71585 },
1308+	{ "midnight blue", 0xff191970 },
1309+	{ "MidnightBlue", 0xff191970 },
1310+	{ "mint cream", 0xfff5fffa },
1311+	{ "MintCream", 0xfff5fffa },
1312+	{ "misty rose", 0xffffe4e1 },
1313+	{ "MistyRose", 0xffffe4e1 },
1314+	{ "MistyRose1", 0xffffe4e1 },
1315+	{ "MistyRose2", 0xffeed5d2 },
1316+	{ "MistyRose3", 0xffcdb7b5 },
1317+	{ "MistyRose4", 0xff8b7d7b },
1318+	{ "moccasin", 0xffffe4b5 },
1319+	{ "navajo white", 0xffffdead },
1320+	{ "NavajoWhite", 0xffffdead },
1321+	{ "NavajoWhite1", 0xffffdead },
1322+	{ "NavajoWhite2", 0xffeecfa1 },
1323+	{ "NavajoWhite3", 0xffcdb38b },
1324+	{ "NavajoWhite4", 0xff8b795e },
1325+	{ "navy", 0xff000080 },
1326+	{ "navy blue", 0xff000080 },
1327+	{ "NavyBlue", 0xff000080 },
1328+	{ "old lace", 0xfffdf5e6 },
1329+	{ "OldLace", 0xfffdf5e6 },
1330+	{ "olive drab", 0xff6b8e23 },
1331+	{ "OliveDrab", 0xff6b8e23 },
1332+	{ "OliveDrab1", 0xffc0ff3e },
1333+	{ "OliveDrab2", 0xffb3ee3a },
1334+	{ "OliveDrab3", 0xff9acd32 },
1335+	{ "OliveDrab4", 0xff698b22 },
1336+	{ "orange", 0xffffa500 },
1337+	{ "orange red", 0xffff4500 },
1338+	{ "orange1", 0xffffa500 },
1339+	{ "orange2", 0xffee9a00 },
1340+	{ "orange3", 0xffcd8500 },
1341+	{ "orange4", 0xff8b5a00 },
1342+	{ "OrangeRed", 0xffff4500 },
1343+	{ "OrangeRed1", 0xffff4500 },
1344+	{ "OrangeRed2", 0xffee4000 },
1345+	{ "OrangeRed3", 0xffcd3700 },
1346+	{ "OrangeRed4", 0xff8b2500 },
1347+	{ "orchid", 0xffda70d6 },
1348+	{ "orchid1", 0xffff83fa },
1349+	{ "orchid2", 0xffee7ae9 },
1350+	{ "orchid3", 0xffcd69c9 },
1351+	{ "orchid4", 0xff8b4789 },
1352+	{ "pale goldenrod", 0xffeee8aa },
1353+	{ "pale green", 0xff98fb98 },
1354+	{ "pale turquoise", 0xffafeeee },
1355+	{ "pale violet red", 0xffdb7093 },
1356+	{ "PaleGoldenrod", 0xffeee8aa },
1357+	{ "PaleGreen", 0xff98fb98 },
1358+	{ "PaleGreen1", 0xff9aff9a },
1359+	{ "PaleGreen2", 0xff90ee90 },
1360+	{ "PaleGreen3", 0xff7ccd7c },
1361+	{ "PaleGreen4", 0xff548b54 },
1362+	{ "PaleTurquoise", 0xffafeeee },
1363+	{ "PaleTurquoise1", 0xffbbffff },
1364+	{ "PaleTurquoise2", 0xffaeeeee },
1365+	{ "PaleTurquoise3", 0xff96cdcd },
1366+	{ "PaleTurquoise4", 0xff668b8b },
1367+	{ "PaleVioletRed", 0xffdb7093 },
1368+	{ "PaleVioletRed1", 0xffff82ab },
1369+	{ "PaleVioletRed2", 0xffee799f },
1370+	{ "PaleVioletRed3", 0xffcd6889 },
1371+	{ "PaleVioletRed4", 0xff8b475d },
1372+	{ "papaya whip", 0xffffefd5 },
1373+	{ "PapayaWhip", 0xffffefd5 },
1374+	{ "peach puff", 0xffffdab9 },
1375+	{ "PeachPuff", 0xffffdab9 },
1376+	{ "PeachPuff1", 0xffffdab9 },
1377+	{ "PeachPuff2", 0xffeecbad },
1378+	{ "PeachPuff3", 0xffcdaf95 },
1379+	{ "PeachPuff4", 0xff8b7765 },
1380+	{ "peru", 0xffcd853f },
1381+	{ "pink", 0xffffc0cb },
1382+	{ "pink1", 0xffffb5c5 },
1383+	{ "pink2", 0xffeea9b8 },
1384+	{ "pink3", 0xffcd919e },
1385+	{ "pink4", 0xff8b636c },
1386+	{ "plum", 0xffdda0dd },
1387+	{ "plum1", 0xffffbbff },
1388+	{ "plum2", 0xffeeaeee },
1389+	{ "plum3", 0xffcd96cd },
1390+	{ "plum4", 0xff8b668b },
1391+	{ "powder blue", 0xffb0e0e6 },
1392+	{ "PowderBlue", 0xffb0e0e6 },
1393+	{ "purple", 0xffa020f0 },
1394+	{ "purple1", 0xff9b30ff },
1395+	{ "purple2", 0xff912cee },
1396+	{ "purple3", 0xff7d26cd },
1397+	{ "purple4", 0xff551a8b },
1398+	{ "red", 0xffff0000 },
1399+	{ "red1", 0xffff0000 },
1400+	{ "red2", 0xffee0000 },
1401+	{ "red3", 0xffcd0000 },
1402+	{ "red4", 0xff8b0000 },
1403+	{ "rosy brown", 0xffbc8f8f },
1404+	{ "RosyBrown", 0xffbc8f8f },
1405+	{ "RosyBrown1", 0xffffc1c1 },
1406+	{ "RosyBrown2", 0xffeeb4b4 },
1407+	{ "RosyBrown3", 0xffcd9b9b },
1408+	{ "RosyBrown4", 0xff8b6969 },
1409+	{ "royal blue", 0xff4169e1 },
1410+	{ "RoyalBlue", 0xff4169e1 },
1411+	{ "RoyalBlue1", 0xff4876ff },
1412+	{ "RoyalBlue2", 0xff436eee },
1413+	{ "RoyalBlue3", 0xff3a5fcd },
1414+	{ "RoyalBlue4", 0xff27408b },
1415+	{ "saddle brown", 0xff8b4513 },
1416+	{ "SaddleBrown", 0xff8b4513 },
1417+	{ "salmon", 0xfffa8072 },
1418+	{ "salmon1", 0xffff8c69 },
1419+	{ "salmon2", 0xffee8262 },
1420+	{ "salmon3", 0xffcd7054 },
1421+	{ "salmon4", 0xff8b4c39 },
1422+	{ "sandy brown", 0xfff4a460 },
1423+	{ "SandyBrown", 0xfff4a460 },
1424+	{ "sea green", 0xff2e8b57 },
1425+	{ "SeaGreen", 0xff2e8b57 },
1426+	{ "SeaGreen1", 0xff54ff9f },
1427+	{ "SeaGreen2", 0xff4eee94 },
1428+	{ "SeaGreen3", 0xff43cd80 },
1429+	{ "SeaGreen4", 0xff2e8b57 },
1430+	{ "seashell", 0xfffff5ee },
1431+	{ "seashell1", 0xfffff5ee },
1432+	{ "seashell2", 0xffeee5de },
1433+	{ "seashell3", 0xffcdc5bf },
1434+	{ "seashell4", 0xff8b8682 },
1435+	{ "sienna", 0xffa0522d },
1436+	{ "sienna1", 0xffff8247 },
1437+	{ "sienna2", 0xffee7942 },
1438+	{ "sienna3", 0xffcd6839 },
1439+	{ "sienna4", 0xff8b4726 },
1440+	{ "sky blue", 0xff87ceeb },
1441+	{ "SkyBlue", 0xff87ceeb },
1442+	{ "SkyBlue1", 0xff87ceff },
1443+	{ "SkyBlue2", 0xff7ec0ee },
1444+	{ "SkyBlue3", 0xff6ca6cd },
1445+	{ "SkyBlue4", 0xff4a708b },
1446+	{ "slate blue", 0xff6a5acd },
1447+	{ "slate gray", 0xff708090 },
1448+	{ "slate grey", 0xff708090 },
1449+	{ "SlateBlue", 0xff6a5acd },
1450+	{ "SlateBlue1", 0xff836fff },
1451+	{ "SlateBlue2", 0xff7a67ee },
1452+	{ "SlateBlue3", 0xff6959cd },
1453+	{ "SlateBlue4", 0xff473c8b },
1454+	{ "SlateGray", 0xff708090 },
1455+	{ "SlateGray1", 0xffc6e2ff },
1456+	{ "SlateGray2", 0xffb9d3ee },
1457+	{ "SlateGray3", 0xff9fb6cd },
1458+	{ "SlateGray4", 0xff6c7b8b },
1459+	{ "SlateGrey", 0xff708090 },
1460+	{ "snow", 0xfffffafa },
1461+	{ "snow1", 0xfffffafa },
1462+	{ "snow2", 0xffeee9e9 },
1463+	{ "snow3", 0xffcdc9c9 },
1464+	{ "snow4", 0xff8b8989 },
1465+	{ "spring green", 0xff00ff7f },
1466+	{ "SpringGreen", 0xff00ff7f },
1467+	{ "SpringGreen1", 0xff00ff7f },
1468+	{ "SpringGreen2", 0xff00ee76 },
1469+	{ "SpringGreen3", 0xff00cd66 },
1470+	{ "SpringGreen4", 0xff008b45 },
1471+	{ "steel blue", 0xff4682b4 },
1472+	{ "SteelBlue", 0xff4682b4 },
1473+	{ "SteelBlue1", 0xff63b8ff },
1474+	{ "SteelBlue2", 0xff5cacee },
1475+	{ "SteelBlue3", 0xff4f94cd },
1476+	{ "SteelBlue4", 0xff36648b },
1477+	{ "tan", 0xffd2b48c },
1478+	{ "tan1", 0xffffa54f },
1479+	{ "tan2", 0xffee9a49 },
1480+	{ "tan3", 0xffcd853f },
1481+	{ "tan4", 0xff8b5a2b },
1482+	{ "thistle", 0xffd8bfd8 },
1483+	{ "thistle1", 0xffffe1ff },
1484+	{ "thistle2", 0xffeed2ee },
1485+	{ "thistle3", 0xffcdb5cd },
1486+	{ "thistle4", 0xff8b7b8b },
1487+	{ "tomato", 0xffff6347 },
1488+	{ "tomato1", 0xffff6347 },
1489+	{ "tomato2", 0xffee5c42 },
1490+	{ "tomato3", 0xffcd4f39 },
1491+	{ "tomato4", 0xff8b3626 },
1492+	{ "turquoise", 0xff40e0d0 },
1493+	{ "turquoise1", 0xff00f5ff },
1494+	{ "turquoise2", 0xff00e5ee },
1495+	{ "turquoise3", 0xff00c5cd },
1496+	{ "turquoise4", 0xff00868b },
1497+	{ "violet", 0xffee82ee },
1498+	{ "violet red", 0xffd02090 },
1499+	{ "VioletRed", 0xffd02090 },
1500+	{ "VioletRed1", 0xffff3e96 },
1501+	{ "VioletRed2", 0xffee3a8c },
1502+	{ "VioletRed3", 0xffcd3278 },
1503+	{ "VioletRed4", 0xff8b2252 },
1504+	{ "wheat", 0xfff5deb3 },
1505+	{ "wheat1", 0xffffe7ba },
1506+	{ "wheat2", 0xffeed8ae },
1507+	{ "wheat3", 0xffcdba96 },
1508+	{ "wheat4", 0xff8b7e66 },
1509+	{ "white", 0xffffffff },
1510+	{ "white smoke", 0xfff5f5f5 },
1511+	{ "WhiteSmoke", 0xfff5f5f5 },
1512+	{ "yellow", 0xffffff00 },
1513+	{ "yellow green", 0xff9acd32 },
1514+	{ "yellow1", 0xffffff00 },
1515+	{ "yellow2", 0xffeeee00 },
1516+	{ "yellow3", 0xffcdcd00 },
1517+	{ "yellow4", 0xff8b8b00 },
1518+	{ "YellowGreen", 0xff9acd32 }
1519 };
1520 
1521 EXPORT
1522-bool wld_lookup_named_color(const char * name, uint32_t * color)
1523+bool
1524+wld_lookup_named_color(const char *name, uint32_t *color)
1525 {
1526-    char * end;
1527-    int low = 0, mid, high = ARRAY_LENGTH(named_colors);
1528-    int r;
1529+	char *end;
1530+	int low = 0, mid, high = ARRAY_LENGTH(named_colors);
1531+	int r;
1532 
1533-    if (name[0] == '#' && name[1] != '\0')
1534-    {
1535-        *color = strtoul(name + 1, &end, 16);
1536+	if (name[0] == '#' && name[1] != '\0') {
1537+		*color = strtoul(name + 1, &end, 16);
1538 
1539-        /* Set alpha channel to opaque. */
1540-        *color |= 0xff << 24;
1541+		/* Set alpha channel to opaque. */
1542+		*color |= 0xff << 24;
1543 
1544-        if (*end == '\0')
1545-            return true;
1546-    }
1547+		if (*end == '\0')
1548+			return true;
1549+	}
1550 
1551-    while (low <= high)
1552-    {
1553-        mid = (low + high) / 2;
1554-        r = strcasecmp(named_colors[mid].name, name);
1555+	while (low <= high) {
1556+		mid = (low + high) / 2;
1557+		r = strcasecmp(named_colors[mid].name, name);
1558 
1559-        if (r == 0)
1560-        {
1561-            *color = named_colors[mid].color;
1562-            return true;
1563-        }
1564-        if (r < 0)
1565-            low = mid + 1;
1566-        else
1567-            high = mid - 1;
1568-    }
1569+		if (r == 0) {
1570+			*color = named_colors[mid].color;
1571+			return true;
1572+		}
1573+		if (r < 0)
1574+			low = mid + 1;
1575+		else
1576+			high = mid - 1;
1577+	}
1578 
1579-    return false;
1580+	return false;
1581 }
1582-
+30, -23
 1@@ -23,48 +23,55 @@
 2 
 3 #include "wld-private.h"
 4 
 5-void context_initialize(struct wld_context * context,
 6-                        const struct wld_context_impl * impl)
 7+void
 8+context_initialize(struct wld_context *context,
 9+                   const struct wld_context_impl *impl)
10 {
11-    *((const struct wld_context_impl **) &context->impl) = impl;
12+	*((const struct wld_context_impl **)&context->impl) = impl;
13 }
14 
15 EXPORT
16-struct wld_renderer * wld_create_renderer(struct wld_context * context)
17+struct wld_renderer *
18+wld_create_renderer(struct wld_context *context)
19 {
20-    return context->impl->create_renderer(context);
21+	return context->impl->create_renderer(context);
22 }
23 
24 EXPORT
25-struct wld_buffer * wld_create_buffer(struct wld_context * context,
26-                                      uint32_t width, uint32_t height,
27-                                      uint32_t format, uint32_t flags)
28+struct wld_buffer *
29+wld_create_buffer(struct wld_context *context,
30+                  uint32_t width, uint32_t height,
31+                  uint32_t format, uint32_t flags)
32 {
33-    return &context->impl->create_buffer(context, width, height,
34-                                         format, flags)->base;
35+	return &context->impl->create_buffer(context, width, height,
36+	                                     format, flags)
37+	            ->base;
38 }
39 
40 EXPORT
41-struct wld_buffer * wld_import_buffer(struct wld_context * context,
42-                                      uint32_t type, union wld_object object,
43-                                      uint32_t width, uint32_t height,
44-                                      uint32_t format, uint32_t pitch)
45+struct wld_buffer *
46+wld_import_buffer(struct wld_context *context,
47+                  uint32_t type, union wld_object object,
48+                  uint32_t width, uint32_t height,
49+                  uint32_t format, uint32_t pitch)
50 {
51-    return &context->impl->import_buffer(context, type, object,
52-                                         width, height, format, pitch)->base;
53+	return &context->impl->import_buffer(context, type, object,
54+	                                     width, height, format, pitch)
55+	            ->base;
56 }
57 
58 EXPORT
59-struct wld_surface * wld_create_surface(struct wld_context * context,
60-                                        uint32_t width, uint32_t height,
61-                                        uint32_t format, uint32_t flags)
62+struct wld_surface *
63+wld_create_surface(struct wld_context *context,
64+                   uint32_t width, uint32_t height,
65+                   uint32_t format, uint32_t flags)
66 {
67-    return context->impl->create_surface(context, width, height, format, flags);
68+	return context->impl->create_surface(context, width, height, format, flags);
69 }
70 
71 EXPORT
72-void wld_destroy_context(struct wld_context * context)
73+void
74+wld_destroy_context(struct wld_context *context)
75 {
76-    context->impl->destroy(context);
77+	context->impl->destroy(context);
78 }
79-
+5, -7
 1@@ -26,11 +26,10 @@
 2 
 3 #include "wld-private.h"
 4 
 5-struct drm_driver
 6-{
 7-    const char * name;
 8-    bool (* device_supported)(uint32_t vendor_id, uint32_t device_id);
 9-    struct wld_context * (* create_context)(int drm_fd);
10+struct drm_driver {
11+	const char *name;
12+	bool (*device_supported)(uint32_t vendor_id, uint32_t device_id);
13+	struct wld_context *(*create_context)(int drm_fd);
14 };
15 
16 #if WITH_DRM_INTEL
17@@ -40,7 +39,6 @@ extern const struct drm_driver intel_drm_driver;
18 extern const struct drm_driver nouveau_drm_driver;
19 #endif
20 extern const struct drm_driver dumb_drm_driver;
21-extern const struct wld_context_impl * dumb_context_impl;
22+extern const struct wld_context_impl *dumb_context_impl;
23 
24 #endif
25-
M drm.c
+60, -59
  1@@ -26,82 +26,83 @@
  2 
  3 #include <sys/sysmacros.h>
  4 
  5-const static struct drm_driver * drivers[] = {
  6+const static struct drm_driver *drivers[] = {
  7 #if WITH_DRM_INTEL
  8-    &intel_drm_driver,
  9+	&intel_drm_driver,
 10 #endif
 11 #if WITH_DRM_NOUVEAU
 12-    &nouveau_drm_driver,
 13+	&nouveau_drm_driver,
 14 #endif
 15-    &dumb_drm_driver
 16+	&dumb_drm_driver
 17 };
 18 
 19-static const struct drm_driver * find_driver(int fd)
 20+static const struct drm_driver *
 21+find_driver(int fd)
 22 {
 23-    char path[64], id[32];
 24-    uint32_t vendor_id, device_id;
 25-    char * path_part;
 26-    struct stat st;
 27-    FILE * file;
 28-    uint32_t index;
 29-    int n;
 30-
 31-    if (fstat(fd, &st) == -1)
 32-        return NULL;
 33-
 34-    if (getenv("WLD_DRM_DUMB"))
 35-        goto dumb;
 36-
 37-    n = snprintf(path, sizeof(path), "/sys/dev/char/%u:%u/device/", major(st.st_rdev), minor(st.st_rdev));
 38-    if (n + 6 >= sizeof(path))
 39-        return NULL;
 40-    path_part = path + n;
 41-
 42-    strcpy(path_part, "vendor");
 43-    file = fopen(path, "r");
 44-    if (!file)
 45-        goto dumb;
 46-    fgets(id, sizeof id, file);
 47-    fclose(file);
 48-    vendor_id = strtoul(id, NULL, 0);
 49-
 50-    strcpy(path_part, "device");
 51-    file = fopen(path, "r");
 52-    if (!file)
 53-        goto dumb;
 54-    fgets(id, sizeof id, file);
 55-    fclose(file);
 56-    device_id = strtoul(id, NULL, 0);
 57-
 58-    for (index = 0; index < ARRAY_LENGTH(drivers); ++index)
 59-    {
 60-        DEBUG("Trying DRM driver `%s'\n", drivers[index]->name);
 61-        if (drivers[index]->device_supported(vendor_id, device_id))
 62-            return drivers[index];
 63-    }
 64-
 65-    DEBUG("No DRM driver supports device 0x%x:0x%x\n", vendor_id, device_id);
 66-
 67-    return NULL;
 68+	char path[64], id[32];
 69+	uint32_t vendor_id, device_id;
 70+	char *path_part;
 71+	struct stat st;
 72+	FILE *file;
 73+	uint32_t index;
 74+	int n;
 75+
 76+	if (fstat(fd, &st) == -1)
 77+		return NULL;
 78+
 79+	if (getenv("WLD_DRM_DUMB"))
 80+		goto dumb;
 81+
 82+	n = snprintf(path, sizeof(path), "/sys/dev/char/%u:%u/device/", major(st.st_rdev), minor(st.st_rdev));
 83+	if (n + 6 >= sizeof(path))
 84+		return NULL;
 85+	path_part = path + n;
 86+
 87+	strcpy(path_part, "vendor");
 88+	file = fopen(path, "r");
 89+	if (!file)
 90+		goto dumb;
 91+	fgets(id, sizeof id, file);
 92+	fclose(file);
 93+	vendor_id = strtoul(id, NULL, 0);
 94+
 95+	strcpy(path_part, "device");
 96+	file = fopen(path, "r");
 97+	if (!file)
 98+		goto dumb;
 99+	fgets(id, sizeof id, file);
100+	fclose(file);
101+	device_id = strtoul(id, NULL, 0);
102+
103+	for (index = 0; index < ARRAY_LENGTH(drivers); ++index) {
104+		DEBUG("Trying DRM driver `%s'\n", drivers[index]->name);
105+		if (drivers[index]->device_supported(vendor_id, device_id))
106+			return drivers[index];
107+	}
108+
109+	DEBUG("No DRM driver supports device 0x%x:0x%x\n", vendor_id, device_id);
110+
111+	return NULL;
112 
113 dumb:
114-    return &dumb_drm_driver;
115+	return &dumb_drm_driver;
116 }
117 
118 EXPORT
119-struct wld_context * wld_drm_create_context(int fd)
120+struct wld_context *
121+wld_drm_create_context(int fd)
122 {
123-    const struct drm_driver * driver;
124+	const struct drm_driver *driver;
125 
126-    if (!(driver = find_driver(fd)))
127-        return NULL;
128+	if (!(driver = find_driver(fd)))
129+		return NULL;
130 
131-    return driver->create_context(fd);
132+	return driver->create_context(fd);
133 }
134 
135 EXPORT
136-bool wld_drm_is_dumb(struct wld_context * context)
137+bool
138+wld_drm_is_dumb(struct wld_context *context)
139 {
140-    return context->impl == dumb_context_impl;
141+	return context->impl == dumb_context_impl;
142 }
143-
M drm.h
+8, -11
 1@@ -29,24 +29,21 @@
 2 
 3 #define WLD_DRM_ID (0x02 << 24)
 4 
 5-enum wld_drm_object_type
 6-{
 7-    WLD_DRM_OBJECT_HANDLE = WLD_DRM_ID,
 8-    WLD_DRM_OBJECT_PRIME_FD,
 9+enum wld_drm_object_type {
10+	WLD_DRM_OBJECT_HANDLE = WLD_DRM_ID,
11+	WLD_DRM_OBJECT_PRIME_FD,
12 };
13 
14-enum wld_drm_flags
15-{
16-    WLD_DRM_FLAG_SCANOUT    = 0x1,
17-    WLD_DRM_FLAG_TILED      = 0x2
18+enum wld_drm_flags {
19+	WLD_DRM_FLAG_SCANOUT = 0x1,
20+	WLD_DRM_FLAG_TILED = 0x2
21 };
22 
23 /**
24  * Create a new WLD context from an opened DRM device file descriptor.
25  */
26-struct wld_context * wld_drm_create_context(int fd);
27+struct wld_context *wld_drm_create_context(int fd);
28 
29-bool wld_drm_is_dumb(struct wld_context * context);
30+bool wld_drm_is_dumb(struct wld_context *context);
31 
32 #endif
33-
M dumb.c
+148, -142
  1@@ -26,210 +26,216 @@
  2 #include "pixman.h"
  3 
  4 #include <fcntl.h>
  5-#include <unistd.h>
  6 #include <sys/mman.h>
  7+#include <unistd.h>
  8 #include <xf86drm.h>
  9 
 10 #include <errno.h>
 11 
 12-struct dumb_context
 13-{
 14-    struct wld_context base;
 15-    int fd;
 16+struct dumb_context {
 17+	struct wld_context base;
 18+	int fd;
 19 };
 20 
 21-struct dumb_buffer
 22-{
 23-    struct buffer base;
 24-    struct wld_exporter exporter;
 25-    struct dumb_context * context;
 26-    uint32_t handle;
 27+struct dumb_buffer {
 28+	struct buffer base;
 29+	struct wld_exporter exporter;
 30+	struct dumb_context *context;
 31+	uint32_t handle;
 32 };
 33 
 34-#include "interface/context.h"
 35 #include "interface/buffer.h"
 36+#include "interface/context.h"
 37 #define DRM_DRIVER_NAME dumb
 38 #include "interface/drm.h"
 39 IMPL(dumb_context, wld_context)
 40 IMPL(dumb_buffer, wld_buffer)
 41 
 42-const struct wld_context_impl * dumb_context_impl = &wld_context_impl;
 43+const struct wld_context_impl *dumb_context_impl = &wld_context_impl;
 44 
 45-bool driver_device_supported(uint32_t vendor_id, uint32_t device_id)
 46+bool
 47+driver_device_supported(uint32_t vendor_id, uint32_t device_id)
 48 {
 49-    return true;
 50+	return true;
 51 }
 52 
 53-struct wld_context * driver_create_context(int drm_fd)
 54+struct wld_context *
 55+driver_create_context(int drm_fd)
 56 {
 57-    struct dumb_context * context;
 58+	struct dumb_context *context;
 59 
 60-    if (!(context = malloc(sizeof *context)))
 61-        return NULL;
 62+	if (!(context = malloc(sizeof *context)))
 63+		return NULL;
 64 
 65-    context_initialize(&context->base, &wld_context_impl);
 66-    context->fd = drm_fd;
 67+	context_initialize(&context->base, &wld_context_impl);
 68+	context->fd = drm_fd;
 69 
 70-    return &context->base;
 71+	return &context->base;
 72 }
 73 
 74-struct wld_renderer * context_create_renderer(struct wld_context * context)
 75+struct wld_renderer *
 76+context_create_renderer(struct wld_context *context)
 77 {
 78-    return wld_create_renderer(wld_pixman_context);
 79+	return wld_create_renderer(wld_pixman_context);
 80 }
 81 
 82-static bool export(struct wld_exporter * exporter, struct wld_buffer * base,
 83-                   uint32_t type, union wld_object * object)
 84+static bool export(struct wld_exporter *exporter, struct wld_buffer *base,
 85+                   uint32_t type, union wld_object *object)
 86 {
 87-    struct dumb_buffer * buffer = dumb_buffer(base);
 88-
 89-    switch (type)
 90-    {
 91-        case WLD_DRM_OBJECT_HANDLE:
 92-            object->u32 = buffer->handle;
 93-            return true;
 94-        case WLD_DRM_OBJECT_PRIME_FD:
 95-            if (drmPrimeHandleToFD(buffer->context->fd, buffer->handle,
 96-                                   DRM_CLOEXEC, &object->i) != 0)
 97-            {
 98-                return false;
 99-            }
100-
101-            return true;
102-        default:
103-            return false;
104-    }
105+	struct dumb_buffer *buffer = dumb_buffer(base);
106+
107+	switch (type) {
108+	case WLD_DRM_OBJECT_HANDLE:
109+		object->u32 = buffer->handle;
110+		return true;
111+	case WLD_DRM_OBJECT_PRIME_FD:
112+		if (drmPrimeHandleToFD(buffer->context->fd, buffer->handle,
113+		                       DRM_CLOEXEC, &object->i)
114+		    != 0) {
115+			return false;
116+		}
117+
118+		return true;
119+	default:
120+		return false;
121+	}
122 }
123 
124-static struct buffer * new_buffer(struct dumb_context * context,
125-                                  uint32_t width, uint32_t height,
126-                                  uint32_t format, uint32_t handle,
127-                                  unsigned long pitch)
128+static struct buffer *
129+new_buffer(struct dumb_context *context,
130+           uint32_t width, uint32_t height,
131+           uint32_t format, uint32_t handle,
132+           unsigned long pitch)
133 {
134-    struct dumb_buffer * buffer;
135+	struct dumb_buffer *buffer;
136 
137-    if (!(buffer = malloc(sizeof *buffer)))
138-        return NULL;
139+	if (!(buffer = malloc(sizeof *buffer)))
140+		return NULL;
141 
142-    buffer_initialize(&buffer->base, &wld_buffer_impl,
143-                      width, height, format, pitch);
144-    buffer->context = context;
145-    buffer->handle = handle;
146-    buffer->exporter.export = &export;
147-    wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
148+	buffer_initialize(&buffer->base, &wld_buffer_impl,
149+	                  width, height, format, pitch);
150+	buffer->context = context;
151+	buffer->handle = handle;
152+	buffer->exporter.export = &export;
153+	wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
154 
155-    return &buffer->base;
156+	return &buffer->base;
157 }
158 
159-struct buffer * context_create_buffer(struct wld_context * base,
160-                                      uint32_t width, uint32_t height,
161-                                      uint32_t format, uint32_t flags)
162+struct buffer *
163+context_create_buffer(struct wld_context *base,
164+                      uint32_t width, uint32_t height,
165+                      uint32_t format, uint32_t flags)
166 {
167-    struct dumb_context * context = dumb_context(base);
168-    struct buffer * buffer;
169-    struct drm_mode_create_dumb create_dumb = {
170-        .height = height, .width = width,
171-        .bpp = format_bytes_per_pixel(format) * 8,
172-    };
173-
174-    if (drmIoctl(context->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_dumb) != 0)
175-        goto error0;
176-
177-    buffer = new_buffer(context, width, height, format,
178-                        create_dumb.handle, create_dumb.pitch);
179-
180-    if (!buffer)
181-        goto error1;
182-
183-    return buffer;
184-
185-  error1:
186-    {
187-        struct drm_mode_destroy_dumb destroy_dumb = {
188-            .handle = create_dumb.handle
189-        };
190-
191-        drmIoctl(context->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
192-    }
193-  error0:
194-    return NULL;
195+	struct dumb_context *context = dumb_context(base);
196+	struct buffer *buffer;
197+	struct drm_mode_create_dumb create_dumb = {
198+		.height = height,
199+		.width = width,
200+		.bpp = format_bytes_per_pixel(format) * 8,
201+	};
202+
203+	if (drmIoctl(context->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_dumb) != 0)
204+		goto error0;
205+
206+	buffer = new_buffer(context, width, height, format,
207+	                    create_dumb.handle, create_dumb.pitch);
208+
209+	if (!buffer)
210+		goto error1;
211+
212+	return buffer;
213+
214+error1 : {
215+	struct drm_mode_destroy_dumb destroy_dumb = {
216+		.handle = create_dumb.handle
217+	};
218+
219+	drmIoctl(context->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
220+}
221+error0:
222+	return NULL;
223 }
224 
225-struct buffer * context_import_buffer(struct wld_context * base,
226-                                      uint32_t type, union wld_object object,
227-                                      uint32_t width, uint32_t height,
228-                                      uint32_t format, uint32_t pitch)
229+struct buffer *
230+context_import_buffer(struct wld_context *base,
231+                      uint32_t type, union wld_object object,
232+                      uint32_t width, uint32_t height,
233+                      uint32_t format, uint32_t pitch)
234 {
235-    struct dumb_context * context = dumb_context(base);
236-    uint32_t handle;
237-
238-    switch (type)
239-    {
240-        case WLD_DRM_OBJECT_PRIME_FD:
241-            if (drmPrimeFDToHandle(context->fd, object.i, &handle) != 0)
242-                return NULL;
243-            break;
244-        default: return NULL;
245-    }
246-
247-    return new_buffer(context, width, height, format, handle, pitch);
248+	struct dumb_context *context = dumb_context(base);
249+	uint32_t handle;
250+
251+	switch (type) {
252+	case WLD_DRM_OBJECT_PRIME_FD:
253+		if (drmPrimeFDToHandle(context->fd, object.i, &handle) != 0)
254+			return NULL;
255+		break;
256+	default:
257+		return NULL;
258+	}
259+
260+	return new_buffer(context, width, height, format, handle, pitch);
261 }
262 
263-void context_destroy(struct wld_context * base)
264+void
265+context_destroy(struct wld_context *base)
266 {
267-    struct dumb_context * context = dumb_context(base);
268+	struct dumb_context *context = dumb_context(base);
269 
270-    close(context->fd);
271-    free(context);
272+	close(context->fd);
273+	free(context);
274 }
275 
276 /**** Buffer ****/
277 
278-bool buffer_map(struct buffer * base)
279+bool
280+buffer_map(struct buffer *base)
281 {
282-    struct dumb_buffer * buffer = dumb_buffer(&base->base);
283-    struct drm_mode_map_dumb map_dumb = { .handle = buffer->handle };
284-    void * data;
285+	struct dumb_buffer *buffer = dumb_buffer(&base->base);
286+	struct drm_mode_map_dumb map_dumb = { .handle = buffer->handle };
287+	void *data;
288 
289-    if (drmIoctl(buffer->context->fd, DRM_IOCTL_MODE_MAP_DUMB,
290-                 &map_dumb) != 0)
291-    {
292-        return false;
293-    }
294+	if (drmIoctl(buffer->context->fd, DRM_IOCTL_MODE_MAP_DUMB,
295+	             &map_dumb)
296+	    != 0) {
297+		return false;
298+	}
299 
300-    data = mmap(NULL, buffer->base.base.pitch * buffer->base.base.height,
301-                PROT_READ | PROT_WRITE, MAP_SHARED,
302-                buffer->context->fd, map_dumb.offset);
303+	data = mmap(NULL, buffer->base.base.pitch * buffer->base.base.height,
304+	            PROT_READ | PROT_WRITE, MAP_SHARED,
305+	            buffer->context->fd, map_dumb.offset);
306 
307-    if (data == MAP_FAILED)
308-        return false;
309+	if (data == MAP_FAILED)
310+		return false;
311 
312-    buffer->base.base.map = data;
313+	buffer->base.base.map = data;
314 
315-    return true;
316+	return true;
317 }
318 
319-bool buffer_unmap(struct buffer * buffer)
320+bool
321+buffer_unmap(struct buffer *buffer)
322 {
323-    if (munmap(buffer->base.map,
324-               buffer->base.pitch * buffer->base.height) == -1)
325-    {
326-        return false;
327-    }
328+	if (munmap(buffer->base.map,
329+	           buffer->base.pitch * buffer->base.height)
330+	    == -1) {
331+		return false;
332+	}
333 
334-    buffer->base.map = NULL;
335+	buffer->base.map = NULL;
336 
337-    return true;
338+	return true;
339 }
340 
341-void buffer_destroy(struct buffer * base)
342+void
343+buffer_destroy(struct buffer *base)
344 {
345-    struct dumb_buffer * buffer = dumb_buffer(&base->base);
346-    struct drm_mode_destroy_dumb destroy_dumb = {
347-        .handle = buffer->handle
348-    };
349+	struct dumb_buffer *buffer = dumb_buffer(&base->base);
350+	struct drm_mode_destroy_dumb destroy_dumb = {
351+		.handle = buffer->handle
352+	};
353 
354-    drmIoctl(buffer->context->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
355-    free(buffer);
356+	drmIoctl(buffer->context->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
357+	free(buffer);
358 }
359-
M font.c
+128, -131
  1@@ -26,210 +26,207 @@
  2 #include <fontconfig/fcfreetype.h>
  3 
  4 EXPORT
  5-struct wld_font_context * wld_font_create_context()
  6+struct wld_font_context *
  7+wld_font_create_context()
  8 {
  9-    struct wld_font_context * context;
 10+	struct wld_font_context *context;
 11 
 12-    context = malloc(sizeof *context);
 13+	context = malloc(sizeof *context);
 14 
 15-    if (!context)
 16-        goto error0;
 17+	if (!context)
 18+		goto error0;
 19 
 20-    if (FT_Init_FreeType(&context->library) != 0)
 21-    {
 22-        DEBUG("Failed to initialize FreeType library\n");
 23+	if (FT_Init_FreeType(&context->library) != 0) {
 24+		DEBUG("Failed to initialize FreeType library\n");
 25 
 26-        goto error1;
 27-    }
 28+		goto error1;
 29+	}
 30 
 31-    return context;
 32+	return context;
 33 
 34-  error1:
 35-    free(context);
 36-  error0:
 37-    return NULL;
 38+error1:
 39+	free(context);
 40+error0:
 41+	return NULL;
 42 }
 43 
 44 EXPORT
 45-void wld_font_destroy_context(struct wld_font_context * context)
 46+void
 47+wld_font_destroy_context(struct wld_font_context *context)
 48 {
 49-    FT_Done_FreeType(context->library);
 50-    free(context);
 51+	FT_Done_FreeType(context->library);
 52+	free(context);
 53 }
 54 
 55 EXPORT
 56-struct wld_font * wld_font_open_name(struct wld_font_context * context,
 57-                                     const char * name)
 58+struct wld_font *
 59+wld_font_open_name(struct wld_font_context *context,
 60+                   const char *name)
 61 {
 62-    FcPattern * pattern, * match;
 63-    FcResult result;
 64+	FcPattern *pattern, *match;
 65+	FcResult result;
 66 
 67-    DEBUG("Opening font with name: %s\n", name);
 68+	DEBUG("Opening font with name: %s\n", name);
 69 
 70-    pattern = FcNameParse((const FcChar8 *) name);
 71-    FcConfigSubstitute(NULL, pattern, FcMatchPattern);
 72-    FcDefaultSubstitute(pattern);
 73+	pattern = FcNameParse((const FcChar8 *)name);
 74+	FcConfigSubstitute(NULL, pattern, FcMatchPattern);
 75+	FcDefaultSubstitute(pattern);
 76 
 77-    match = FcFontMatch(NULL, pattern, &result);
 78+	match = FcFontMatch(NULL, pattern, &result);
 79 
 80-    if (!match)
 81-        return NULL;
 82+	if (!match)
 83+		return NULL;
 84 
 85-    return wld_font_open_pattern(context, match);
 86+	return wld_font_open_pattern(context, match);
 87 }
 88 
 89 EXPORT
 90-struct wld_font * wld_font_open_pattern(struct wld_font_context * context,
 91-                                        FcPattern * match)
 92+struct wld_font *
 93+wld_font_open_pattern(struct wld_font_context *context,
 94+                      FcPattern *match)
 95 {
 96-    char * filename;
 97-    struct font * font;
 98-    FcResult result;
 99-    double pixel_size, aspect;
100+	char *filename;
101+	struct font *font;
102+	FcResult result;
103+	double pixel_size, aspect;
104 
105-    font = malloc(sizeof *font);
106+	font = malloc(sizeof *font);
107 
108-    if (!font)
109-        goto error0;
110+	if (!font)
111+		goto error0;
112 
113-    font->context = context;
114+	font->context = context;
115 
116-    result = FcPatternGetString(match, FC_FILE, 0, (FcChar8 **) &filename);
117+	result = FcPatternGetString(match, FC_FILE, 0, (FcChar8 **)&filename);
118 
119-    if (result == FcResultMatch)
120-    {
121-        FT_Error error;
122+	if (result == FcResultMatch) {
123+		FT_Error error;
124 
125-        DEBUG("Loading font file: %s\n", filename);
126+		DEBUG("Loading font file: %s\n", filename);
127 
128-        error = FT_New_Face(context->library, filename, 0, &font->face);
129+		error = FT_New_Face(context->library, filename, 0, &font->face);
130 
131-        if (error == 0)
132-            goto load_face;
133-    }
134+		if (error == 0)
135+			goto load_face;
136+	}
137 
138-    result = FcPatternGetFTFace(match, FC_FT_FACE, 0, &font->face);
139+	result = FcPatternGetFTFace(match, FC_FT_FACE, 0, &font->face);
140 
141-    if (result != FcResultMatch)
142-    {
143-        DEBUG("Couldn't determine font filename or FreeType face\n");
144-        goto error1;
145-    }
146+	if (result != FcResultMatch) {
147+		DEBUG("Couldn't determine font filename or FreeType face\n");
148+		goto error1;
149+	}
150 
151-  load_face:
152-    result = FcPatternGetDouble(match, FC_PIXEL_SIZE, 0, &pixel_size);
153+load_face:
154+	result = FcPatternGetDouble(match, FC_PIXEL_SIZE, 0, &pixel_size);
155 
156-    result = FcPatternGetDouble(match, FC_ASPECT, 0, &aspect);
157+	result = FcPatternGetDouble(match, FC_ASPECT, 0, &aspect);
158 
159-    if (result == FcResultNoMatch)
160-        aspect = 1.0;
161+	if (result == FcResultNoMatch)
162+		aspect = 1.0;
163 
164-    if (font->face->face_flags & FT_FACE_FLAG_SCALABLE)
165-    {
166-        FT_F26Dot6 width, height;
167+	if (font->face->face_flags & FT_FACE_FLAG_SCALABLE) {
168+		FT_F26Dot6 width, height;
169 
170-        width = ((unsigned int) pixel_size) << 6;
171-        height = ((unsigned int) (pixel_size * aspect)) << 6;
172+		width = ((unsigned int)pixel_size) << 6;
173+		height = ((unsigned int)(pixel_size * aspect)) << 6;
174 
175-        FT_Set_Char_Size(font->face, width, height, 0, 0);
176-    }
177-    else
178-    {
179-        FT_Set_Pixel_Sizes(font->face, (unsigned int) pixel_size,
180-                           (unsigned int) (pixel_size * aspect));
181-    }
182+		FT_Set_Char_Size(font->face, width, height, 0, 0);
183+	} else {
184+		FT_Set_Pixel_Sizes(font->face, (unsigned int)pixel_size,
185+		                   (unsigned int)(pixel_size * aspect));
186+	}
187 
188-    font->base.ascent = font->face->size->metrics.ascender >> 6;
189-    font->base.descent = -font->face->size->metrics.descender >> 6;
190-    font->base.height = font->base.ascent + font->base.descent;
191-    font->base.max_advance = font->face->size->metrics.max_advance >> 6;
192+	font->base.ascent = font->face->size->metrics.ascender >> 6;
193+	font->base.descent = -font->face->size->metrics.descender >> 6;
194+	font->base.height = font->base.ascent + font->base.descent;
195+	font->base.max_advance = font->face->size->metrics.max_advance >> 6;
196 
197-    font->glyphs = calloc(font->face->num_glyphs, sizeof(struct glyph *));
198+	font->glyphs = calloc(font->face->num_glyphs, sizeof(struct glyph *));
199 
200-    return &font->base;
201+	return &font->base;
202 
203-  error1:
204-    free(font);
205-  error0:
206-    return NULL;
207+error1:
208+	free(font);
209+error0:
210+	return NULL;
211 }
212 
213 EXPORT
214-void wld_font_close(struct wld_font * font_base)
215+void
216+wld_font_close(struct wld_font *font_base)
217 {
218-    struct font * font = (void *) font_base;
219+	struct font *font = (void *)font_base;
220 
221-    FT_Done_Face(font->face);
222-    free(font);
223+	FT_Done_Face(font->face);
224+	free(font);
225 }
226 
227-bool font_ensure_glyph(struct font * font, FT_UInt glyph_index)
228+bool
229+font_ensure_glyph(struct font *font, FT_UInt glyph_index)
230 {
231-    if (glyph_index)
232-    {
233-        if (!font->glyphs[glyph_index])
234-        {
235-            struct glyph * glyph;
236+	if (glyph_index) {
237+		if (!font->glyphs[glyph_index]) {
238+			struct glyph *glyph;
239 
240-            glyph = malloc(sizeof *glyph);
241+			glyph = malloc(sizeof *glyph);
242 
243-            if (!glyph)
244-                return false;
245+			if (!glyph)
246+				return false;
247 
248-            FT_Load_Glyph(font->face, glyph_index, FT_LOAD_RENDER
249-                          | FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO);
250+			FT_Load_Glyph(font->face, glyph_index, FT_LOAD_RENDER | FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO);
251 
252-            FT_Bitmap_New(&glyph->bitmap);
253+			FT_Bitmap_New(&glyph->bitmap);
254 
255-            FT_Bitmap_Copy(font->context->library,
256-                           &font->face->glyph->bitmap, &glyph->bitmap);
257+			FT_Bitmap_Copy(font->context->library,
258+			               &font->face->glyph->bitmap, &glyph->bitmap);
259 
260-            glyph->advance = font->face->glyph->metrics.horiAdvance >> 6;
261-            glyph->x = font->face->glyph->bitmap_left;
262-            glyph->y = -font->face->glyph->bitmap_top;
263+			glyph->advance = font->face->glyph->metrics.horiAdvance >> 6;
264+			glyph->x = font->face->glyph->bitmap_left;
265+			glyph->y = -font->face->glyph->bitmap_top;
266 
267-            font->glyphs[glyph_index] = glyph;
268-        }
269+			font->glyphs[glyph_index] = glyph;
270+		}
271 
272-        return true;
273-    }
274+		return true;
275+	}
276 
277-    return false;
278+	return false;
279 }
280 
281 EXPORT
282-bool wld_font_ensure_char(struct wld_font * font_base, uint32_t character)
283+bool
284+wld_font_ensure_char(struct wld_font *font_base, uint32_t character)
285 {
286-    struct font * font = (void *) font_base;
287-    FT_UInt glyph_index;
288+	struct font *font = (void *)font_base;
289+	FT_UInt glyph_index;
290 
291-    glyph_index = FT_Get_Char_Index(font->face, character);
292+	glyph_index = FT_Get_Char_Index(font->face, character);
293 
294-    return font_ensure_glyph(font, glyph_index);
295+	return font_ensure_glyph(font, glyph_index);
296 }
297 
298 EXPORT
299-void wld_font_text_extents_n(struct wld_font * font_base,
300-                             const char * text, int32_t length,
301-                             struct wld_extents * extents)
302+void
303+wld_font_text_extents_n(struct wld_font *font_base,
304+                        const char *text, int32_t length,
305+                        struct wld_extents *extents)
306 {
307-    struct font * font = (void *) font_base;
308-    int ret;
309-    uint32_t c;
310-    FT_UInt glyph_index;
311+	struct font *font = (void *)font_base;
312+	int ret;
313+	uint32_t c;
314+	FT_UInt glyph_index;
315 
316-    extents->advance = 0;
317+	extents->advance = 0;
318 
319-    while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length) > 0) && c != '\0')
320-    {
321-        length -= ret;
322-        text += ret;
323-        glyph_index = FT_Get_Char_Index(font->face, c);
324+	while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length) > 0) && c != '\0') {
325+		length -= ret;
326+		text += ret;
327+		glyph_index = FT_Get_Char_Index(font->face, c);
328 
329-        if (!font_ensure_glyph(font, glyph_index))
330-            continue;
331+		if (!font_ensure_glyph(font, glyph_index))
332+			continue;
333 
334-        extents->advance += font->glyphs[glyph_index]->advance;
335-    }
336+		extents->advance += font->glyphs[glyph_index]->advance;
337+	}
338 }
339-
+259, -251
  1@@ -27,33 +27,30 @@
  2 #include "intel/blt.h"
  3 #include "wld-private.h"
  4 
  5-#include <unistd.h>
  6-#include <intel_bufmgr.h>
  7 #include <i915_drm.h>
  8+#include <intel_bufmgr.h>
  9+#include <unistd.h>
 10 
 11-struct intel_context
 12-{
 13-    struct wld_context base;
 14-    drm_intel_bufmgr * bufmgr;
 15+struct intel_context {
 16+	struct wld_context base;
 17+	drm_intel_bufmgr *bufmgr;
 18 };
 19 
 20-struct intel_renderer
 21-{
 22-    struct wld_renderer base;
 23-    struct intel_batch batch;
 24-    struct intel_buffer * target;
 25+struct intel_renderer {
 26+	struct wld_renderer base;
 27+	struct intel_batch batch;
 28+	struct intel_buffer *target;
 29 };
 30 
 31-struct intel_buffer
 32-{
 33-    struct buffer base;
 34-    struct wld_exporter exporter;
 35-    drm_intel_bo * bo;
 36+struct intel_buffer {
 37+	struct buffer base;
 38+	struct wld_exporter exporter;
 39+	drm_intel_bo *bo;
 40 };
 41 
 42+#include "interface/buffer.h"
 43 #include "interface/context.h"
 44 #include "interface/renderer.h"
 45-#include "interface/buffer.h"
 46 #define DRM_DRIVER_NAME intel
 47 #include "interface/drm.h"
 48 IMPL(intel_context, wld_context)
 49@@ -61,330 +58,341 @@ IMPL(intel_renderer, wld_renderer)
 50 IMPL(intel_buffer, wld_buffer)
 51 
 52 /**** DRM driver ****/
 53-bool driver_device_supported(uint32_t vendor_id, uint32_t device_id)
 54+bool
 55+driver_device_supported(uint32_t vendor_id, uint32_t device_id)
 56 {
 57-    return vendor_id == 0x8086;
 58+	return vendor_id == 0x8086;
 59 }
 60 
 61-struct wld_context * driver_create_context(int drm_fd)
 62+struct wld_context *
 63+driver_create_context(int drm_fd)
 64 {
 65-    struct intel_context * context;
 66+	struct intel_context *context;
 67 
 68-    context = malloc(sizeof *context);
 69+	context = malloc(sizeof *context);
 70 
 71-    if (!context)
 72-        goto error0;
 73+	if (!context)
 74+		goto error0;
 75 
 76-    context_initialize(&context->base, &wld_context_impl);
 77-    context->bufmgr = drm_intel_bufmgr_gem_init(drm_fd, INTEL_BATCH_SIZE);
 78+	context_initialize(&context->base, &wld_context_impl);
 79+	context->bufmgr = drm_intel_bufmgr_gem_init(drm_fd, INTEL_BATCH_SIZE);
 80 
 81-    if (!context->bufmgr)
 82-        goto error1;
 83+	if (!context->bufmgr)
 84+		goto error1;
 85 
 86-    return &context->base;
 87+	return &context->base;
 88 
 89-  error1:
 90-    free(context);
 91-  error0:
 92-    return NULL;
 93+error1:
 94+	free(context);
 95+error0:
 96+	return NULL;
 97 }
 98 
 99 /**** Context ****/
100-struct wld_renderer * context_create_renderer(struct wld_context * base)
101+struct wld_renderer *
102+context_create_renderer(struct wld_context *base)
103 {
104-    struct intel_context * context = intel_context(base);
105-    struct intel_renderer * renderer;
106+	struct intel_context *context = intel_context(base);
107+	struct intel_renderer *renderer;
108 
109-    if (!(renderer = malloc(sizeof *renderer)))
110-        goto error0;
111+	if (!(renderer = malloc(sizeof *renderer)))
112+		goto error0;
113 
114-    if (!(intel_batch_initialize(&renderer->batch, context->bufmgr)))
115-        goto error1;
116+	if (!(intel_batch_initialize(&renderer->batch, context->bufmgr)))
117+		goto error1;
118 
119-    renderer_initialize(&renderer->base, &wld_renderer_impl);
120+	renderer_initialize(&renderer->base, &wld_renderer_impl);
121 
122-    return &renderer->base;
123+	return &renderer->base;
124 
125-  error1:
126-    free(renderer);
127-  error0:
128-    return NULL;
129+error1:
130+	free(renderer);
131+error0:
132+	return NULL;
133 }
134 
135-static bool export(struct wld_exporter * exporter, struct wld_buffer * base,
136-                   uint32_t type, union wld_object * object)
137+static bool export(struct wld_exporter *exporter, struct wld_buffer *base,
138+                   uint32_t type, union wld_object *object)
139 {
140-    struct intel_buffer * buffer = intel_buffer(base);
141-
142-    switch (type)
143-    {
144-        case WLD_DRM_OBJECT_HANDLE:
145-            object->u32 = buffer->bo->handle;
146-            return true;
147-        case WLD_DRM_OBJECT_PRIME_FD:
148-            if (drm_intel_bo_gem_export_to_prime(buffer->bo, &object->i) != 0)
149-                return false;
150-            return true;
151-        default:
152-            return false;
153-    }
154+	struct intel_buffer *buffer = intel_buffer(base);
155+
156+	switch (type) {
157+	case WLD_DRM_OBJECT_HANDLE:
158+		object->u32 = buffer->bo->handle;
159+		return true;
160+	case WLD_DRM_OBJECT_PRIME_FD:
161+		if (drm_intel_bo_gem_export_to_prime(buffer->bo, &object->i) != 0)
162+			return false;
163+		return true;
164+	default:
165+		return false;
166+	}
167 }
168 
169-static struct buffer * new_buffer(uint32_t width, uint32_t height,
170-                                  uint32_t format, uint32_t pitch,
171-                                  drm_intel_bo * bo)
172+static struct buffer *
173+new_buffer(uint32_t width, uint32_t height,
174+           uint32_t format, uint32_t pitch,
175+           drm_intel_bo *bo)
176 {
177-    struct intel_buffer * buffer;
178+	struct intel_buffer *buffer;
179 
180-    if (!(buffer = malloc(sizeof *buffer)))
181-        return NULL;
182+	if (!(buffer = malloc(sizeof *buffer)))
183+		return NULL;
184 
185-    buffer_initialize(&buffer->base, &wld_buffer_impl,
186-                      width, height, format, pitch);
187-    buffer->bo = bo;
188-    buffer->exporter.export = &export;
189-    wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
190+	buffer_initialize(&buffer->base, &wld_buffer_impl,
191+	                  width, height, format, pitch);
192+	buffer->bo = bo;
193+	buffer->exporter.export = &export;
194+	wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
195 
196-    return &buffer->base;
197+	return &buffer->base;
198 }
199 
200-struct buffer * context_create_buffer(struct wld_context * base,
201-                                      uint32_t width, uint32_t height,
202-                                      uint32_t format, uint32_t flags)
203+struct buffer *
204+context_create_buffer(struct wld_context *base,
205+                      uint32_t width, uint32_t height,
206+                      uint32_t format, uint32_t flags)
207 {
208-    struct intel_context * context = intel_context(base);
209-    struct buffer * buffer;
210-    drm_intel_bo * bo;
211-    uint32_t tiling_mode = width >= 128 && !(flags & WLD_FLAG_CURSOR) ? I915_TILING_X : I915_TILING_NONE;
212-    unsigned long pitch;
213+	struct intel_context *context = intel_context(base);
214+	struct buffer *buffer;
215+	drm_intel_bo *bo;
216+	uint32_t tiling_mode = width >= 128 && !(flags & WLD_FLAG_CURSOR) ? I915_TILING_X : I915_TILING_NONE;
217+	unsigned long pitch;
218 
219-    bo = drm_intel_bo_alloc_tiled(context->bufmgr, "buffer", width, height, 4,
220-                                  &tiling_mode, &pitch, 0);
221+	bo = drm_intel_bo_alloc_tiled(context->bufmgr, "buffer", width, height, 4,
222+	                              &tiling_mode, &pitch, 0);
223 
224-    if (!bo)
225-        goto error0;
226+	if (!bo)
227+		goto error0;
228 
229-    if (!(buffer = new_buffer(width, height, format, pitch, bo)))
230-        goto error1;
231+	if (!(buffer = new_buffer(width, height, format, pitch, bo)))
232+		goto error1;
233 
234-    return buffer;
235+	return buffer;
236 
237-  error1:
238-    drm_intel_bo_unreference(bo);
239-  error0:
240-    return NULL;
241+error1:
242+	drm_intel_bo_unreference(bo);
243+error0:
244+	return NULL;
245 }
246 
247-struct buffer * context_import_buffer(struct wld_context * base,
248-                                      uint32_t type, union wld_object object,
249-                                      uint32_t width, uint32_t height,
250-                                      uint32_t format, uint32_t pitch)
251+struct buffer *
252+context_import_buffer(struct wld_context *base,
253+                      uint32_t type, union wld_object object,
254+                      uint32_t width, uint32_t height,
255+                      uint32_t format, uint32_t pitch)
256 {
257-    struct intel_context * context = intel_context(base);
258-    struct buffer * buffer;
259-    drm_intel_bo * bo;
260-
261-    switch (type)
262-    {
263-        case WLD_DRM_OBJECT_PRIME_FD:
264-        {
265-            uint32_t size = width * height * format_bytes_per_pixel(format);
266-            bo = drm_intel_bo_gem_create_from_prime(context->bufmgr,
267-                                                    object.i, size);
268-            break;
269-        }
270-        default: bo = NULL;
271-    };
272-
273-    if (!bo)
274-        goto error0;
275-
276-    if (!(buffer = new_buffer(width, height, format, pitch, bo)))
277-        goto error1;
278-
279-    return buffer;
280-
281-  error1:
282-    drm_intel_bo_unreference(bo);
283-  error0:
284-    return NULL;
285+	struct intel_context *context = intel_context(base);
286+	struct buffer *buffer;
287+	drm_intel_bo *bo;
288+
289+	switch (type) {
290+	case WLD_DRM_OBJECT_PRIME_FD: {
291+		uint32_t size = width * height * format_bytes_per_pixel(format);
292+		bo = drm_intel_bo_gem_create_from_prime(context->bufmgr,
293+		                                        object.i, size);
294+		break;
295+	}
296+	default:
297+		bo = NULL;
298+	};
299+
300+	if (!bo)
301+		goto error0;
302+
303+	if (!(buffer = new_buffer(width, height, format, pitch, bo)))
304+		goto error1;
305+
306+	return buffer;
307+
308+error1:
309+	drm_intel_bo_unreference(bo);
310+error0:
311+	return NULL;
312 }
313 
314-void context_destroy(struct wld_context * base)
315+void
316+context_destroy(struct wld_context *base)
317 {
318-    struct intel_context * context = intel_context(base);
319+	struct intel_context *context = intel_context(base);
320 
321-    drm_intel_bufmgr_destroy(context->bufmgr);
322-    free(context);
323+	drm_intel_bufmgr_destroy(context->bufmgr);
324+	free(context);
325 }
326 
327 /**** Renderer ****/
328-uint32_t renderer_capabilities(struct wld_renderer * renderer,
329-                               struct buffer * buffer)
330+uint32_t
331+renderer_capabilities(struct wld_renderer *renderer,
332+                      struct buffer *buffer)
333 {
334-    if (buffer->base.impl == &wld_buffer_impl)
335-        return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
336+	if (buffer->base.impl == &wld_buffer_impl)
337+		return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
338 
339-    return 0;
340+	return 0;
341 }
342 
343-bool renderer_set_target(struct wld_renderer * base, struct buffer * buffer)
344+bool
345+renderer_set_target(struct wld_renderer *base, struct buffer *buffer)
346 {
347-    struct intel_renderer * renderer = intel_renderer(base);
348+	struct intel_renderer *renderer = intel_renderer(base);
349 
350-    if (buffer && buffer->base.impl != &wld_buffer_impl)
351-        return false;
352+	if (buffer && buffer->base.impl != &wld_buffer_impl)
353+		return false;
354 
355-    renderer->target = buffer ? intel_buffer(&buffer->base) : NULL;
356+	renderer->target = buffer ? intel_buffer(&buffer->base) : NULL;
357 
358-    return true;
359+	return true;
360 }
361 
362-void renderer_fill_rectangle(struct wld_renderer * base, uint32_t color,
363-                             int32_t x, int32_t y,
364-                             uint32_t width, uint32_t height)
365+void
366+renderer_fill_rectangle(struct wld_renderer *base, uint32_t color,
367+                        int32_t x, int32_t y,
368+                        uint32_t width, uint32_t height)
369 {
370-    struct intel_renderer * renderer = intel_renderer(base);
371-    struct intel_buffer * dst = renderer->target;
372+	struct intel_renderer *renderer = intel_renderer(base);
373+	struct intel_buffer *dst = renderer->target;
374 
375-    xy_color_blt(&renderer->batch, dst->bo, dst->base.base.pitch,
376-                 x, y, x + width, y + height, color);
377+	xy_color_blt(&renderer->batch, dst->bo, dst->base.base.pitch,
378+	             x, y, x + width, y + height, color);
379 }
380 
381-void renderer_copy_rectangle(struct wld_renderer * base,
382-                             struct buffer * buffer_base,
383-                             int32_t dst_x, int32_t dst_y,
384-                             int32_t src_x, int32_t src_y,
385-                             uint32_t width, uint32_t height)
386+void
387+renderer_copy_rectangle(struct wld_renderer *base,
388+                        struct buffer *buffer_base,
389+                        int32_t dst_x, int32_t dst_y,
390+                        int32_t src_x, int32_t src_y,
391+                        uint32_t width, uint32_t height)
392 {
393-    struct intel_renderer * renderer = intel_renderer(base);
394+	struct intel_renderer *renderer = intel_renderer(base);
395 
396-    if (buffer_base->base.impl != &wld_buffer_impl)
397-        return;
398+	if (buffer_base->base.impl != &wld_buffer_impl)
399+		return;
400 
401-    struct intel_buffer * src = intel_buffer(&buffer_base->base),
402-                        * dst = renderer->target;
403+	struct intel_buffer *src = intel_buffer(&buffer_base->base),
404+	                    *dst = renderer->target;
405 
406-    xy_src_copy_blt(&renderer->batch,
407-                    src->bo, src->base.base.pitch, src_x, src_y,
408-                    dst->bo, dst->base.base.pitch, dst_x, dst_y, width, height);
409+	xy_src_copy_blt(&renderer->batch,
410+	                src->bo, src->base.base.pitch, src_x, src_y,
411+	                dst->bo, dst->base.base.pitch, dst_x, dst_y, width, height);
412 }
413 
414-void renderer_draw_text(struct wld_renderer * base,
415-                        struct font * font, uint32_t color,
416-                        int32_t x, int32_t y, const char * text,
417-                        uint32_t length, struct wld_extents * extents)
418+void
419+renderer_draw_text(struct wld_renderer *base,
420+                   struct font *font, uint32_t color,
421+                   int32_t x, int32_t y, const char *text,
422+                   uint32_t length, struct wld_extents *extents)
423 {
424-    struct intel_renderer * renderer = intel_renderer(base);
425-    struct intel_buffer * dst = renderer->target;
426-    int ret;
427-    struct glyph * glyph;
428-    uint32_t row;
429-    FT_UInt glyph_index;
430-    uint32_t c;
431-    uint8_t immediate[512];
432-    uint8_t * byte;
433-    int32_t origin_x = x;
434-
435-    xy_setup_blt(&renderer->batch, true, BLT_RASTER_OPERATION_SRC,
436-                 0, color, dst->bo, dst->base.base.pitch);
437-
438-    if (length == -1)
439-        length = strlen(text);
440-
441-    while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length)) > 0 && c != '\0')
442-    {
443-        text += ret;
444-        length -= ret;
445-        glyph_index = FT_Get_Char_Index(font->face, c);
446-
447-        if (!font_ensure_glyph(font, glyph_index))
448-            continue;
449-
450-        glyph = font->glyphs[glyph_index];
451-
452-        if (glyph->bitmap.width == 0 || glyph->bitmap.rows == 0)
453-            goto advance;
454-
455-        byte = immediate;
456-
457-        /* XY_TEXT_IMMEDIATE requires a pitch with no extra bytes */
458-        for (row = 0; row < glyph->bitmap.rows; ++row)
459-        {
460-            memcpy(byte, glyph->bitmap.buffer + (row * glyph->bitmap.pitch),
461-                   (glyph->bitmap.width + 7) / 8);
462-            byte += (glyph->bitmap.width + 7) / 8;
463-        }
464-
465-      retry:
466-        ret = xy_text_immediate_blt(&renderer->batch, dst->bo,
467-                                    origin_x + glyph->x, y + glyph->y,
468-                                    origin_x + glyph->x + glyph->bitmap.width,
469-                                    y + glyph->y + glyph->bitmap.rows,
470-                                    (byte - immediate + 3) / 4,
471-                                    (uint32_t *) immediate);
472-
473-        if (ret == INTEL_BATCH_NO_SPACE)
474-        {
475-            intel_batch_flush(&renderer->batch);
476-            xy_setup_blt(&renderer->batch, true, BLT_RASTER_OPERATION_SRC,
477-                         0, color, dst->bo, dst->base.base.pitch);
478-            goto retry;
479-        }
480-
481-      advance:
482-        origin_x += glyph->advance;
483-    }
484-
485-    if (extents)
486-        extents->advance = origin_x - x;
487+	struct intel_renderer *renderer = intel_renderer(base);
488+	struct intel_buffer *dst = renderer->target;
489+	int ret;
490+	struct glyph *glyph;
491+	uint32_t row;
492+	FT_UInt glyph_index;
493+	uint32_t c;
494+	uint8_t immediate[512];
495+	uint8_t *byte;
496+	int32_t origin_x = x;
497+
498+	xy_setup_blt(&renderer->batch, true, BLT_RASTER_OPERATION_SRC,
499+	             0, color, dst->bo, dst->base.base.pitch);
500+
501+	if (length == -1)
502+		length = strlen(text);
503+
504+	while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length)) > 0 && c != '\0') {
505+		text += ret;
506+		length -= ret;
507+		glyph_index = FT_Get_Char_Index(font->face, c);
508+
509+		if (!font_ensure_glyph(font, glyph_index))
510+			continue;
511+
512+		glyph = font->glyphs[glyph_index];
513+
514+		if (glyph->bitmap.width == 0 || glyph->bitmap.rows == 0)
515+			goto advance;
516+
517+		byte = immediate;
518+
519+		/* XY_TEXT_IMMEDIATE requires a pitch with no extra bytes */
520+		for (row = 0; row < glyph->bitmap.rows; ++row) {
521+			memcpy(byte, glyph->bitmap.buffer + (row * glyph->bitmap.pitch),
522+			       (glyph->bitmap.width + 7) / 8);
523+			byte += (glyph->bitmap.width + 7) / 8;
524+		}
525+
526+	retry:
527+		ret = xy_text_immediate_blt(&renderer->batch, dst->bo,
528+		                            origin_x + glyph->x, y + glyph->y,
529+		                            origin_x + glyph->x + glyph->bitmap.width,
530+		                            y + glyph->y + glyph->bitmap.rows,
531+		                            (byte - immediate + 3) / 4,
532+		                            (uint32_t *)immediate);
533+
534+		if (ret == INTEL_BATCH_NO_SPACE) {
535+			intel_batch_flush(&renderer->batch);
536+			xy_setup_blt(&renderer->batch, true, BLT_RASTER_OPERATION_SRC,
537+			             0, color, dst->bo, dst->base.base.pitch);
538+			goto retry;
539+		}
540+
541+	advance:
542+		origin_x += glyph->advance;
543+	}
544+
545+	if (extents)
546+		extents->advance = origin_x - x;
547 }
548 
549-void renderer_flush(struct wld_renderer * base)
550+void
551+renderer_flush(struct wld_renderer *base)
552 {
553-    struct intel_renderer * renderer = intel_renderer(base);
554+	struct intel_renderer *renderer = intel_renderer(base);
555 
556-    intel_batch_flush(&renderer->batch);
557+	intel_batch_flush(&renderer->batch);
558 }
559 
560-void renderer_destroy(struct wld_renderer * base)
561+void
562+renderer_destroy(struct wld_renderer *base)
563 {
564-    struct intel_renderer * renderer = intel_renderer(base);
565+	struct intel_renderer *renderer = intel_renderer(base);
566 
567-    intel_batch_finalize(&renderer->batch);
568-    free(renderer);
569+	intel_batch_finalize(&renderer->batch);
570+	free(renderer);
571 }
572 
573 /**** Buffer ****/
574-bool buffer_map(struct buffer * base)
575+bool
576+buffer_map(struct buffer *base)
577 {
578-    struct intel_buffer * buffer = intel_buffer(&base->base);
579+	struct intel_buffer *buffer = intel_buffer(&base->base);
580 
581-    if (drm_intel_gem_bo_map_gtt(buffer->bo) != 0)
582-        return false;
583+	if (drm_intel_gem_bo_map_gtt(buffer->bo) != 0)
584+		return false;
585 
586-    buffer->base.base.map = buffer->bo->virtual;
587+	buffer->base.base.map = buffer->bo->virtual;
588 
589-    return true;
590+	return true;
591 }
592 
593-bool buffer_unmap(struct buffer * base)
594+bool
595+buffer_unmap(struct buffer *base)
596 {
597-    struct intel_buffer * buffer = intel_buffer(&base->base);
598+	struct intel_buffer *buffer = intel_buffer(&base->base);
599 
600-    if (drm_intel_gem_bo_unmap_gtt(buffer->bo) != 0)
601-        return false;
602+	if (drm_intel_gem_bo_unmap_gtt(buffer->bo) != 0)
603+		return false;
604 
605-    buffer->base.base.map = NULL;
606+	buffer->base.base.map = NULL;
607 
608-    return true;
609+	return true;
610 }
611 
612-void buffer_destroy(struct buffer * base)
613+void
614+buffer_destroy(struct buffer *base)
615 {
616-    struct intel_buffer * buffer = intel_buffer(&base->base);
617+	struct intel_buffer *buffer = intel_buffer(&base->base);
618 
619-    drm_intel_bo_unreference(buffer->bo);
620-    free(buffer);
621+	drm_intel_bo_unreference(buffer->bo);
622+	free(buffer);
623 }
624-
+78, -74
  1@@ -27,97 +27,101 @@
  2 #include <i915_drm.h>
  3 #include <stdlib.h>
  4 
  5-static const struct intel_device_info device_info_i965      = { .gen = 4 };
  6-static const struct intel_device_info device_info_g4x       = { .gen = 4 };
  7-static const struct intel_device_info device_info_ilk       = { .gen = 5 };
  8-static const struct intel_device_info device_info_snb_gt1   = { .gen = 6 };
  9-static const struct intel_device_info device_info_snb_gt2   = { .gen = 6 };
 10-static const struct intel_device_info device_info_ivb_gt1   = { .gen = 7 };
 11-static const struct intel_device_info device_info_ivb_gt2   = { .gen = 7 };
 12-static const struct intel_device_info device_info_byt       = { .gen = 7 };
 13-static const struct intel_device_info device_info_hsw_gt1   = { .gen = 7 };
 14-static const struct intel_device_info device_info_hsw_gt2   = { .gen = 7 };
 15-static const struct intel_device_info device_info_hsw_gt3   = { .gen = 7 };
 16-static const struct intel_device_info device_info_bdw_gt1   = { .gen = 8 };
 17-static const struct intel_device_info device_info_bdw_gt2   = { .gen = 8 };
 18-static const struct intel_device_info device_info_bdw_gt3   = { .gen = 8 };
 19-static const struct intel_device_info device_info_chv       = { .gen = 8 };
 20-static const struct intel_device_info device_info_skl_gt1   = { .gen = 9 };
 21-static const struct intel_device_info device_info_skl_gt2   = { .gen = 9 };
 22-static const struct intel_device_info device_info_skl_gt3   = { .gen = 9 };
 23-static const struct intel_device_info device_info_skl_gt4   = { .gen = 9 };
 24-static const struct intel_device_info device_info_bxt       = { .gen = 9 };
 25-static const struct intel_device_info device_info_bxt_2x6   = { .gen = 9 };
 26-static const struct intel_device_info device_info_kbl_gt1   = { .gen = 9 };
 27+static const struct intel_device_info device_info_i965 = { .gen = 4 };
 28+static const struct intel_device_info device_info_g4x = { .gen = 4 };
 29+static const struct intel_device_info device_info_ilk = { .gen = 5 };
 30+static const struct intel_device_info device_info_snb_gt1 = { .gen = 6 };
 31+static const struct intel_device_info device_info_snb_gt2 = { .gen = 6 };
 32+static const struct intel_device_info device_info_ivb_gt1 = { .gen = 7 };
 33+static const struct intel_device_info device_info_ivb_gt2 = { .gen = 7 };
 34+static const struct intel_device_info device_info_byt = { .gen = 7 };
 35+static const struct intel_device_info device_info_hsw_gt1 = { .gen = 7 };
 36+static const struct intel_device_info device_info_hsw_gt2 = { .gen = 7 };
 37+static const struct intel_device_info device_info_hsw_gt3 = { .gen = 7 };
 38+static const struct intel_device_info device_info_bdw_gt1 = { .gen = 8 };
 39+static const struct intel_device_info device_info_bdw_gt2 = { .gen = 8 };
 40+static const struct intel_device_info device_info_bdw_gt3 = { .gen = 8 };
 41+static const struct intel_device_info device_info_chv = { .gen = 8 };
 42+static const struct intel_device_info device_info_skl_gt1 = { .gen = 9 };
 43+static const struct intel_device_info device_info_skl_gt2 = { .gen = 9 };
 44+static const struct intel_device_info device_info_skl_gt3 = { .gen = 9 };
 45+static const struct intel_device_info device_info_skl_gt4 = { .gen = 9 };
 46+static const struct intel_device_info device_info_bxt = { .gen = 9 };
 47+static const struct intel_device_info device_info_bxt_2x6 = { .gen = 9 };
 48+static const struct intel_device_info device_info_kbl_gt1 = { .gen = 9 };
 49 static const struct intel_device_info device_info_kbl_gt1_5 = { .gen = 9 };
 50-static const struct intel_device_info device_info_kbl_gt2   = { .gen = 9 };
 51-static const struct intel_device_info device_info_kbl_gt3   = { .gen = 9 };
 52-static const struct intel_device_info device_info_kbl_gt4   = { .gen = 9 };
 53-static const struct intel_device_info device_info_glk       = { .gen = 9 };
 54-static const struct intel_device_info device_info_glk_2x6   = { .gen = 9 };
 55-static const struct intel_device_info device_info_cfl_gt1   = { .gen = 9 };
 56-static const struct intel_device_info device_info_cfl_gt2   = { .gen = 9 };
 57-static const struct intel_device_info device_info_cfl_gt3   = { .gen = 9 };
 58-static const struct intel_device_info device_info_cnl_2x8   = { .gen = 10 };
 59-static const struct intel_device_info device_info_cnl_3x8   = { .gen = 10 };
 60-static const struct intel_device_info device_info_cnl_4x8   = { .gen = 10 };
 61-static const struct intel_device_info device_info_cnl_5x8   = { .gen = 10 };
 62-
 63-static const struct intel_device_info * device_info(int device_id)
 64+static const struct intel_device_info device_info_kbl_gt2 = { .gen = 9 };
 65+static const struct intel_device_info device_info_kbl_gt3 = { .gen = 9 };
 66+static const struct intel_device_info device_info_kbl_gt4 = { .gen = 9 };
 67+static const struct intel_device_info device_info_glk = { .gen = 9 };
 68+static const struct intel_device_info device_info_glk_2x6 = { .gen = 9 };
 69+static const struct intel_device_info device_info_cfl_gt1 = { .gen = 9 };
 70+static const struct intel_device_info device_info_cfl_gt2 = { .gen = 9 };
 71+static const struct intel_device_info device_info_cfl_gt3 = { .gen = 9 };
 72+static const struct intel_device_info device_info_cnl_2x8 = { .gen = 10 };
 73+static const struct intel_device_info device_info_cnl_3x8 = { .gen = 10 };
 74+static const struct intel_device_info device_info_cnl_4x8 = { .gen = 10 };
 75+static const struct intel_device_info device_info_cnl_5x8 = { .gen = 10 };
 76+
 77+static const struct intel_device_info *
 78+device_info(int device_id)
 79 {
 80-    switch (device_id)
 81-    {
 82+	switch (device_id) {
 83 #define CHIPSET(device_id, type, name) \
 84-        case device_id: return &device_info_ ## type;
 85+	case device_id:                \
 86+		return &device_info_##type;
 87 #include "i965_pci_ids.h"
 88 #undef CHIPSET
 89-        default: return NULL;
 90-    }
 91+	default:
 92+		return NULL;
 93+	}
 94 }
 95 
 96-bool intel_batch_initialize(struct intel_batch * batch,
 97-                            drm_intel_bufmgr * bufmgr)
 98+bool
 99+intel_batch_initialize(struct intel_batch *batch,
100+                       drm_intel_bufmgr *bufmgr)
101 {
102-    int device_id = drm_intel_bufmgr_gem_get_devid(bufmgr);
103+	int device_id = drm_intel_bufmgr_gem_get_devid(bufmgr);
104 
105-    batch->command_count = 0;
106-    batch->device_info = device_info(device_id);
107+	batch->command_count = 0;
108+	batch->device_info = device_info(device_id);
109 
110-    if (!batch->device_info)
111-        return false;
112+	if (!batch->device_info)
113+		return false;
114 
115-    /* Alignment argument (4096) is not used */
116-    batch->bo = drm_intel_bo_alloc(bufmgr, "batchbuffer",
117-                                   sizeof batch->commands, 4096);
118+	/* Alignment argument (4096) is not used */
119+	batch->bo = drm_intel_bo_alloc(bufmgr, "batchbuffer",
120+	                               sizeof batch->commands, 4096);
121 
122-    if (!batch->bo)
123-        return false;
124+	if (!batch->bo)
125+		return false;
126 
127-    return true;
128+	return true;
129 }
130 
131-void intel_batch_finalize(struct intel_batch * batch)
132+void
133+intel_batch_finalize(struct intel_batch *batch)
134 {
135-    drm_intel_bo_unreference(batch->bo);
136+	drm_intel_bo_unreference(batch->bo);
137 }
138 
139-void intel_batch_flush(struct intel_batch * batch)
140+void
141+intel_batch_flush(struct intel_batch *batch)
142 {
143-    if (batch->command_count == 0)
144-        return;
145-
146-    intel_batch_add_dword(batch, MI_BATCH_BUFFER_END);
147-
148-    /* Pad the batch buffer to the next quad-word. */
149-    if (batch->command_count & 1)
150-        intel_batch_add_dword(batch, MI_NOOP);
151-
152-    drm_intel_bo_subdata(batch->bo, 0, batch->command_count << 2,
153-                         batch->commands);
154-    drm_intel_bo_mrb_exec(batch->bo, batch->command_count << 2, NULL, 0, 0,
155-                          GEN(batch, 6) ? I915_EXEC_BLT
156-                                        : I915_EXEC_DEFAULT);
157-    drm_intel_gem_bo_clear_relocs(batch->bo, 0);
158-    batch->command_count = 0;
159+	if (batch->command_count == 0)
160+		return;
161+
162+	intel_batch_add_dword(batch, MI_BATCH_BUFFER_END);
163+
164+	/* Pad the batch buffer to the next quad-word. */
165+	if (batch->command_count & 1)
166+		intel_batch_add_dword(batch, MI_NOOP);
167+
168+	drm_intel_bo_subdata(batch->bo, 0, batch->command_count << 2,
169+	                     batch->commands);
170+	drm_intel_bo_mrb_exec(batch->bo, batch->command_count << 2, NULL, 0, 0,
171+	                      GEN(batch, 6) ? I915_EXEC_BLT
172+	                                    : I915_EXEC_DEFAULT);
173+	drm_intel_gem_bo_clear_relocs(batch->bo, 0);
174+	batch->command_count = 0;
175 }
176-
+45, -42
  1@@ -24,83 +24,86 @@
  2 #ifndef WLD_INTEL_BATCH_H
  3 #define WLD_INTEL_BATCH_H
  4 
  5+#include <intel_bufmgr.h>
  6 #include <stdarg.h>
  7 #include <stdbool.h>
  8 #include <stdint.h>
  9-#include <intel_bufmgr.h>
 10 
 11 #define INTEL_BATCH_MAX_COMMANDS (1 << 13)
 12 #define INTEL_BATCH_RESERVED_COMMANDS 2
 13 #define INTEL_BATCH_SIZE (INTEL_BATCH_MAX_COMMANDS << 2)
 14 
 15-enum intel_batch_result
 16-{
 17-    INTEL_BATCH_SUCCESS,
 18-    INTEL_BATCH_NO_SPACE
 19+enum intel_batch_result {
 20+	INTEL_BATCH_SUCCESS,
 21+	INTEL_BATCH_NO_SPACE
 22 };
 23 
 24-struct intel_device_info
 25-{
 26-    int gen;
 27+struct intel_device_info {
 28+	int gen;
 29 };
 30 
 31 #define GEN(b, m) ((b)->device_info->gen >= (m))
 32 
 33-struct intel_batch
 34-{
 35-    const struct intel_device_info * device_info;
 36-    drm_intel_bo * bo;
 37-    uint32_t commands[INTEL_BATCH_MAX_COMMANDS];
 38-    uint32_t command_count;
 39+struct intel_batch {
 40+	const struct intel_device_info *device_info;
 41+	drm_intel_bo *bo;
 42+	uint32_t commands[INTEL_BATCH_MAX_COMMANDS];
 43+	uint32_t command_count;
 44 };
 45 
 46-bool intel_batch_initialize(struct intel_batch * batch,
 47-                            drm_intel_bufmgr * bufmgr);
 48+bool intel_batch_initialize(struct intel_batch *batch,
 49+                            drm_intel_bufmgr *bufmgr);
 50 
 51-void intel_batch_finalize(struct intel_batch * batch);
 52+void intel_batch_finalize(struct intel_batch *batch);
 53 
 54-void intel_batch_flush(struct intel_batch * batch);
 55+void intel_batch_flush(struct intel_batch *batch);
 56 
 57-static inline uint32_t intel_batch_check_space(struct intel_batch * batch,
 58-                                               uint32_t size)
 59+static inline uint32_t
 60+intel_batch_check_space(struct intel_batch *batch,
 61+                        uint32_t size)
 62 {
 63-    return (INTEL_BATCH_MAX_COMMANDS - INTEL_BATCH_RESERVED_COMMANDS
 64-            - batch->command_count) >= size;
 65+	return (INTEL_BATCH_MAX_COMMANDS - INTEL_BATCH_RESERVED_COMMANDS
 66+	        - batch->command_count)
 67+	       >= size;
 68 }
 69 
 70-static inline void intel_batch_ensure_space(struct intel_batch * batch, uint32_t size)
 71+static inline void
 72+intel_batch_ensure_space(struct intel_batch *batch, uint32_t size)
 73 {
 74-    if (!intel_batch_check_space(batch, size))
 75-        intel_batch_flush(batch);
 76+	if (!intel_batch_check_space(batch, size))
 77+		intel_batch_flush(batch);
 78 }
 79 
 80-static inline void intel_batch_add_dword(struct intel_batch * batch,
 81-                                         uint32_t dword)
 82+static inline void
 83+intel_batch_add_dword(struct intel_batch *batch,
 84+                      uint32_t dword)
 85 {
 86-    batch->commands[batch->command_count++] = dword;
 87+	batch->commands[batch->command_count++] = dword;
 88 }
 89 
 90-static inline void intel_batch_add_dwords_va(struct intel_batch * batch,
 91-                                             uint32_t count, va_list dwords)
 92+static inline void
 93+intel_batch_add_dwords_va(struct intel_batch *batch,
 94+                          uint32_t count, va_list dwords)
 95 {
 96-    while (count--)
 97-        intel_batch_add_dword(batch, va_arg(dwords, uint32_t));
 98+	while (count--)
 99+		intel_batch_add_dword(batch, va_arg(dwords, uint32_t));
100 }
101 
102-static inline void intel_batch_add_dwords(struct intel_batch * batch,
103-                                          uint32_t count, ...)
104+static inline void
105+intel_batch_add_dwords(struct intel_batch *batch,
106+                       uint32_t count, ...)
107 {
108-    va_list dwords;
109-    va_start(dwords, count);
110-    intel_batch_add_dwords_va(batch, count, dwords);
111-    va_end(dwords);
112+	va_list dwords;
113+	va_start(dwords, count);
114+	intel_batch_add_dwords_va(batch, count, dwords);
115+	va_end(dwords);
116 }
117 
118-static inline uint32_t intel_batch_offset(struct intel_batch * batch,
119-                                         uint32_t command_index)
120+static inline uint32_t
121+intel_batch_offset(struct intel_batch *batch,
122+                   uint32_t command_index)
123 {
124-    return (batch->command_count + command_index) << 2;
125+	return (batch->command_count + command_index) << 2;
126 }
127 
128 #endif
129-
+263, -279
  1@@ -29,360 +29,344 @@
  2 
  3 #define INTEL_CLIENT_BLT 0x2
  4 
  5-enum blt_op
  6-{
  7-    BLT_OP_XY_SETUP_BLT             = 0x01,
  8-    BLT_OP_XY_TEXT_BLT              = 0x26,
  9-    BLT_OP_XY_TEXT_IMMEDIATE_BLT    = 0x31,
 10-    BLT_OP_XY_COLOR_BLT             = 0x50,
 11-    BLT_OP_XY_SRC_COPY_BLT          = 0x53
 12+enum blt_op {
 13+	BLT_OP_XY_SETUP_BLT = 0x01,
 14+	BLT_OP_XY_TEXT_BLT = 0x26,
 15+	BLT_OP_XY_TEXT_IMMEDIATE_BLT = 0x31,
 16+	BLT_OP_XY_COLOR_BLT = 0x50,
 17+	BLT_OP_XY_SRC_COPY_BLT = 0x53
 18 };
 19 
 20-enum blt_32bpp_mask
 21-{
 22-    BLT_32BPP_MASK_ALPHA            = (1 << 0),
 23-    BLT_32BPP_MASK_RGB              = (1 << 1)
 24+enum blt_32bpp_mask {
 25+	BLT_32BPP_MASK_ALPHA = (1 << 0),
 26+	BLT_32BPP_MASK_RGB = (1 << 1)
 27 };
 28 
 29-enum blt_packing
 30-{
 31-    BLT_PACKING_BIT                 = 0,
 32-    BLT_PACKING_BYTE                = 1
 33+enum blt_packing {
 34+	BLT_PACKING_BIT = 0,
 35+	BLT_PACKING_BYTE = 1
 36 };
 37 
 38-enum blt_color_depth
 39-{
 40-    BLT_COLOR_DEPTH_8BIT            = 0x0,
 41-    BLT_COLOR_DEPTH_16BIT_565       = 0x1,
 42-    BLT_COLOR_DEPTH_16BIT_1555      = 0x2,
 43-    BLT_COLOR_DEPTH_32BIT           = 0x3
 44+enum blt_color_depth {
 45+	BLT_COLOR_DEPTH_8BIT = 0x0,
 46+	BLT_COLOR_DEPTH_16BIT_565 = 0x1,
 47+	BLT_COLOR_DEPTH_16BIT_1555 = 0x2,
 48+	BLT_COLOR_DEPTH_32BIT = 0x3
 49 };
 50 
 51-enum blt_raster_operation
 52-{
 53-    BLT_RASTER_OPERATION_SRC        = 0xcc,
 54-    BLT_RASTER_OPERATION_PAT        = 0xf0
 55+enum blt_raster_operation {
 56+	BLT_RASTER_OPERATION_SRC = 0xcc,
 57+	BLT_RASTER_OPERATION_PAT = 0xf0
 58 };
 59 
 60 /* BR00 : BLT Opcode & Control */
 61-#define BLT_BR00_CLIENT(x)                  ((x) << 29) /* 31:29 */
 62-#define BLT_BR00_OP(x)                      ((x) << 22) /* 28:22 */
 63-#define BLT_BR00_32BPP_MASK(x)              ((x) << 20) /* 21:20 */
 64-                                                        /* 19:17 */
 65-#define BLT_BR00_PACKING(x)                 ((x) << 16) /* 16 */
 66-#define BLT_BR00_SRC_TILING_ENABLE(x)       ((x) << 15) /* 15 */
 67-                                                        /* 14:12 */
 68-#define BLT_BR00_DST_TILING_ENABLE(x)       ((x) << 11) /* 11 */
 69-#define BLT_BR00_DWORD_LENGTH(x)            ((x) << 0)  /* 7:0 */
 70+#define BLT_BR00_CLIENT(x) ((x) << 29)            /* 31:29 */
 71+#define BLT_BR00_OP(x) ((x) << 22)                /* 28:22 */
 72+#define BLT_BR00_32BPP_MASK(x) ((x) << 20)        /* 21:20 */
 73+                                                  /* 19:17 */
 74+#define BLT_BR00_PACKING(x) ((x) << 16)           /* 16 */
 75+#define BLT_BR00_SRC_TILING_ENABLE(x) ((x) << 15) /* 15 */
 76+                                                  /* 14:12 */
 77+#define BLT_BR00_DST_TILING_ENABLE(x) ((x) << 11) /* 11 */
 78+#define BLT_BR00_DWORD_LENGTH(x) ((x) << 0)       /* 7:0 */
 79 
 80 /* BR01 : Setup BLT Raster OP, Control, and Destination Offset */
 81-#define BLT_BR01_SOLID_PATTERN(x)           ((x) << 31) /* 31 */
 82-#define BLT_BR01_CLIPPING_ENABLE(x)         ((x) << 30) /* 30 */
 83-#define BLT_BR01_MONO_SRC_TRANSPARENCY(x)   ((x) << 29) /* 29 */
 84-#define BLT_BR01_MONO_PAT_TRANSPARENCY(x)   ((x) << 28) /* 28 */
 85-#define BLT_BR01_COLOR_DEPTH(x)             ((x) << 24) /* 25:24 */
 86-#define BLT_BR01_RASTER_OPERATION(x)        ((x) << 16) /* 23:16 */
 87-#define BLT_BR01_DST_PITCH(x)               ((x) << 0)  /* 15:0 */
 88+#define BLT_BR01_SOLID_PATTERN(x) ((x) << 31)         /* 31 */
 89+#define BLT_BR01_CLIPPING_ENABLE(x) ((x) << 30)       /* 30 */
 90+#define BLT_BR01_MONO_SRC_TRANSPARENCY(x) ((x) << 29) /* 29 */
 91+#define BLT_BR01_MONO_PAT_TRANSPARENCY(x) ((x) << 28) /* 28 */
 92+#define BLT_BR01_COLOR_DEPTH(x) ((x) << 24)           /* 25:24 */
 93+#define BLT_BR01_RASTER_OPERATION(x) ((x) << 16)      /* 23:16 */
 94+#define BLT_BR01_DST_PITCH(x) ((x) << 0)              /* 15:0 */
 95 
 96 /* BR05 : Setup Expansion Background Color */
 97-#define BLT_BR05_BACKGROUND_COLOR(x)        ((x) << 0)  /* 31:0 */
 98+#define BLT_BR05_BACKGROUND_COLOR(x) ((x) << 0) /* 31:0 */
 99 
100 /* BR06 : Setup Expansion Foreground Color */
101-#define BLT_BR06_FOREGROUND_COLOR(x)        ((x) << 0)  /* 31:0 */
102+#define BLT_BR06_FOREGROUND_COLOR(x) ((x) << 0) /* 31:0 */
103 
104 /* BR07 : Setup Blit Color Pattern Address Low Bits */
105-                                                        /* 31:29 */
106-#define BLT_BR07_PAT_ADDRESS(x)             ((x) << 6)  /* 28:6 */
107-                                                        /* 5:0 */
108+/* 31:29 */
109+#define BLT_BR07_PAT_ADDRESS(x) ((x) << 6) /* 28:6 */
110+                                           /* 5:0 */
111 
112 /* BR09 : Destination Address Low Bits */
113-                                                        /* 31:29 */
114-#define BLT_BR09_DST_ADDRESS(x)             ((x) << 0)  /* 28:0 */
115+/* 31:29 */
116+#define BLT_BR09_DST_ADDRESS(x) ((x) << 0) /* 28:0 */
117 
118 /* BR11 : Source Pitch */
119-                                                        /* 31:16 */
120-#define BLT_BR11_SRC_PITCH(x)               ((x) << 0)  /* 15:0 */
121+/* 31:16 */
122+#define BLT_BR11_SRC_PITCH(x) ((x) << 0) /* 15:0 */
123 
124 /* BR12 : Source Address Low Bits */
125-                                                        /* 31:29 */
126-#define BLT_BR12_SRC_ADDRESS(x)             ((x) << 0)  /* 28:0 */
127+/* 31:29 */
128+#define BLT_BR12_SRC_ADDRESS(x) ((x) << 0) /* 28:0 */
129 
130 /* BR13 : BLT Raster OP, Control, and Destination Pitch */
131-#define BLT_BR13_SOLID_PATTERN(x)           ((x) << 31) /* 31 */
132-#define BLT_BR13_CLIPPING_ENABLE(x)         ((x) << 30) /* 30 */
133-#define BLT_BR13_MONO_SRC_TRANSPARENT(x)    ((x) << 29) /* 29 */
134-#define BLT_BR13_MONO_PAT_TRANSPARENT(x)    ((x) << 28) /* 28 */
135-#define BLT_BR13_COLOR_DEPTH(x)             ((x) << 24) /* 25:24 */
136-#define BLT_BR13_RASTER_OPERATION(x)        ((x) << 16) /* 23:16 */
137-#define BLT_BR13_DST_PITCH(x)               ((x) << 0)  /* 15:0 */
138+#define BLT_BR13_SOLID_PATTERN(x) ((x) << 31)        /* 31 */
139+#define BLT_BR13_CLIPPING_ENABLE(x) ((x) << 30)      /* 30 */
140+#define BLT_BR13_MONO_SRC_TRANSPARENT(x) ((x) << 29) /* 29 */
141+#define BLT_BR13_MONO_PAT_TRANSPARENT(x) ((x) << 28) /* 28 */
142+#define BLT_BR13_COLOR_DEPTH(x) ((x) << 24)          /* 25:24 */
143+#define BLT_BR13_RASTER_OPERATION(x) ((x) << 16)     /* 23:16 */
144+#define BLT_BR13_DST_PITCH(x) ((x) << 0)             /* 15:0 */
145 
146 /* BR16 : Pattern Expansion Background & Solid Pattern Color */
147-#define BLT_BR16_COLOR(x)                   ((x) << 0)  /* 31 : 0 */
148+#define BLT_BR16_COLOR(x) ((x) << 0) /* 31 : 0 */
149 
150 /* BR22 : Destination Top Left */
151-#define BLT_BR22_DST_Y1(x)                  ((x) << 16) /* 31:16 */
152-#define BLT_BR22_DST_X1(x)                  ((x) << 0)  /* 16:0 */
153+#define BLT_BR22_DST_Y1(x) ((x) << 16) /* 31:16 */
154+#define BLT_BR22_DST_X1(x) ((x) << 0)  /* 16:0 */
155 
156 /* BR23 : Destination Bottom Right */
157-#define BLT_BR23_DST_Y2(x)                  ((x) << 16) /* 31:16 */
158-#define BLT_BR23_DST_X2(x)                  ((x) << 0)  /* 16:0 */
159+#define BLT_BR23_DST_Y2(x) ((x) << 16) /* 31:16 */
160+#define BLT_BR23_DST_X2(x) ((x) << 0)  /* 16:0 */
161 
162 /* BR24 : Clip Rectangle Top Left */
163-                                                        /* 31 */
164-#define BLT_BR24_CLP_Y1(x)                  ((x) << 16) /* 30:16 */
165-                                                        /* 15 */
166-#define BLT_BR24_CLP_X1(x)                  ((x) << 0)  /* 14:0 */
167+/* 31 */
168+#define BLT_BR24_CLP_Y1(x) ((x) << 16) /* 30:16 */
169+                                       /* 15 */
170+#define BLT_BR24_CLP_X1(x) ((x) << 0)  /* 14:0 */
171 
172 /* BR25 : Clip Rectangle Bottom Right */
173-                                                        /* 31 */
174-#define BLT_BR25_CLP_Y2(x)                  ((x) << 16) /* 30:16 */
175-                                                        /* 15 */
176-#define BLT_BR25_CLP_X2(x)                  ((x) << 0)  /* 14:0 */
177+/* 31 */
178+#define BLT_BR25_CLP_Y2(x) ((x) << 16) /* 30:16 */
179+                                       /* 15 */
180+#define BLT_BR25_CLP_X2(x) ((x) << 0)  /* 14:0 */
181 
182 /* BR26 : Source Top Left */
183-#define BLT_BR26_SRC_Y1(x)                  ((x) << 16) /* 31:16 */
184-#define BLT_BR26_SRC_X1(x)                  ((x) << 0)  /* 15:0 */
185+#define BLT_BR26_SRC_Y1(x) ((x) << 16) /* 31:16 */
186+#define BLT_BR26_SRC_X1(x) ((x) << 0)  /* 15:0 */
187 
188 /* BR27 : Destination Address High Bits */
189-                                                        /* 31:16 */
190-#define BLT_BR27_DST_ADDRESS_HI(x)          ((x) << 0)  /* 15:0 */
191+/* 31:16 */
192+#define BLT_BR27_DST_ADDRESS_HI(x) ((x) << 0) /* 15:0 */
193 
194 /* BR28 : Source Address High Bits */
195-                                                        /* 31:16 */
196-#define BLT_BR28_SRC_ADDRESS_HI(x)          ((x) << 0)  /* 15:0 */
197+/* 31:16 */
198+#define BLT_BR28_SRC_ADDRESS_HI(x) ((x) << 0) /* 15:0 */
199 
200 /* BR30 : Setup Blit Color Pattern Address High Bits */
201-                                                        /* 31:16 */
202-#define BLT_BR30_PAT_ADDRESS_HI(x)          ((x) << 0)  /* 15:0 */
203-
204-static inline void xy_setup_blt(struct intel_batch * batch,
205-                                bool monochrome_source_transparency,
206-                                uint8_t raster_operation,
207-                                uint32_t background_color,
208-                                uint32_t foreground_color,
209-                                drm_intel_bo * dst, uint16_t dst_pitch)
210+/* 31:16 */
211+#define BLT_BR30_PAT_ADDRESS_HI(x) ((x) << 0) /* 15:0 */
212+
213+static inline void
214+xy_setup_blt(struct intel_batch *batch,
215+             bool monochrome_source_transparency,
216+             uint8_t raster_operation,
217+             uint32_t background_color,
218+             uint32_t foreground_color,
219+             drm_intel_bo *dst, uint16_t dst_pitch)
220 {
221-    uint32_t tiling_mode, swizzle_mode;
222-
223-    intel_batch_ensure_space(batch, GEN(batch, 8) ? 10 : 8);
224-
225-    drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
226-    drm_intel_bo_emit_reloc_fence
227-        (batch->bo, intel_batch_offset(batch, 4), dst, 0,
228-         I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
229-
230-    intel_batch_add_dwords(batch, 4,
231-        BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
232-      | BLT_BR00_OP(BLT_OP_XY_SETUP_BLT)
233-      | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
234-      | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
235-      | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 8 : 6),
236-
237-        BLT_BR01_CLIPPING_ENABLE(false)
238-      | BLT_BR01_MONO_SRC_TRANSPARENCY(monochrome_source_transparency)
239-      | BLT_BR01_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
240-      | BLT_BR01_RASTER_OPERATION(raster_operation)
241-      | BLT_BR01_DST_PITCH(tiling_mode == I915_TILING_NONE
242-                           ? dst_pitch : dst_pitch >> 2),
243-
244-        /* XXX: No clipping yet */
245-        BLT_BR24_CLP_Y1(0)
246-      | BLT_BR24_CLP_X1(0),
247-
248-        BLT_BR25_CLP_Y2(0)
249-      | BLT_BR25_CLP_X2(0)
250-    );
251-
252-    intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
253-        BLT_BR09_DST_ADDRESS(dst->offset64),
254-        /* if gen8 */
255-        BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32)
256-    );
257-
258-    intel_batch_add_dwords(batch, 2,
259-        BLT_BR05_BACKGROUND_COLOR(background_color),
260-        BLT_BR06_FOREGROUND_COLOR(foreground_color)
261-    );
262-
263-    intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
264-        BLT_BR07_PAT_ADDRESS(0),
265-        /* if gen8 */
266-        BLT_BR30_PAT_ADDRESS_HI(0)
267-    );
268+	uint32_t tiling_mode, swizzle_mode;
269+
270+	intel_batch_ensure_space(batch, GEN(batch, 8) ? 10 : 8);
271+
272+	drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
273+	drm_intel_bo_emit_reloc_fence(batch->bo, intel_batch_offset(batch, 4), dst, 0,
274+	                              I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
275+
276+	intel_batch_add_dwords(batch, 4,
277+	                       BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
278+	                           | BLT_BR00_OP(BLT_OP_XY_SETUP_BLT)
279+	                           | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
280+	                           | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
281+	                           | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 8 : 6),
282+
283+	                       BLT_BR01_CLIPPING_ENABLE(false)
284+	                           | BLT_BR01_MONO_SRC_TRANSPARENCY(monochrome_source_transparency)
285+	                           | BLT_BR01_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
286+	                           | BLT_BR01_RASTER_OPERATION(raster_operation)
287+	                           | BLT_BR01_DST_PITCH(tiling_mode == I915_TILING_NONE
288+	                                                    ? dst_pitch
289+	                                                    : dst_pitch >> 2),
290+
291+	                       /* XXX: No clipping yet */
292+	                       BLT_BR24_CLP_Y1(0)
293+	                           | BLT_BR24_CLP_X1(0),
294+
295+	                       BLT_BR25_CLP_Y2(0)
296+	                           | BLT_BR25_CLP_X2(0));
297+
298+	intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
299+	                       BLT_BR09_DST_ADDRESS(dst->offset64),
300+	                       /* if gen8 */
301+	                       BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32));
302+
303+	intel_batch_add_dwords(batch, 2,
304+	                       BLT_BR05_BACKGROUND_COLOR(background_color),
305+	                       BLT_BR06_FOREGROUND_COLOR(foreground_color));
306+
307+	intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
308+	                       BLT_BR07_PAT_ADDRESS(0),
309+	                       /* if gen8 */
310+	                       BLT_BR30_PAT_ADDRESS_HI(0));
311 }
312 
313-static inline int xy_text_blt(struct intel_batch * batch,
314-                              drm_intel_bo * src, uint32_t src_offset,
315-                              drm_intel_bo * dst,
316-                              int16_t dst_x1, int16_t dst_y1,
317-                              int16_t dst_x2, int16_t dst_y2)
318+static inline int
319+xy_text_blt(struct intel_batch *batch,
320+            drm_intel_bo *src, uint32_t src_offset,
321+            drm_intel_bo *dst,
322+            int16_t dst_x1, int16_t dst_y1,
323+            int16_t dst_x2, int16_t dst_y2)
324 {
325-    uint32_t tiling_mode, swizzle_mode;
326+	uint32_t tiling_mode, swizzle_mode;
327 
328-    if (!intel_batch_check_space(batch, GEN(batch, 8) ? 5 : 4))
329-        return INTEL_BATCH_NO_SPACE;
330+	if (!intel_batch_check_space(batch, GEN(batch, 8) ? 5 : 4))
331+		return INTEL_BATCH_NO_SPACE;
332 
333-    drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
334+	drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
335 
336-    drm_intel_bo_emit_reloc_fence
337-        (batch->bo, intel_batch_offset(batch, 3), src, src_offset,
338-         I915_GEM_DOMAIN_RENDER, 0);
339+	drm_intel_bo_emit_reloc_fence(batch->bo, intel_batch_offset(batch, 3), src, src_offset,
340+	                              I915_GEM_DOMAIN_RENDER, 0);
341 
342-    intel_batch_add_dwords(batch, 3,
343-        BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
344-      | BLT_BR00_OP(BLT_OP_XY_TEXT_BLT)
345-      | BLT_BR00_PACKING(BLT_PACKING_BYTE)
346-      | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
347-      | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 3 : 2),
348+	intel_batch_add_dwords(batch, 3,
349+	                       BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
350+	                           | BLT_BR00_OP(BLT_OP_XY_TEXT_BLT)
351+	                           | BLT_BR00_PACKING(BLT_PACKING_BYTE)
352+	                           | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
353+	                           | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 3 : 2),
354 
355-        BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
356-        BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2)
357-    );
358+	                       BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
359+	                       BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2));
360 
361-    intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
362-        BLT_BR12_SRC_ADDRESS(src->offset64 + src_offset),
363-        /* if gen8 */
364-        BLT_BR28_SRC_ADDRESS_HI((src->offset64 + src_offset) >> 32)
365-    );
366+	intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
367+	                       BLT_BR12_SRC_ADDRESS(src->offset64 + src_offset),
368+	                       /* if gen8 */
369+	                       BLT_BR28_SRC_ADDRESS_HI((src->offset64 + src_offset) >> 32));
370 
371-    return INTEL_BATCH_SUCCESS;
372+	return INTEL_BATCH_SUCCESS;
373 }
374 
375-static inline int xy_text_immediate_blt(struct intel_batch * batch,
376-                                        drm_intel_bo * dst,
377-                                        int16_t dst_x1, int16_t dst_y1,
378-                                        int16_t dst_x2, int16_t dst_y2,
379-                                        uint16_t count, uint32_t * immediates)
380+static inline int
381+xy_text_immediate_blt(struct intel_batch *batch,
382+                      drm_intel_bo *dst,
383+                      int16_t dst_x1, int16_t dst_y1,
384+                      int16_t dst_x2, int16_t dst_y2,
385+                      uint16_t count, uint32_t *immediates)
386 {
387-    /* Round up to the next even number. */
388-    uint8_t dwords = (count + 1) & ~1;
389-    uint32_t index;
390-    uint32_t tiling_mode, swizzle_mode;
391+	/* Round up to the next even number. */
392+	uint8_t dwords = (count + 1) & ~1;
393+	uint32_t index;
394+	uint32_t tiling_mode, swizzle_mode;
395 
396-    if (!intel_batch_check_space(batch, 3 + dwords))
397-        return INTEL_BATCH_NO_SPACE;
398+	if (!intel_batch_check_space(batch, 3 + dwords))
399+		return INTEL_BATCH_NO_SPACE;
400 
401-    drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
402+	drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
403 
404-    intel_batch_add_dwords(batch, 3,
405-        BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
406-      | BLT_BR00_OP(BLT_OP_XY_TEXT_IMMEDIATE_BLT)
407-      | BLT_BR00_PACKING(BLT_PACKING_BYTE)
408-      | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
409-      | BLT_BR00_DWORD_LENGTH(1 + dwords),
410+	intel_batch_add_dwords(batch, 3,
411+	                       BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
412+	                           | BLT_BR00_OP(BLT_OP_XY_TEXT_IMMEDIATE_BLT)
413+	                           | BLT_BR00_PACKING(BLT_PACKING_BYTE)
414+	                           | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
415+	                           | BLT_BR00_DWORD_LENGTH(1 + dwords),
416 
417-        BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
418-        BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2)
419-    );
420+	                       BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
421+	                       BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2));
422 
423-    for (index = 0; index < count; ++index)
424-        intel_batch_add_dword(batch, *immediates++);
425+	for (index = 0; index < count; ++index)
426+		intel_batch_add_dword(batch, *immediates++);
427 
428-    /* From BLT engine documentation:
429+	/* From BLT engine documentation:
430      *
431      * The IMMEDIATE_BLT data MUST transfer an even number of doublewords. The
432      * BLT engine will hang if it does not get an even number of doublewords. */
433-    if (count & 1)
434-        intel_batch_add_dword(batch, 0);
435+	if (count & 1)
436+		intel_batch_add_dword(batch, 0);
437 
438-    return INTEL_BATCH_SUCCESS;
439+	return INTEL_BATCH_SUCCESS;
440 }
441 
442-static inline void xy_src_copy_blt(struct intel_batch * batch,
443-                                   drm_intel_bo * src, uint16_t src_pitch,
444-                                   uint16_t src_x, uint16_t src_y,
445-                                   drm_intel_bo * dst, uint16_t dst_pitch,
446-                                   uint16_t dst_x, uint16_t dst_y,
447-                                   uint16_t width, uint16_t height)
448+static inline void
449+xy_src_copy_blt(struct intel_batch *batch,
450+                drm_intel_bo *src, uint16_t src_pitch,
451+                uint16_t src_x, uint16_t src_y,
452+                drm_intel_bo *dst, uint16_t dst_pitch,
453+                uint16_t dst_x, uint16_t dst_y,
454+                uint16_t width, uint16_t height)
455 {
456-    uint32_t src_tiling_mode, dst_tiling_mode, swizzle;
457-
458-    intel_batch_ensure_space(batch, GEN(batch, 8) ? 10 : 8);
459-
460-    drm_intel_bo_get_tiling(dst, &dst_tiling_mode, &swizzle);
461-    drm_intel_bo_get_tiling(src, &src_tiling_mode, &swizzle);
462-
463-    drm_intel_bo_emit_reloc_fence
464-        (batch->bo, intel_batch_offset(batch, 4), dst, 0,
465-         I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
466-    drm_intel_bo_emit_reloc_fence
467-        (batch->bo, intel_batch_offset(batch, GEN(batch, 8) ? 8 : 7), src, 0,
468-         I915_GEM_DOMAIN_RENDER, 0);
469-
470-    intel_batch_add_dwords(batch, 4,
471-        BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
472-      | BLT_BR00_OP(BLT_OP_XY_SRC_COPY_BLT)
473-      | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
474-      | BLT_BR00_SRC_TILING_ENABLE(src_tiling_mode != I915_TILING_NONE)
475-      | BLT_BR00_DST_TILING_ENABLE(dst_tiling_mode != I915_TILING_NONE)
476-      | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 8 : 6),
477-
478-        BLT_BR13_CLIPPING_ENABLE(false)
479-      | BLT_BR13_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
480-      | BLT_BR13_RASTER_OPERATION(BLT_RASTER_OPERATION_SRC)
481-      | BLT_BR13_DST_PITCH(dst_tiling_mode == I915_TILING_NONE
482-                                 ? dst_pitch : dst_pitch >> 2),
483-
484-        BLT_BR22_DST_Y1(dst_y) | BLT_BR22_DST_X1(dst_x),
485-
486-        BLT_BR23_DST_Y2(dst_y + height)
487-      | BLT_BR23_DST_X2(dst_x + width)
488-    );
489-    intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
490-        BLT_BR09_DST_ADDRESS(dst->offset64),
491-        BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32)
492-    );
493-    intel_batch_add_dwords(batch, 2,
494-        BLT_BR26_SRC_Y1(src_y) | BLT_BR26_SRC_X1(src_x),
495-        BLT_BR11_SRC_PITCH(src_tiling_mode == I915_TILING_NONE
496-                           ? src_pitch : src_pitch >> 2)
497-    );
498-    intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
499-        BLT_BR12_SRC_ADDRESS(src->offset64),
500-        BLT_BR28_SRC_ADDRESS_HI(src->offset64 >> 32)
501-    );
502+	uint32_t src_tiling_mode, dst_tiling_mode, swizzle;
503+
504+	intel_batch_ensure_space(batch, GEN(batch, 8) ? 10 : 8);
505+
506+	drm_intel_bo_get_tiling(dst, &dst_tiling_mode, &swizzle);
507+	drm_intel_bo_get_tiling(src, &src_tiling_mode, &swizzle);
508+
509+	drm_intel_bo_emit_reloc_fence(batch->bo, intel_batch_offset(batch, 4), dst, 0,
510+	                              I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
511+	drm_intel_bo_emit_reloc_fence(batch->bo, intel_batch_offset(batch, GEN(batch, 8) ? 8 : 7), src, 0,
512+	                              I915_GEM_DOMAIN_RENDER, 0);
513+
514+	intel_batch_add_dwords(batch, 4,
515+	                       BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
516+	                           | BLT_BR00_OP(BLT_OP_XY_SRC_COPY_BLT)
517+	                           | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
518+	                           | BLT_BR00_SRC_TILING_ENABLE(src_tiling_mode != I915_TILING_NONE)
519+	                           | BLT_BR00_DST_TILING_ENABLE(dst_tiling_mode != I915_TILING_NONE)
520+	                           | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 8 : 6),
521+
522+	                       BLT_BR13_CLIPPING_ENABLE(false)
523+	                           | BLT_BR13_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
524+	                           | BLT_BR13_RASTER_OPERATION(BLT_RASTER_OPERATION_SRC)
525+	                           | BLT_BR13_DST_PITCH(dst_tiling_mode == I915_TILING_NONE
526+	                                                    ? dst_pitch
527+	                                                    : dst_pitch >> 2),
528+
529+	                       BLT_BR22_DST_Y1(dst_y) | BLT_BR22_DST_X1(dst_x),
530+
531+	                       BLT_BR23_DST_Y2(dst_y + height)
532+	                           | BLT_BR23_DST_X2(dst_x + width));
533+	intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
534+	                       BLT_BR09_DST_ADDRESS(dst->offset64),
535+	                       BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32));
536+	intel_batch_add_dwords(batch, 2,
537+	                       BLT_BR26_SRC_Y1(src_y) | BLT_BR26_SRC_X1(src_x),
538+	                       BLT_BR11_SRC_PITCH(src_tiling_mode == I915_TILING_NONE
539+	                                              ? src_pitch
540+	                                              : src_pitch >> 2));
541+	intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
542+	                       BLT_BR12_SRC_ADDRESS(src->offset64),
543+	                       BLT_BR28_SRC_ADDRESS_HI(src->offset64 >> 32));
544 }
545 
546-static inline void xy_color_blt(struct intel_batch * batch,
547-                                drm_intel_bo * dst, uint16_t dst_pitch,
548-                                uint16_t dst_x1, uint16_t dst_y1,
549-                                uint16_t dst_x2, uint16_t dst_y2,
550-                                uint32_t color)
551+static inline void
552+xy_color_blt(struct intel_batch *batch,
553+             drm_intel_bo *dst, uint16_t dst_pitch,
554+             uint16_t dst_x1, uint16_t dst_y1,
555+             uint16_t dst_x2, uint16_t dst_y2,
556+             uint32_t color)
557 {
558-    uint32_t tiling_mode, swizzle_mode;
559-
560-    intel_batch_ensure_space(batch, GEN(batch, 8) ? 7 : 6);
561-
562-    drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
563-
564-    drm_intel_bo_emit_reloc_fence
565-        (batch->bo, intel_batch_offset(batch, 4), dst, 0,
566-         I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
567-
568-    intel_batch_add_dwords(batch, 4,
569-        BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
570-      | BLT_BR00_OP(BLT_OP_XY_COLOR_BLT)
571-      | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
572-      | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
573-      | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 5 : 4),
574-
575-        BLT_BR13_CLIPPING_ENABLE(false)
576-      | BLT_BR13_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
577-      | BLT_BR13_RASTER_OPERATION(BLT_RASTER_OPERATION_PAT)
578-      | BLT_BR13_DST_PITCH(tiling_mode == I915_TILING_NONE
579-                           ? dst_pitch : dst_pitch >> 2),
580-
581-        BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
582-        BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2)
583-    );
584-    intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
585-        BLT_BR09_DST_ADDRESS(dst->offset64),
586-        BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32)
587-    );
588-    intel_batch_add_dword(batch,
589-        BLT_BR16_COLOR(color)
590-    );
591+	uint32_t tiling_mode, swizzle_mode;
592+
593+	intel_batch_ensure_space(batch, GEN(batch, 8) ? 7 : 6);
594+
595+	drm_intel_bo_get_tiling(dst, &tiling_mode, &swizzle_mode);
596+
597+	drm_intel_bo_emit_reloc_fence(batch->bo, intel_batch_offset(batch, 4), dst, 0,
598+	                              I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
599+
600+	intel_batch_add_dwords(batch, 4,
601+	                       BLT_BR00_CLIENT(INTEL_CLIENT_BLT)
602+	                           | BLT_BR00_OP(BLT_OP_XY_COLOR_BLT)
603+	                           | BLT_BR00_32BPP_MASK(BLT_32BPP_MASK_ALPHA | BLT_32BPP_MASK_RGB)
604+	                           | BLT_BR00_DST_TILING_ENABLE(tiling_mode != I915_TILING_NONE)
605+	                           | BLT_BR00_DWORD_LENGTH(GEN(batch, 8) ? 5 : 4),
606+
607+	                       BLT_BR13_CLIPPING_ENABLE(false)
608+	                           | BLT_BR13_COLOR_DEPTH(BLT_COLOR_DEPTH_32BIT)
609+	                           | BLT_BR13_RASTER_OPERATION(BLT_RASTER_OPERATION_PAT)
610+	                           | BLT_BR13_DST_PITCH(tiling_mode == I915_TILING_NONE
611+	                                                    ? dst_pitch
612+	                                                    : dst_pitch >> 2),
613+
614+	                       BLT_BR22_DST_Y1(dst_y1) | BLT_BR22_DST_X1(dst_x1),
615+	                       BLT_BR23_DST_Y2(dst_y2) | BLT_BR23_DST_X2(dst_x2));
616+	intel_batch_add_dwords(batch, GEN(batch, 8) ? 2 : 1,
617+	                       BLT_BR09_DST_ADDRESS(dst->offset64),
618+	                       BLT_BR27_DST_ADDRESS_HI(dst->offset64 >> 32));
619+	intel_batch_add_dword(batch,
620+	                      BLT_BR16_COLOR(color));
621 }
622 
623 #endif
624-
+12, -13
 1@@ -26,25 +26,24 @@
 2 
 3 #define INTEL_CLIENT_MI 0x0
 4 
 5-#define MI_OP(opcode) (                                                     \
 6-      INTEL_CLIENT_MI << 29 /* 31:29 */                                     \
 7-    | opcode << 23          /* 28:23 */                                     \
 8+#define MI_OP(opcode) (               \
 9+    INTEL_CLIENT_MI << 29 /* 31:29 */ \
10+    | opcode << 23        /* 28:23 */ \
11 )
12 
13-#define MI_NOOP                 MI_OP(0x00)
14-#define MI_FLUSH                MI_OP(0x04)
15-#define MI_BATCH_BUFFER_END     MI_OP(0x0A)
16+#define MI_NOOP MI_OP(0x00)
17+#define MI_FLUSH MI_OP(0x04)
18+#define MI_BATCH_BUFFER_END MI_OP(0x0A)
19 
20 /* MI_NOOP */
21-#define MI_NOOP_IDENTIFICATION_NUMBER(number)       (1 << 22 | number)
22+#define MI_NOOP_IDENTIFICATION_NUMBER(number) (1 << 22 | number)
23 
24 /* MI_FLUSH */
25-#define MI_FLUSH_ENABLE_PROTECTED_MEMORY            (1 << 6)
26-#define MI_FLUSH_DISABLE_INDIRECT_STATE_POINTERS    (1 << 5)
27-#define MI_FLUSH_CLEAR_GENERIC_MEDIA_STATE          (1 << 4)
28-#define MI_FLUSH_RESET_GLOBAL_SNAPSHOT_COUNT        (1 << 3)
29-#define MI_FLUSH_INHIBIT_RENDER_CACHE_FLUSH         (1 << 2)
30+#define MI_FLUSH_ENABLE_PROTECTED_MEMORY (1 << 6)
31+#define MI_FLUSH_DISABLE_INDIRECT_STATE_POINTERS (1 << 5)
32+#define MI_FLUSH_CLEAR_GENERIC_MEDIA_STATE (1 << 4)
33+#define MI_FLUSH_RESET_GLOBAL_SNAPSHOT_COUNT (1 << 3)
34+#define MI_FLUSH_INHIBIT_RENDER_CACHE_FLUSH (1 << 2)
35 #define MI_FLUSH_INVALIDATE_STATE_INSTRUCTION_CACHE (1 << 1)
36 
37 #endif
38-
+6, -7
 1@@ -21,13 +21,12 @@
 2  * SOFTWARE.
 3  */
 4 
 5-static bool buffer_map(struct buffer * drawable);
 6-static bool buffer_unmap(struct buffer * drawable);
 7-static void buffer_destroy(struct buffer * drawable);
 8+static bool buffer_map(struct buffer *drawable);
 9+static bool buffer_unmap(struct buffer *drawable);
10+static void buffer_destroy(struct buffer *drawable);
11 
12 static const struct wld_buffer_impl wld_buffer_impl = {
13-    .map = &buffer_map,
14-    .unmap = &buffer_unmap,
15-    .destroy = &buffer_destroy
16+	.map = &buffer_map,
17+	.unmap = &buffer_unmap,
18+	.destroy = &buffer_destroy
19 };
20-
+14, -19
 1@@ -21,30 +21,25 @@
 2  * SOFTWARE.
 3  */
 4 
 5-static struct wld_renderer * context_create_renderer
 6-    (struct wld_context * context);
 7-static struct buffer * context_create_buffer
 8-    (struct wld_context * context,
 9-     uint32_t width, uint32_t height, uint32_t format, uint32_t flags);
10-static struct buffer * context_import_buffer
11-    (struct wld_context * context, uint32_t type, union wld_object object,
12-     uint32_t width, uint32_t height, uint32_t format, uint32_t pitch);
13+static struct wld_renderer *context_create_renderer(struct wld_context *context);
14+static struct buffer *context_create_buffer(struct wld_context *context,
15+                                            uint32_t width, uint32_t height, uint32_t format, uint32_t flags);
16+static struct buffer *context_import_buffer(struct wld_context *context, uint32_t type, union wld_object object,
17+                                            uint32_t width, uint32_t height, uint32_t format, uint32_t pitch);
18 #ifdef CONTEXT_IMPLEMENTS_CREATE_SURFACE
19-static struct wld_surface * context_create_surface
20-    (struct wld_context * context,
21-     uint32_t width, uint32_t height, uint32_t format, uint32_t flags);
22+static struct wld_surface *context_create_surface(struct wld_context *context,
23+                                                  uint32_t width, uint32_t height, uint32_t format, uint32_t flags);
24 #endif
25-static void context_destroy(struct wld_context * context);
26+static void context_destroy(struct wld_context *context);
27 
28 static const struct wld_context_impl wld_context_impl = {
29-    .create_renderer = &context_create_renderer,
30-    .create_buffer = &context_create_buffer,
31-    .import_buffer = &context_import_buffer,
32+	.create_renderer = &context_create_renderer,
33+	.create_buffer = &context_create_buffer,
34+	.import_buffer = &context_import_buffer,
35 #ifdef CONTEXT_IMPLEMENTS_CREATE_SURFACE
36-    .create_surface = &context_create_surface,
37+	.create_surface = &context_create_surface,
38 #else
39-    .create_surface = &default_create_surface,
40+	.create_surface = &default_create_surface,
41 #endif
42-    .destroy = &context_destroy
43+	.destroy = &context_destroy
44 };
45-
+7, -8
 1@@ -22,22 +22,21 @@
 2  */
 3 
 4 #ifndef DRM_DRIVER_NAME
 5-#   error "You must define DRM_DRIVER_NAME before including interface/drm.h"
 6+#error "You must define DRM_DRIVER_NAME before including interface/drm.h"
 7 #endif
 8 
 9 /* DRM driver */
10 static bool driver_device_supported(uint32_t vendor_id, uint32_t device_id);
11-static struct wld_context * driver_create_context(int drm_fd);
12+static struct wld_context *driver_create_context(int drm_fd);
13 
14 #define EXPAND(f, x) f(x)
15-#define VAR(name) name ## _drm_driver
16-#define STRING(name) # name
17+#define VAR(name) name##_drm_driver
18+#define STRING(name) #name
19 const struct drm_driver EXPAND(VAR, DRM_DRIVER_NAME) = {
20-    .name = EXPAND(STRING, DRM_DRIVER_NAME),
21-    .device_supported = &driver_device_supported,
22-    .create_context = &driver_create_context,
23+	.name = EXPAND(STRING, DRM_DRIVER_NAME),
24+	.device_supported = &driver_device_supported,
25+	.create_context = &driver_create_context,
26 };
27 #undef VAR
28 #undef STRING
29 #undef EXPAND
30-
+29, -30
 1@@ -21,48 +21,47 @@
 2  * SOFTWARE.
 3  */
 4 
 5-static uint32_t renderer_capabilities(struct wld_renderer * renderer,
 6-                                      struct buffer * buffer);
 7-static bool renderer_set_target(struct wld_renderer * renderer,
 8-                                struct buffer * buffer);
 9-static void renderer_fill_rectangle(struct wld_renderer * renderer,
10+static uint32_t renderer_capabilities(struct wld_renderer *renderer,
11+                                      struct buffer *buffer);
12+static bool renderer_set_target(struct wld_renderer *renderer,
13+                                struct buffer *buffer);
14+static void renderer_fill_rectangle(struct wld_renderer *renderer,
15                                     uint32_t color, int32_t x, int32_t y,
16                                     uint32_t width, uint32_t height);
17-static void renderer_copy_rectangle(struct wld_renderer * renderer,
18-                                    struct buffer * buffer,
19+static void renderer_copy_rectangle(struct wld_renderer *renderer,
20+                                    struct buffer *buffer,
21                                     int32_t dst_x, int32_t dst_y,
22                                     int32_t src_x, int32_t src_y,
23                                     uint32_t width, uint32_t height);
24 #ifdef RENDERER_IMPLEMENTS_REGION
25-static void renderer_fill_region(struct wld_renderer * base, uint32_t color,
26-                                 pixman_region32_t * region);
27-static void renderer_copy_region(struct wld_renderer * base,
28-                                 struct buffer * buffer,
29+static void renderer_fill_region(struct wld_renderer *base, uint32_t color,
30+                                 pixman_region32_t *region);
31+static void renderer_copy_region(struct wld_renderer *base,
32+                                 struct buffer *buffer,
33                                  int32_t dst_x, int32_t dst_y,
34-                                 pixman_region32_t * region);
35+                                 pixman_region32_t *region);
36 #endif
37-static void renderer_draw_text(struct wld_renderer * renderer,
38-                               struct font * font, uint32_t color,
39+static void renderer_draw_text(struct wld_renderer *renderer,
40+                               struct font *font, uint32_t color,
41                                int32_t x, int32_t y,
42-                               const char * text, uint32_t length,
43-                               struct wld_extents * extents);
44-static void renderer_flush(struct wld_renderer * renderer);
45-static void renderer_destroy(struct wld_renderer * renderer);
46+                               const char *text, uint32_t length,
47+                               struct wld_extents *extents);
48+static void renderer_flush(struct wld_renderer *renderer);
49+static void renderer_destroy(struct wld_renderer *renderer);
50 
51 static const struct wld_renderer_impl wld_renderer_impl = {
52-    .capabilities = &renderer_capabilities,
53-    .set_target = &renderer_set_target,
54-    .fill_rectangle = &renderer_fill_rectangle,
55-    .copy_rectangle = &renderer_copy_rectangle,
56+	.capabilities = &renderer_capabilities,
57+	.set_target = &renderer_set_target,
58+	.fill_rectangle = &renderer_fill_rectangle,
59+	.copy_rectangle = &renderer_copy_rectangle,
60 #ifdef RENDERER_IMPLEMENTS_REGION
61-    .fill_region = &renderer_fill_region,
62-    .copy_region = &renderer_copy_region,
63+	.fill_region = &renderer_fill_region,
64+	.copy_region = &renderer_copy_region,
65 #else
66-    .fill_region = &default_fill_region,
67-    .copy_region = &default_copy_region,
68+	.fill_region = &default_fill_region,
69+	.copy_region = &default_copy_region,
70 #endif
71-    .draw_text = &renderer_draw_text,
72-    .flush = &renderer_flush,
73-    .destroy = &renderer_destroy
74+	.draw_text = &renderer_draw_text,
75+	.flush = &renderer_flush,
76+	.destroy = &renderer_destroy
77 };
78-
+14, -15
 1@@ -21,21 +21,20 @@
 2  * SOFTWARE.
 3  */
 4 
 5-static pixman_region32_t * surface_damage(struct wld_surface * surface,
 6-                                          pixman_region32_t * new_damage);
 7-static struct buffer * surface_back(struct wld_surface * surface);
 8-static struct buffer * surface_take(struct wld_surface * surface);
 9-static bool surface_release(struct wld_surface * surface,
10-                            struct buffer * buffer);
11-static bool surface_swap(struct wld_surface * surface);
12-static void surface_destroy(struct wld_surface * surface);
13+static pixman_region32_t *surface_damage(struct wld_surface *surface,
14+                                         pixman_region32_t *new_damage);
15+static struct buffer *surface_back(struct wld_surface *surface);
16+static struct buffer *surface_take(struct wld_surface *surface);
17+static bool surface_release(struct wld_surface *surface,
18+                            struct buffer *buffer);
19+static bool surface_swap(struct wld_surface *surface);
20+static void surface_destroy(struct wld_surface *surface);
21 
22 static const struct wld_surface_impl wld_surface_impl = {
23-    .damage = &surface_damage,
24-    .back = &surface_back,
25-    .take = &surface_take,
26-    .release = &surface_release,
27-    .swap = &surface_swap,
28-    .destroy = &surface_destroy
29+	.damage = &surface_damage,
30+	.back = &surface_back,
31+	.take = &surface_take,
32+	.release = &surface_release,
33+	.swap = &surface_swap,
34+	.destroy = &surface_destroy
35 };
36-
+7, -9
 1@@ -22,20 +22,18 @@
 2  */
 3 
 4 #ifndef WAYLAND_IMPL_NAME
 5-#   error you must define WAYLAND_IMPL_NAME before including interface/wayland.h
 6+#error you must define WAYLAND_IMPL_NAME before including interface/wayland.h
 7 #endif
 8 
 9-static struct wayland_context * wayland_create_context
10-    (struct wl_display * display, struct wl_event_queue * queue);
11-static bool wayland_has_format(struct wld_context * context, uint32_t format);
12+static struct wayland_context *wayland_create_context(struct wl_display *display, struct wl_event_queue *queue);
13+static bool wayland_has_format(struct wld_context *context, uint32_t format);
14 
15 #define EXPAND(f, x) f(x)
16-#define VAR(name) name ## _wayland_impl
17+#define VAR(name) name##_wayland_impl
18 const struct wayland_impl EXPAND(VAR, WAYLAND_IMPL_NAME) = {
19-    .create_context = &wayland_create_context,
20-    .has_format = &wayland_has_format,
21-    //.create_surface = &wayland_create_surface,
22+	.create_context = &wayland_create_context,
23+	.has_format = &wayland_has_format,
24+	//.create_surface = &wayland_create_surface,
25 };
26 #undef VAR
27 #undef EXPAND
28-
+469, -456
   1@@ -28,51 +28,47 @@
   2 
   3 #include "drm-private.h"
   4 #include "drm.h"
   5-#include "pixman.h"
   6-#include "nouveau/nv_object.xml.h"
   7 #include "nouveau/g80_2d.xml.h"
   8 #include "nouveau/g80_defs.xml.h"
   9+#include "nouveau/nv_object.xml.h"
  10+#include "pixman.h"
  11 
  12 #include <nouveau.h>
  13 #include <sys/mman.h>
  14 
  15-enum nv_architecture
  16-{
  17-    NV_ARCH_50 = 0x50,
  18-    NV_ARCH_C0 = 0xc0,
  19-    NV_ARCH_E0 = 0xe0
  20+enum nv_architecture {
  21+	NV_ARCH_50 = 0x50,
  22+	NV_ARCH_C0 = 0xc0,
  23+	NV_ARCH_E0 = 0xe0
  24 };
  25 
  26-struct nouveau_context
  27-{
  28-    struct wld_context base;
  29-    struct nouveau_device * device;
  30-    struct nouveau_client * client;
  31-    enum nv_architecture architecture;
  32+struct nouveau_context {
  33+	struct wld_context base;
  34+	struct nouveau_device *device;
  35+	struct nouveau_client *client;
  36+	enum nv_architecture architecture;
  37 };
  38 
  39-struct nouveau_renderer
  40-{
  41-    struct wld_renderer base;
  42-    struct nouveau_object * channel;
  43-    struct nouveau_pushbuf * pushbuf;
  44-    struct nouveau_bufctx * bufctx;
  45-    struct nouveau_object * nvc0_2d;
  46+struct nouveau_renderer {
  47+	struct wld_renderer base;
  48+	struct nouveau_object *channel;
  49+	struct nouveau_pushbuf *pushbuf;
  50+	struct nouveau_bufctx *bufctx;
  51+	struct nouveau_object *nvc0_2d;
  52 
  53-    struct nouveau_buffer * target;
  54+	struct nouveau_buffer *target;
  55 };
  56 
  57-struct nouveau_buffer
  58-{
  59-    struct buffer base;
  60-    struct wld_exporter exporter;
  61-    struct nouveau_context * context;
  62-    struct nouveau_bo * bo;
  63+struct nouveau_buffer {
  64+	struct buffer base;
  65+	struct wld_exporter exporter;
  66+	struct nouveau_context *context;
  67+	struct nouveau_bo *bo;
  68 };
  69 
  70+#include "interface/buffer.h"
  71 #include "interface/context.h"
  72 #include "interface/renderer.h"
  73-#include "interface/buffer.h"
  74 #define DRM_DRIVER_NAME nouveau
  75 #include "interface/drm.h"
  76 IMPL(nouveau_context, wld_context)
  77@@ -80,24 +76,25 @@ IMPL(nouveau_renderer, wld_renderer)
  78 IMPL(nouveau_buffer, wld_buffer)
  79 
  80 /**** DRM driver ****/
  81-bool driver_device_supported(uint32_t vendor_id, uint32_t device_id)
  82+bool
  83+driver_device_supported(uint32_t vendor_id, uint32_t device_id)
  84 {
  85-    return vendor_id == 0x10de;
  86+	return vendor_id == 0x10de;
  87 }
  88 
  89-struct wld_context * driver_create_context(int drm_fd)
  90+struct wld_context *
  91+driver_create_context(int drm_fd)
  92 {
  93-    struct nouveau_context * context;
  94+	struct nouveau_context *context;
  95 
  96-    if (!(context = malloc(sizeof *context)))
  97-        goto error0;
  98+	if (!(context = malloc(sizeof *context)))
  99+		goto error0;
 100 
 101-    if (nouveau_device_wrap(drm_fd, 0, &context->device) != 0)
 102-        goto error1;
 103+	if (nouveau_device_wrap(drm_fd, 0, &context->device) != 0)
 104+		goto error1;
 105 
 106-    switch (context->device->chipset & ~0xf)
 107-    {
 108-        /* TODO: Support NV50
 109+	switch (context->device->chipset & ~0xf) {
 110+	/* TODO: Support NV50
 111         case 0x50:
 112         case 0x80:
 113         case 0x90:
 114@@ -105,574 +102,590 @@ struct wld_context * driver_create_context(int drm_fd)
 115             context->architecture = NV_ARCH_50;
 116             break;
 117         */
 118-        case 0xc0:
 119-        case 0xd0:
 120-            context->architecture = NV_ARCH_C0;
 121-            break;
 122-        /* TODO: Support NVE0
 123+	case 0xc0:
 124+	case 0xd0:
 125+		context->architecture = NV_ARCH_C0;
 126+		break;
 127+	/* TODO: Support NVE0
 128         case 0xe0:
 129         case 0xf0:
 130         case 0x100:
 131             context->architecture = NV_ARCH_E0;
 132             break;
 133         */
 134-        default:
 135-            return NULL;
 136-    }
 137+	default:
 138+		return NULL;
 139+	}
 140 
 141-    if (nouveau_client_new(context->device, &context->client) != 0)
 142-        goto error2;
 143+	if (nouveau_client_new(context->device, &context->client) != 0)
 144+		goto error2;
 145 
 146-    context_initialize(&context->base, &wld_context_impl);
 147+	context_initialize(&context->base, &wld_context_impl);
 148 
 149-    return &context->base;
 150+	return &context->base;
 151 
 152-  error2:
 153-    nouveau_device_del(&context->device);
 154-  error1:
 155-    free(context);
 156-  error0:
 157-    return NULL;
 158+error2:
 159+	nouveau_device_del(&context->device);
 160+error1:
 161+	free(context);
 162+error0:
 163+	return NULL;
 164 }
 165 
 166 /**** Context ****/
 167-static inline bool ensure_space(struct nouveau_pushbuf * push, uint32_t count)
 168+static inline bool
 169+ensure_space(struct nouveau_pushbuf *push, uint32_t count)
 170 {
 171-    if (push->end - push->cur > count)
 172-        return true;
 173+	if (push->end - push->cur > count)
 174+		return true;
 175 
 176-    return nouveau_pushbuf_space(push, count, 0, 0) == 0;
 177+	return nouveau_pushbuf_space(push, count, 0, 0) == 0;
 178 }
 179 
 180-static inline void nv_add_dword(struct nouveau_pushbuf * push, uint32_t dword)
 181+static inline void
 182+nv_add_dword(struct nouveau_pushbuf *push, uint32_t dword)
 183 {
 184-    *push->cur++ = dword;
 185+	*push->cur++ = dword;
 186 }
 187 
 188-static inline void nv_add_dwords_va(struct nouveau_pushbuf * push,
 189-                                    uint16_t count, va_list dwords)
 190+static inline void
 191+nv_add_dwords_va(struct nouveau_pushbuf *push,
 192+                 uint16_t count, va_list dwords)
 193 {
 194-    while (count--)
 195-        nv_add_dword(push, va_arg(dwords, uint32_t));
 196+	while (count--)
 197+		nv_add_dword(push, va_arg(dwords, uint32_t));
 198 }
 199 
 200-static inline void nv_add_data(struct nouveau_pushbuf * push,
 201-                               void * data, uint32_t count)
 202+static inline void
 203+nv_add_data(struct nouveau_pushbuf *push,
 204+            void *data, uint32_t count)
 205 {
 206-    memcpy(push->cur, data, count * 4);
 207-    push->cur += count;
 208+	memcpy(push->cur, data, count * 4);
 209+	push->cur += count;
 210 }
 211 
 212-static inline uint32_t nvc0_format(uint32_t format)
 213+static inline uint32_t
 214+nvc0_format(uint32_t format)
 215 {
 216-    switch (format)
 217-    {
 218-        case WLD_FORMAT_XRGB8888:
 219-            return G80_SURFACE_FORMAT_BGRX8_UNORM;
 220-        case WLD_FORMAT_ARGB8888:
 221-            return G80_SURFACE_FORMAT_BGRA8_UNORM;
 222-    }
 223-
 224-    return 0;
 225+	switch (format) {
 226+	case WLD_FORMAT_XRGB8888:
 227+		return G80_SURFACE_FORMAT_BGRX8_UNORM;
 228+	case WLD_FORMAT_ARGB8888:
 229+		return G80_SURFACE_FORMAT_BGRA8_UNORM;
 230+	}
 231+
 232+	return 0;
 233 }
 234 
 235-enum
 236-{
 237-    GF100_COMMAND_TYPE_INCREASING       = 1,
 238-    GF100_COMMAND_TYPE_NON_INCREASING   = 3,
 239-    GF100_COMMAND_TYPE_INLINE           = 4
 240+enum {
 241+	GF100_COMMAND_TYPE_INCREASING = 1,
 242+	GF100_COMMAND_TYPE_NON_INCREASING = 3,
 243+	GF100_COMMAND_TYPE_INLINE = 4
 244 };
 245 
 246-enum
 247-{
 248-    GF100_SUBCHANNEL_2D = 3,
 249+enum {
 250+	GF100_SUBCHANNEL_2D = 3,
 251 };
 252 
 253-static inline uint32_t nvc0_command(uint8_t type, uint8_t subchannel,
 254-                                    uint16_t method, uint16_t count_or_value)
 255+static inline uint32_t
 256+nvc0_command(uint8_t type, uint8_t subchannel,
 257+             uint16_t method, uint16_t count_or_value)
 258 {
 259-    return type << 29 | count_or_value << 16 | subchannel << 13 | method >> 2;
 260+	return type << 29 | count_or_value << 16 | subchannel << 13 | method >> 2;
 261 }
 262 
 263-static inline void nvc0_inline(struct nouveau_pushbuf * push,
 264-                               uint8_t subchannel, uint16_t method,
 265-                               uint16_t value)
 266+static inline void
 267+nvc0_inline(struct nouveau_pushbuf *push,
 268+            uint8_t subchannel, uint16_t method,
 269+            uint16_t value)
 270 {
 271-    nv_add_dword(push, nvc0_command(GF100_COMMAND_TYPE_INLINE,
 272-                                    subchannel, method, value));
 273+	nv_add_dword(push, nvc0_command(GF100_COMMAND_TYPE_INLINE,
 274+	                                subchannel, method, value));
 275 }
 276 
 277-static inline void nvc0_methods(struct nouveau_pushbuf * push,
 278-                                uint8_t subchannel, uint16_t start_method,
 279-                                uint16_t count, ...)
 280-{
 281-    va_list dwords;
 282-    nv_add_dword(push, nvc0_command(GF100_COMMAND_TYPE_INCREASING,
 283-                                    subchannel, start_method, count));
 284-    va_start(dwords, count);
 285-    nv_add_dwords_va(push, count, dwords);
 286-    va_end(dwords);
 287+static inline void
 288+nvc0_methods(struct nouveau_pushbuf *push,
 289+             uint8_t subchannel, uint16_t start_method,
 290+             uint16_t count, ...)
 291+{
 292+	va_list dwords;
 293+	nv_add_dword(push, nvc0_command(GF100_COMMAND_TYPE_INCREASING,
 294+	                                subchannel, start_method, count));
 295+	va_start(dwords, count);
 296+	nv_add_dwords_va(push, count, dwords);
 297+	va_end(dwords);
 298 }
 299 
 300 #define nvc0_2d(push, method, count, ...) \
 301-    nvc0_methods(push, GF100_SUBCHANNEL_2D, method, count, __VA_ARGS__)
 302+	nvc0_methods(push, GF100_SUBCHANNEL_2D, method, count, __VA_ARGS__)
 303 #define nvc0_2d_inline(push, method, value) \
 304-    nvc0_inline(push, GF100_SUBCHANNEL_2D, method, value)
 305+	nvc0_inline(push, GF100_SUBCHANNEL_2D, method, value)
 306 
 307-static bool nvc0_2d_initialize(struct nouveau_renderer * renderer)
 308+static bool
 309+nvc0_2d_initialize(struct nouveau_renderer *renderer)
 310 {
 311-    int ret;
 312+	int ret;
 313 
 314-    ret = nouveau_object_new(renderer->channel, GF100_2D, GF100_2D, NULL, 0,
 315-                             &renderer->nvc0_2d);
 316+	ret = nouveau_object_new(renderer->channel, GF100_2D, GF100_2D, NULL, 0,
 317+	                         &renderer->nvc0_2d);
 318 
 319-    if (ret != 0)
 320-        goto error0;
 321+	if (ret != 0)
 322+		goto error0;
 323 
 324-    if (!ensure_space(renderer->pushbuf, 5))
 325-        goto error1;
 326+	if (!ensure_space(renderer->pushbuf, 5))
 327+		goto error1;
 328 
 329-    nvc0_2d(renderer->pushbuf, NV1_SUBCHAN_OBJECT, 1,
 330-            renderer->nvc0_2d->handle);
 331-    nvc0_2d_inline(renderer->pushbuf, G80_2D_OPERATION,
 332-                   G80_2D_OPERATION_SRCCOPY_AND);
 333-    nvc0_2d_inline(renderer->pushbuf, G80_2D_UNK0884, 0x3f);
 334-    nvc0_2d_inline(renderer->pushbuf, G80_2D_UNK0888, 1);
 335+	nvc0_2d(renderer->pushbuf, NV1_SUBCHAN_OBJECT, 1,
 336+	        renderer->nvc0_2d->handle);
 337+	nvc0_2d_inline(renderer->pushbuf, G80_2D_OPERATION,
 338+	               G80_2D_OPERATION_SRCCOPY_AND);
 339+	nvc0_2d_inline(renderer->pushbuf, G80_2D_UNK0884, 0x3f);
 340+	nvc0_2d_inline(renderer->pushbuf, G80_2D_UNK0888, 1);
 341 
 342-    return true;
 343+	return true;
 344 
 345-  error1:
 346-    nouveau_object_del(&renderer->nvc0_2d);
 347-  error0:
 348-    return false;
 349+error1:
 350+	nouveau_object_del(&renderer->nvc0_2d);
 351+error0:
 352+	return false;
 353 }
 354 
 355-static void nvc0_2d_finalize(struct nouveau_renderer * renderer)
 356+static void
 357+nvc0_2d_finalize(struct nouveau_renderer *renderer)
 358 {
 359-    nouveau_object_del(&renderer->nvc0_2d);
 360+	nouveau_object_del(&renderer->nvc0_2d);
 361 }
 362 
 363-struct wld_renderer * context_create_renderer(struct wld_context * base)
 364+struct wld_renderer *
 365+context_create_renderer(struct wld_context *base)
 366 {
 367-    struct nouveau_context * context = nouveau_context(base);
 368-    struct nouveau_renderer * renderer;
 369-    struct nvc0_fifo fifo = { };
 370-    int ret;
 371+	struct nouveau_context *context = nouveau_context(base);
 372+	struct nouveau_renderer *renderer;
 373+	struct nvc0_fifo fifo = {};
 374+	int ret;
 375 
 376-    if (!(renderer = malloc(sizeof *renderer)))
 377-        goto error0;
 378+	if (!(renderer = malloc(sizeof *renderer)))
 379+		goto error0;
 380 
 381-    ret = nouveau_object_new(&context->device->object, 0,
 382-                             NOUVEAU_FIFO_CHANNEL_CLASS, &fifo, sizeof fifo,
 383-                             &renderer->channel);
 384+	ret = nouveau_object_new(&context->device->object, 0,
 385+	                         NOUVEAU_FIFO_CHANNEL_CLASS, &fifo, sizeof fifo,
 386+	                         &renderer->channel);
 387 
 388-    if (ret != 0)
 389-        goto error1;
 390+	if (ret != 0)
 391+		goto error1;
 392 
 393-    ret = nouveau_pushbuf_new(context->client, renderer->channel, 4, 32 * 1024,
 394-                              true, &renderer->pushbuf);
 395+	ret = nouveau_pushbuf_new(context->client, renderer->channel, 4, 32 * 1024,
 396+	                          true, &renderer->pushbuf);
 397 
 398-    if (ret != 0)
 399-        goto error2;
 400+	if (ret != 0)
 401+		goto error2;
 402 
 403-    if (nouveau_bufctx_new(context->client, 1, &renderer->bufctx) != 0)
 404-        goto error3;
 405+	if (nouveau_bufctx_new(context->client, 1, &renderer->bufctx) != 0)
 406+		goto error3;
 407 
 408-    if (!nvc0_2d_initialize(renderer))
 409-        goto error4;
 410+	if (!nvc0_2d_initialize(renderer))
 411+		goto error4;
 412 
 413-    renderer_initialize(&renderer->base, &wld_renderer_impl);
 414-    renderer->target = NULL;
 415+	renderer_initialize(&renderer->base, &wld_renderer_impl);
 416+	renderer->target = NULL;
 417 
 418-    return &renderer->base;
 419+	return &renderer->base;
 420 
 421-  error4:
 422-    nouveau_bufctx_del(&renderer->bufctx);
 423-  error3:
 424-    nouveau_pushbuf_del(&renderer->pushbuf);
 425-  error2:
 426-    nouveau_object_del(&renderer->channel);
 427-  error1:
 428-    free(renderer);
 429-  error0:
 430-    return NULL;
 431+error4:
 432+	nouveau_bufctx_del(&renderer->bufctx);
 433+error3:
 434+	nouveau_pushbuf_del(&renderer->pushbuf);
 435+error2:
 436+	nouveau_object_del(&renderer->channel);
 437+error1:
 438+	free(renderer);
 439+error0:
 440+	return NULL;
 441 }
 442 
 443-static bool export(struct wld_exporter * exporter, struct wld_buffer * base,
 444-                   uint32_t type, union wld_object * object)
 445-{
 446-    struct nouveau_buffer * buffer = nouveau_buffer(base);
 447-
 448-    switch (type)
 449-    {
 450-        case WLD_DRM_OBJECT_HANDLE:
 451-            object->u32 = buffer->bo->handle;
 452-            return true;
 453-        case WLD_DRM_OBJECT_PRIME_FD:
 454-            if (nouveau_bo_set_prime(buffer->bo, &object->i) != 0)
 455-                return false;
 456-            return true;
 457-        default:
 458-            return false;
 459-    }
 460+static bool export(struct wld_exporter *exporter, struct wld_buffer *base,
 461+                   uint32_t type, union wld_object *object)
 462+{
 463+	struct nouveau_buffer *buffer = nouveau_buffer(base);
 464+
 465+	switch (type) {
 466+	case WLD_DRM_OBJECT_HANDLE:
 467+		object->u32 = buffer->bo->handle;
 468+		return true;
 469+	case WLD_DRM_OBJECT_PRIME_FD:
 470+		if (nouveau_bo_set_prime(buffer->bo, &object->i) != 0)
 471+			return false;
 472+		return true;
 473+	default:
 474+		return false;
 475+	}
 476 }
 477 
 478-static struct nouveau_buffer * new_buffer(struct nouveau_context * context,
 479-                                          uint32_t width, uint32_t height,
 480-                                          uint32_t format, uint32_t pitch)
 481+static struct nouveau_buffer *
 482+new_buffer(struct nouveau_context *context,
 483+           uint32_t width, uint32_t height,
 484+           uint32_t format, uint32_t pitch)
 485 {
 486-    struct nouveau_buffer * buffer;
 487+	struct nouveau_buffer *buffer;
 488 
 489-    if (!(buffer = malloc(sizeof *buffer)))
 490-        return NULL;
 491+	if (!(buffer = malloc(sizeof *buffer)))
 492+		return NULL;
 493 
 494-    buffer_initialize(&buffer->base, &wld_buffer_impl,
 495-                        width, height, format, pitch);
 496-    buffer->context = context;
 497-    buffer->exporter.export = &export;
 498-    wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
 499+	buffer_initialize(&buffer->base, &wld_buffer_impl,
 500+	                  width, height, format, pitch);
 501+	buffer->context = context;
 502+	buffer->exporter.export = &export;
 503+	wld_buffer_add_exporter(&buffer->base.base, &buffer->exporter);
 504 
 505-    return buffer;
 506+	return buffer;
 507 }
 508 
 509-static inline uint32_t roundup(uint32_t value, uint32_t alignment)
 510+static inline uint32_t
 511+roundup(uint32_t value, uint32_t alignment)
 512 {
 513-    return (value + alignment - 1) & ~(alignment - 1);
 514+	return (value + alignment - 1) & ~(alignment - 1);
 515 }
 516 
 517-struct buffer * context_create_buffer(struct wld_context * base,
 518-                                      uint32_t width, uint32_t height,
 519-                                      uint32_t format, uint32_t flags)
 520+struct buffer *
 521+context_create_buffer(struct wld_context *base,
 522+                      uint32_t width, uint32_t height,
 523+                      uint32_t format, uint32_t flags)
 524 {
 525-    struct nouveau_context * context = nouveau_context(base);
 526-    struct nouveau_buffer * buffer;
 527-    uint32_t bpp = format_bytes_per_pixel(format),
 528-             pitch = roundup(width * bpp, 64), bo_flags;
 529-    union nouveau_bo_config config = { };
 530-
 531-    if (!(buffer = new_buffer(context, width, height, format, pitch)))
 532-        goto error0;
 533-
 534-    bo_flags = NOUVEAU_BO_VRAM;
 535-
 536-    if (flags & WLD_DRM_FLAG_SCANOUT)
 537-        bo_flags |= NOUVEAU_BO_CONTIG;
 538-
 539-    if (height > 0x40 && !(flags & WLD_FLAG_MAP))
 540-    {
 541-        config.nvc0.tile_mode = 0x40;
 542-        config.nvc0.memtype = 0xfe;
 543-        height = roundup(height, 0x80);
 544-    }
 545-    else
 546-        bo_flags |= NOUVEAU_BO_MAP;
 547-
 548-    if (nouveau_bo_new(context->device, bo_flags, 0, pitch * height,
 549-                       &config, &buffer->bo) != 0)
 550-    {
 551-        goto error1;
 552-    }
 553-
 554-    return &buffer->base;
 555-
 556-  error1:
 557-    free(buffer);
 558-  error0:
 559-    return NULL;
 560-}
 561+	struct nouveau_context *context = nouveau_context(base);
 562+	struct nouveau_buffer *buffer;
 563+	uint32_t bpp = format_bytes_per_pixel(format),
 564+	         pitch = roundup(width * bpp, 64), bo_flags;
 565+	union nouveau_bo_config config = {};
 566 
 567-struct buffer * context_import_buffer(struct wld_context * base,
 568-                                      uint32_t type, union wld_object object,
 569-                                      uint32_t width, uint32_t height,
 570-                                      uint32_t format, uint32_t pitch)
 571-{
 572-    struct nouveau_context * context = (void *) base;
 573-    struct nouveau_buffer * buffer;
 574-    struct nouveau_bo * bo = NULL;
 575-
 576-    switch (type)
 577-    {
 578-        case WLD_DRM_OBJECT_PRIME_FD:
 579-            if (nouveau_bo_prime_handle_ref(context->device,
 580-                                            object.i, &bo) != 0)
 581-            {
 582-                goto error0;
 583-            }
 584-            break;
 585-        default: goto error0;
 586-    }
 587+	if (!(buffer = new_buffer(context, width, height, format, pitch)))
 588+		goto error0;
 589 
 590-    if (!(buffer = new_buffer(context, width, height, format, pitch)))
 591-        goto error1;
 592+	bo_flags = NOUVEAU_BO_VRAM;
 593 
 594-    buffer->bo = bo;
 595+	if (flags & WLD_DRM_FLAG_SCANOUT)
 596+		bo_flags |= NOUVEAU_BO_CONTIG;
 597 
 598-    return &buffer->base;
 599+	if (height > 0x40 && !(flags & WLD_FLAG_MAP)) {
 600+		config.nvc0.tile_mode = 0x40;
 601+		config.nvc0.memtype = 0xfe;
 602+		height = roundup(height, 0x80);
 603+	} else
 604+		bo_flags |= NOUVEAU_BO_MAP;
 605 
 606-  error1:
 607-    nouveau_bo_ref(NULL, &buffer->bo);
 608-  error0:
 609-    return NULL;
 610+	if (nouveau_bo_new(context->device, bo_flags, 0, pitch * height,
 611+	                   &config, &buffer->bo)
 612+	    != 0) {
 613+		goto error1;
 614+	}
 615+
 616+	return &buffer->base;
 617+
 618+error1:
 619+	free(buffer);
 620+error0:
 621+	return NULL;
 622 }
 623 
 624-void context_destroy(struct wld_context * base)
 625+struct buffer *
 626+context_import_buffer(struct wld_context *base,
 627+                      uint32_t type, union wld_object object,
 628+                      uint32_t width, uint32_t height,
 629+                      uint32_t format, uint32_t pitch)
 630+{
 631+	struct nouveau_context *context = (void *)base;
 632+	struct nouveau_buffer *buffer;
 633+	struct nouveau_bo *bo = NULL;
 634+
 635+	switch (type) {
 636+	case WLD_DRM_OBJECT_PRIME_FD:
 637+		if (nouveau_bo_prime_handle_ref(context->device,
 638+		                                object.i, &bo)
 639+		    != 0) {
 640+			goto error0;
 641+		}
 642+		break;
 643+	default:
 644+		goto error0;
 645+	}
 646+
 647+	if (!(buffer = new_buffer(context, width, height, format, pitch)))
 648+		goto error1;
 649+
 650+	buffer->bo = bo;
 651+
 652+	return &buffer->base;
 653+
 654+error1:
 655+	nouveau_bo_ref(NULL, &buffer->bo);
 656+error0:
 657+	return NULL;
 658+}
 659+
 660+void
 661+context_destroy(struct wld_context *base)
 662 {
 663-    struct nouveau_context * context = nouveau_context(base);
 664+	struct nouveau_context *context = nouveau_context(base);
 665 
 666-    nouveau_client_del(&context->client);
 667-    nouveau_device_del(&context->device);
 668-    free(context);
 669+	nouveau_client_del(&context->client);
 670+	nouveau_device_del(&context->device);
 671+	free(context);
 672 }
 673 
 674 /**** Renderer ****/
 675-uint32_t renderer_capabilities(struct wld_renderer * renderer,
 676-                               struct buffer * buffer)
 677+uint32_t
 678+renderer_capabilities(struct wld_renderer *renderer,
 679+                      struct buffer *buffer)
 680 {
 681-    if (buffer->base.impl == &wld_buffer_impl)
 682-        return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
 683+	if (buffer->base.impl == &wld_buffer_impl)
 684+		return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
 685 
 686-    return 0;
 687+	return 0;
 688 }
 689 
 690-bool renderer_set_target(struct wld_renderer * base, struct buffer * buffer)
 691+bool
 692+renderer_set_target(struct wld_renderer *base, struct buffer *buffer)
 693 {
 694-    struct nouveau_renderer * renderer = nouveau_renderer(base);
 695+	struct nouveau_renderer *renderer = nouveau_renderer(base);
 696 
 697-    if (buffer && buffer->base.impl != &wld_buffer_impl)
 698-        return false;
 699+	if (buffer && buffer->base.impl != &wld_buffer_impl)
 700+		return false;
 701 
 702-    renderer->target = buffer ? nouveau_buffer(&buffer->base) : NULL;
 703+	renderer->target = buffer ? nouveau_buffer(&buffer->base) : NULL;
 704 
 705-    return true;
 706+	return true;
 707 }
 708 
 709-static inline void nvc0_2d_use_buffer(struct nouveau_renderer * renderer,
 710-                                      struct nouveau_buffer * buffer,
 711-                                      uint16_t format_method, uint16_t format)
 712-{
 713-    uint32_t access = format == G80_2D_SRC_FORMAT ? NOUVEAU_BO_RD
 714-                                                  : NOUVEAU_BO_WR;
 715-
 716-    nvc0_2d_inline(renderer->pushbuf, format_method, format);
 717-
 718-    if (buffer->bo->config.nvc0.memtype)
 719-    {
 720-        nvc0_2d(renderer->pushbuf, format_method + 0x04, 2,
 721-                0, buffer->bo->config.nvc0.tile_mode);
 722-    }
 723-    else
 724-    {
 725-        nvc0_2d_inline(renderer->pushbuf, format_method + 0x04, 1);
 726-        nvc0_2d(renderer->pushbuf, format_method + 0x14, 1,
 727-                buffer->base.base.pitch);
 728-    }
 729-
 730-    nvc0_2d(renderer->pushbuf, format_method + 0x18, 4,
 731-            buffer->base.base.width, buffer->base.base.height,
 732-            buffer->bo->offset >> 32, buffer->bo->offset);
 733-    nouveau_bufctx_refn(renderer->bufctx, 0, buffer->bo,
 734-                        NOUVEAU_BO_VRAM | access);
 735+static inline void
 736+nvc0_2d_use_buffer(struct nouveau_renderer *renderer,
 737+                   struct nouveau_buffer *buffer,
 738+                   uint16_t format_method, uint16_t format)
 739+{
 740+	uint32_t access = format == G80_2D_SRC_FORMAT ? NOUVEAU_BO_RD
 741+	                                              : NOUVEAU_BO_WR;
 742+
 743+	nvc0_2d_inline(renderer->pushbuf, format_method, format);
 744+
 745+	if (buffer->bo->config.nvc0.memtype) {
 746+		nvc0_2d(renderer->pushbuf, format_method + 0x04, 2,
 747+		        0, buffer->bo->config.nvc0.tile_mode);
 748+	} else {
 749+		nvc0_2d_inline(renderer->pushbuf, format_method + 0x04, 1);
 750+		nvc0_2d(renderer->pushbuf, format_method + 0x14, 1,
 751+		        buffer->base.base.pitch);
 752+	}
 753+
 754+	nvc0_2d(renderer->pushbuf, format_method + 0x18, 4,
 755+	        buffer->base.base.width, buffer->base.base.height,
 756+	        buffer->bo->offset >> 32, buffer->bo->offset);
 757+	nouveau_bufctx_refn(renderer->bufctx, 0, buffer->bo,
 758+	                    NOUVEAU_BO_VRAM | access);
 759 }
 760 
 761-void renderer_fill_rectangle(struct wld_renderer * base, uint32_t color,
 762-                             int32_t x, int32_t y,
 763-                             uint32_t width, uint32_t height)
 764+void
 765+renderer_fill_rectangle(struct wld_renderer *base, uint32_t color,
 766+                        int32_t x, int32_t y,
 767+                        uint32_t width, uint32_t height)
 768 {
 769-    struct nouveau_renderer * renderer = nouveau_renderer(base);
 770-    struct nouveau_buffer * dst = renderer->target;
 771-    uint32_t format;
 772+	struct nouveau_renderer *renderer = nouveau_renderer(base);
 773+	struct nouveau_buffer *dst = renderer->target;
 774+	uint32_t format;
 775 
 776-    if (!ensure_space(renderer->pushbuf, 18))
 777-        return;
 778+	if (!ensure_space(renderer->pushbuf, 18))
 779+		return;
 780 
 781-    format = nvc0_format(dst->base.base.format);
 782+	format = nvc0_format(dst->base.base.format);
 783 
 784-    nouveau_bufctx_reset(renderer->bufctx, 0);
 785-    nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, format);
 786-    nvc0_2d(renderer->pushbuf, G80_2D_DRAW_SHAPE, 3,
 787-            G80_2D_DRAW_SHAPE_RECTANGLES, format, color);
 788-    nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
 789+	nouveau_bufctx_reset(renderer->bufctx, 0);
 790+	nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, format);
 791+	nvc0_2d(renderer->pushbuf, G80_2D_DRAW_SHAPE, 3,
 792+	        G80_2D_DRAW_SHAPE_RECTANGLES, format, color);
 793+	nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
 794 
 795-    if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
 796-        return;
 797+	if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
 798+		return;
 799 
 800-    nvc0_2d(renderer->pushbuf, G80_2D_DRAW_POINT32_X(0), 4,
 801-            x, y, x + width, y + height);
 802+	nvc0_2d(renderer->pushbuf, G80_2D_DRAW_POINT32_X(0), 4,
 803+	        x, y, x + width, y + height);
 804 }
 805 
 806-void renderer_copy_rectangle(struct wld_renderer * base,
 807-                             struct buffer * buffer_base,
 808-                             int32_t dst_x, int32_t dst_y,
 809-                             int32_t src_x, int32_t src_y,
 810-                             uint32_t width, uint32_t height)
 811+void
 812+renderer_copy_rectangle(struct wld_renderer *base,
 813+                        struct buffer *buffer_base,
 814+                        int32_t dst_x, int32_t dst_y,
 815+                        int32_t src_x, int32_t src_y,
 816+                        uint32_t width, uint32_t height)
 817 {
 818-    struct nouveau_renderer * renderer = nouveau_renderer(base);
 819+	struct nouveau_renderer *renderer = nouveau_renderer(base);
 820 
 821-    if (buffer_base->base.impl != &wld_buffer_impl)
 822-        return;
 823+	if (buffer_base->base.impl != &wld_buffer_impl)
 824+		return;
 825 
 826-    struct nouveau_buffer * src = nouveau_buffer(&buffer_base->base),
 827-                          * dst = renderer->target;
 828-    uint32_t src_format, dst_format;
 829+	struct nouveau_buffer *src = nouveau_buffer(&buffer_base->base),
 830+	                      *dst = renderer->target;
 831+	uint32_t src_format, dst_format;
 832 
 833-    if (!ensure_space(renderer->pushbuf, 33))
 834-        return;
 835+	if (!ensure_space(renderer->pushbuf, 33))
 836+		return;
 837 
 838-    src_format = nvc0_format(src->base.base.format);
 839-    dst_format = nvc0_format(dst->base.base.format);
 840+	src_format = nvc0_format(src->base.base.format);
 841+	dst_format = nvc0_format(dst->base.base.format);
 842 
 843-    nouveau_bufctx_reset(renderer->bufctx, 0);
 844-    nvc0_2d_use_buffer(renderer, src, G80_2D_SRC_FORMAT, src_format);
 845-    nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, dst_format);
 846-    nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
 847+	nouveau_bufctx_reset(renderer->bufctx, 0);
 848+	nvc0_2d_use_buffer(renderer, src, G80_2D_SRC_FORMAT, src_format);
 849+	nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, dst_format);
 850+	nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
 851 
 852-    if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
 853-        return;
 854+	if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
 855+		return;
 856 
 857-    nvc0_2d_inline(renderer->pushbuf, G80_GRAPH_SERIALIZE, 0);
 858-    nvc0_2d_inline(renderer->pushbuf, G80_2D_BLIT_CONTROL,
 859-                   G80_2D_BLIT_CONTROL_ORIGIN_CENTER
 860-                 | G80_2D_BLIT_CONTROL_FILTER_POINT_SAMPLE);
 861-    nvc0_2d(renderer->pushbuf, G80_2D_BLIT_DST_X, 12,
 862-            dst_x, dst_y, width, height, 0, 1, 0, 1, 0, src_x, 0, src_y);
 863+	nvc0_2d_inline(renderer->pushbuf, G80_GRAPH_SERIALIZE, 0);
 864+	nvc0_2d_inline(renderer->pushbuf, G80_2D_BLIT_CONTROL,
 865+	               G80_2D_BLIT_CONTROL_ORIGIN_CENTER
 866+	                   | G80_2D_BLIT_CONTROL_FILTER_POINT_SAMPLE);
 867+	nvc0_2d(renderer->pushbuf, G80_2D_BLIT_DST_X, 12,
 868+	        dst_x, dst_y, width, height, 0, 1, 0, 1, 0, src_x, 0, src_y);
 869 
 870-    renderer_flush(base);
 871+	renderer_flush(base);
 872 }
 873 
 874-void renderer_draw_text(struct wld_renderer * base,
 875-                        struct font * font, uint32_t color,
 876-                        int32_t x, int32_t y, const char * text,
 877-                        uint32_t length, struct wld_extents * extents)
 878+void
 879+renderer_draw_text(struct wld_renderer *base,
 880+                   struct font *font, uint32_t color,
 881+                   int32_t x, int32_t y, const char *text,
 882+                   uint32_t length, struct wld_extents *extents)
 883 {
 884-    struct nouveau_renderer * renderer = nouveau_renderer(base);
 885-    struct nouveau_buffer * dst = renderer->target;
 886-    uint32_t format;
 887-    int ret;
 888-    struct glyph * glyph;
 889-    FT_UInt glyph_index;
 890-    uint32_t c, count;
 891-    int32_t origin_x = x;
 892-
 893-    if (!ensure_space(renderer->pushbuf, 17))
 894-        return;
 895-
 896-    format = nvc0_format(dst->base.base.format);
 897-
 898-    nouveau_bufctx_reset(renderer->bufctx, 0);
 899-    nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, format);
 900-    nvc0_2d_inline(renderer->pushbuf, G80_2D_SIFC_BITMAP_ENABLE, 1);
 901-    nvc0_2d(renderer->pushbuf, G80_2D_SIFC_BITMAP_FORMAT, 6,
 902-            G80_2D_SIFC_BITMAP_FORMAT_I1,
 903-            0,          /* SIFC_FORMAT */
 904-            G80_2D_SIFC_BITMAP_LINE_PACK_MODE_ALIGN_BYTE,
 905-            0, color,   /* SIFC_BITMAP_COLOR_BIT0, SIFC_BITMAP_COLOR_BIT1 */
 906-            0           /* SIFC_BITMAP_WRITE_BIT0_ENABLE */
 907-    );
 908-    nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
 909-
 910-    if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
 911-        return;
 912-
 913-    if (length == -1)
 914-        length = strlen(text);
 915-
 916-    while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length)) > 0 && c != '\0')
 917-    {
 918-        text += ret;
 919-        length -= ret;
 920-        glyph_index = FT_Get_Char_Index(font->face, c);
 921-
 922-        if (!font_ensure_glyph(font, glyph_index))
 923-            continue;
 924-
 925-        glyph = font->glyphs[glyph_index];
 926-
 927-        if (glyph->bitmap.width == 0 || glyph->bitmap.rows == 0)
 928-            goto advance;
 929-
 930-        count = (glyph->bitmap.pitch * glyph->bitmap.rows + 3) / 4;
 931-
 932-        if (!ensure_space(renderer->pushbuf, 12 + count))
 933-            return;
 934-
 935-        nvc0_2d(renderer->pushbuf, G80_2D_SIFC_WIDTH, 10,
 936-                /* Use the pitch instead of width to ensure the correct
 937+	struct nouveau_renderer *renderer = nouveau_renderer(base);
 938+	struct nouveau_buffer *dst = renderer->target;
 939+	uint32_t format;
 940+	int ret;
 941+	struct glyph *glyph;
 942+	FT_UInt glyph_index;
 943+	uint32_t c, count;
 944+	int32_t origin_x = x;
 945+
 946+	if (!ensure_space(renderer->pushbuf, 17))
 947+		return;
 948+
 949+	format = nvc0_format(dst->base.base.format);
 950+
 951+	nouveau_bufctx_reset(renderer->bufctx, 0);
 952+	nvc0_2d_use_buffer(renderer, dst, G80_2D_DST_FORMAT, format);
 953+	nvc0_2d_inline(renderer->pushbuf, G80_2D_SIFC_BITMAP_ENABLE, 1);
 954+	nvc0_2d(renderer->pushbuf, G80_2D_SIFC_BITMAP_FORMAT, 6,
 955+	        G80_2D_SIFC_BITMAP_FORMAT_I1,
 956+	        0, /* SIFC_FORMAT */
 957+	        G80_2D_SIFC_BITMAP_LINE_PACK_MODE_ALIGN_BYTE,
 958+	        0, color, /* SIFC_BITMAP_COLOR_BIT0, SIFC_BITMAP_COLOR_BIT1 */
 959+	        0         /* SIFC_BITMAP_WRITE_BIT0_ENABLE */
 960+	);
 961+	nouveau_pushbuf_bufctx(renderer->pushbuf, renderer->bufctx);
 962+
 963+	if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
 964+		return;
 965+
 966+	if (length == -1)
 967+		length = strlen(text);
 968+
 969+	while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length)) > 0 && c != '\0') {
 970+		text += ret;
 971+		length -= ret;
 972+		glyph_index = FT_Get_Char_Index(font->face, c);
 973+
 974+		if (!font_ensure_glyph(font, glyph_index))
 975+			continue;
 976+
 977+		glyph = font->glyphs[glyph_index];
 978+
 979+		if (glyph->bitmap.width == 0 || glyph->bitmap.rows == 0)
 980+			goto advance;
 981+
 982+		count = (glyph->bitmap.pitch * glyph->bitmap.rows + 3) / 4;
 983+
 984+		if (!ensure_space(renderer->pushbuf, 12 + count))
 985+			return;
 986+
 987+		nvc0_2d(renderer->pushbuf, G80_2D_SIFC_WIDTH, 10,
 988+		        /* Use the pitch instead of width to ensure the correct
 989                  * alignment is used. */
 990-                glyph->bitmap.pitch * 8, glyph->bitmap.rows,
 991-                0, 1, 0, 1,
 992-                0, origin_x + glyph->x, 0, y + glyph->y);
 993-        nv_add_dword(renderer->pushbuf,
 994-                     nvc0_command(GF100_COMMAND_TYPE_NON_INCREASING,
 995-                                  GF100_SUBCHANNEL_2D,
 996-                                  G80_2D_SIFC_DATA, count));
 997-        nv_add_data(renderer->pushbuf, glyph->bitmap.buffer, count);
 998-
 999-      advance:
1000-        origin_x += glyph->advance;
1001-    }
1002-
1003-    if (extents)
1004-        extents->advance = origin_x - x;
1005+		        glyph->bitmap.pitch * 8, glyph->bitmap.rows,
1006+		        0, 1, 0, 1,
1007+		        0, origin_x + glyph->x, 0, y + glyph->y);
1008+		nv_add_dword(renderer->pushbuf,
1009+		             nvc0_command(GF100_COMMAND_TYPE_NON_INCREASING,
1010+		                          GF100_SUBCHANNEL_2D,
1011+		                          G80_2D_SIFC_DATA, count));
1012+		nv_add_data(renderer->pushbuf, glyph->bitmap.buffer, count);
1013+
1014+	advance:
1015+		origin_x += glyph->advance;
1016+	}
1017+
1018+	if (extents)
1019+		extents->advance = origin_x - x;
1020 }
1021 
1022-void renderer_flush(struct wld_renderer * base)
1023+void
1024+renderer_flush(struct wld_renderer *base)
1025 {
1026-    struct nouveau_renderer * renderer = nouveau_renderer(base);
1027+	struct nouveau_renderer *renderer = nouveau_renderer(base);
1028 
1029-    nouveau_pushbuf_kick(renderer->pushbuf, renderer->channel);
1030-    nouveau_pushbuf_bufctx(renderer->pushbuf, NULL);
1031+	nouveau_pushbuf_kick(renderer->pushbuf, renderer->channel);
1032+	nouveau_pushbuf_bufctx(renderer->pushbuf, NULL);
1033 }
1034 
1035-void renderer_destroy(struct wld_renderer * base)
1036+void
1037+renderer_destroy(struct wld_renderer *base)
1038 {
1039-    struct nouveau_renderer * renderer = nouveau_renderer(base);
1040+	struct nouveau_renderer *renderer = nouveau_renderer(base);
1041 
1042-    nvc0_2d_finalize(renderer);
1043-    nouveau_bufctx_del(&renderer->bufctx);
1044-    nouveau_pushbuf_del(&renderer->pushbuf);
1045-    nouveau_object_del(&renderer->channel);
1046-    free(renderer);
1047+	nvc0_2d_finalize(renderer);
1048+	nouveau_bufctx_del(&renderer->bufctx);
1049+	nouveau_pushbuf_del(&renderer->pushbuf);
1050+	nouveau_object_del(&renderer->channel);
1051+	free(renderer);
1052 }
1053 
1054 /**** Buffer ****/
1055-bool buffer_map(struct buffer * base)
1056+bool
1057+buffer_map(struct buffer *base)
1058 {
1059-    struct nouveau_buffer * buffer = nouveau_buffer(&base->base);
1060+	struct nouveau_buffer *buffer = nouveau_buffer(&base->base);
1061 
1062-    /* If the buffer is tiled, it cannot be mapped into virtual memory in order
1063+	/* If the buffer is tiled, it cannot be mapped into virtual memory in order
1064      * to appear linear like intel can do with map_gtt. */
1065-    if (buffer->bo->config.nvc0.tile_mode)
1066-        return false;
1067+	if (buffer->bo->config.nvc0.tile_mode)
1068+		return false;
1069 
1070-    if (nouveau_bo_map(buffer->bo, NOUVEAU_BO_WR,
1071-                       buffer->context->client) != 0)
1072-    {
1073-        return false;
1074-    }
1075+	if (nouveau_bo_map(buffer->bo, NOUVEAU_BO_WR,
1076+	                   buffer->context->client)
1077+	    != 0) {
1078+		return false;
1079+	}
1080 
1081-    buffer->base.base.map = buffer->bo->map;
1082+	buffer->base.base.map = buffer->bo->map;
1083 
1084-    return true;
1085+	return true;
1086 }
1087 
1088-bool buffer_unmap(struct buffer * base)
1089+bool
1090+buffer_unmap(struct buffer *base)
1091 {
1092-    struct nouveau_buffer * buffer = nouveau_buffer(&base->base);
1093+	struct nouveau_buffer *buffer = nouveau_buffer(&base->base);
1094 
1095-    if (munmap(buffer->bo->map, buffer->bo->size) == -1)
1096-        return false;
1097+	if (munmap(buffer->bo->map, buffer->bo->size) == -1)
1098+		return false;
1099 
1100-    buffer->bo->map = NULL;
1101-    base->base.map = NULL;
1102+	buffer->bo->map = NULL;
1103+	base->base.map = NULL;
1104 
1105-    return true;
1106+	return true;
1107 }
1108 
1109-void buffer_destroy(struct buffer * base)
1110+void
1111+buffer_destroy(struct buffer *base)
1112 {
1113-    struct nouveau_buffer * buffer = nouveau_buffer(&base->base);
1114+	struct nouveau_buffer *buffer = nouveau_buffer(&base->base);
1115 
1116-    nouveau_bo_ref(NULL, &buffer->bo);
1117-    free(buffer);
1118+	nouveau_bo_ref(NULL, &buffer->bo);
1119+	free(buffer);
1120 }
1121-
+310, -298
  1@@ -24,427 +24,439 @@
  2 #include "pixman.h"
  3 #include "wld-private.h"
  4 
  5-#define PIXMAN_COLOR(c) {                   \
  6-    .alpha  = ((c >> 24) & 0xff) * 0x101,   \
  7-    .red    = ((c >> 16) & 0xff) * 0x101,   \
  8-    .green  = ((c >>  8) & 0xff) * 0x101,   \
  9-    .blue   = ((c >>  0) & 0xff) * 0x101,   \
 10-}
 11-
 12-struct pixman_renderer
 13-{
 14-    struct wld_renderer base;
 15-    pixman_image_t * target;
 16-    pixman_glyph_cache_t * glyph_cache;
 17+#define PIXMAN_COLOR(c)                              \
 18+	{                                            \
 19+		.alpha = ((c >> 24) & 0xff) * 0x101, \
 20+		.red = ((c >> 16) & 0xff) * 0x101,   \
 21+		.green = ((c >> 8) & 0xff) * 0x101,  \
 22+		.blue = ((c >> 0) & 0xff) * 0x101,   \
 23+	}
 24+
 25+struct pixman_renderer {
 26+	struct wld_renderer base;
 27+	pixman_image_t *target;
 28+	pixman_glyph_cache_t *glyph_cache;
 29 };
 30 
 31-struct pixman_buffer
 32-{
 33-    struct buffer base;
 34-    pixman_image_t * image;
 35+struct pixman_buffer {
 36+	struct buffer base;
 37+	pixman_image_t *image;
 38 };
 39 
 40-struct pixman_map
 41-{
 42-    struct wld_exporter exporter;
 43-    struct wld_destructor destructor;
 44-    pixman_image_t * image;
 45+struct pixman_map {
 46+	struct wld_exporter exporter;
 47+	struct wld_destructor destructor;
 48+	pixman_image_t *image;
 49 };
 50 
 51 #include "interface/context.h"
 52 #define RENDERER_IMPLEMENTS_REGION
 53-#include "interface/renderer.h"
 54 #include "interface/buffer.h"
 55+#include "interface/renderer.h"
 56 IMPL(pixman_renderer, wld_renderer)
 57 IMPL(pixman_buffer, wld_buffer)
 58 
 59 static struct wld_context context = { .impl = &wld_context_impl };
 60 
 61 EXPORT
 62-struct wld_context * wld_pixman_context = &context;
 63+struct wld_context *wld_pixman_context = &context;
 64 
 65-struct wld_renderer * context_create_renderer(struct wld_context * context)
 66+struct wld_renderer *
 67+context_create_renderer(struct wld_context *context)
 68 {
 69-    struct pixman_renderer * renderer;
 70+	struct pixman_renderer *renderer;
 71 
 72-    if (!(renderer = malloc(sizeof *renderer)))
 73-        goto error0;
 74+	if (!(renderer = malloc(sizeof *renderer)))
 75+		goto error0;
 76 
 77-    if (!(renderer->glyph_cache = pixman_glyph_cache_create()))
 78-        goto error1;
 79+	if (!(renderer->glyph_cache = pixman_glyph_cache_create()))
 80+		goto error1;
 81 
 82-    renderer_initialize(&renderer->base, &wld_renderer_impl);
 83-    renderer->target = NULL;
 84+	renderer_initialize(&renderer->base, &wld_renderer_impl);
 85+	renderer->target = NULL;
 86 
 87-    return &renderer->base;
 88+	return &renderer->base;
 89 
 90-  error1:
 91-    free(renderer);
 92-  error0:
 93-    return NULL;
 94+error1:
 95+	free(renderer);
 96+error0:
 97+	return NULL;
 98 }
 99 
100-static struct buffer * new_buffer(pixman_image_t * image)
101+static struct buffer *
102+new_buffer(pixman_image_t *image)
103 {
104-    struct pixman_buffer * buffer;
105+	struct pixman_buffer *buffer;
106 
107-    if (!(buffer = malloc(sizeof *buffer)))
108-        return NULL;
109+	if (!(buffer = malloc(sizeof *buffer)))
110+		return NULL;
111 
112-    buffer_initialize(&buffer->base, &wld_buffer_impl,
113-                      pixman_image_get_width(image),
114-                      pixman_image_get_height(image),
115-                      format_pixman_to_wld(pixman_image_get_format(image)),
116-                      pixman_image_get_stride(image));
117-    buffer->base.base.map = pixman_image_get_data(image);
118-    buffer->image = image;
119+	buffer_initialize(&buffer->base, &wld_buffer_impl,
120+	                  pixman_image_get_width(image),
121+	                  pixman_image_get_height(image),
122+	                  format_pixman_to_wld(pixman_image_get_format(image)),
123+	                  pixman_image_get_stride(image));
124+	buffer->base.base.map = pixman_image_get_data(image);
125+	buffer->image = image;
126 
127-    return &buffer->base;
128+	return &buffer->base;
129 }
130 
131-struct buffer * context_create_buffer(struct wld_context * context,
132-                                      uint32_t width, uint32_t height,
133-                                      uint32_t format, uint32_t flags)
134+struct buffer *
135+context_create_buffer(struct wld_context *context,
136+                      uint32_t width, uint32_t height,
137+                      uint32_t format, uint32_t flags)
138 {
139-    struct buffer * buffer;
140-    pixman_image_t * image;
141+	struct buffer *buffer;
142+	pixman_image_t *image;
143 
144-    image = pixman_image_create_bits(format_wld_to_pixman(format),
145-                                     width, height, NULL, 0);
146+	image = pixman_image_create_bits(format_wld_to_pixman(format),
147+	                                 width, height, NULL, 0);
148 
149-    if (!image)
150-        goto error0;
151+	if (!image)
152+		goto error0;
153 
154-    if (!(buffer = new_buffer(image)))
155-        goto error1;
156+	if (!(buffer = new_buffer(image)))
157+		goto error1;
158 
159-    return buffer;
160+	return buffer;
161 
162-  error1:
163-    pixman_image_unref(image);
164-  error0:
165-    return NULL;
166+error1:
167+	pixman_image_unref(image);
168+error0:
169+	return NULL;
170 }
171 
172-struct buffer * context_import_buffer(struct wld_context * context,
173-                                      uint32_t type, union wld_object object,
174-                                      uint32_t width, uint32_t height,
175-                                      uint32_t format, uint32_t pitch)
176+struct buffer *
177+context_import_buffer(struct wld_context *context,
178+                      uint32_t type, union wld_object object,
179+                      uint32_t width, uint32_t height,
180+                      uint32_t format, uint32_t pitch)
181 {
182-    struct buffer * buffer;
183-    pixman_image_t * image;
184-
185-    switch (type)
186-    {
187-        case WLD_OBJECT_DATA:
188-            image = pixman_image_create_bits(format_wld_to_pixman(format),
189-                                             width, height, object.ptr, pitch);
190-            break;
191-        default: image = NULL;
192-    }
193-
194-    if (!image)
195-        goto error0;
196-
197-    if (!(buffer = new_buffer(image)))
198-        goto error1;
199-
200-    return buffer;
201-
202-  error1:
203-    pixman_image_unref(image);
204-  error0:
205-    return NULL;
206-
207+	struct buffer *buffer;
208+	pixman_image_t *image;
209+
210+	switch (type) {
211+	case WLD_OBJECT_DATA:
212+		image = pixman_image_create_bits(format_wld_to_pixman(format),
213+		                                 width, height, object.ptr, pitch);
214+		break;
215+	default:
216+		image = NULL;
217+	}
218+
219+	if (!image)
220+		goto error0;
221+
222+	if (!(buffer = new_buffer(image)))
223+		goto error1;
224+
225+	return buffer;
226+
227+error1:
228+	pixman_image_unref(image);
229+error0:
230+	return NULL;
231 }
232 
233-void context_destroy(struct wld_context * context)
234+void
235+context_destroy(struct wld_context *context)
236 {
237 }
238 
239-uint32_t renderer_capabilities(struct wld_renderer * renderer,
240-                               struct buffer * buffer)
241+uint32_t
242+renderer_capabilities(struct wld_renderer *renderer,
243+                      struct buffer *buffer)
244 {
245-    /* The pixman renderer can read and write to any buffer using it's map
246+	/* The pixman renderer can read and write to any buffer using it's map
247      * implementation. */
248-    return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
249+	return WLD_CAPABILITY_READ | WLD_CAPABILITY_WRITE;
250 }
251 
252-static void destroy_image(pixman_image_t * image, void * data)
253+static void
254+destroy_image(pixman_image_t *image, void *data)
255 {
256-    struct buffer * buffer = data;
257+	struct buffer *buffer = data;
258 
259-    wld_unmap(&buffer->base);
260+	wld_unmap(&buffer->base);
261 }
262 
263-bool map_export(struct wld_exporter * exporter, struct wld_buffer * buffer,
264-                uint32_t type, union wld_object * object)
265+bool
266+map_export(struct wld_exporter *exporter, struct wld_buffer *buffer,
267+           uint32_t type, union wld_object *object)
268 {
269-    struct pixman_map * map
270-        = CONTAINER_OF(exporter, struct pixman_map, exporter);
271-
272-    switch (type)
273-    {
274-        case WLD_PIXMAN_OBJECT_IMAGE:
275-            object->ptr = pixman_image_ref(map->image);
276-            return true;
277-        default:
278-            return false;
279-    }
280+	struct pixman_map *map = CONTAINER_OF(exporter, struct pixman_map, exporter);
281+
282+	switch (type) {
283+	case WLD_PIXMAN_OBJECT_IMAGE:
284+		object->ptr = pixman_image_ref(map->image);
285+		return true;
286+	default:
287+		return false;
288+	}
289 }
290 
291-void map_destroy(struct wld_destructor * destructor)
292+void
293+map_destroy(struct wld_destructor *destructor)
294 {
295-    struct pixman_map * map
296-        = CONTAINER_OF(destructor, struct pixman_map, destructor);
297+	struct pixman_map *map = CONTAINER_OF(destructor, struct pixman_map, destructor);
298 
299-    pixman_image_unref(map->image);
300-    free(map);
301+	pixman_image_unref(map->image);
302+	free(map);
303 }
304 
305-static pixman_image_t * pixman_image(struct buffer * buffer)
306+static pixman_image_t *
307+pixman_image(struct buffer *buffer)
308 {
309-    if (buffer->base.impl == &wld_buffer_impl)
310-        return pixman_image_ref(pixman_buffer(&buffer->base)->image);
311+	if (buffer->base.impl == &wld_buffer_impl)
312+		return pixman_image_ref(pixman_buffer(&buffer->base)->image);
313 
314-    union wld_object object;
315+	union wld_object object;
316 
317-    if (wld_export(&buffer->base, WLD_PIXMAN_OBJECT_IMAGE, &object))
318-        return object.ptr;
319+	if (wld_export(&buffer->base, WLD_PIXMAN_OBJECT_IMAGE, &object))
320+		return object.ptr;
321 
322-    struct pixman_map * map;
323-    pixman_image_t * image;
324+	struct pixman_map *map;
325+	pixman_image_t *image;
326 
327-    if (!wld_map(&buffer->base))
328-        goto error0;
329+	if (!wld_map(&buffer->base))
330+		goto error0;
331 
332-    image = pixman_image_create_bits(format_wld_to_pixman(buffer->base.format),
333-                                     buffer->base.width, buffer->base.height,
334-                                     buffer->base.map, buffer->base.pitch);
335+	image = pixman_image_create_bits(format_wld_to_pixman(buffer->base.format),
336+	                                 buffer->base.width, buffer->base.height,
337+	                                 buffer->base.map, buffer->base.pitch);
338 
339-    if (!image)
340-        goto error1;
341+	if (!image)
342+		goto error1;
343 
344-    if (!(map = malloc(sizeof *map)))
345-        goto error2;
346+	if (!(map = malloc(sizeof *map)))
347+		goto error2;
348 
349-    map->image = image;
350-    map->exporter.export = &map_export;
351-    wld_buffer_add_exporter(&buffer->base, &map->exporter);
352-    map->destructor.destroy = &map_destroy;
353-    wld_buffer_add_destructor(&buffer->base, &map->destructor);
354-    pixman_image_set_destroy_function(image, &destroy_image, buffer);
355+	map->image = image;
356+	map->exporter.export = &map_export;
357+	wld_buffer_add_exporter(&buffer->base, &map->exporter);
358+	map->destructor.destroy = &map_destroy;
359+	wld_buffer_add_destructor(&buffer->base, &map->destructor);
360+	pixman_image_set_destroy_function(image, &destroy_image, buffer);
361 
362-    return pixman_image_ref(image);
363+	return pixman_image_ref(image);
364 
365-  error2:
366-    pixman_image_unref(image);
367-  error1:
368-    wld_unmap(&buffer->base);
369-  error0:
370-    return NULL;
371+error2:
372+	pixman_image_unref(image);
373+error1:
374+	wld_unmap(&buffer->base);
375+error0:
376+	return NULL;
377 }
378 
379-bool renderer_set_target(struct wld_renderer * base, struct buffer * buffer)
380+bool
381+renderer_set_target(struct wld_renderer *base, struct buffer *buffer)
382 {
383-    struct pixman_renderer * renderer = pixman_renderer(base);
384+	struct pixman_renderer *renderer = pixman_renderer(base);
385 
386-    if (renderer->target)
387-        pixman_image_unref(renderer->target);
388+	if (renderer->target)
389+		pixman_image_unref(renderer->target);
390 
391-    if (buffer)
392-        return (renderer->target = pixman_image(buffer));
393+	if (buffer)
394+		return (renderer->target = pixman_image(buffer));
395 
396-    renderer->target = NULL;
397-    return true;
398+	renderer->target = NULL;
399+	return true;
400 }
401 
402-void renderer_fill_rectangle(struct wld_renderer * base, uint32_t color,
403-                             int32_t x, int32_t y,
404-                             uint32_t width, uint32_t height)
405+void
406+renderer_fill_rectangle(struct wld_renderer *base, uint32_t color,
407+                        int32_t x, int32_t y,
408+                        uint32_t width, uint32_t height)
409 {
410-    struct pixman_renderer * renderer = pixman_renderer(base);
411-    pixman_color_t pixman_color = PIXMAN_COLOR(color);
412-    pixman_box32_t box = { x, y, x + width, y + height };
413+	struct pixman_renderer *renderer = pixman_renderer(base);
414+	pixman_color_t pixman_color = PIXMAN_COLOR(color);
415+	pixman_box32_t box = { x, y, x + width, y + height };
416 
417-    pixman_image_fill_boxes(PIXMAN_OP_SRC, renderer->target,
418-                            &pixman_color, 1, &box);
419+	pixman_image_fill_boxes(PIXMAN_OP_SRC, renderer->target,
420+	                        &pixman_color, 1, &box);
421 }
422 
423-void renderer_fill_region(struct wld_renderer * base, uint32_t color,
424-                          pixman_region32_t * region)
425+void
426+renderer_fill_region(struct wld_renderer *base, uint32_t color,
427+                     pixman_region32_t *region)
428 {
429-    struct pixman_renderer * renderer = pixman_renderer(base);
430-    pixman_color_t pixman_color = PIXMAN_COLOR(color);
431-    pixman_box32_t * boxes;
432-    int num_boxes;
433-
434-    boxes = pixman_region32_rectangles(region, &num_boxes);
435-    pixman_image_fill_boxes(PIXMAN_OP_SRC, renderer->target,
436-                            &pixman_color, num_boxes, boxes);
437+	struct pixman_renderer *renderer = pixman_renderer(base);
438+	pixman_color_t pixman_color = PIXMAN_COLOR(color);
439+	pixman_box32_t *boxes;
440+	int num_boxes;
441+
442+	boxes = pixman_region32_rectangles(region, &num_boxes);
443+	pixman_image_fill_boxes(PIXMAN_OP_SRC, renderer->target,
444+	                        &pixman_color, num_boxes, boxes);
445 }
446 
447-void renderer_copy_rectangle(struct wld_renderer * base, struct buffer * buffer,
448-                             int32_t dst_x, int32_t dst_y,
449-                             int32_t src_x, int32_t src_y,
450-                             uint32_t width, uint32_t height)
451+void
452+renderer_copy_rectangle(struct wld_renderer *base, struct buffer *buffer,
453+                        int32_t dst_x, int32_t dst_y,
454+                        int32_t src_x, int32_t src_y,
455+                        uint32_t width, uint32_t height)
456 {
457-    struct pixman_renderer * renderer = pixman_renderer(base);
458-    pixman_image_t * src = pixman_image(buffer), * dst = renderer->target;
459+	struct pixman_renderer *renderer = pixman_renderer(base);
460+	pixman_image_t *src = pixman_image(buffer), *dst = renderer->target;
461 
462-    if (!src) return;
463+	if (!src)
464+		return;
465 
466-    pixman_image_composite32(PIXMAN_OP_SRC, src, NULL, dst,
467-                             src_x, src_y, 0, 0, dst_x, dst_y, width, height);
468+	pixman_image_composite32(PIXMAN_OP_SRC, src, NULL, dst,
469+	                         src_x, src_y, 0, 0, dst_x, dst_y, width, height);
470 }
471 
472-void renderer_copy_region(struct wld_renderer * base, struct buffer * buffer,
473-                          int32_t dst_x, int32_t dst_y,
474-                          pixman_region32_t * region)
475+void
476+renderer_copy_region(struct wld_renderer *base, struct buffer *buffer,
477+                     int32_t dst_x, int32_t dst_y,
478+                     pixman_region32_t *region)
479 {
480-    struct pixman_renderer * renderer = pixman_renderer(base);
481-    pixman_image_t * src = pixman_image(buffer), * dst = renderer->target;
482-
483-    if (!src) return;
484-
485-    pixman_image_set_clip_region32(src, region);
486-    pixman_image_composite32(PIXMAN_OP_SRC, src, NULL, dst,
487-                             region->extents.x1, region->extents.y1, 0, 0,
488-                             region->extents.x1 + dst_x,
489-                             region->extents.y1 + dst_y,
490-                             region->extents.x2 - region->extents.x1,
491-                             region->extents.y2 - region->extents.y1);
492-    pixman_image_set_clip_region32(src, NULL);
493+	struct pixman_renderer *renderer = pixman_renderer(base);
494+	pixman_image_t *src = pixman_image(buffer), *dst = renderer->target;
495+
496+	if (!src)
497+		return;
498+
499+	pixman_image_set_clip_region32(src, region);
500+	pixman_image_composite32(PIXMAN_OP_SRC, src, NULL, dst,
501+	                         region->extents.x1, region->extents.y1, 0, 0,
502+	                         region->extents.x1 + dst_x,
503+	                         region->extents.y1 + dst_y,
504+	                         region->extents.x2 - region->extents.x1,
505+	                         region->extents.y2 - region->extents.y1);
506+	pixman_image_set_clip_region32(src, NULL);
507 }
508 
509-static inline uint8_t reverse(uint8_t byte)
510+static inline uint8_t
511+reverse(uint8_t byte)
512 {
513-    byte = ((byte << 1) & 0xaa) | ((byte >> 1) & 0x55);
514-    byte = ((byte << 2) & 0xcc) | ((byte >> 2) & 0x33);
515-    byte = ((byte << 4) & 0xf0) | ((byte >> 4) & 0x0f);
516+	byte = ((byte << 1) & 0xaa) | ((byte >> 1) & 0x55);
517+	byte = ((byte << 2) & 0xcc) | ((byte >> 2) & 0x33);
518+	byte = ((byte << 4) & 0xf0) | ((byte >> 4) & 0x0f);
519 
520-    return byte;
521+	return byte;
522 }
523 
524-void renderer_draw_text(struct wld_renderer * base,
525-                        struct font * font, uint32_t color,
526-                        int32_t x, int32_t y, const char * text,
527-                        uint32_t length, struct wld_extents * extents)
528+void
529+renderer_draw_text(struct wld_renderer *base,
530+                   struct font *font, uint32_t color,
531+                   int32_t x, int32_t y, const char *text,
532+                   uint32_t length, struct wld_extents *extents)
533 {
534-    struct pixman_renderer * renderer = pixman_renderer(base);
535-    int ret;
536-    uint32_t c;
537-    struct glyph * glyph;
538-    FT_UInt glyph_index;
539-    pixman_glyph_t glyphs[length == -1 ? (length = strlen(text)) : length];
540-    uint32_t index = 0, origin_x = 0;
541-    pixman_color_t pixman_color = PIXMAN_COLOR(color);
542-    pixman_image_t * solid;
543-
544-    solid = pixman_image_create_solid_fill(&pixman_color);
545-
546-    while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length)) > 0 && c != '\0')
547-    {
548-        text += ret;
549-        length -= ret;
550-        glyph_index = FT_Get_Char_Index(font->face, c);
551-
552-        if (!font_ensure_glyph(font, glyph_index))
553-            continue;
554-
555-        glyph = font->glyphs[glyph_index];
556-
557-        glyphs[index].x = origin_x;
558-        glyphs[index].y = 0;
559-        glyphs[index].glyph = pixman_glyph_cache_lookup(renderer->glyph_cache,
560-                                                        font, glyph);
561-
562-        /* If we don't have the glyph in our cache, do some conversions to make
563+	struct pixman_renderer *renderer = pixman_renderer(base);
564+	int ret;
565+	uint32_t c;
566+	struct glyph *glyph;
567+	FT_UInt glyph_index;
568+	pixman_glyph_t glyphs[length == -1 ? (length = strlen(text)) : length];
569+	uint32_t index = 0, origin_x = 0;
570+	pixman_color_t pixman_color = PIXMAN_COLOR(color);
571+	pixman_image_t *solid;
572+
573+	solid = pixman_image_create_solid_fill(&pixman_color);
574+
575+	while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length)) > 0 && c != '\0') {
576+		text += ret;
577+		length -= ret;
578+		glyph_index = FT_Get_Char_Index(font->face, c);
579+
580+		if (!font_ensure_glyph(font, glyph_index))
581+			continue;
582+
583+		glyph = font->glyphs[glyph_index];
584+
585+		glyphs[index].x = origin_x;
586+		glyphs[index].y = 0;
587+		glyphs[index].glyph = pixman_glyph_cache_lookup(renderer->glyph_cache,
588+		                                                font, glyph);
589+
590+		/* If we don't have the glyph in our cache, do some conversions to make
591          * pixman happy, and then insert it. */
592-        if (!glyphs[index].glyph)
593-        {
594-            uint8_t * src, * dst;
595-            uint32_t row, byte_index, bytes_per_row, pitch;
596-            pixman_image_t * image;
597-            FT_Bitmap * bitmap;
598-
599-            bitmap = &glyph->bitmap;
600-            image = pixman_image_create_bits
601-                (PIXMAN_a1, bitmap->width, bitmap->rows, NULL, bitmap->pitch);
602-
603-            if (!image)
604-                goto advance;
605-
606-            pitch = pixman_image_get_stride(image);
607-            bytes_per_row = (bitmap->width + 7) / 8;
608-            src = bitmap->buffer;
609-            dst = (uint8_t *) pixman_image_get_data(image);
610-
611-            for (row = 0; row < bitmap->rows; ++row)
612-            {
613-                /* Pixman's A1 format expects the bits in the opposite order
614+		if (!glyphs[index].glyph) {
615+			uint8_t *src, *dst;
616+			uint32_t row, byte_index, bytes_per_row, pitch;
617+			pixman_image_t *image;
618+			FT_Bitmap *bitmap;
619+
620+			bitmap = &glyph->bitmap;
621+			image = pixman_image_create_bits(PIXMAN_a1, bitmap->width, bitmap->rows, NULL, bitmap->pitch);
622+
623+			if (!image)
624+				goto advance;
625+
626+			pitch = pixman_image_get_stride(image);
627+			bytes_per_row = (bitmap->width + 7) / 8;
628+			src = bitmap->buffer;
629+			dst = (uint8_t *)pixman_image_get_data(image);
630+
631+			for (row = 0; row < bitmap->rows; ++row) {
632+				/* Pixman's A1 format expects the bits in the opposite order
633                  * that Freetype gives us. Sigh... */
634-                for (byte_index = 0; byte_index < bytes_per_row; ++byte_index)
635-                    dst[byte_index] = reverse(src[byte_index]);
636+				for (byte_index = 0; byte_index < bytes_per_row; ++byte_index)
637+					dst[byte_index] = reverse(src[byte_index]);
638 
639-                dst += pitch;
640-                src += bitmap->pitch;
641-            }
642+				dst += pitch;
643+				src += bitmap->pitch;
644+			}
645 
646-            /* Insert the glyph into the cache. */
647-            pixman_glyph_cache_freeze(renderer->glyph_cache);
648-            glyphs[index].glyph = pixman_glyph_cache_insert
649-                (renderer->glyph_cache, font, glyph,
650-                 -glyph->x, -glyph->y, image);
651-            pixman_glyph_cache_thaw(renderer->glyph_cache);
652+			/* Insert the glyph into the cache. */
653+			pixman_glyph_cache_freeze(renderer->glyph_cache);
654+			glyphs[index].glyph = pixman_glyph_cache_insert(renderer->glyph_cache, font, glyph,
655+			                                                -glyph->x, -glyph->y, image);
656+			pixman_glyph_cache_thaw(renderer->glyph_cache);
657 
658-            /* The glyph cache copies the contents of the glyph bitmap. */
659-            pixman_image_unref(image);
660-        }
661+			/* The glyph cache copies the contents of the glyph bitmap. */
662+			pixman_image_unref(image);
663+		}
664 
665-        ++index;
666+		++index;
667 
668-      advance:
669-        origin_x += glyph->advance;
670-    }
671+	advance:
672+		origin_x += glyph->advance;
673+	}
674 
675-    pixman_composite_glyphs_no_mask(PIXMAN_OP_OVER, solid, renderer->target,
676-                                    0, 0, x, y, renderer->glyph_cache,
677-                                    index, glyphs);
678+	pixman_composite_glyphs_no_mask(PIXMAN_OP_OVER, solid, renderer->target,
679+	                                0, 0, x, y, renderer->glyph_cache,
680+	                                index, glyphs);
681 
682-    pixman_image_unref(solid);
683+	pixman_image_unref(solid);
684 
685-    if (extents)
686-        extents->advance = origin_x;
687+	if (extents)
688+		extents->advance = origin_x;
689 }
690 
691-void renderer_flush(struct wld_renderer * renderer)
692+void
693+renderer_flush(struct wld_renderer *renderer)
694 {
695 }
696 
697-void renderer_destroy(struct wld_renderer * base)
698+void
699+renderer_destroy(struct wld_renderer *base)
700 {
701-    struct pixman_renderer * renderer = pixman_renderer(base);
702+	struct pixman_renderer *renderer = pixman_renderer(base);
703 
704-    pixman_glyph_cache_destroy(renderer->glyph_cache);
705-    free(renderer);
706+	pixman_glyph_cache_destroy(renderer->glyph_cache);
707+	free(renderer);
708 }
709 
710-bool buffer_map(struct buffer * buffer)
711+bool
712+buffer_map(struct buffer *buffer)
713 {
714-    return true;
715+	return true;
716 }
717 
718-bool buffer_unmap(struct buffer * buffer)
719+bool
720+buffer_unmap(struct buffer *buffer)
721 {
722-    return true;
723+	return true;
724 }
725 
726-void buffer_destroy(struct buffer * base)
727+void
728+buffer_destroy(struct buffer *base)
729 {
730-    struct pixman_buffer * buffer = pixman_buffer(&base->base);
731+	struct pixman_buffer *buffer = pixman_buffer(&base->base);
732 
733-    pixman_image_unref(buffer->image);
734-    free(buffer);
735+	pixman_image_unref(buffer->image);
736+	free(buffer);
737 }
738-
+6, -7
 1@@ -28,17 +28,16 @@
 2 
 3 #define WLD_PIXMAN_ID (0x01 << 24)
 4 
 5-enum wld_pixman_object_type
 6-{
 7-    WLD_PIXMAN_OBJECT_IMAGE = WLD_PIXMAN_ID
 8+enum wld_pixman_object_type {
 9+	WLD_PIXMAN_OBJECT_IMAGE = WLD_PIXMAN_ID
10 };
11 
12-extern struct wld_context * wld_pixman_context;
13+extern struct wld_context *wld_pixman_context;
14 
15-static inline struct wld_context * wld_pixman_create_context()
16+static inline struct wld_context *
17+wld_pixman_create_context()
18 {
19-    return wld_pixman_context;
20+	return wld_pixman_context;
21 }
22 
23 #endif
24-
+87, -77
  1@@ -23,135 +23,145 @@
  2 
  3 #include "wld-private.h"
  4 
  5-void default_fill_region(struct wld_renderer * renderer, uint32_t color,
  6-                         pixman_region32_t * region)
  7+void
  8+default_fill_region(struct wld_renderer *renderer, uint32_t color,
  9+                    pixman_region32_t *region)
 10 {
 11-    pixman_box32_t * box;
 12-    int num_boxes;
 13+	pixman_box32_t *box;
 14+	int num_boxes;
 15 
 16-    box = pixman_region32_rectangles(region, &num_boxes);
 17+	box = pixman_region32_rectangles(region, &num_boxes);
 18 
 19-    while (num_boxes--)
 20-    {
 21-        renderer->impl->fill_rectangle(renderer, color, box->x1, box->y1,
 22-                                       box->x2 - box->x1, box->y2 - box->y1);
 23-        ++box;
 24-    }
 25+	while (num_boxes--) {
 26+		renderer->impl->fill_rectangle(renderer, color, box->x1, box->y1,
 27+		                               box->x2 - box->x1, box->y2 - box->y1);
 28+		++box;
 29+	}
 30 }
 31 
 32-void default_copy_region(struct wld_renderer * renderer, struct buffer * buffer,
 33-                         int32_t dst_x, int32_t dst_y,
 34-                         pixman_region32_t * region)
 35+void
 36+default_copy_region(struct wld_renderer *renderer, struct buffer *buffer,
 37+                    int32_t dst_x, int32_t dst_y,
 38+                    pixman_region32_t *region)
 39 {
 40-    pixman_box32_t * box;
 41-    int num_boxes;
 42-
 43-    box = pixman_region32_rectangles(region, &num_boxes);
 44-
 45-    while (num_boxes--)
 46-    {
 47-        renderer->impl->copy_rectangle(renderer, buffer,
 48-                                       dst_x + box->x1, dst_y + box->y1,
 49-                                       box->x1, box->y1,
 50-                                       box->x2 - box->x1, box->y2 - box->y1);
 51-        ++box;
 52-    }
 53+	pixman_box32_t *box;
 54+	int num_boxes;
 55+
 56+	box = pixman_region32_rectangles(region, &num_boxes);
 57+
 58+	while (num_boxes--) {
 59+		renderer->impl->copy_rectangle(renderer, buffer,
 60+		                               dst_x + box->x1, dst_y + box->y1,
 61+		                               box->x1, box->y1,
 62+		                               box->x2 - box->x1, box->y2 - box->y1);
 63+		++box;
 64+	}
 65 }
 66 
 67-void renderer_initialize(struct wld_renderer * renderer,
 68-                         const struct wld_renderer_impl * impl)
 69+void
 70+renderer_initialize(struct wld_renderer *renderer,
 71+                    const struct wld_renderer_impl *impl)
 72 {
 73-    *((const struct wld_renderer_impl **) &renderer->impl) = impl;
 74-    renderer->target = NULL;
 75+	*((const struct wld_renderer_impl **)&renderer->impl) = impl;
 76+	renderer->target = NULL;
 77 }
 78 
 79 EXPORT
 80-void wld_destroy_renderer(struct wld_renderer * renderer)
 81+void
 82+wld_destroy_renderer(struct wld_renderer *renderer)
 83 {
 84-    renderer->impl->destroy(renderer);
 85+	renderer->impl->destroy(renderer);
 86 }
 87 
 88 EXPORT
 89-uint32_t wld_capabilities(struct wld_renderer * renderer,
 90-                          struct wld_buffer * buffer)
 91+uint32_t
 92+wld_capabilities(struct wld_renderer *renderer,
 93+                 struct wld_buffer *buffer)
 94 {
 95-    return renderer->impl->capabilities(renderer, (struct buffer *) buffer);
 96+	return renderer->impl->capabilities(renderer, (struct buffer *)buffer);
 97 }
 98 
 99 EXPORT
100-bool wld_set_target_buffer(struct wld_renderer * renderer,
101-                           struct wld_buffer * buffer)
102+bool
103+wld_set_target_buffer(struct wld_renderer *renderer,
104+                      struct wld_buffer *buffer)
105 {
106-    if (!renderer->impl->set_target(renderer, (struct buffer *) buffer))
107-        return false;
108+	if (!renderer->impl->set_target(renderer, (struct buffer *)buffer))
109+		return false;
110 
111-    renderer->target = buffer;
112+	renderer->target = buffer;
113 
114-    return true;
115+	return true;
116 }
117 
118 EXPORT
119-bool wld_set_target_surface(struct wld_renderer * renderer,
120-                            struct wld_surface * surface)
121+bool
122+wld_set_target_surface(struct wld_renderer *renderer,
123+                       struct wld_surface *surface)
124 {
125-    struct buffer * back_buffer;
126+	struct buffer *back_buffer;
127 
128-    if (!(back_buffer = surface->impl->back(surface)))
129-        return false;
130+	if (!(back_buffer = surface->impl->back(surface)))
131+		return false;
132 
133-    return renderer->impl->set_target(renderer, back_buffer);
134+	return renderer->impl->set_target(renderer, back_buffer);
135 }
136 
137 EXPORT
138-void wld_fill_rectangle(struct wld_renderer * renderer, uint32_t color,
139-                        int32_t x, int32_t y, uint32_t width, uint32_t height)
140+void
141+wld_fill_rectangle(struct wld_renderer *renderer, uint32_t color,
142+                   int32_t x, int32_t y, uint32_t width, uint32_t height)
143 {
144-    renderer->impl->fill_rectangle(renderer, color, x, y, width, height);
145+	renderer->impl->fill_rectangle(renderer, color, x, y, width, height);
146 }
147 
148 EXPORT
149-void wld_fill_region(struct wld_renderer * renderer, uint32_t color,
150-                     pixman_region32_t * region)
151+void
152+wld_fill_region(struct wld_renderer *renderer, uint32_t color,
153+                pixman_region32_t *region)
154 {
155-    renderer->impl->fill_region(renderer, color, region);
156+	renderer->impl->fill_region(renderer, color, region);
157 }
158 
159 EXPORT
160-void wld_copy_rectangle(struct wld_renderer * renderer,
161-                        struct wld_buffer * buffer,
162-                        int32_t dst_x, int32_t dst_y,
163-                        int32_t src_x, int32_t src_y,
164-                        uint32_t width, uint32_t height)
165+void
166+wld_copy_rectangle(struct wld_renderer *renderer,
167+                   struct wld_buffer *buffer,
168+                   int32_t dst_x, int32_t dst_y,
169+                   int32_t src_x, int32_t src_y,
170+                   uint32_t width, uint32_t height)
171 {
172-    renderer->impl->copy_rectangle(renderer, (struct buffer *) buffer,
173-                                   dst_x, dst_y, src_x, src_y, width, height);
174+	renderer->impl->copy_rectangle(renderer, (struct buffer *)buffer,
175+	                               dst_x, dst_y, src_x, src_y, width, height);
176 }
177 
178 EXPORT
179-void wld_copy_region(struct wld_renderer * renderer,
180-                     struct wld_buffer * buffer,
181-                     int32_t dst_x, int32_t dst_y, pixman_region32_t * region)
182+void
183+wld_copy_region(struct wld_renderer *renderer,
184+                struct wld_buffer *buffer,
185+                int32_t dst_x, int32_t dst_y, pixman_region32_t *region)
186 {
187-    renderer->impl->copy_region(renderer, (struct buffer *) buffer,
188-                                dst_x, dst_y, region);
189+	renderer->impl->copy_region(renderer, (struct buffer *)buffer,
190+	                            dst_x, dst_y, region);
191 }
192 
193 EXPORT
194-void wld_draw_text(struct wld_renderer * renderer,
195-                   struct wld_font * font_base, uint32_t color,
196-                   int32_t x, int32_t y, const char * text, uint32_t length,
197-                   struct wld_extents * extents)
198+void
199+wld_draw_text(struct wld_renderer *renderer,
200+              struct wld_font *font_base, uint32_t color,
201+              int32_t x, int32_t y, const char *text, uint32_t length,
202+              struct wld_extents *extents)
203 {
204-    struct font * font = (void *) font_base;
205+	struct font *font = (void *)font_base;
206 
207-    renderer->impl->draw_text(renderer, font, color, x, y, text, length,
208-                              extents);
209+	renderer->impl->draw_text(renderer, font, color, x, y, text, length,
210+	                          extents);
211 }
212 
213 EXPORT
214-void wld_flush(struct wld_renderer * renderer)
215+void
216+wld_flush(struct wld_renderer *renderer)
217 {
218-    renderer->impl->flush(renderer);
219-    renderer->impl->set_target(renderer, NULL);
220+	renderer->impl->flush(renderer);
221+	renderer->impl->set_target(renderer, NULL);
222 }
223-
+26, -20
 1@@ -23,48 +23,54 @@
 2 
 3 #include "wld-private.h"
 4 
 5-struct wld_surface * default_create_surface(struct wld_context * context,
 6-                                            uint32_t width, uint32_t height,
 7-                                            uint32_t format, uint32_t flags)
 8+struct wld_surface *
 9+default_create_surface(struct wld_context *context,
10+                       uint32_t width, uint32_t height,
11+                       uint32_t format, uint32_t flags)
12 {
13-    return buffered_surface_create(context, width, height, format, flags, NULL);
14+	return buffered_surface_create(context, width, height, format, flags, NULL);
15 }
16 
17-void surface_initialize(struct wld_surface * surface,
18-                        const struct wld_surface_impl * impl)
19+void
20+surface_initialize(struct wld_surface *surface,
21+                   const struct wld_surface_impl *impl)
22 {
23-    *((const struct wld_surface_impl **) &surface->impl) = impl;
24+	*((const struct wld_surface_impl **)&surface->impl) = impl;
25 }
26 
27 EXPORT
28-pixman_region32_t * wld_surface_damage(struct wld_surface * surface,
29-                                       pixman_region32_t * new_damage)
30+pixman_region32_t *
31+wld_surface_damage(struct wld_surface *surface,
32+                   pixman_region32_t *new_damage)
33 {
34-    return surface->impl->damage(surface, new_damage);
35+	return surface->impl->damage(surface, new_damage);
36 }
37 
38 EXPORT
39-struct wld_buffer * wld_surface_take(struct wld_surface * surface)
40+struct wld_buffer *
41+wld_surface_take(struct wld_surface *surface)
42 {
43-    return &surface->impl->take(surface)->base;
44+	return &surface->impl->take(surface)->base;
45 }
46 
47 EXPORT
48-void wld_surface_release(struct wld_surface * surface,
49-                         struct wld_buffer * buffer)
50+void
51+wld_surface_release(struct wld_surface *surface,
52+                    struct wld_buffer *buffer)
53 {
54-    surface->impl->release(surface, (struct buffer *) buffer);
55+	surface->impl->release(surface, (struct buffer *)buffer);
56 }
57 
58 EXPORT
59-bool wld_swap(struct wld_surface * surface)
60+bool
61+wld_swap(struct wld_surface *surface)
62 {
63-    return surface->impl->swap(surface);
64+	return surface->impl->swap(surface);
65 }
66 
67 EXPORT
68-void wld_destroy_surface(struct wld_surface * surface)
69+void
70+wld_destroy_surface(struct wld_surface *surface)
71 {
72-    surface->impl->destroy(surface);
73+	surface->impl->destroy(surface);
74 }
75-
+189, -186
  1@@ -21,29 +21,28 @@
  2  * SOFTWARE.
  3  */
  4 
  5-#include "wayland.h"
  6+#include "drm-private.h"
  7 #include "drm.h"
  8 #include "protocol/wayland-drm-client-protocol.h"
  9 #include "wayland-private.h"
 10+#include "wayland.h"
 11 #include "wld-private.h"
 12-#include "drm-private.h"
 13 
 14+#include <fcntl.h>
 15 #include <stdlib.h>
 16 #include <string.h>
 17 #include <unistd.h>
 18-#include <fcntl.h>
 19 #include <xf86drm.h>
 20 
 21-struct drm_context
 22-{
 23-    struct wayland_context base;
 24-    struct wld_context * driver_context;
 25-    struct wl_drm * wl;
 26-    struct wl_registry * registry;
 27-    struct wl_array formats;
 28-    uint32_t capabilities;
 29-    int fd;
 30-    bool authenticated;
 31+struct drm_context {
 32+	struct wayland_context base;
 33+	struct wld_context *driver_context;
 34+	struct wl_drm *wl;
 35+	struct wl_registry *registry;
 36+	struct wl_array formats;
 37+	uint32_t capabilities;
 38+	int fd;
 39+	bool authenticated;
 40 };
 41 
 42 #define WAYLAND_IMPL_NAME drm
 43@@ -51,246 +50,250 @@ struct drm_context
 44 #include "interface/wayland.h"
 45 IMPL(drm_context, wld_context)
 46 
 47-static void registry_global(void * data, struct wl_registry * registry,
 48-                            uint32_t name, const char * interface,
 49+static void registry_global(void *data, struct wl_registry *registry,
 50+                            uint32_t name, const char *interface,
 51                             uint32_t version);
 52-static void registry_global_remove(void * data, struct wl_registry * registry,
 53+static void registry_global_remove(void *data, struct wl_registry *registry,
 54                                    uint32_t name);
 55 
 56-static void drm_device(void * data, struct wl_drm * wl, const char * name);
 57-static void drm_format(void * data, struct wl_drm * wl, uint32_t format);
 58-static void drm_authenticated(void * data, struct wl_drm * wl);
 59-static void drm_capabilities(void * data, struct wl_drm * wl,
 60+static void drm_device(void *data, struct wl_drm *wl, const char *name);
 61+static void drm_format(void *data, struct wl_drm *wl, uint32_t format);
 62+static void drm_authenticated(void *data, struct wl_drm *wl);
 63+static void drm_capabilities(void *data, struct wl_drm *wl,
 64                              uint32_t capabilities);
 65 
 66 const static struct wl_registry_listener registry_listener = {
 67-    .global = &registry_global,
 68-    .global_remove = &registry_global_remove
 69+	.global = &registry_global,
 70+	.global_remove = &registry_global_remove
 71 };
 72 
 73 const static struct wl_drm_listener drm_listener = {
 74-    .device = &drm_device,
 75-    .format = &drm_format,
 76-    .authenticated = &drm_authenticated,
 77-    .capabilities = &drm_capabilities
 78+	.device = &drm_device,
 79+	.format = &drm_format,
 80+	.authenticated = &drm_authenticated,
 81+	.capabilities = &drm_capabilities
 82 };
 83 
 84-struct wayland_context * wayland_create_context(struct wl_display * display,
 85-                                                struct wl_event_queue * queue)
 86+struct wayland_context *
 87+wayland_create_context(struct wl_display *display,
 88+                       struct wl_event_queue *queue)
 89 {
 90-    struct drm_context * context;
 91-
 92-    if (!(context = malloc(sizeof *context)))
 93-        goto error0;
 94-
 95-    context_initialize(&context->base.base, &wld_context_impl);
 96-    context->wl = NULL;
 97-    context->fd = -1;
 98-    context->capabilities = 0;
 99-    wl_array_init(&context->formats);
100-
101-    if (!(context->registry = wl_display_get_registry(display)))
102-        goto error1;
103-
104-    wl_registry_add_listener(context->registry, &registry_listener, context);
105-    wl_proxy_set_queue((struct wl_proxy *) context->registry, queue);
106-
107-    /* Wait for wl_drm global. */
108-    wl_display_roundtrip_queue(display, queue);
109-
110-    if (!context->wl)
111-    {
112-        DEBUG("No wl_drm global\n");
113-        goto error2;
114-    }
115-
116-    wl_drm_add_listener(context->wl, &drm_listener, context);
117-
118-    /* Wait for DRM capabilities and device. */
119-    wl_display_roundtrip_queue(display, queue);
120-
121-    if (!(context->capabilities & WL_DRM_CAPABILITY_PRIME))
122-    {
123-        DEBUG("No PRIME support\n");
124-        goto error3;
125-    }
126-
127-    if (context->fd == -1)
128-    {
129-        DEBUG("No DRM device\n");
130-        goto error3;
131-    }
132-
133-    /* Wait for DRM authentication. */
134-    wl_display_roundtrip_queue(display, queue);
135-
136-    if (!context->authenticated)
137-    {
138-        DEBUG("DRM authentication failed\n");
139-        goto error4;
140-    }
141-
142-    if (!(context->driver_context = wld_drm_create_context(context->fd)))
143-    {
144-        DEBUG("Couldn't initialize context for DRM device\n");
145-        goto error4;
146-    }
147-
148-    return &context->base;
149-
150-  error4:
151-    close(context->fd);
152-  error3:
153-    wl_drm_destroy(context->wl);
154-  error2:
155-    wl_registry_destroy(context->registry);
156-  error1:
157-    wl_array_release(&context->formats);
158-    free(context);
159-  error0:
160-    return NULL;
161+	struct drm_context *context;
162+
163+	if (!(context = malloc(sizeof *context)))
164+		goto error0;
165+
166+	context_initialize(&context->base.base, &wld_context_impl);
167+	context->wl = NULL;
168+	context->fd = -1;
169+	context->capabilities = 0;
170+	wl_array_init(&context->formats);
171+
172+	if (!(context->registry = wl_display_get_registry(display)))
173+		goto error1;
174+
175+	wl_registry_add_listener(context->registry, &registry_listener, context);
176+	wl_proxy_set_queue((struct wl_proxy *)context->registry, queue);
177+
178+	/* Wait for wl_drm global. */
179+	wl_display_roundtrip_queue(display, queue);
180+
181+	if (!context->wl) {
182+		DEBUG("No wl_drm global\n");
183+		goto error2;
184+	}
185+
186+	wl_drm_add_listener(context->wl, &drm_listener, context);
187+
188+	/* Wait for DRM capabilities and device. */
189+	wl_display_roundtrip_queue(display, queue);
190+
191+	if (!(context->capabilities & WL_DRM_CAPABILITY_PRIME)) {
192+		DEBUG("No PRIME support\n");
193+		goto error3;
194+	}
195+
196+	if (context->fd == -1) {
197+		DEBUG("No DRM device\n");
198+		goto error3;
199+	}
200+
201+	/* Wait for DRM authentication. */
202+	wl_display_roundtrip_queue(display, queue);
203+
204+	if (!context->authenticated) {
205+		DEBUG("DRM authentication failed\n");
206+		goto error4;
207+	}
208+
209+	if (!(context->driver_context = wld_drm_create_context(context->fd))) {
210+		DEBUG("Couldn't initialize context for DRM device\n");
211+		goto error4;
212+	}
213+
214+	return &context->base;
215+
216+error4:
217+	close(context->fd);
218+error3:
219+	wl_drm_destroy(context->wl);
220+error2:
221+	wl_registry_destroy(context->registry);
222+error1:
223+	wl_array_release(&context->formats);
224+	free(context);
225+error0:
226+	return NULL;
227 }
228 
229-bool wayland_has_format(struct wld_context * base, uint32_t format)
230+bool
231+wayland_has_format(struct wld_context *base, uint32_t format)
232 {
233-    struct drm_context * context = drm_context(base);
234-    uint32_t * supported_format;
235+	struct drm_context *context = drm_context(base);
236+	uint32_t *supported_format;
237 
238-    wl_array_for_each(supported_format, &context->formats)
239-    {
240-        if (*supported_format == format)
241-            return true;
242-    }
243+	wl_array_for_each (supported_format, &context->formats) {
244+		if (*supported_format == format)
245+			return true;
246+	}
247 
248-    return false;
249+	return false;
250 }
251 
252 EXPORT
253-int wld_wayland_drm_get_fd(struct wld_context * base)
254+int
255+wld_wayland_drm_get_fd(struct wld_context *base)
256 {
257-    struct drm_context * context = drm_context(base);
258+	struct drm_context *context = drm_context(base);
259 
260-    return context->authenticated ? context->fd : -1;
261+	return context->authenticated ? context->fd : -1;
262 }
263 
264-struct wld_renderer * context_create_renderer(struct wld_context * base)
265+struct wld_renderer *
266+context_create_renderer(struct wld_context *base)
267 {
268-    struct drm_context * context = drm_context(base);
269+	struct drm_context *context = drm_context(base);
270 
271-    return wld_create_renderer(context->driver_context);
272+	return wld_create_renderer(context->driver_context);
273 }
274 
275-struct buffer * context_create_buffer(struct wld_context * base,
276-                                      uint32_t width, uint32_t height,
277-                                      uint32_t format, uint32_t flags)
278+struct buffer *
279+context_create_buffer(struct wld_context *base,
280+                      uint32_t width, uint32_t height,
281+                      uint32_t format, uint32_t flags)
282 {
283-    struct drm_context * context = drm_context(base);
284-    struct buffer * buffer;
285-    union wld_object object;
286-    struct wl_buffer * wl;
287+	struct drm_context *context = drm_context(base);
288+	struct buffer *buffer;
289+	union wld_object object;
290+	struct wl_buffer *wl;
291 
292-    if (!wayland_has_format(base, format))
293-        goto error0;
294+	if (!wayland_has_format(base, format))
295+		goto error0;
296 
297-    buffer = context->driver_context->impl->create_buffer
298-        (context->driver_context, width, height, format, flags);
299+	buffer = context->driver_context->impl->create_buffer(context->driver_context, width, height, format, flags);
300 
301-    if (!buffer)
302-        goto error0;
303+	if (!buffer)
304+		goto error0;
305 
306-    if (!wld_export(&buffer->base, WLD_DRM_OBJECT_PRIME_FD, &object))
307-        goto error1;
308+	if (!wld_export(&buffer->base, WLD_DRM_OBJECT_PRIME_FD, &object))
309+		goto error1;
310 
311-    wl = wl_drm_create_prime_buffer(context->wl, object.i, width, height,
312-                                    format, 0, buffer->base.pitch, 0, 0, 0, 0);
313-    close(object.i);
314+	wl = wl_drm_create_prime_buffer(context->wl, object.i, width, height,
315+	                                format, 0, buffer->base.pitch, 0, 0, 0, 0);
316+	close(object.i);
317 
318-    if (!wl)
319-        goto error1;
320+	if (!wl)
321+		goto error1;
322 
323-    if (!wayland_buffer_add_exporter(buffer, wl))
324-        goto error2;
325+	if (!wayland_buffer_add_exporter(buffer, wl))
326+		goto error2;
327 
328-    return buffer;
329+	return buffer;
330 
331-  error2:
332-    wl_buffer_destroy(wl);
333-  error1:
334-    wld_buffer_unreference(&buffer->base);
335-  error0:
336-    return NULL;
337+error2:
338+	wl_buffer_destroy(wl);
339+error1:
340+	wld_buffer_unreference(&buffer->base);
341+error0:
342+	return NULL;
343 }
344 
345-struct buffer * context_import_buffer(struct wld_context * context,
346-                                      uint32_t type, union wld_object object,
347-                                      uint32_t width, uint32_t height,
348-                                      uint32_t format, uint32_t pitch)
349+struct buffer *
350+context_import_buffer(struct wld_context *context,
351+                      uint32_t type, union wld_object object,
352+                      uint32_t width, uint32_t height,
353+                      uint32_t format, uint32_t pitch)
354 {
355-    return NULL;
356+	return NULL;
357 }
358 
359-void context_destroy(struct wld_context * base)
360+void
361+context_destroy(struct wld_context *base)
362 {
363-    struct drm_context * context = drm_context(base);
364-
365-    wld_destroy_context(context->driver_context);
366-    close(context->fd);
367-    wl_drm_destroy(context->wl);
368-    wl_registry_destroy(context->registry);
369-    wl_array_release(&context->formats);
370-    wl_event_queue_destroy(context->base.queue);
371-    free(context);
372+	struct drm_context *context = drm_context(base);
373+
374+	wld_destroy_context(context->driver_context);
375+	close(context->fd);
376+	wl_drm_destroy(context->wl);
377+	wl_registry_destroy(context->registry);
378+	wl_array_release(&context->formats);
379+	wl_event_queue_destroy(context->base.queue);
380+	free(context);
381 }
382 
383-void registry_global(void * data, struct wl_registry * registry, uint32_t name,
384-                     const char * interface, uint32_t version)
385+void
386+registry_global(void *data, struct wl_registry *registry, uint32_t name,
387+                const char *interface, uint32_t version)
388 {
389-    struct drm_context * context = data;
390+	struct drm_context *context = data;
391 
392-    if (strcmp(interface, "wl_drm") == 0 && version >= 2)
393-        context->wl = wl_registry_bind(registry, name, &wl_drm_interface, 2);
394+	if (strcmp(interface, "wl_drm") == 0 && version >= 2)
395+		context->wl = wl_registry_bind(registry, name, &wl_drm_interface, 2);
396 }
397 
398-void registry_global_remove(void * data, struct wl_registry * registry,
399-                            uint32_t name)
400+void
401+registry_global_remove(void *data, struct wl_registry *registry,
402+                       uint32_t name)
403 {
404 }
405 
406-void drm_device(void * data, struct wl_drm * wl, const char * name)
407+void
408+drm_device(void *data, struct wl_drm *wl, const char *name)
409 {
410-    struct drm_context * context = data;
411-    drm_magic_t magic;
412+	struct drm_context *context = data;
413+	drm_magic_t magic;
414 
415-    context->fd = open(name, O_RDWR);
416+	context->fd = open(name, O_RDWR);
417 
418-    if (context->fd == -1)
419-    {
420-        DEBUG("Couldn't open DRM device '%s'\n", name);
421-        return;
422-    }
423+	if (context->fd == -1) {
424+		DEBUG("Couldn't open DRM device '%s'\n", name);
425+		return;
426+	}
427 
428-    drmGetMagic(context->fd, &magic);
429-    wl_drm_authenticate(wl, magic);
430+	drmGetMagic(context->fd, &magic);
431+	wl_drm_authenticate(wl, magic);
432 }
433 
434-void drm_format(void * data, struct wl_drm * wl, uint32_t format)
435+void
436+drm_format(void *data, struct wl_drm *wl, uint32_t format)
437 {
438-    struct drm_context * context = data;
439+	struct drm_context *context = data;
440 
441-    *((uint32_t *) wl_array_add(&context->formats, sizeof format)) = format;
442+	*((uint32_t *)wl_array_add(&context->formats, sizeof format)) = format;
443 }
444 
445-void drm_authenticated(void * data, struct wl_drm * wl)
446+void
447+drm_authenticated(void *data, struct wl_drm *wl)
448 {
449-    struct drm_context * context = data;
450+	struct drm_context *context = data;
451 
452-    context->authenticated = true;
453+	context->authenticated = true;
454 }
455 
456-void drm_capabilities(void * data, struct wl_drm * wl, uint32_t capabilities)
457+void
458+drm_capabilities(void *data, struct wl_drm *wl, uint32_t capabilities)
459 {
460-    struct drm_context * context = data;
461+	struct drm_context *context = data;
462 
463-    context->capabilities = capabilities;
464+	context->capabilities = capabilities;
465 }
466-
+10, -13
 1@@ -31,19 +31,17 @@ struct wl_display;
 2 struct wl_event_queue;
 3 struct wl_buffer;
 4 
 5-struct wayland_context
 6-{
 7-    struct wld_context base;
 8-    const struct wayland_impl * impl;
 9-    struct wl_display * display;
10-    struct wl_event_queue * queue;
11+struct wayland_context {
12+	struct wld_context base;
13+	const struct wayland_impl *impl;
14+	struct wl_display *display;
15+	struct wl_event_queue *queue;
16 };
17 
18-struct wayland_impl
19-{
20-    struct wayland_context * (* create_context)(struct wl_display * display,
21-                                                struct wl_event_queue * queue);
22-    bool (* has_format)(struct wld_context * context, uint32_t format);
23+struct wayland_impl {
24+	struct wayland_context *(*create_context)(struct wl_display *display,
25+	                                          struct wl_event_queue *queue);
26+	bool (*has_format)(struct wld_context *context, uint32_t format);
27 };
28 
29 #if WITH_WAYLAND_DRM
30@@ -54,7 +52,6 @@ extern const struct wayland_impl drm_wayland_impl;
31 extern const struct wayland_impl shm_wayland_impl;
32 #endif
33 
34-bool wayland_buffer_add_exporter(struct buffer * buffer, struct wl_buffer * wl);
35+bool wayland_buffer_add_exporter(struct buffer *buffer, struct wl_buffer *wl);
36 
37 #endif
38-
+170, -164
  1@@ -23,10 +23,10 @@
  2 
  3 #define _GNU_SOURCE /* Required for mkostemp */
  4 
  5-#include "wayland.h"
  6+#include "pixman.h"
  7 #include "wayland-private.h"
  8+#include "wayland.h"
  9 #include "wld-private.h"
 10-#include "pixman.h"
 11 
 12 #include <fcntl.h>
 13 #include <stdlib.h>
 14@@ -35,260 +35,266 @@
 15 #include <unistd.h>
 16 #include <wayland-client.h>
 17 
 18-struct shm_context
 19-{
 20-    struct wayland_context base;
 21-    struct wl_registry * registry;
 22-    struct wl_shm * wl;
 23-    struct wl_array formats;
 24+struct shm_context {
 25+	struct wayland_context base;
 26+	struct wl_registry *registry;
 27+	struct wl_shm *wl;
 28+	struct wl_array formats;
 29 };
 30 
 31-struct shm_buffer
 32-{
 33-    struct buffer base;
 34-    int fd;
 35+struct shm_buffer {
 36+	struct buffer base;
 37+	int fd;
 38 };
 39 
 40 #define WAYLAND_IMPL_NAME shm
 41-#include "interface/context.h"
 42 #include "interface/buffer.h"
 43+#include "interface/context.h"
 44 #include "interface/wayland.h"
 45 IMPL(shm_context, wld_context)
 46 IMPL(shm_buffer, wld_buffer)
 47 
 48-static void registry_global(void * data, struct wl_registry * registry,
 49-                            uint32_t name, const char * interface,
 50+static void registry_global(void *data, struct wl_registry *registry,
 51+                            uint32_t name, const char *interface,
 52                             uint32_t version);
 53-static void registry_global_remove(void * data, struct wl_registry * registry,
 54+static void registry_global_remove(void *data, struct wl_registry *registry,
 55                                    uint32_t name);
 56 
 57-static void shm_format(void * data, struct wl_shm * wl, uint32_t format);
 58+static void shm_format(void *data, struct wl_shm *wl, uint32_t format);
 59 
 60 const static struct wl_registry_listener registry_listener = {
 61-    .global = &registry_global,
 62-    .global_remove = &registry_global_remove
 63+	.global = &registry_global,
 64+	.global_remove = &registry_global_remove
 65 };
 66 
 67 const static struct wl_shm_listener shm_listener = {
 68-    .format = &shm_format,
 69+	.format = &shm_format,
 70 };
 71 
 72-static inline uint32_t format_wld_to_shm(uint32_t format)
 73+static inline uint32_t
 74+format_wld_to_shm(uint32_t format)
 75 {
 76-    switch (format)
 77-    {
 78-        case WLD_FORMAT_ARGB8888:
 79-            return WL_SHM_FORMAT_ARGB8888;
 80-        case WLD_FORMAT_XRGB8888:
 81-            return WL_SHM_FORMAT_XRGB8888;
 82-        default:
 83-            return 0;
 84-    }
 85+	switch (format) {
 86+	case WLD_FORMAT_ARGB8888:
 87+		return WL_SHM_FORMAT_ARGB8888;
 88+	case WLD_FORMAT_XRGB8888:
 89+		return WL_SHM_FORMAT_XRGB8888;
 90+	default:
 91+		return 0;
 92+	}
 93 }
 94 
 95-struct wayland_context * wayland_create_context(struct wl_display * display,
 96-                                                struct wl_event_queue * queue)
 97+struct wayland_context *
 98+wayland_create_context(struct wl_display *display,
 99+                       struct wl_event_queue *queue)
100 {
101-    struct shm_context * context;
102+	struct shm_context *context;
103 
104-    if (!(context = malloc(sizeof *context)))
105-        goto error0;
106+	if (!(context = malloc(sizeof *context)))
107+		goto error0;
108 
109-    context_initialize(&context->base.base, &wld_context_impl);
110-    context->wl = NULL;
111-    wl_array_init(&context->formats);
112+	context_initialize(&context->base.base, &wld_context_impl);
113+	context->wl = NULL;
114+	wl_array_init(&context->formats);
115 
116-    if (!(context->registry = wl_display_get_registry(display)))
117-    {
118-        DEBUG("Couldn't get registry\n");
119-        goto error1;
120-    }
121+	if (!(context->registry = wl_display_get_registry(display))) {
122+		DEBUG("Couldn't get registry\n");
123+		goto error1;
124+	}
125 
126-    wl_registry_add_listener(context->registry, &registry_listener, context);
127-    wl_proxy_set_queue((struct wl_proxy *) context->registry, queue);
128+	wl_registry_add_listener(context->registry, &registry_listener, context);
129+	wl_proxy_set_queue((struct wl_proxy *)context->registry, queue);
130 
131-    /* Wait for wl_shm global. */
132-    wl_display_roundtrip_queue(display, queue);
133+	/* Wait for wl_shm global. */
134+	wl_display_roundtrip_queue(display, queue);
135 
136-    if (!context->wl)
137-    {
138-        DEBUG("No wl_shm global\n");
139-        goto error2;
140-    }
141+	if (!context->wl) {
142+		DEBUG("No wl_shm global\n");
143+		goto error2;
144+	}
145 
146-    wl_shm_add_listener(context->wl, &shm_listener, context);
147+	wl_shm_add_listener(context->wl, &shm_listener, context);
148 
149-    /* Wait for SHM formats. */
150-    wl_display_roundtrip_queue(display, queue);
151+	/* Wait for SHM formats. */
152+	wl_display_roundtrip_queue(display, queue);
153 
154-    return &context->base;
155+	return &context->base;
156 
157-  error2:
158-    wl_registry_destroy(context->registry);
159-  error1:
160-    wl_array_release(&context->formats);
161-    free(context);
162-  error0:
163-    return NULL;
164+error2:
165+	wl_registry_destroy(context->registry);
166+error1:
167+	wl_array_release(&context->formats);
168+	free(context);
169+error0:
170+	return NULL;
171 }
172 
173-bool wayland_has_format(struct wld_context * base, uint32_t format)
174+bool
175+wayland_has_format(struct wld_context *base, uint32_t format)
176 {
177-    struct shm_context * context = shm_context(base);
178-    uint32_t * supported_format;
179-    uint32_t shm_format = format_wld_to_shm(format);
180+	struct shm_context *context = shm_context(base);
181+	uint32_t *supported_format;
182+	uint32_t shm_format = format_wld_to_shm(format);
183 
184-    wl_array_for_each(supported_format, &context->formats)
185-    {
186-        if (*supported_format == shm_format)
187-            return true;
188-    }
189+	wl_array_for_each (supported_format, &context->formats) {
190+		if (*supported_format == shm_format)
191+			return true;
192+	}
193 
194-    return false;
195+	return false;
196 }
197 
198-struct wld_renderer * context_create_renderer(struct wld_context * context)
199+struct wld_renderer *
200+context_create_renderer(struct wld_context *context)
201 {
202-    return wld_create_renderer(wld_pixman_context);
203+	return wld_create_renderer(wld_pixman_context);
204 }
205 
206-struct buffer * context_create_buffer(struct wld_context * base,
207-                                      uint32_t width, uint32_t height,
208-                                      uint32_t format, uint32_t flags)
209+struct buffer *
210+context_create_buffer(struct wld_context *base,
211+                      uint32_t width, uint32_t height,
212+                      uint32_t format, uint32_t flags)
213 {
214-    struct shm_context * context = shm_context(base);
215-    struct shm_buffer * buffer;
216-    char name[] = "/tmp/wld-XXXXXX";
217-    uint32_t pitch = width * format_bytes_per_pixel(format);
218-    size_t size = pitch * height;
219-    int fd;
220-    struct wl_shm_pool * pool;
221-    struct wl_buffer * wl;
222+	struct shm_context *context = shm_context(base);
223+	struct shm_buffer *buffer;
224+	char name[] = "/tmp/wld-XXXXXX";
225+	uint32_t pitch = width * format_bytes_per_pixel(format);
226+	size_t size = pitch * height;
227+	int fd;
228+	struct wl_shm_pool *pool;
229+	struct wl_buffer *wl;
230 
231-    if (!wayland_has_format(base, format))
232-        goto error0;
233+	if (!wayland_has_format(base, format))
234+		goto error0;
235 
236-    if (!(buffer = malloc(sizeof *buffer)))
237-        goto error0;
238+	if (!(buffer = malloc(sizeof *buffer)))
239+		goto error0;
240 
241-    fd = mkostemp(name, O_CLOEXEC);
242+	fd = mkostemp(name, O_CLOEXEC);
243 
244-    if (fd < 0)
245-        goto error1;
246+	if (fd < 0)
247+		goto error1;
248 
249-    unlink(name);
250+	unlink(name);
251 
252-    if (posix_fallocate(fd, 0, size) != 0)
253-        goto error2;
254+	if (posix_fallocate(fd, 0, size) != 0)
255+		goto error2;
256 
257-    if (!(pool = wl_shm_create_pool(context->wl, fd, size)))
258-        goto error2;
259+	if (!(pool = wl_shm_create_pool(context->wl, fd, size)))
260+		goto error2;
261 
262-    wl = wl_shm_pool_create_buffer(pool, 0, width, height, pitch,
263-                                   format_wld_to_shm(format));
264-    wl_shm_pool_destroy(pool);
265+	wl = wl_shm_pool_create_buffer(pool, 0, width, height, pitch,
266+	                               format_wld_to_shm(format));
267+	wl_shm_pool_destroy(pool);
268 
269-    if (!wl)
270-        goto error2;
271+	if (!wl)
272+		goto error2;
273 
274-    buffer_initialize(&buffer->base, &wld_buffer_impl,
275-                      width, height, format, pitch);
276-    buffer->fd = fd;
277+	buffer_initialize(&buffer->base, &wld_buffer_impl,
278+	                  width, height, format, pitch);
279+	buffer->fd = fd;
280 
281-    if (!(wayland_buffer_add_exporter(&buffer->base, wl)))
282-        goto error3;
283+	if (!(wayland_buffer_add_exporter(&buffer->base, wl)))
284+		goto error3;
285 
286-    return &buffer->base;
287+	return &buffer->base;
288 
289-  error3:
290-    wl_buffer_destroy(wl);
291-  error2:
292-    close(fd);
293-  error1:
294-    free(buffer);
295-  error0:
296-    return NULL;
297+error3:
298+	wl_buffer_destroy(wl);
299+error2:
300+	close(fd);
301+error1:
302+	free(buffer);
303+error0:
304+	return NULL;
305 }
306 
307-struct buffer * context_import_buffer(struct wld_context * context,
308-                                      uint32_t type, union wld_object object,
309-                                      uint32_t width, uint32_t height,
310-                                      uint32_t format, uint32_t pitch)
311+struct buffer *
312+context_import_buffer(struct wld_context *context,
313+                      uint32_t type, union wld_object object,
314+                      uint32_t width, uint32_t height,
315+                      uint32_t format, uint32_t pitch)
316 {
317-    return NULL;
318+	return NULL;
319 }
320 
321-void context_destroy(struct wld_context * base)
322+void
323+context_destroy(struct wld_context *base)
324 {
325-    struct shm_context * context = shm_context(base);
326+	struct shm_context *context = shm_context(base);
327 
328-    wl_shm_destroy(context->wl);
329-    wl_registry_destroy(context->registry);
330-    wl_array_release(&context->formats);
331-    wl_event_queue_destroy(context->base.queue);
332-    free(context);
333+	wl_shm_destroy(context->wl);
334+	wl_registry_destroy(context->registry);
335+	wl_array_release(&context->formats);
336+	wl_event_queue_destroy(context->base.queue);
337+	free(context);
338 }
339 
340 /**** Buffer ****/
341 
342-bool buffer_map(struct buffer * base)
343+bool
344+buffer_map(struct buffer *base)
345 {
346-    struct shm_buffer * buffer = shm_buffer(&base->base);
347-    void * data;
348+	struct shm_buffer *buffer = shm_buffer(&base->base);
349+	void *data;
350 
351-    data = mmap(NULL, buffer->base.base.pitch * buffer->base.base.height,
352-                PROT_READ | PROT_WRITE, MAP_SHARED, buffer->fd, 0);
353+	data = mmap(NULL, buffer->base.base.pitch * buffer->base.base.height,
354+	            PROT_READ | PROT_WRITE, MAP_SHARED, buffer->fd, 0);
355 
356-    if (data == MAP_FAILED)
357-        return false;
358+	if (data == MAP_FAILED)
359+		return false;
360 
361-    buffer->base.base.map = data;
362+	buffer->base.base.map = data;
363 
364-    return true;
365+	return true;
366 }
367 
368-bool buffer_unmap(struct buffer * buffer)
369+bool
370+buffer_unmap(struct buffer *buffer)
371 {
372-    if (munmap(buffer->base.map,
373-               buffer->base.pitch * buffer->base.height) == -1)
374-    {
375-        return false;
376-    }
377+	if (munmap(buffer->base.map,
378+	           buffer->base.pitch * buffer->base.height)
379+	    == -1) {
380+		return false;
381+	}
382 
383-    buffer->base.map = NULL;
384+	buffer->base.map = NULL;
385 
386-    return true;
387+	return true;
388 }
389 
390-void buffer_destroy(struct buffer * base)
391+void
392+buffer_destroy(struct buffer *base)
393 {
394-    struct shm_buffer * buffer = shm_buffer(&base->base);
395+	struct shm_buffer *buffer = shm_buffer(&base->base);
396 
397-    close(buffer->fd);
398-    free(buffer);
399+	close(buffer->fd);
400+	free(buffer);
401 }
402 
403-void registry_global(void * data, struct wl_registry * registry, uint32_t name,
404-                     const char * interface, uint32_t version)
405+void
406+registry_global(void *data, struct wl_registry *registry, uint32_t name,
407+                const char *interface, uint32_t version)
408 {
409-    struct shm_context * context = data;
410+	struct shm_context *context = data;
411 
412-    if (strcmp(interface, "wl_shm") == 0)
413-        context->wl = wl_registry_bind(registry, name, &wl_shm_interface, 1);
414+	if (strcmp(interface, "wl_shm") == 0)
415+		context->wl = wl_registry_bind(registry, name, &wl_shm_interface, 1);
416 }
417 
418-void registry_global_remove(void * data, struct wl_registry * registry,
419-                            uint32_t name)
420+void
421+registry_global_remove(void *data, struct wl_registry *registry,
422+                       uint32_t name)
423 {
424 }
425 
426-void shm_format(void * data, struct wl_shm * wl, uint32_t format)
427+void
428+shm_format(void *data, struct wl_shm *wl, uint32_t format)
429 {
430-    struct shm_context * context = data;
431-    uint32_t * added_format;
432+	struct shm_context *context = data;
433+	uint32_t *added_format;
434 
435-    if (!(added_format = wl_array_add(&context->formats, sizeof format)))
436-        return;
437-    *added_format = format;
438+	if (!(added_format = wl_array_add(&context->formats, sizeof format)))
439+		return;
440+	*added_format = format;
441 }
442-
+173, -176
  1@@ -28,281 +28,278 @@
  2 #include <stdlib.h>
  3 #include <wayland-client.h>
  4 
  5-struct wayland_buffer
  6-{
  7-    struct wld_exporter exporter;
  8-    struct wld_destructor destructor;
  9-    struct wl_buffer * wl;
 10+struct wayland_buffer {
 11+	struct wld_exporter exporter;
 12+	struct wld_destructor destructor;
 13+	struct wl_buffer *wl;
 14 };
 15 
 16-struct wayland_buffer_socket
 17-{
 18-    struct buffer_socket base;
 19-    struct wl_buffer_listener listener;
 20-    struct wld_surface * surface;
 21-    struct wl_surface * wl;
 22-    struct wl_display * display;
 23-    struct wl_event_queue * queue;
 24+struct wayland_buffer_socket {
 25+	struct buffer_socket base;
 26+	struct wl_buffer_listener listener;
 27+	struct wld_surface *surface;
 28+	struct wl_surface *wl;
 29+	struct wl_display *display;
 30+	struct wl_event_queue *queue;
 31 };
 32 
 33-static bool buffer_socket_attach(struct buffer_socket * socket,
 34-                                 struct buffer * buffer);
 35-static void buffer_socket_process(struct buffer_socket * socket);
 36-static void buffer_socket_destroy(struct buffer_socket * socket);
 37+static bool buffer_socket_attach(struct buffer_socket *socket,
 38+                                 struct buffer *buffer);
 39+static void buffer_socket_process(struct buffer_socket *socket);
 40+static void buffer_socket_destroy(struct buffer_socket *socket);
 41 
 42 static const struct buffer_socket_impl buffer_socket_impl = {
 43-    .attach = &buffer_socket_attach,
 44-    .process = &buffer_socket_process,
 45-    .destroy = &buffer_socket_destroy
 46+	.attach = &buffer_socket_attach,
 47+	.process = &buffer_socket_process,
 48+	.destroy = &buffer_socket_destroy
 49 };
 50 
 51 IMPL(wayland_buffer_socket, buffer_socket)
 52 
 53-static void sync_done(void * data, struct wl_callback * callback,
 54+static void sync_done(void *data, struct wl_callback *callback,
 55                       uint32_t msecs);
 56 
 57 static const struct wl_callback_listener sync_listener = {
 58-    .done = &sync_done
 59+	.done = &sync_done
 60 };
 61 
 62-static void buffer_release(void * data, struct wl_buffer * buffer);
 63+static void buffer_release(void *data, struct wl_buffer *buffer);
 64 
 65-const static struct wayland_impl * impls[] = {
 66+const static struct wayland_impl *impls[] = {
 67 #if WITH_WAYLAND_DRM
 68-    [WLD_DRM] = &drm_wayland_impl,
 69+	[WLD_DRM] = &drm_wayland_impl,
 70 #endif
 71 
 72 #if WITH_WAYLAND_SHM
 73-    [WLD_SHM] = &shm_wayland_impl,
 74+	[WLD_SHM] = &shm_wayland_impl,
 75 #endif
 76 };
 77 
 78-enum wld_wayland_interface_id interface_id(const char * string)
 79+enum wld_wayland_interface_id
 80+interface_id(const char *string)
 81 {
 82-    if (strcmp(string, "drm") == 0)
 83-        return WLD_DRM;
 84-    if (strcmp(string, "shm") == 0)
 85-        return WLD_SHM;
 86+	if (strcmp(string, "drm") == 0)
 87+		return WLD_DRM;
 88+	if (strcmp(string, "shm") == 0)
 89+		return WLD_SHM;
 90 
 91-    fprintf(stderr, "Unknown Wayland interface specified: '%s'\n", string);
 92+	fprintf(stderr, "Unknown Wayland interface specified: '%s'\n", string);
 93 
 94-    return WLD_NONE;
 95+	return WLD_NONE;
 96 }
 97 
 98 EXPORT
 99-struct wld_context * wld_wayland_create_context
100-    (struct wl_display * display, enum wld_wayland_interface_id id, ...)
101+struct wld_context *
102+wld_wayland_create_context(struct wl_display *display, enum wld_wayland_interface_id id, ...)
103 {
104-    struct wayland_context * context = NULL;
105-    struct wl_event_queue * queue;
106-    va_list requested_impls;
107-    bool impls_tried[ARRAY_LENGTH(impls)] = {0};
108-    const char * interface_string;
109+	struct wayland_context *context = NULL;
110+	struct wl_event_queue *queue;
111+	va_list requested_impls;
112+	bool impls_tried[ARRAY_LENGTH(impls)] = { 0 };
113+	const char *interface_string;
114 
115-    if (!(queue = wl_display_create_queue(display)))
116-        return NULL;
117+	if (!(queue = wl_display_create_queue(display)))
118+		return NULL;
119 
120-    if ((interface_string = getenv("WLD_WAYLAND_INTERFACE")))
121-    {
122-        id = interface_id(interface_string);
123+	if ((interface_string = getenv("WLD_WAYLAND_INTERFACE"))) {
124+		id = interface_id(interface_string);
125 
126-        if ((context = impls[id]->create_context(display, queue)))
127-            return &context->base;
128+		if ((context = impls[id]->create_context(display, queue)))
129+			return &context->base;
130 
131-        fprintf(stderr, "Could not create context for Wayland interface '%s'\n",
132-                interface_string);
133+		fprintf(stderr, "Could not create context for Wayland interface '%s'\n",
134+		        interface_string);
135 
136-        return NULL;
137-    }
138+		return NULL;
139+	}
140 
141-    va_start(requested_impls, id);
142+	va_start(requested_impls, id);
143 
144-    while (id >= 0)
145-    {
146-        if (impls_tried[id] || !impls[id])
147-            continue;
148+	while (id >= 0) {
149+		if (impls_tried[id] || !impls[id])
150+			continue;
151 
152-        if ((context = impls[id]->create_context(display, queue)))
153-            goto done;
154+		if ((context = impls[id]->create_context(display, queue)))
155+			goto done;
156 
157-        impls_tried[id] = true;
158-        id = va_arg(requested_impls, enum wld_wayland_interface_id);
159-    }
160+		impls_tried[id] = true;
161+		id = va_arg(requested_impls, enum wld_wayland_interface_id);
162+	}
163 
164-    va_end(requested_impls);
165+	va_end(requested_impls);
166 
167-    /* If the user specified WLD_ANY, try any remaining implementations. */
168-    if (!context && id == WLD_ANY)
169-    {
170-        for (id = 0; id < ARRAY_LENGTH(impls); ++id)
171-        {
172-            if (impls_tried[id] || !impls[id])
173-                continue;
174+	/* If the user specified WLD_ANY, try any remaining implementations. */
175+	if (!context && id == WLD_ANY) {
176+		for (id = 0; id < ARRAY_LENGTH(impls); ++id) {
177+			if (impls_tried[id] || !impls[id])
178+				continue;
179 
180-            if ((context = impls[id]->create_context(display, queue)))
181-                break;
182-        }
183-    }
184+			if ((context = impls[id]->create_context(display, queue)))
185+				break;
186+		}
187+	}
188 
189-    if (!context)
190-    {
191-        DEBUG("Could not initialize any of the specified implementations\n");
192-        return NULL;
193-    }
194+	if (!context) {
195+		DEBUG("Could not initialize any of the specified implementations\n");
196+		return NULL;
197+	}
198 
199-  done:
200-    context->impl = impls[id];
201-    context->display = display;
202-    context->queue = queue;
203+done:
204+	context->impl = impls[id];
205+	context->display = display;
206+	context->queue = queue;
207 
208-    return &context->base;
209+	return &context->base;
210 }
211 
212 EXPORT
213-struct wld_surface * wld_wayland_create_surface(struct wld_context * context,
214-                                                uint32_t width, uint32_t height,
215-                                                uint32_t format, uint32_t flags,
216-                                                struct wl_surface * wl)
217+struct wld_surface *
218+wld_wayland_create_surface(struct wld_context *context,
219+                           uint32_t width, uint32_t height,
220+                           uint32_t format, uint32_t flags,
221+                           struct wl_surface *wl)
222 {
223-    struct wayland_buffer_socket * socket;
224+	struct wayland_buffer_socket *socket;
225 
226-    if (!(socket = malloc(sizeof *socket)))
227-        goto error0;
228+	if (!(socket = malloc(sizeof *socket)))
229+		goto error0;
230 
231-    socket->base.impl = &buffer_socket_impl;
232-    socket->listener.release = &buffer_release;
233-    socket->wl = wl;
234-    socket->queue = ((struct wayland_context *) context)->queue;
235-    socket->display = ((struct wayland_context *) context)->display;
236-    socket->surface = buffered_surface_create(context, width, height, format,
237-                                              flags, &socket->base);
238+	socket->base.impl = &buffer_socket_impl;
239+	socket->listener.release = &buffer_release;
240+	socket->wl = wl;
241+	socket->queue = ((struct wayland_context *)context)->queue;
242+	socket->display = ((struct wayland_context *)context)->display;
243+	socket->surface = buffered_surface_create(context, width, height, format,
244+	                                          flags, &socket->base);
245 
246-    if (!socket->surface)
247-        goto error1;
248+	if (!socket->surface)
249+		goto error1;
250 
251-    return socket->surface;
252+	return socket->surface;
253 
254-  error1:
255-    free(socket);
256-  error0:
257-    return NULL;
258+error1:
259+	free(socket);
260+error0:
261+	return NULL;
262 }
263 
264 EXPORT
265-bool wld_wayland_has_format(struct wld_context * base, uint32_t format)
266+bool
267+wld_wayland_has_format(struct wld_context *base, uint32_t format)
268 {
269-    struct wayland_context * context = (void *) base;
270+	struct wayland_context *context = (void *)base;
271 
272-    return context->impl->has_format(base, format);
273+	return context->impl->has_format(base, format);
274 }
275 
276-static bool buffer_export(struct wld_exporter * exporter,
277-                          struct wld_buffer * buffer,
278-                          uint32_t type, union wld_object * object)
279+static bool
280+buffer_export(struct wld_exporter *exporter,
281+              struct wld_buffer *buffer,
282+              uint32_t type, union wld_object *object)
283 {
284-    struct wayland_buffer * wayland_buffer
285-        = CONTAINER_OF(exporter, struct wayland_buffer, exporter);
286-
287-    switch (type)
288-    {
289-        case WLD_WAYLAND_OBJECT_BUFFER:
290-            object->ptr = wayland_buffer->wl;
291-            return true;
292-        default: return false;
293-    }
294+	struct wayland_buffer *wayland_buffer = CONTAINER_OF(exporter, struct wayland_buffer, exporter);
295+
296+	switch (type) {
297+	case WLD_WAYLAND_OBJECT_BUFFER:
298+		object->ptr = wayland_buffer->wl;
299+		return true;
300+	default:
301+		return false;
302+	}
303 }
304 
305-static void buffer_destroy(struct wld_destructor * destructor)
306+static void
307+buffer_destroy(struct wld_destructor *destructor)
308 {
309-    struct wayland_buffer * wayland_buffer
310-        = CONTAINER_OF(destructor, struct wayland_buffer, destructor);
311+	struct wayland_buffer *wayland_buffer = CONTAINER_OF(destructor, struct wayland_buffer, destructor);
312 
313-    wl_buffer_destroy(wayland_buffer->wl);
314-    free(wayland_buffer);
315+	wl_buffer_destroy(wayland_buffer->wl);
316+	free(wayland_buffer);
317 }
318 
319-bool wayland_buffer_add_exporter(struct buffer * buffer, struct wl_buffer * wl)
320+bool
321+wayland_buffer_add_exporter(struct buffer *buffer, struct wl_buffer *wl)
322 {
323-    struct wayland_buffer * wayland_buffer;
324+	struct wayland_buffer *wayland_buffer;
325 
326-    if (!(wayland_buffer = malloc(sizeof *wayland_buffer)))
327-        return false;
328+	if (!(wayland_buffer = malloc(sizeof *wayland_buffer)))
329+		return false;
330 
331-    wayland_buffer->wl = wl;
332-    wayland_buffer->exporter.export = &buffer_export;
333-    wld_buffer_add_exporter(&buffer->base, &wayland_buffer->exporter);
334-    wayland_buffer->destructor.destroy = &buffer_destroy;
335-    wld_buffer_add_destructor(&buffer->base, &wayland_buffer->destructor);
336+	wayland_buffer->wl = wl;
337+	wayland_buffer->exporter.export = &buffer_export;
338+	wld_buffer_add_exporter(&buffer->base, &wayland_buffer->exporter);
339+	wayland_buffer->destructor.destroy = &buffer_destroy;
340+	wld_buffer_add_destructor(&buffer->base, &wayland_buffer->destructor);
341 
342-    return true;
343+	return true;
344 }
345 
346-bool buffer_socket_attach(struct buffer_socket * base, struct buffer * buffer)
347+bool
348+buffer_socket_attach(struct buffer_socket *base, struct buffer *buffer)
349 {
350-    struct wayland_buffer_socket * socket = wayland_buffer_socket(base);
351-    struct wl_buffer * wl;
352-    union wld_object object;
353+	struct wayland_buffer_socket *socket = wayland_buffer_socket(base);
354+	struct wl_buffer *wl;
355+	union wld_object object;
356 
357-    if (!wld_export(&buffer->base, WLD_WAYLAND_OBJECT_BUFFER, &object))
358-        return false;
359+	if (!wld_export(&buffer->base, WLD_WAYLAND_OBJECT_BUFFER, &object))
360+		return false;
361 
362-    wl = object.ptr;
363+	wl = object.ptr;
364 
365-    if (!wl_proxy_get_listener((struct wl_proxy *) wl))
366-        wl_buffer_add_listener(wl, &socket->listener, buffer);
367+	if (!wl_proxy_get_listener((struct wl_proxy *)wl))
368+		wl_buffer_add_listener(wl, &socket->listener, buffer);
369 
370-    wl_surface_attach(socket->wl, wl, 0, 0);
371+	wl_surface_attach(socket->wl, wl, 0, 0);
372 
373-    if (pixman_region32_not_empty(&buffer->base.damage))
374-    {
375-        pixman_box32_t * box;
376-        int num_boxes;
377+	if (pixman_region32_not_empty(&buffer->base.damage)) {
378+		pixman_box32_t *box;
379+		int num_boxes;
380 
381-        box = pixman_region32_rectangles(&buffer->base.damage, &num_boxes);
382+		box = pixman_region32_rectangles(&buffer->base.damage, &num_boxes);
383 
384-        while (num_boxes--)
385-        {
386-            wl_surface_damage(socket->wl, box->x1, box->y1,
387-                              box->x2 - box->x1, box->y2 - box->y1);
388-        }
389-    }
390+		while (num_boxes--) {
391+			wl_surface_damage(socket->wl, box->x1, box->y1,
392+			                  box->x2 - box->x1, box->y2 - box->y1);
393+		}
394+	}
395 
396-    wl_surface_commit(socket->wl);
397+	wl_surface_commit(socket->wl);
398 
399-    return true;
400+	return true;
401 }
402 
403-void buffer_socket_process(struct buffer_socket * base)
404+void
405+buffer_socket_process(struct buffer_socket *base)
406 {
407-    struct wayland_buffer_socket * socket = wayland_buffer_socket(base);
408+	struct wayland_buffer_socket *socket = wayland_buffer_socket(base);
409 
410-    /* Since events for our wl_buffers lie in a special queue used by WLD, we
411+	/* Since events for our wl_buffers lie in a special queue used by WLD, we
412      * must dispatch these events here so that we see any release events before
413      * the next back buffer is chosen. */
414-    wl_display_dispatch_queue_pending(socket->display, socket->queue);
415+	wl_display_dispatch_queue_pending(socket->display, socket->queue);
416 }
417 
418-void buffer_socket_destroy(struct buffer_socket * socket)
419+void
420+buffer_socket_destroy(struct buffer_socket *socket)
421 {
422-    free(socket);
423+	free(socket);
424 }
425 
426-void sync_done(void * data, struct wl_callback * callback, uint32_t msecs)
427+void
428+sync_done(void *data, struct wl_callback *callback, uint32_t msecs)
429 {
430-    bool * done = data;
431+	bool *done = data;
432 
433-    *done = true;
434-    wl_callback_destroy(callback);
435+	*done = true;
436+	wl_callback_destroy(callback);
437 }
438 
439-void buffer_release(void * data, struct wl_buffer * wl)
440+void
441+buffer_release(void *data, struct wl_buffer *wl)
442 {
443-    struct wld_buffer * buffer = data;
444-    const struct wl_buffer_listener * listener
445-        = wl_proxy_get_listener((struct wl_proxy *) wl);
446-    struct wayland_buffer_socket * socket
447-        = CONTAINER_OF(listener, struct wayland_buffer_socket, listener);
448+	struct wld_buffer *buffer = data;
449+	const struct wl_buffer_listener *listener = wl_proxy_get_listener((struct wl_proxy *)wl);
450+	struct wayland_buffer_socket *socket = CONTAINER_OF(listener, struct wayland_buffer_socket, listener);
451 
452-    wld_surface_release(socket->surface, buffer);
453+	wld_surface_release(socket->surface, buffer);
454 }
455-
+15, -19
 1@@ -32,25 +32,23 @@ struct wl_surface;
 2 
 3 #define WLD_WAYLAND_ID (0x3 << 24)
 4 
 5-enum wld_wayland_interface_id
 6-{
 7-    /**
 8+enum wld_wayland_interface_id {
 9+	/**
10      * Give up on trying any new interfaces. This can be considered as a
11      * sentinel for wld_wayland_create_context.
12      */
13-    WLD_NONE = -2,
14+	WLD_NONE = -2,
15 
16-    /**
17+	/**
18      * Try any available interface.
19      */
20-    WLD_ANY = -1,
21-    WLD_DRM,
22-    WLD_SHM
23+	WLD_ANY = -1,
24+	WLD_DRM,
25+	WLD_SHM
26 };
27 
28-enum wld_wayland_object_type
29-{
30-    WLD_WAYLAND_OBJECT_BUFFER = WLD_WAYLAND_ID
31+enum wld_wayland_object_type {
32+	WLD_WAYLAND_OBJECT_BUFFER = WLD_WAYLAND_ID
33 };
34 
35 /**
36@@ -65,20 +63,18 @@ enum wld_wayland_object_type
37  *
38  * @see enum wld_wayland_interface_id
39  */
40-struct wld_context * wld_wayland_create_context
41-    (struct wl_display * display, enum wld_wayland_interface_id id, ...);
42+struct wld_context *wld_wayland_create_context(struct wl_display *display, enum wld_wayland_interface_id id, ...);
43 
44-struct wld_surface * wld_wayland_create_surface(struct wld_context * context,
45-                                                uint32_t width, uint32_t height,
46-                                                uint32_t format, uint32_t flags,
47-                                                struct wl_surface * surface);
48+struct wld_surface *wld_wayland_create_surface(struct wld_context *context,
49+                                               uint32_t width, uint32_t height,
50+                                               uint32_t format, uint32_t flags,
51+                                               struct wl_surface *surface);
52 
53 /**
54  * Check if the wayland implementation supports a particular pixel format.
55  *
56  * @see enum wld_format
57  */
58-bool wld_wayland_has_format(struct wld_context * context, uint32_t format);
59+bool wld_wayland_has_format(struct wld_context *context, uint32_t format);
60 
61 #endif
62-
+132, -143
  1@@ -27,217 +27,206 @@
  2 #include "wld.h"
  3 
  4 #include <assert.h>
  5+#include <ft2build.h>
  6 #include <stdbool.h>
  7 #include <stdint.h>
  8-#include <ft2build.h>
  9 #include FT_FREETYPE_H
 10 #include FT_BITMAP_H
 11 
 12-#define ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0])
 13+#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array)[0])
 14 #if ENABLE_DEBUG
 15-#   define DEBUG(format, ...) \
 16-        fprintf(stderr, "# %s: " format, __func__, ## __VA_ARGS__)
 17+#define DEBUG(format, ...) \
 18+	fprintf(stderr, "# %s: " format, __func__, ##__VA_ARGS__)
 19 #else
 20-#   define DEBUG(format, ...)
 21+#define DEBUG(format, ...)
 22 #endif
 23 
 24 #define EXPORT __attribute__((visibility("default")))
 25 #define CONTAINER_OF(ptr, type, member) \
 26-    ((type *)((uintptr_t) ptr - offsetof(type, member)))
 27+	((type *)((uintptr_t)ptr - offsetof(type, member)))
 28 #define IMPL(impl_type, base_type)                                          \
 29-    static inline struct impl_type * impl_type(struct base_type * object)   \
 30-    {                                                                       \
 31-        assert(object->impl == &base_type ## _impl);                        \
 32-        return (struct impl_type *) object;                                 \
 33-    }
 34-
 35-struct wld_font_context
 36-{
 37-    FT_Library library;
 38+	static inline struct impl_type *impl_type(struct base_type *object) \
 39+	{                                                                   \
 40+		assert(object->impl == &base_type##_impl);                  \
 41+		return (struct impl_type *)object;                          \
 42+	}
 43+
 44+struct wld_font_context {
 45+	FT_Library library;
 46 };
 47 
 48-struct glyph
 49-{
 50-    FT_Bitmap bitmap;
 51+struct glyph {
 52+	FT_Bitmap bitmap;
 53 
 54-    /**
 55+	/**
 56      * The offset from the origin to the top left corner of the bitmap.
 57      */
 58-    int16_t x, y;
 59+	int16_t x, y;
 60 
 61-    /**
 62+	/**
 63      * The width to advance to the origin of the next character.
 64      */
 65-    uint16_t advance;
 66+	uint16_t advance;
 67 };
 68 
 69-struct font
 70-{
 71-    struct wld_font base;
 72+struct font {
 73+	struct wld_font base;
 74 
 75-    struct wld_font_context * context;
 76-    FT_Face face;
 77-    struct glyph ** glyphs;
 78+	struct wld_font_context *context;
 79+	FT_Face face;
 80+	struct glyph **glyphs;
 81 };
 82 
 83-struct wld_context_impl
 84-{
 85-    struct wld_renderer * (* create_renderer)(struct wld_context * context);
 86-    struct buffer * (* create_buffer)(struct wld_context * context,
 87-                                      uint32_t width, uint32_t height,
 88-                                      uint32_t format, uint32_t flags);
 89-    struct buffer * (* import_buffer)(struct wld_context * context,
 90-                                      uint32_t type, union wld_object object,
 91-                                      uint32_t width, uint32_t height,
 92-                                      uint32_t format, uint32_t pitch);
 93-    struct wld_surface * (* create_surface)(struct wld_context * context,
 94-                                            uint32_t width, uint32_t height,
 95-                                            uint32_t format, uint32_t flags);
 96-    void (* destroy)(struct wld_context * context);
 97+struct wld_context_impl {
 98+	struct wld_renderer *(*create_renderer)(struct wld_context *context);
 99+	struct buffer *(*create_buffer)(struct wld_context *context,
100+	                                uint32_t width, uint32_t height,
101+	                                uint32_t format, uint32_t flags);
102+	struct buffer *(*import_buffer)(struct wld_context *context,
103+	                                uint32_t type, union wld_object object,
104+	                                uint32_t width, uint32_t height,
105+	                                uint32_t format, uint32_t pitch);
106+	struct wld_surface *(*create_surface)(struct wld_context *context,
107+	                                      uint32_t width, uint32_t height,
108+	                                      uint32_t format, uint32_t flags);
109+	void (*destroy)(struct wld_context *context);
110 };
111 
112-struct wld_renderer_impl
113-{
114-    uint32_t (* capabilities)(struct wld_renderer * renderer,
115-                              struct buffer * buffer);
116-    bool (* set_target)(struct wld_renderer * renderer, struct buffer * buffer);
117-    void (* fill_rectangle)(struct wld_renderer * renderer,
118-                            uint32_t color, int32_t x, int32_t y,
119-                            uint32_t width, uint32_t height);
120-    void (* fill_region)(struct wld_renderer * renderer,
121-                         uint32_t color, pixman_region32_t * region);
122-    void (* copy_rectangle)(struct wld_renderer * renderer, struct buffer * src,
123-                            int32_t dst_x, int32_t dst_y,
124-                            int32_t src_x, int32_t src_y,
125-                            uint32_t width, uint32_t height);
126-    void (* copy_region)(struct wld_renderer * renderer, struct buffer * src,
127-                         int32_t dst_x, int32_t dst_y,
128-                         pixman_region32_t * region);
129-    void (* draw_text)(struct wld_renderer * renderer,
130-                       struct font * font, uint32_t color,
131-                       int32_t x, int32_t y, const char * text, uint32_t length,
132-                       struct wld_extents * extents);
133-    void (* flush)(struct wld_renderer * renderer);
134-    void (* destroy)(struct wld_renderer * renderer);
135+struct wld_renderer_impl {
136+	uint32_t (*capabilities)(struct wld_renderer *renderer,
137+	                         struct buffer *buffer);
138+	bool (*set_target)(struct wld_renderer *renderer, struct buffer *buffer);
139+	void (*fill_rectangle)(struct wld_renderer *renderer,
140+	                       uint32_t color, int32_t x, int32_t y,
141+	                       uint32_t width, uint32_t height);
142+	void (*fill_region)(struct wld_renderer *renderer,
143+	                    uint32_t color, pixman_region32_t *region);
144+	void (*copy_rectangle)(struct wld_renderer *renderer, struct buffer *src,
145+	                       int32_t dst_x, int32_t dst_y,
146+	                       int32_t src_x, int32_t src_y,
147+	                       uint32_t width, uint32_t height);
148+	void (*copy_region)(struct wld_renderer *renderer, struct buffer *src,
149+	                    int32_t dst_x, int32_t dst_y,
150+	                    pixman_region32_t *region);
151+	void (*draw_text)(struct wld_renderer *renderer,
152+	                  struct font *font, uint32_t color,
153+	                  int32_t x, int32_t y, const char *text, uint32_t length,
154+	                  struct wld_extents *extents);
155+	void (*flush)(struct wld_renderer *renderer);
156+	void (*destroy)(struct wld_renderer *renderer);
157 };
158 
159-struct buffer
160-{
161-    struct wld_buffer base;
162+struct buffer {
163+	struct wld_buffer base;
164 
165-    unsigned references, map_references;
166-    struct wld_exporter * exporters;
167-    struct wld_destructor * destructors;
168+	unsigned references, map_references;
169+	struct wld_exporter *exporters;
170+	struct wld_destructor *destructors;
171 };
172 
173-struct wld_buffer_impl
174-{
175-    bool (* map)(struct buffer * buffer);
176-    bool (* unmap)(struct buffer * buffer);
177-    void (* destroy)(struct buffer * buffer);
178+struct wld_buffer_impl {
179+	bool (*map)(struct buffer *buffer);
180+	bool (*unmap)(struct buffer *buffer);
181+	void (*destroy)(struct buffer *buffer);
182 };
183 
184-struct wld_surface_impl
185-{
186-    pixman_region32_t * (* damage)(struct wld_surface * surface,
187-                                   pixman_region32_t * damage);
188-    struct buffer * (* back)(struct wld_surface * surface);
189-    struct buffer * (* take)(struct wld_surface * surface);
190-    bool (* release)(struct wld_surface * surface, struct buffer * buffer);
191-    bool (* swap)(struct wld_surface * surface);
192-    void (* destroy)(struct wld_surface * surface);
193+struct wld_surface_impl {
194+	pixman_region32_t *(*damage)(struct wld_surface *surface,
195+	                             pixman_region32_t *damage);
196+	struct buffer *(*back)(struct wld_surface *surface);
197+	struct buffer *(*take)(struct wld_surface *surface);
198+	bool (*release)(struct wld_surface *surface, struct buffer *buffer);
199+	bool (*swap)(struct wld_surface *surface);
200+	void (*destroy)(struct wld_surface *surface);
201 };
202 
203-struct buffer_socket
204-{
205-    const struct buffer_socket_impl * impl;
206+struct buffer_socket {
207+	const struct buffer_socket_impl *impl;
208 };
209 
210-struct buffer_socket_impl
211-{
212-    bool (* attach)(struct buffer_socket * socket, struct buffer * buffer);
213-    void (* process)(struct buffer_socket * socket);
214-    void (* destroy)(struct buffer_socket * socket);
215+struct buffer_socket_impl {
216+	bool (*attach)(struct buffer_socket *socket, struct buffer *buffer);
217+	void (*process)(struct buffer_socket *socket);
218+	void (*destroy)(struct buffer_socket *socket);
219 };
220 
221-bool font_ensure_glyph(struct font * font, FT_UInt glyph_index);
222+bool font_ensure_glyph(struct font *font, FT_UInt glyph_index);
223 
224 /**
225  * Returns the number of bytes per pixel for the given format.
226  */
227-static inline uint8_t format_bytes_per_pixel(enum wld_format format)
228+static inline uint8_t
229+format_bytes_per_pixel(enum wld_format format)
230 {
231-    switch (format)
232-    {
233-        case WLD_FORMAT_ARGB8888:
234-        case WLD_FORMAT_XRGB8888:
235-            return 4;
236-        default:
237-            return 0;
238-    }
239+	switch (format) {
240+	case WLD_FORMAT_ARGB8888:
241+	case WLD_FORMAT_XRGB8888:
242+		return 4;
243+	default:
244+		return 0;
245+	}
246 }
247 
248-static inline pixman_format_code_t format_wld_to_pixman(uint32_t format)
249+static inline pixman_format_code_t
250+format_wld_to_pixman(uint32_t format)
251 {
252-    switch (format)
253-    {
254-        case WLD_FORMAT_ARGB8888:
255-            return PIXMAN_a8r8g8b8;
256-        case WLD_FORMAT_XRGB8888:
257-            return PIXMAN_x8r8g8b8;
258-        default:
259-            return 0;
260-    }
261+	switch (format) {
262+	case WLD_FORMAT_ARGB8888:
263+		return PIXMAN_a8r8g8b8;
264+	case WLD_FORMAT_XRGB8888:
265+		return PIXMAN_x8r8g8b8;
266+	default:
267+		return 0;
268+	}
269 }
270 
271-static inline uint32_t format_pixman_to_wld(pixman_format_code_t format)
272+static inline uint32_t
273+format_pixman_to_wld(pixman_format_code_t format)
274 {
275-    switch (format)
276-    {
277-        case PIXMAN_a8r8g8b8:
278-            return WLD_FORMAT_ARGB8888;
279-        case PIXMAN_x8r8g8b8:
280-            return WLD_FORMAT_XRGB8888;
281-        default:
282-            return 0;
283-    }
284+	switch (format) {
285+	case PIXMAN_a8r8g8b8:
286+		return WLD_FORMAT_ARGB8888;
287+	case PIXMAN_x8r8g8b8:
288+		return WLD_FORMAT_XRGB8888;
289+	default:
290+		return 0;
291+	}
292 }
293 
294 /**
295  * This default fill_region method is implemented in terms of fill_rectangle.
296  */
297-void default_fill_region(struct wld_renderer * renderer, uint32_t color,
298-                         pixman_region32_t * region);
299+void default_fill_region(struct wld_renderer *renderer, uint32_t color,
300+                         pixman_region32_t *region);
301 
302 /**
303  * This default copy_region method is implemented in terms of copy_rectangle.
304  */
305-void default_copy_region(struct wld_renderer * renderer, struct buffer * buffer,
306+void default_copy_region(struct wld_renderer *renderer, struct buffer *buffer,
307                          int32_t dst_x, int32_t dst_y,
308-                         pixman_region32_t * region);
309+                         pixman_region32_t *region);
310 
311-struct wld_surface * default_create_surface(struct wld_context * context,
312-                                            uint32_t width, uint32_t height,
313-                                            uint32_t format, uint32_t flags);
314+struct wld_surface *default_create_surface(struct wld_context *context,
315+                                           uint32_t width, uint32_t height,
316+                                           uint32_t format, uint32_t flags);
317 
318-struct wld_surface * buffered_surface_create(struct wld_context * context,
319-                                             uint32_t width, uint32_t height,
320-                                             uint32_t format, uint32_t flags,
321-                                             struct buffer_socket * socket);
322+struct wld_surface *buffered_surface_create(struct wld_context *context,
323+                                            uint32_t width, uint32_t height,
324+                                            uint32_t format, uint32_t flags,
325+                                            struct buffer_socket *socket);
326 
327-void context_initialize(struct wld_context * context,
328-                        const struct wld_context_impl * impl);
329+void context_initialize(struct wld_context *context,
330+                        const struct wld_context_impl *impl);
331 
332-void renderer_initialize(struct wld_renderer * renderer,
333-                         const struct wld_renderer_impl * impl);
334+void renderer_initialize(struct wld_renderer *renderer,
335+                         const struct wld_renderer_impl *impl);
336 
337-void buffer_initialize(struct buffer * buffer,
338-                       const struct wld_buffer_impl * impl,
339+void buffer_initialize(struct buffer *buffer,
340+                       const struct wld_buffer_impl *impl,
341                        uint32_t width, uint32_t height,
342                        uint32_t format, uint32_t pitch);
343 
344-void surface_initialize(struct wld_surface * surface,
345-                        const struct wld_surface_impl * impl);
346+void surface_initialize(struct wld_surface *surface,
347+                        const struct wld_surface_impl *impl);
348 
349 #endif
350-
M wld.h
+114, -127
  1@@ -24,85 +24,78 @@
  2 #ifndef WLD_H
  3 #define WLD_H
  4 
  5+#include <fontconfig/fontconfig.h>
  6+#include <pixman.h>
  7 #include <stdbool.h>
  8 #include <stdint.h>
  9-#include <pixman.h>
 10-#include <fontconfig/fontconfig.h>
 11 
 12 #define WLD_USER_ID (0xff << 24)
 13 
 14-#define __WLD_FOURCC(a, b, c, d) ( (a)          \
 15-                                 | ((b) << 8)   \
 16-                                 | ((c) << 16)  \
 17-                                 | ((d) << 24) )
 18+#define __WLD_FOURCC(a, b, c, d) ((a)           \
 19+	                          | ((b) << 8)  \
 20+	                          | ((c) << 16) \
 21+	                          | ((d) << 24))
 22 
 23 /**
 24  * Supported pixel formats.
 25  *
 26  * These formats can safely be interchanged with GBM and wl_drm formats.
 27  */
 28-enum wld_format
 29-{
 30-    WLD_FORMAT_XRGB8888 = __WLD_FOURCC('X', 'R', '2', '4'),
 31-    WLD_FORMAT_ARGB8888 = __WLD_FOURCC('A', 'R', '2', '4')
 32+enum wld_format {
 33+	WLD_FORMAT_XRGB8888 = __WLD_FOURCC('X', 'R', '2', '4'),
 34+	WLD_FORMAT_ARGB8888 = __WLD_FOURCC('A', 'R', '2', '4')
 35 };
 36 
 37-enum wld_flags
 38-{
 39-    WLD_FLAG_MAP    = 1 << 16,
 40-    WLD_FLAG_CURSOR = 1 << 17,
 41+enum wld_flags {
 42+	WLD_FLAG_MAP = 1 << 16,
 43+	WLD_FLAG_CURSOR = 1 << 17,
 44 };
 45 
 46-bool wld_lookup_named_color(const char * name, uint32_t * color);
 47+bool wld_lookup_named_color(const char *name, uint32_t *color);
 48 
 49 /**** WLD Context ****/
 50 
 51-enum wld_object_type
 52-{
 53-    WLD_OBJECT_DATA
 54+enum wld_object_type {
 55+	WLD_OBJECT_DATA
 56 };
 57 
 58-union wld_object
 59-{
 60-    void * ptr;
 61-    uint32_t u32;
 62-    int i;
 63+union wld_object {
 64+	void *ptr;
 65+	uint32_t u32;
 66+	int i;
 67 };
 68 
 69-struct wld_context
 70-{
 71-    const struct wld_context_impl * const impl;
 72+struct wld_context {
 73+	const struct wld_context_impl *const impl;
 74 };
 75 
 76-struct wld_renderer * wld_create_renderer(struct wld_context * context);
 77+struct wld_renderer *wld_create_renderer(struct wld_context *context);
 78 
 79-struct wld_buffer * wld_create_buffer(struct wld_context * context,
 80-                                      uint32_t width, uint32_t height,
 81-                                      uint32_t format, uint32_t flags);
 82+struct wld_buffer *wld_create_buffer(struct wld_context *context,
 83+                                     uint32_t width, uint32_t height,
 84+                                     uint32_t format, uint32_t flags);
 85 
 86-struct wld_buffer * wld_import_buffer(struct wld_context * context,
 87-                                      uint32_t type, union wld_object object,
 88-                                      uint32_t width, uint32_t height,
 89-                                      uint32_t format, uint32_t pitch);
 90+struct wld_buffer *wld_import_buffer(struct wld_context *context,
 91+                                     uint32_t type, union wld_object object,
 92+                                     uint32_t width, uint32_t height,
 93+                                     uint32_t format, uint32_t pitch);
 94 
 95-struct wld_surface * wld_create_surface(struct wld_context * context,
 96-                                        uint32_t width, uint32_t height,
 97-                                        uint32_t format, uint32_t flags);
 98+struct wld_surface *wld_create_surface(struct wld_context *context,
 99+                                       uint32_t width, uint32_t height,
100+                                       uint32_t format, uint32_t flags);
101 
102-void wld_destroy_context(struct wld_context * context);
103+void wld_destroy_context(struct wld_context *context);
104 
105 /**** Font Handling ****/
106 
107-struct wld_extents
108-{
109-    uint32_t advance;
110+struct wld_extents {
111+	uint32_t advance;
112 };
113 
114-struct wld_font
115-{
116-    uint32_t ascent, descent;
117-    uint32_t height;
118-    uint32_t max_advance;
119+struct wld_font {
120+	uint32_t ascent, descent;
121+	uint32_t height;
122+	uint32_t max_advance;
123 };
124 
125 /**
126@@ -110,160 +103,155 @@ struct wld_font
127  *
128  * This sets up the underlying FreeType library.
129  */
130-struct wld_font_context * wld_font_create_context();
131+struct wld_font_context *wld_font_create_context();
132 
133 /**
134  * Destroy a font context.
135  */
136-void wld_font_destroy_context(struct wld_font_context * context);
137+void wld_font_destroy_context(struct wld_font_context *context);
138 
139 /**
140  * Open a new font from the given fontconfig match.
141  */
142-struct wld_font * wld_font_open_pattern(struct wld_font_context * context,
143-                                        FcPattern * match);
144+struct wld_font *wld_font_open_pattern(struct wld_font_context *context,
145+                                       FcPattern *match);
146 
147 /**
148  * Open a new font from a fontconfig pattern string.
149  */
150-struct wld_font * wld_font_open_name(struct wld_font_context * context,
151-                                     const char * name);
152+struct wld_font *wld_font_open_name(struct wld_font_context *context,
153+                                    const char *name);
154 
155 /**
156  * Close a font.
157  */
158-void wld_font_close(struct wld_font * font);
159+void wld_font_close(struct wld_font *font);
160 
161 /**
162  * Check if the given font has a particular character (in UTF-32), and if so,
163  * load the glyph.
164  */
165-bool wld_font_ensure_char(struct wld_font * font, uint32_t character);
166+bool wld_font_ensure_char(struct wld_font *font, uint32_t character);
167 
168 /**
169  * Calculate the text extents of the given UTF-8 string.
170  *
171  * @param length The maximum number of bytes in the string to process
172  */
173-void wld_font_text_extents_n(struct wld_font * font,
174-                             const char * text, int32_t length,
175-                             struct wld_extents * extents);
176-
177-static inline void wld_font_text_extents(struct wld_font * font,
178-                                         const char * text,
179-                                         struct wld_extents * extents)
180+void wld_font_text_extents_n(struct wld_font *font,
181+                             const char *text, int32_t length,
182+                             struct wld_extents *extents);
183+
184+static inline void
185+wld_font_text_extents(struct wld_font *font,
186+                      const char *text,
187+                      struct wld_extents *extents)
188 {
189-    wld_font_text_extents_n(font, text, INT32_MAX, extents);
190+	wld_font_text_extents_n(font, text, INT32_MAX, extents);
191 }
192 
193 /**** Buffers ****/
194 
195-struct wld_exporter
196-{
197-    bool (* export)(struct wld_exporter * exporter, struct wld_buffer * buffer,
198-                    uint32_t type, union wld_object * object);
199-    struct wld_exporter * next;
200+struct wld_exporter {
201+	bool (*export)(struct wld_exporter *exporter, struct wld_buffer *buffer,
202+	               uint32_t type, union wld_object *object);
203+	struct wld_exporter *next;
204 };
205 
206-struct wld_destructor
207-{
208-    void (* destroy)(struct wld_destructor * destructor);
209-    struct wld_destructor * next;
210+struct wld_destructor {
211+	void (*destroy)(struct wld_destructor *destructor);
212+	struct wld_destructor *next;
213 };
214 
215-struct wld_buffer
216-{
217-    const struct wld_buffer_impl * const impl;
218+struct wld_buffer {
219+	const struct wld_buffer_impl *const impl;
220 
221-    uint32_t width, height, pitch;
222-    enum wld_format format;
223-    pixman_region32_t damage;
224-    void * map;
225+	uint32_t width, height, pitch;
226+	enum wld_format format;
227+	pixman_region32_t damage;
228+	void *map;
229 };
230 
231-bool wld_map(struct wld_buffer * buffer);
232-bool wld_unmap(struct wld_buffer * buffer);
233+bool wld_map(struct wld_buffer *buffer);
234+bool wld_unmap(struct wld_buffer *buffer);
235 
236-bool wld_export(struct wld_buffer * buffer,
237-                uint32_t type, union wld_object * object);
238+bool wld_export(struct wld_buffer *buffer,
239+                uint32_t type, union wld_object *object);
240 
241-void wld_buffer_add_exporter(struct wld_buffer * buffer,
242-                             struct wld_exporter * exporter);
243+void wld_buffer_add_exporter(struct wld_buffer *buffer,
244+                             struct wld_exporter *exporter);
245 
246-void wld_buffer_add_destructor(struct wld_buffer * buffer,
247-                               struct wld_destructor * destructor);
248+void wld_buffer_add_destructor(struct wld_buffer *buffer,
249+                               struct wld_destructor *destructor);
250 
251 /**
252  * Increase the reference count of a buffer.
253  */
254-void wld_buffer_reference(struct wld_buffer * buffer);
255+void wld_buffer_reference(struct wld_buffer *buffer);
256 
257 /**
258  * Decrease the reference count of a buffer.
259  *
260  * When the reference count drops to zero, the buffer will be destroyed.
261  */
262-void wld_buffer_unreference(struct wld_buffer * buffer);
263+void wld_buffer_unreference(struct wld_buffer *buffer);
264 
265 /**** Surfaces ****/
266 
267-struct wld_surface
268-{
269-    const struct wld_surface_impl * const impl;
270+struct wld_surface {
271+	const struct wld_surface_impl *const impl;
272 };
273 
274-pixman_region32_t * wld_surface_damage(struct wld_surface * surface,
275-                                       pixman_region32_t * new_damage);
276+pixman_region32_t *wld_surface_damage(struct wld_surface *surface,
277+                                      pixman_region32_t *new_damage);
278 
279-struct wld_buffer * wld_surface_take(struct wld_surface * surface);
280+struct wld_buffer *wld_surface_take(struct wld_surface *surface);
281 
282-void wld_surface_release(struct wld_surface * surface,
283-                         struct wld_buffer * buffer);
284+void wld_surface_release(struct wld_surface *surface,
285+                         struct wld_buffer *buffer);
286 
287-bool wld_swap(struct wld_surface * surface);
288+bool wld_swap(struct wld_surface *surface);
289 
290-void wld_destroy_surface(struct wld_surface * surface);
291+void wld_destroy_surface(struct wld_surface *surface);
292 
293 /**** Renderers ****/
294 
295-struct wld_renderer
296-{
297-    const struct wld_renderer_impl * const impl;
298-    struct wld_buffer * target;
299+struct wld_renderer {
300+	const struct wld_renderer_impl *const impl;
301+	struct wld_buffer *target;
302 };
303 
304-enum wld_capability
305-{
306-    WLD_CAPABILITY_READ     = 1<<0,
307-    WLD_CAPABILITY_WRITE    = 1<<1,
308+enum wld_capability {
309+	WLD_CAPABILITY_READ = 1 << 0,
310+	WLD_CAPABILITY_WRITE = 1 << 1,
311 };
312 
313-void wld_destroy_renderer(struct wld_renderer * renderer);
314+void wld_destroy_renderer(struct wld_renderer *renderer);
315 
316-uint32_t wld_capabilities(struct wld_renderer * renderer,
317-                          struct wld_buffer * buffer);
318+uint32_t wld_capabilities(struct wld_renderer *renderer,
319+                          struct wld_buffer *buffer);
320 
321-bool wld_set_target_buffer(struct wld_renderer * renderer,
322-                           struct wld_buffer * buffer);
323+bool wld_set_target_buffer(struct wld_renderer *renderer,
324+                           struct wld_buffer *buffer);
325 
326-bool wld_set_target_surface(struct wld_renderer * renderer,
327-                            struct wld_surface * surface);
328+bool wld_set_target_surface(struct wld_renderer *renderer,
329+                            struct wld_surface *surface);
330 
331-void wld_fill_rectangle(struct wld_renderer * renderer, uint32_t color,
332+void wld_fill_rectangle(struct wld_renderer *renderer, uint32_t color,
333                         int32_t x, int32_t y, uint32_t width, uint32_t height);
334 
335-void wld_fill_region(struct wld_renderer * renderer, uint32_t color,
336-                     pixman_region32_t * region);
337+void wld_fill_region(struct wld_renderer *renderer, uint32_t color,
338+                     pixman_region32_t *region);
339 
340-void wld_copy_rectangle(struct wld_renderer * renderer,
341-                        struct wld_buffer * buffer,
342+void wld_copy_rectangle(struct wld_renderer *renderer,
343+                        struct wld_buffer *buffer,
344                         int32_t dst_x, int32_t dst_y,
345                         int32_t src_x, int32_t src_y,
346                         uint32_t width, uint32_t height);
347 
348-void wld_copy_region(struct wld_renderer * renderer,
349-                     struct wld_buffer * buffer,
350-                     int32_t dst_x, int32_t dst_y, pixman_region32_t * region);
351+void wld_copy_region(struct wld_renderer *renderer,
352+                     struct wld_buffer *buffer,
353+                     int32_t dst_x, int32_t dst_y, pixman_region32_t *region);
354 
355 /**
356  * Draw a UTF-8 text string to the given buffer.
357@@ -273,12 +261,11 @@ void wld_copy_region(struct wld_renderer * renderer,
358  * @param extents   If not NULL, will be initialized to the extents of the
359  *                  drawn text
360  */
361-void wld_draw_text(struct wld_renderer * renderer,
362-                   struct wld_font * font, uint32_t color,
363-                   int32_t x, int32_t y, const char * text, uint32_t length,
364-                   struct wld_extents * extents);
365+void wld_draw_text(struct wld_renderer *renderer,
366+                   struct wld_font *font, uint32_t color,
367+                   int32_t x, int32_t y, const char *text, uint32_t length,
368+                   struct wld_extents *extents);
369 
370-void wld_flush(struct wld_renderer * renderer);
371+void wld_flush(struct wld_renderer *renderer);
372 
373 #endif
374-