GST: Use GL acceleration

Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
Vasiliy Doylov 2025-06-21 13:22:53 +03:00
parent d57a6b4475
commit d0920db024
Signed by: NekoCWD
GPG key ID: B7BE22D44474A582
3 changed files with 17 additions and 12 deletions

View file

@ -39,6 +39,7 @@ public class EyeNeko.Application : Adw.Application {
public override void activate () {
base.activate ();
Gstreamer.instance.init ();
var win = this.active_window ?? new EyeNeko.Window (this);
win.present ();
var styling = new Gtk.CssProvider ();

View file

@ -152,11 +152,13 @@ public class EyeNeko.Gstreamer : Object {
private bool is_initialised = false;
public void init () {
if (is_initialised)
if (is_initialised) {
warning ("Gstreamer init duplicated");
return;
}
is_initialised = true;
viewfinder.bind_property ("paintable", this, "viewfinder-paintable", GLib.BindingFlags.SYNC_CREATE);
camerabin.set_property ("camera-source", camerasrc_wrapper);
camerabin.set_property ("viewfinder-sink", viewfinder);
color_correction_matrix.red_in_red = 1f;
color_correction_matrix.blue_in_blue = 1f;
color_correction_matrix.green_in_green = 0.9f;
@ -192,11 +194,18 @@ public class EyeNeko.Gstreamer : Object {
}
});
viewfinder.bind_property ("paintable", this, "viewfinder-paintable", GLib.BindingFlags.SYNC_CREATE);
Gdk.GLContext context;
viewfinder_paintable.get ("gl-context", out context);
if (context != null)
message ("GL supported");
if (context != null) {
message ("GL supported <3");
var gl_sink = Gst.ElementFactory.make ("glsinkbin");
gl_sink.set_property ("sink", viewfinder);
camerabin.set_property ("viewfinder-sink", gl_sink);
} else {
warning ("GL NOT supported. Viewfinder will be slow as shit");
camerabin.set_property ("viewfinder-sink", viewfinder);
}
camerabin.bus.add_watch (0, bus_callback);
}
@ -251,10 +260,4 @@ public class EyeNeko.Gstreamer : Object {
return _instance;
}
}
static string[] gst_args = {};
static construct {
unowned var a = gst_args;
Gst.init (ref a);
}
}

View file

@ -19,11 +19,12 @@
*/
int main (string[] args) {
Gst.init (ref args);
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Config.GETTEXT_PACKAGE);
var app = new EyeNeko.Application ();
EyeNeko.Gstreamer.instance.init ();
return app.run (args);
}