commit d6cfcbff26ad3807d814825d8b024b608bc91428
parent fd0e372626f5593a16e8ffdc411d5ebda4fb9802
Author: Michael Forney <mforney@mforney.org>
Date: Thu, 16 Jan 2014 02:58:15 -0800
Add shm context/renderer
Diffstat:
5 files changed, 119 insertions(+), 11 deletions(-)
diff --git a/libswc/internal.h b/libswc/internal.h
@@ -35,6 +35,7 @@ struct swc
const struct swc_seat_global * const seat;
const struct swc_bindings_global * const bindings;
struct swc_compositor * compositor;
+ struct swc_shm * const shm;
struct swc_drm * const drm;
};
diff --git a/libswc/local.mk b/libswc/local.mk
@@ -46,6 +46,7 @@ SWC_SOURCES = \
libswc/mode.c \
libswc/evdev_device.c \
libswc/xkb.c \
+ libswc/shm.c \
libswc/drm.c \
libswc/drm_buffer.c \
protocol/wayland-drm-protocol.c \
diff --git a/libswc/shm.c b/libswc/shm.c
@@ -0,0 +1,54 @@
+/* swc: libswc/shm.c
+ *
+ * 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.
+ */
+
+#include "shm.h"
+#include "internal.h"
+
+#include <stddef.h>
+#include <wld/wld.h>
+#include <wld/pixman.h>
+
+struct swc_shm shm_global;
+
+bool swc_shm_initialize()
+{
+ if (!(swc.shm->context = wld_pixman_create_context()))
+ goto error0;
+
+ if (!(swc.shm->renderer = wld_create_renderer(swc.shm->context)))
+ goto error1;
+
+ return true;
+
+ error1:
+ wld_destroy_context(swc.shm->context);
+ error0:
+ return false;
+}
+
+void swc_shm_finalize()
+{
+ wld_destroy_renderer(swc.shm->renderer);
+ wld_destroy_context(swc.shm->context);
+}
+
diff --git a/libswc/shm.h b/libswc/shm.h
@@ -0,0 +1,40 @@
+/* swc: libswc/shm.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.
+ */
+
+#ifndef SWC_SHM_H
+#define SWC_SHM_H
+
+#include <stdbool.h>
+
+struct swc_shm
+{
+ struct wld_context * context;
+ struct wld_renderer * renderer;
+};
+
+bool swc_shm_initialize();
+
+void swc_shm_finalize();
+
+#endif
+
diff --git a/libswc/swc.c b/libswc/swc.c
@@ -32,6 +32,7 @@
#include "pointer.h"
#include "seat.h"
#include "shell.h"
+#include "shm.h"
#include "window.h"
#ifdef ENABLE_XWAYLAND
# include "xserver.h"
@@ -42,6 +43,7 @@
extern const struct swc_seat_global seat_global;
extern const struct swc_bindings_global bindings_global;
extern struct swc_drm drm_global;
+extern struct swc_shm shm_global;
static struct swc_compositor compositor;
struct swc swc = {
@@ -49,6 +51,7 @@ struct swc swc = {
.bindings = &bindings_global,
.compositor = &compositor,
.drm = &drm_global,
+ .shm = &shm_global
};
static void setup_compositor()
@@ -99,10 +102,16 @@ bool swc_initialize(struct wl_display * display,
goto error1;
}
+ if (!swc_shm_initialize())
+ {
+ ERROR("Could not initialize SHM\n");
+ goto error2;
+ }
+
if (!swc_compositor_initialize(&compositor, display, swc.event_loop))
{
ERROR("Could not initialize compositor\n");
- goto error2;
+ goto error3;
}
swc_compositor_add_globals(&compositor, display);
@@ -110,32 +119,32 @@ bool swc_initialize(struct wl_display * display,
if (!swc_data_device_manager_initialize())
{
ERROR("Could not initialize data device manager\n");
- goto error3;
+ goto error4;
}
if (!swc_seat_initialize())
{
ERROR("Could not initialize seat\n");
- goto error4;
+ goto error5;
}
if (!swc_bindings_initialize())
{
ERROR("Could not initialize bindings\n");
- goto error5;
+ goto error6;
}
if (!swc_shell_initialize())
{
ERROR("Could not initialize shell\n");
- goto error6;
+ goto error7;
}
#ifdef ENABLE_XWAYLAND
if (!swc_xserver_initialize())
{
ERROR("Could not initialize xwayland\n");
- goto error7;
+ goto error8;
}
#endif
@@ -143,16 +152,18 @@ bool swc_initialize(struct wl_display * display,
return true;
- error7:
+ error8:
swc_shell_finalize();
- error6:
+ error7:
swc_bindings_finalize();
- error5:
+ error6:
swc_seat_finalize();
- error4:
+ error5:
swc_data_device_manager_finalize();
- error3:
+ error4:
swc_compositor_finish(&compositor);
+ error3:
+ swc_shm_finalize();
error2:
swc_drm_finalize();
error1:
@@ -172,6 +183,7 @@ void swc_finalize()
swc_seat_finalize();
swc_data_device_manager_finalize();
swc_compositor_finish(&compositor);
+ swc_shm_finalize();
swc_drm_finalize();
udev_unref(swc.udev);
}