commit d6cfcbf
Michael Forney
·
2014-01-16 10:58:15 +0000 UTC
parent fd0e372
Add shm context/renderer
5 files changed,
+119,
-11
+1,
-0
1@@ -35,6 +35,7 @@ struct swc
2 const struct swc_seat_global * const seat;
3 const struct swc_bindings_global * const bindings;
4 struct swc_compositor * compositor;
5+ struct swc_shm * const shm;
6 struct swc_drm * const drm;
7 };
8
+1,
-0
1@@ -46,6 +46,7 @@ SWC_SOURCES = \
2 libswc/mode.c \
3 libswc/evdev_device.c \
4 libswc/xkb.c \
5+ libswc/shm.c \
6 libswc/drm.c \
7 libswc/drm_buffer.c \
8 protocol/wayland-drm-protocol.c \
+54,
-0
1@@ -0,0 +1,54 @@
2+/* swc: libswc/shm.c
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+#include "shm.h"
26+#include "internal.h"
27+
28+#include <stddef.h>
29+#include <wld/wld.h>
30+#include <wld/pixman.h>
31+
32+struct swc_shm shm_global;
33+
34+bool swc_shm_initialize()
35+{
36+ if (!(swc.shm->context = wld_pixman_create_context()))
37+ goto error0;
38+
39+ if (!(swc.shm->renderer = wld_create_renderer(swc.shm->context)))
40+ goto error1;
41+
42+ return true;
43+
44+ error1:
45+ wld_destroy_context(swc.shm->context);
46+ error0:
47+ return false;
48+}
49+
50+void swc_shm_finalize()
51+{
52+ wld_destroy_renderer(swc.shm->renderer);
53+ wld_destroy_context(swc.shm->context);
54+}
55+
+40,
-0
1@@ -0,0 +1,40 @@
2+/* swc: libswc/shm.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+#ifndef SWC_SHM_H
26+#define SWC_SHM_H
27+
28+#include <stdbool.h>
29+
30+struct swc_shm
31+{
32+ struct wld_context * context;
33+ struct wld_renderer * renderer;
34+};
35+
36+bool swc_shm_initialize();
37+
38+void swc_shm_finalize();
39+
40+#endif
41+
+23,
-11
1@@ -32,6 +32,7 @@
2 #include "pointer.h"
3 #include "seat.h"
4 #include "shell.h"
5+#include "shm.h"
6 #include "window.h"
7 #ifdef ENABLE_XWAYLAND
8 # include "xserver.h"
9@@ -42,6 +43,7 @@
10 extern const struct swc_seat_global seat_global;
11 extern const struct swc_bindings_global bindings_global;
12 extern struct swc_drm drm_global;
13+extern struct swc_shm shm_global;
14 static struct swc_compositor compositor;
15
16 struct swc swc = {
17@@ -49,6 +51,7 @@ struct swc swc = {
18 .bindings = &bindings_global,
19 .compositor = &compositor,
20 .drm = &drm_global,
21+ .shm = &shm_global
22 };
23
24 static void setup_compositor()
25@@ -99,10 +102,16 @@ bool swc_initialize(struct wl_display * display,
26 goto error1;
27 }
28
29+ if (!swc_shm_initialize())
30+ {
31+ ERROR("Could not initialize SHM\n");
32+ goto error2;
33+ }
34+
35 if (!swc_compositor_initialize(&compositor, display, swc.event_loop))
36 {
37 ERROR("Could not initialize compositor\n");
38- goto error2;
39+ goto error3;
40 }
41
42 swc_compositor_add_globals(&compositor, display);
43@@ -110,32 +119,32 @@ bool swc_initialize(struct wl_display * display,
44 if (!swc_data_device_manager_initialize())
45 {
46 ERROR("Could not initialize data device manager\n");
47- goto error3;
48+ goto error4;
49 }
50
51 if (!swc_seat_initialize())
52 {
53 ERROR("Could not initialize seat\n");
54- goto error4;
55+ goto error5;
56 }
57
58 if (!swc_bindings_initialize())
59 {
60 ERROR("Could not initialize bindings\n");
61- goto error5;
62+ goto error6;
63 }
64
65 if (!swc_shell_initialize())
66 {
67 ERROR("Could not initialize shell\n");
68- goto error6;
69+ goto error7;
70 }
71
72 #ifdef ENABLE_XWAYLAND
73 if (!swc_xserver_initialize())
74 {
75 ERROR("Could not initialize xwayland\n");
76- goto error7;
77+ goto error8;
78 }
79 #endif
80
81@@ -143,16 +152,18 @@ bool swc_initialize(struct wl_display * display,
82
83 return true;
84
85- error7:
86+ error8:
87 swc_shell_finalize();
88- error6:
89+ error7:
90 swc_bindings_finalize();
91- error5:
92+ error6:
93 swc_seat_finalize();
94- error4:
95+ error5:
96 swc_data_device_manager_finalize();
97- error3:
98+ error4:
99 swc_compositor_finish(&compositor);
100+ error3:
101+ swc_shm_finalize();
102 error2:
103 swc_drm_finalize();
104 error1:
105@@ -172,6 +183,7 @@ void swc_finalize()
106 swc_seat_finalize();
107 swc_data_device_manager_finalize();
108 swc_compositor_finish(&compositor);
109+ swc_shm_finalize();
110 swc_drm_finalize();
111 udev_unref(swc.udev);
112 }