[retro-gtk/wip/aplazas/c-port: 12/36] Port VideoFilter to C



commit e8f68029b725c0868c00b0a488f973482c077dbd
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    |   35 ++++++++++++++++++++++++++++
 retro-gtk/vapi/retro-gtk-c.vapi   |    8 ++++++
 retro-gtk/video/video-filter.vala |   13 ----------
 6 files changed, 91 insertions(+), 14 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 9397369..8891cd5 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -41,6 +41,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 = \
@@ -87,6 +88,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 \
@@ -94,7 +96,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..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..39eae00
--- /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]