[gthumb] video viewer: added option to use opengl instead of cairo



commit b4cfc787ad25465848d2169ad37b7ea4678cc2f2
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Dec 31 10:19:52 2018 +0100

    video viewer: added option to use opengl instead of cairo

 .../org.gnome.gthumb.gstreamer-tools.gschema.xml   |  3 ++
 .../data/ui/media-viewer-preferences.ui            | 56 ++++++++++++++++------
 .../gstreamer_tools/dlg-media-viewer-preferences.c | 14 +++---
 extensions/gstreamer_tools/gth-media-viewer-page.c | 28 +++++++++--
 extensions/gstreamer_tools/preferences.h           |  1 +
 5 files changed, 77 insertions(+), 25 deletions(-)
---
diff --git a/data/gschemas/org.gnome.gthumb.gstreamer-tools.gschema.xml 
b/data/gschemas/org.gnome.gthumb.gstreamer-tools.gschema.xml
index 11e8b7e9..77db6139 100644
--- a/data/gschemas/org.gnome.gthumb.gstreamer-tools.gschema.xml
+++ b/data/gschemas/org.gnome.gthumb.gstreamer-tools.gschema.xml
@@ -25,6 +25,9 @@
     <key name="volume" type="i">
       <default>100</default>
     </key>
+    <key name="use-hardware-acceleration" type="b">
+      <default>false</default>
+    </key>
   </schema>
 
 </schemalist>
diff --git a/extensions/gstreamer_tools/data/ui/media-viewer-preferences.ui 
b/extensions/gstreamer_tools/data/ui/media-viewer-preferences.ui
index fbe06858..d844d04a 100644
--- a/extensions/gstreamer_tools/data/ui/media-viewer-preferences.ui
+++ b/extensions/gstreamer_tools/data/ui/media-viewer-preferences.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.19.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.16"/>
   <object class="GtkBox" id="dialog_content">
@@ -7,33 +7,59 @@
     <property name="can_focus">False</property>
     <property name="border_width">15</property>
     <property name="orientation">vertical</property>
-    <property name="spacing">6</property>
+    <property name="spacing">15</property>
     <child>
-      <object class="GtkLabel" id="label1">
+      <object class="GtkCheckButton" id="use_hardware_acceleration_checkbutton">
+        <property name="label" translatable="yes">Use hardware acceleration</property>
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">_Screenshots location:</property>
-        <property name="use_underline">True</property>
-        <property name="mnemonic_widget">screenshots_filechooserbutton</property>
-        <property name="xalign">0</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="draw_indicator">True</property>
       </object>
       <packing>
         <property name="expand">False</property>
-        <property name="fill">False</property>
+        <property name="fill">True</property>
         <property name="position">0</property>
       </packing>
     </child>
     <child>
-      <object class="GtkFileChooserButton" id="screenshots_filechooserbutton">
-        <property name="width_request">300</property>
+      <object class="GtkBox">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="action">select-folder</property>
-        <property name="local_only">False</property>
-        <property name="title" translatable="yes"/>
+        <property name="orientation">vertical</property>
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">_Screenshots location:</property>
+            <property name="use_underline">True</property>
+            <property name="xalign">0</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFileChooserButton" id="screenshots_filechooserbutton">
+            <property name="width_request">300</property>
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="action">select-folder</property>
+            <property name="local_only">False</property>
+            <property name="title" translatable="yes"/>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
       </object>
       <packing>
-        <property name="expand">True</property>
+        <property name="expand">False</property>
         <property name="fill">True</property>
         <property name="position">1</property>
       </packing>
diff --git a/extensions/gstreamer_tools/dlg-media-viewer-preferences.c 
b/extensions/gstreamer_tools/dlg-media-viewer-preferences.c
index 6d07f98b..f75b45c3 100644
--- a/extensions/gstreamer_tools/dlg-media-viewer-preferences.c
+++ b/extensions/gstreamer_tools/dlg-media-viewer-preferences.c
@@ -39,14 +39,12 @@ update_settings (DialogData *data)
        char *uri;
 
        uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (gtk_builder_get_object (data->builder, 
"screenshots_filechooserbutton")));
-       if (uri == NULL)
-               return;
+       if (uri != NULL) {
+               _g_settings_set_uri (data->settings, PREF_GSTREAMER_TOOLS_SCREESHOT_LOCATION, uri);
+               g_free (uri);
+       }
 
-       _g_settings_set_uri (data->settings,
-                            PREF_GSTREAMER_TOOLS_SCREESHOT_LOCATION,
-                            uri);
-
-       g_free (uri);
+       g_settings_set_boolean (data->settings, PREF_GSTREAMER_USE_HARDWARE_ACCEL, 
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (data->builder, 
"use_hardware_acceleration_checkbutton"))));
 }
 
 
@@ -92,6 +90,8 @@ dlg_media_viewer_preferences (GtkWindow *parent)
        gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (gtk_builder_get_object (data->builder, 
"screenshots_filechooserbutton")), uri);
        g_free (uri);
 
+       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (data->builder, 
"use_hardware_acceleration_checkbutton")), g_settings_get_boolean (data->settings, 
PREF_GSTREAMER_USE_HARDWARE_ACCEL));
+
        /* Set the signals handlers. */
 
        g_signal_connect (G_OBJECT (data->dialog),
diff --git a/extensions/gstreamer_tools/gth-media-viewer-page.c 
b/extensions/gstreamer_tools/gth-media-viewer-page.c
index 0170ddfd..43205e0d 100644
--- a/extensions/gstreamer_tools/gth-media-viewer-page.c
+++ b/extensions/gstreamer_tools/gth-media-viewer-page.c
@@ -806,8 +806,31 @@ create_playbin (GthMediaViewerPage *self)
                return;
 
        self->priv->playbin = gst_element_factory_make ("playbin", "playbin");
-       video_sink = gst_element_factory_make ("gtksink", NULL);
-       g_object_set (self->priv->playbin, "video-sink", video_sink, NULL);
+
+       settings = g_settings_new (GTHUMB_GSTREAMER_TOOLS_SCHEMA);
+       if (g_settings_get_boolean (settings, PREF_GSTREAMER_USE_HARDWARE_ACCEL)) {
+               GstElement *video_bin;
+               GstElement *glupload;
+               GstPad     *pad;
+               GstPad     *ghost_pad;
+
+               /* pipeline taken from GNOME Twitch */
+
+               video_sink = gst_element_factory_make ("gtkglsink", "sink");
+               video_bin = gst_bin_new ("video_bin");
+               glupload = gst_element_factory_make ("glupload", NULL);
+               gst_bin_add_many (GST_BIN(video_bin), glupload, video_sink, NULL);
+               gst_element_link_many (glupload, video_sink, NULL);
+               pad = gst_element_get_static_pad (glupload, "sink");
+               ghost_pad = gst_ghost_pad_new ("sink", pad);
+               gst_pad_set_active (ghost_pad, TRUE);
+               gst_element_add_pad (video_bin, ghost_pad);
+               g_object_set (self->priv->playbin, "video-sink", video_bin, NULL);
+       }
+       else {
+               video_sink = gst_element_factory_make ("gtksink", "sink");
+               g_object_set (self->priv->playbin, "video-sink", video_sink, NULL);
+       }
 
        g_object_get (video_sink, "widget", &self->priv->video_area, NULL);
        gtk_style_context_add_class (gtk_widget_get_style_context (self->priv->video_area), "video-player");
@@ -847,7 +870,6 @@ create_playbin (GthMediaViewerPage *self)
        gtk_stack_add_named (GTK_STACK (self->priv->area_box), self->priv->video_area, "video-area");
        gtk_widget_show (self->priv->video_area);
 
-       settings = g_settings_new (GTHUMB_GSTREAMER_TOOLS_SCHEMA);
        g_object_set (self->priv->playbin,
                      "volume", (double) g_settings_get_int (settings, PREF_GSTREAMER_TOOLS_VOLUME) / 100.0,
                      "force-aspect-ratio", TRUE,
diff --git a/extensions/gstreamer_tools/preferences.h b/extensions/gstreamer_tools/preferences.h
index 5a0b6413..930de65b 100644
--- a/extensions/gstreamer_tools/preferences.h
+++ b/extensions/gstreamer_tools/preferences.h
@@ -30,5 +30,6 @@
 
 #define  PREF_GSTREAMER_TOOLS_SCREESHOT_LOCATION "screenshot-location"
 #define  PREF_GSTREAMER_TOOLS_VOLUME             "volume"
+#define  PREF_GSTREAMER_USE_HARDWARE_ACCEL       "use-hardware-acceleration"
 
 #endif /* PREFERENCES_H */


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