[retro-gtk/c-port: 13/37] Port VideoFilter to C



commit 338a74a90c722567480e1e2e2a31e59c593dfaef
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    |   45 +++++++++++++++++++++++++++++++++++++
 retro-gtk/retro-video-filter.h    |   31 +++++++++++++++++++++++++
 retro-gtk/vapi/retro-gtk-c.vapi   |    8 ++++++
 retro-gtk/video/video-filter.vala |   13 ----------
 6 files changed, 87 insertions(+), 14 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 334d47f..d8662f4 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -55,6 +55,7 @@ libretro_gtk_la_SOURCES = \
        retro-module-iterator.vala \
        retro-option.c \
        retro-options.c \
+       retro-video-filter.c \
        rumble.vala \
        video.vala \
        retro-core.c \
@@ -63,7 +64,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
@@ -120,6 +120,7 @@ retro_gtkinclude_HEADERS = \
        retro-options.h \
        retro-pointer-id.h \
        retro-variable.h \
+       retro-video-filter.h \
        $(NULL)
 
 # Introspection
diff --git a/retro-gtk/retro-gtk.h b/retro-gtk/retro-gtk.h
index c9f4a75..33827a5 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -17,5 +17,6 @@
 #include "retro-lightgun-id.h"
 #include "retro-mouse-id.h"
 #include "retro-pointer-id.h"
+#include "retro-video-filter.h"
 
 #endif
diff --git a/retro-gtk/retro-video-filter.c b/retro-gtk/retro-video-filter.c
new file mode 100644
index 0000000..eafa6ad
--- /dev/null
+++ b/retro-gtk/retro-video-filter.c
@@ -0,0 +1,45 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#include "retro-video-filter.h"
+
+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..0826f26
--- /dev/null
+++ b/retro-gtk/retro-video-filter.h
@@ -0,0 +1,31 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_VIDEO_FILTER_H
+#define RETRO_VIDEO_FILTER_H
+
+#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]