neuwld

patched neuwld library (tracked)
git clone https://git.daat.foo/neuwld.git
Log | Files | Refs | README | LICENSE

commit ea660218241c7ff45c491420f68dc8495858afa8
parent 226ac956036dc030f1524f3bb20e42f185f6443f
Author: Michael Forney <mforney@mforney.org>
Date:   Mon, 13 Jan 2014 14:27:22 -0800

Add exporters

Diffstat:
Mdrawable.c | 30++++++++++++++++++++++++++++++
Ainterface/exporter.h | 33+++++++++++++++++++++++++++++++++
Mwld-private.h | 20++++++++++++++++++++
Mwld.h | 5+++++
4 files changed, 88 insertions(+), 0 deletions(-)

diff --git a/drawable.c b/drawable.c @@ -70,6 +70,21 @@ void drawable_initialize(struct wld_drawable * drawable, drawable->height = height; drawable->format = format; drawable->pitch = pitch; + drawable->exporters = NULL; +} + +void drawable_add_exporter(struct wld_drawable * drawable, + struct wld_exporter * exporter) +{ + exporter->next = drawable->exporters; + drawable->exporters = exporter; +} + +void exporter_initialize(struct wld_exporter * exporter, + const struct wld_exporter_impl * impl) +{ + *((const struct wld_exporter_impl **) &exporter->impl) = impl; + exporter->next = NULL; } EXPORT @@ -137,6 +152,21 @@ pixman_image_t * wld_map(struct wld_drawable * drawable) } EXPORT +bool wld_export(struct wld_drawable * drawable, + uint32_t type, union wld_object * object) +{ + struct wld_exporter * exporter; + + for (exporter = drawable->exporters; exporter; exporter = exporter->next) + { + if (exporter->impl->export(exporter, drawable, type, object)) + return true; + } + + return false; +} + +EXPORT void wld_flush(struct wld_drawable * drawable) { drawable->impl->flush(drawable); diff --git a/interface/exporter.h b/interface/exporter.h @@ -0,0 +1,33 @@ +/* wld: interface/exporter.h + * + * Copyright (c) 2013 Michael Forney + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +static void exporter_destroy(struct wld_exporter * exporter); +static bool exporter_export(struct wld_exporter * exporter, + struct wld_drawable * drawable, + uint32_t type, union wld_object * object); + +static const struct wld_exporter_impl exporter_impl = { + .destroy = &exporter_destroy, + .export = &exporter_export +}; + diff --git a/wld-private.h b/wld-private.h @@ -121,6 +121,20 @@ struct wld_drawable_impl void (* destroy)(struct wld_drawable * drawable); }; +struct wld_exporter +{ + const struct wld_exporter_impl * const impl; + struct wld_exporter * next; +}; + +struct wld_exporter_impl +{ + bool (* export)(struct wld_exporter * exporter, + struct wld_drawable * drawable, + uint32_t type, union wld_object * object); + void (* destroy)(struct wld_exporter * exporter); +}; + bool font_ensure_glyph(struct font * font, FT_UInt glyph_index); /** @@ -185,5 +199,11 @@ void drawable_initialize(struct wld_drawable * drawable, uint32_t width, uint32_t height, uint32_t format, uint32_t pitch); +void drawable_add_exporter(struct wld_drawable * drawable, + struct wld_exporter * exporter); + +void exporter_initialize(struct wld_exporter * exporter, + const struct wld_exporter_impl * impl); + #endif diff --git a/wld.h b/wld.h @@ -150,9 +150,14 @@ struct wld_drawable unsigned long pitch; enum wld_format format; + struct wld_exporter * exporters; + const struct wld_drawable_impl * impl; }; +bool wld_export(struct wld_drawable * drawable, + uint32_t type, union wld_object * object); + /** * Destroy a drawable (created with any context). */