commit ea66021
Michael Forney
·
2014-01-13 22:27:22 +0000 UTC
parent 226ac95
Add exporters
4 files changed,
+88,
-0
+30,
-0
1@@ -70,6 +70,21 @@ void drawable_initialize(struct wld_drawable * drawable,
2 drawable->height = height;
3 drawable->format = format;
4 drawable->pitch = pitch;
5+ drawable->exporters = NULL;
6+}
7+
8+void drawable_add_exporter(struct wld_drawable * drawable,
9+ struct wld_exporter * exporter)
10+{
11+ exporter->next = drawable->exporters;
12+ drawable->exporters = exporter;
13+}
14+
15+void exporter_initialize(struct wld_exporter * exporter,
16+ const struct wld_exporter_impl * impl)
17+{
18+ *((const struct wld_exporter_impl **) &exporter->impl) = impl;
19+ exporter->next = NULL;
20 }
21
22 EXPORT
23@@ -136,6 +151,21 @@ pixman_image_t * wld_map(struct wld_drawable * drawable)
24 return drawable->impl->map(drawable);
25 }
26
27+EXPORT
28+bool wld_export(struct wld_drawable * drawable,
29+ uint32_t type, union wld_object * object)
30+{
31+ struct wld_exporter * exporter;
32+
33+ for (exporter = drawable->exporters; exporter; exporter = exporter->next)
34+ {
35+ if (exporter->impl->export(exporter, drawable, type, object))
36+ return true;
37+ }
38+
39+ return false;
40+}
41+
42 EXPORT
43 void wld_flush(struct wld_drawable * drawable)
44 {
+33,
-0
1@@ -0,0 +1,33 @@
2+/* wld: interface/exporter.h
3+ *
4+ * Copyright (c) 2013 Michael Forney
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+
25+static void exporter_destroy(struct wld_exporter * exporter);
26+static bool exporter_export(struct wld_exporter * exporter,
27+ struct wld_drawable * drawable,
28+ uint32_t type, union wld_object * object);
29+
30+static const struct wld_exporter_impl exporter_impl = {
31+ .destroy = &exporter_destroy,
32+ .export = &exporter_export
33+};
34+
+20,
-0
1@@ -121,6 +121,20 @@ struct wld_drawable_impl
2 void (* destroy)(struct wld_drawable * drawable);
3 };
4
5+struct wld_exporter
6+{
7+ const struct wld_exporter_impl * const impl;
8+ struct wld_exporter * next;
9+};
10+
11+struct wld_exporter_impl
12+{
13+ bool (* export)(struct wld_exporter * exporter,
14+ struct wld_drawable * drawable,
15+ uint32_t type, union wld_object * object);
16+ void (* destroy)(struct wld_exporter * exporter);
17+};
18+
19 bool font_ensure_glyph(struct font * font, FT_UInt glyph_index);
20
21 /**
22@@ -185,5 +199,11 @@ void drawable_initialize(struct wld_drawable * drawable,
23 uint32_t width, uint32_t height,
24 uint32_t format, uint32_t pitch);
25
26+void drawable_add_exporter(struct wld_drawable * drawable,
27+ struct wld_exporter * exporter);
28+
29+void exporter_initialize(struct wld_exporter * exporter,
30+ const struct wld_exporter_impl * impl);
31+
32 #endif
33
M
wld.h
+5,
-0
1@@ -150,9 +150,14 @@ struct wld_drawable
2 unsigned long pitch;
3 enum wld_format format;
4
5+ struct wld_exporter * exporters;
6+
7 const struct wld_drawable_impl * impl;
8 };
9
10+bool wld_export(struct wld_drawable * drawable,
11+ uint32_t type, union wld_object * object);
12+
13 /**
14 * Destroy a drawable (created with any context).
15 */