[retro-gtk/wip/aplazas/c-port: 12/34] Port VideoFilter to C
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/wip/aplazas/c-port: 12/34] Port VideoFilter to C
- Date: Tue, 10 Oct 2017 04:53:31 +0000 (UTC)
commit 8023338f8ce0893c48ad41462e6554b2def54191
Author: Adrien Plazas <kekun plazas laposte net>
Date: Tue Sep 5 18:39:49 2017 +0200
Port VideoFilter to C
retro-gtk/Makefile.am | 3 +-
retro-gtk/retro-gtk.h | 1 +
retro-gtk/retro-video-filter.c | 54 +++++++++++++++++++++++++++++++++++++
retro-gtk/retro-video-filter.h | 35 ++++++++++++++++++++++++
retro-gtk/vapi/retro-gtk-c.vapi | 8 +++++
retro-gtk/video/video-filter.vala | 13 ---------
6 files changed, 100 insertions(+), 14 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 4a6abbd..5103cd7 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -40,6 +40,7 @@ retro_gtk_public_h_sources = \
retro-lightgun-id.h \
retro-mouse-id.h \
retro-pointer-id.h \
+ retro-video-filter.h \
$(NULL)
retro_gtk_private_h_sources = \
@@ -94,6 +95,7 @@ libretro_gtk_la_SOURCES = \
retro-option.c \
retro-options.c \
retro-pointer-id.c \
+ retro-video-filter.c \
rumble.vala \
video.vala \
retro-core.c \
@@ -101,7 +103,6 @@ libretro_gtk_la_SOURCES = \
\
video/cairo-display.vala \
video/retro-video-converter.c \
- video/video-filter.vala \
$(NULL)
video/retro-video-converter.c: retro-gtk-internal.h
diff --git a/retro-gtk/retro-gtk.h b/retro-gtk/retro-gtk.h
index f4c552d..1bedfd6 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -19,6 +19,7 @@
#include "retro-lightgun-id.h"
#include "retro-mouse-id.h"
#include "retro-pointer-id.h"
+#include "retro-video-filter.h"
#undef __RETRO_GTK_INSIDE__
diff --git a/retro-gtk/retro-video-filter.c b/retro-gtk/retro-video-filter.c
new file mode 100644
index 0000000..cbff527
--- /dev/null
+++ b/retro-gtk/retro-video-filter.c
@@ -0,0 +1,54 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#include "retro-video-filter.h"
+
+/**
+ * retro_video_filter_from_string:
+ * @filter: a filter name
+ *
+ * Gets a #RetroVideoFilter from it's name. It defaults to
+ * RETRO_VIDEO_FILTER_SMOOTH in case of error.
+ *
+ * Returns: a #RetroVideoFilter
+ */
+RetroVideoFilter
+retro_video_filter_from_string (const gchar *filter)
+{
+ GEnumClass* enum_class;
+ RetroVideoFilter result;
+ GEnumValue* eval = NULL;
+
+ g_return_val_if_fail (filter != NULL, RETRO_VIDEO_FILTER_SMOOTH);
+
+ enum_class = (GEnumClass *) g_type_class_ref (RETRO_TYPE_VIDEO_FILTER);
+ eval = g_enum_get_value_by_nick (enum_class, filter);
+
+ result = (eval == NULL) ?
+ RETRO_VIDEO_FILTER_SMOOTH :
+ (RetroVideoFilter) eval->value;
+
+ g_type_class_unref (enum_class);
+
+ return result;
+}
+
+GType
+retro_video_filter_get_type (void)
+{
+ static volatile gsize retro_video_filter_type = 0;
+
+ if (g_once_init_enter (&retro_video_filter_type)) {
+ static const GEnumValue values[] = {
+ { RETRO_VIDEO_FILTER_SMOOTH, "RETRO_VIDEO_FILTER_SMOOTH", "smooth" },
+ { RETRO_VIDEO_FILTER_SHARP, "RETRO_VIDEO_FILTER_SHARP", "sharp" },
+ { 0, NULL, NULL },
+ };
+ GType type;
+
+ type = g_enum_register_static ("RetroVideoFilter", values);
+
+ g_once_init_leave (&retro_video_filter_type, type);
+ }
+
+ return retro_video_filter_type;
+}
diff --git a/retro-gtk/retro-video-filter.h b/retro-gtk/retro-video-filter.h
new file mode 100644
index 0000000..7eb6f53
--- /dev/null
+++ b/retro-gtk/retro-video-filter.h
@@ -0,0 +1,35 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_VIDEO_FILTER_H
+#define RETRO_VIDEO_FILTER_H
+
+#if !defined(__RETRO_GTK_INSIDE__) && !defined(RETRO_GTK_COMPILATION)
+# error "Only <retro-gtk.h> can be included directly."
+#endif
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define RETRO_TYPE_VIDEO_FILTER (retro_video_filter_get_type ())
+
+GType retro_video_filter_get_type (void) G_GNUC_CONST;
+
+/**
+ * RetroVideoFilter:
+ * @RETRO_VIDEO_FILTER_SMOOTH: a smooth but blurry video filer
+ * @RETRO_VIDEO_FILTER_SHARP: a sharp video filter showing every pixel
+ *
+ * Represents the filters that can be applied to the video output.
+ */
+typedef enum
+{
+ RETRO_VIDEO_FILTER_SMOOTH,
+ RETRO_VIDEO_FILTER_SHARP,
+} RetroVideoFilter;
+
+RetroVideoFilter retro_video_filter_from_string (const gchar *filter);
+
+G_END_DECLS
+
+#endif /* RETRO_VIDEO_FILTER_H */
diff --git a/retro-gtk/vapi/retro-gtk-c.vapi b/retro-gtk/vapi/retro-gtk-c.vapi
index c22ec5c..dca05f9 100644
--- a/retro-gtk/vapi/retro-gtk-c.vapi
+++ b/retro-gtk/vapi/retro-gtk-c.vapi
@@ -12,6 +12,14 @@ public enum Retro.DeviceType {
POINTER = 6,
}
+[CCode (cheader_filename = "retro-video-filter.h")]
+public enum Retro.VideoFilter {
+ SMOOTH,
+ SHARP;
+
+ public static VideoFilter from_string (string filter);
+}
+
[CCode (cheader_filename = "retro-input-device.h")]
public interface Retro.InputDevice : GLib.Object {
public abstract void poll ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]