[retro-gtk/wip/aplazas/0.13: 13/14] Port PixelFormat to C



commit 1ff4c009437bca27c0f623be61630298b38b0b21
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Sep 6 07:24:03 2017 +0200

    Port PixelFormat to C

 retro-gtk/Makefile.am                   |    3 +-
 retro-gtk/retro-core.h                  |    1 +
 retro-gtk/retro-gtk.h                   |    1 +
 retro-gtk/retro-pixel-format.c          |   26 +++++++++++++++++++++
 retro-gtk/retro-pixel-format.h          |   33 ++++++++++++++++++++++++++
 retro-gtk/vapi/retro-gtk-c.vapi         |    8 ++++++
 retro-gtk/video.vala                    |   38 -------------------------------
 retro-gtk/video/retro-video-converter.c |    2 +-
 8 files changed, 72 insertions(+), 40 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 308b3df..0769308 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -55,9 +55,9 @@ libretro_gtk_la_SOURCES = \
        retro-module.c \
        retro-module-query.vala \
        retro-module-iterator.vala \
+       retro-pixel-format.c \
        retro-video-filter.c \
        rumble.vala \
-       video.vala \
        retro-core.c \
        retro-environment.c \
        libretro-environment.h \
@@ -116,6 +116,7 @@ retro_gtkinclude_HEADERS = \
        retro-joypad-id.h \
        retro-lightgun-id.h \
        retro-mouse-id.h \
+       retro-pixel-format.h \
        retro-pointer-id.h \
        retro-video-filter.h \
        $(NULL)
diff --git a/retro-gtk/retro-core.h b/retro-gtk/retro-core.h
index d651c05..12058db 100644
--- a/retro-gtk/retro-core.h
+++ b/retro-gtk/retro-core.h
@@ -6,6 +6,7 @@
 #include "retro-disk-control-callback.h"
 #include "retro-gtk-internal.h"
 #include "retro-module.h"
+#include "retro-pixel-format.h"
 #include "retro-rotation.h"
 
 G_BEGIN_DECLS
diff --git a/retro-gtk/retro-gtk.h b/retro-gtk/retro-gtk.h
index 3029968..281c1cf 100644
--- a/retro-gtk/retro-gtk.h
+++ b/retro-gtk/retro-gtk.h
@@ -12,6 +12,7 @@
 #include "retro-joypad-id.h"
 #include "retro-lightgun-id.h"
 #include "retro-mouse-id.h"
+#include "retro-pixel-format.h"
 #include "retro-pointer-id.h"
 #include "retro-video-filter.h"
 
diff --git a/retro-gtk/retro-pixel-format.c b/retro-gtk/retro-pixel-format.c
new file mode 100644
index 0000000..5184211
--- /dev/null
+++ b/retro-gtk/retro-pixel-format.c
@@ -0,0 +1,26 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#include "retro-pixel-format.h"
+
+GType
+retro_pixel_format_get_type (void)
+{
+  static volatile gsize retro_pixel_format_type = 0;
+
+  if (g_once_init_enter (&retro_pixel_format_type)) {
+    static const GEnumValue values[] = {
+      { RETRO_PIXEL_FORMAT_XRGB1555, "RETRO_PIXEL_FORMAT_XRGB1555", "xrgb1555" },
+      { RETRO_PIXEL_FORMAT_XRGB8888, "RETRO_PIXEL_FORMAT_XRGB8888", "xrgb8888" },
+      { RETRO_PIXEL_FORMAT_RGB565, "RETRO_PIXEL_FORMAT_RGB565", "rgb565" },
+      { RETRO_PIXEL_FORMAT_UNKNOWN, "RETRO_PIXEL_FORMAT_UNKNOWN", "unknown" },
+      { 0, NULL, NULL },
+    };
+    GType type;
+
+    type = g_enum_register_static ("RetroPixelFormat", values);
+
+    g_once_init_leave (&retro_pixel_format_type, type);
+  }
+
+  return retro_pixel_format_type;
+}
diff --git a/retro-gtk/retro-pixel-format.h b/retro-gtk/retro-pixel-format.h
new file mode 100644
index 0000000..e00853f
--- /dev/null
+++ b/retro-gtk/retro-pixel-format.h
@@ -0,0 +1,33 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_PIXEL_FORMAT_H
+#define RETRO_PIXEL_FORMAT_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define RETRO_TYPE_PIXEL_FORMAT (retro_pixel_format_get_type ())
+
+GType retro_pixel_format_get_type (void) G_GNUC_CONST;
+
+/**
+ * RetroPixelFormat:
+ * @RETRO_PIXEL_FORMAT_XRGB1555: Native endian, the first bit is ignored.
+ * @RETRO_PIXEL_FORMAT_XRGB8888: Native endian, the first 8 bits are ignored.
+ * @RETRO_PIXEL_FORMAT_RGB565: Native endian.
+ * @RETRO_PIXEL_FORMAT_UNKNOWN: An unknown format.
+ *
+ * Represents the pixel formats used by Libretro.
+ */
+typedef enum
+{
+  RETRO_PIXEL_FORMAT_XRGB1555,
+  RETRO_PIXEL_FORMAT_XRGB8888,
+  RETRO_PIXEL_FORMAT_RGB565,
+  RETRO_PIXEL_FORMAT_UNKNOWN = -1,
+} RetroPixelFormat;
+
+G_END_DECLS
+
+#endif /* RETRO_PIXEL_FORMAT_H */
diff --git a/retro-gtk/vapi/retro-gtk-c.vapi b/retro-gtk/vapi/retro-gtk-c.vapi
index dca05f9..1d548e2 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-pixel-format.h")]
+public enum Retro.PixelFormat {
+       XRGB1555,
+       XRGB8888,
+       RGB565,
+       UNKNOWN = -1,
+}
+
 [CCode (cheader_filename = "retro-video-filter.h")]
 public enum Retro.VideoFilter {
        SMOOTH,
diff --git a/retro-gtk/video/retro-video-converter.c b/retro-gtk/video/retro-video-converter.c
index 6057a6a..4e675f7 100644
--- a/retro-gtk/video/retro-video-converter.c
+++ b/retro-gtk/video/retro-video-converter.c
@@ -2,7 +2,7 @@
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
-#include "retro-gtk-internal.h"
+#include "retro-pixel-format.h"
 
 typedef struct _xrgb1555 {
   guint16 b: 5;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]