[vlc-devel] [PATCH v2] opengl: use union for on- and off-screen fields

Romain Vimont rom1v at videolabs.io
Tue Mar 2 08:22:24 UTC 2021


---
 include/vlc_opengl.h | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/include/vlc_opengl.h b/include/vlc_opengl.h
index f91f387bf7..7c86a63d9b 100644
--- a/include/vlc_opengl.h
+++ b/include/vlc_opengl.h
@@ -49,24 +49,30 @@ struct vlc_gl_t
 {
     struct vlc_object_t obj;
 
-    struct vlc_decoder_device *device;
-    struct vout_window_t *surface;
     module_t *module;
     void *sys;
 
-    vlc_fourcc_t offscreen_chroma_out;
-    struct vlc_video_context *offscreen_vctx_out;
-    /* Flag to indicate if the OpenGL implementation produces upside-down
-     * pictures */
-    bool offscreen_vflip;
+    union {
+        struct { /* on-screen */
+            void (*swap)(vlc_gl_t *);
+
+            struct vout_window_t *surface;
+        };
+        struct { /* off-screen */
+            picture_t *(*swap_offscreen)(vlc_gl_t *);
+
+            struct vlc_decoder_device *device;
+            vlc_fourcc_t offscreen_chroma_out;
+            struct vlc_video_context *offscreen_vctx_out;
+            /* Flag to indicate if the OpenGL implementation produces upside-down
+             * pictures */
+            bool offscreen_vflip;
+        };
+    };
 
     int  (*make_current)(vlc_gl_t *);
     void (*release_current)(vlc_gl_t *);
     void (*resize)(vlc_gl_t *, unsigned, unsigned);
-    union {
-        void (*swap)(vlc_gl_t *);
-        picture_t *(*swap_offscreen)(vlc_gl_t *);
-    };
     void*(*get_proc_address)(vlc_gl_t *, const char *);
     void (*destroy)(vlc_gl_t *);
 
-- 
2.30.1



More information about the vlc-devel mailing list