gtk4: Enable GtkGraphicsOffload::black-background property when building with GTK 4.16

This allows offloading in more situations.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/576

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1673>
This commit is contained in:
Sebastian Dröge 2024-07-18 12:28:20 +03:00
parent 5a1d12419f
commit 380448587b
3 changed files with 9 additions and 0 deletions

View file

@ -57,6 +57,7 @@ doc = ["gst/v1_18"]
gtk_v4_10 = ["gtk/v4_10"] gtk_v4_10 = ["gtk/v4_10"]
gtk_v4_12 = ["gtk/v4_12", "gtk_v4_10"] gtk_v4_12 = ["gtk/v4_12", "gtk_v4_10"]
gtk_v4_14 = ["gtk/v4_14", "gtk_v4_12"] gtk_v4_14 = ["gtk/v4_14", "gtk_v4_12"]
gtk_v4_16 = ["gtk/v4_16", "gtk_v4_14"]
[package.metadata.capi] [package.metadata.capi]
min_version = "0.9.21" min_version = "0.9.21"

View file

@ -69,6 +69,10 @@ fn create_ui(app: &gtk::Application) {
{ {
let offload = gtk::GraphicsOffload::new(Some(&picture)); let offload = gtk::GraphicsOffload::new(Some(&picture));
offload.set_enabled(gtk::GraphicsOffloadEnabled::Enabled); offload.set_enabled(gtk::GraphicsOffloadEnabled::Enabled);
#[cfg(feature = "gtk_v4_16")]
{
offload.set_black_background(true);
}
vbox.append(&offload); vbox.append(&offload);
} }
#[cfg(not(feature = "gtk_v4_14"))] #[cfg(not(feature = "gtk_v4_14"))]

View file

@ -762,6 +762,10 @@ impl PaintableSink {
{ {
let offload = gtk::GraphicsOffload::new(Some(&picture)); let offload = gtk::GraphicsOffload::new(Some(&picture));
offload.set_enabled(gtk::GraphicsOffloadEnabled::Enabled); offload.set_enabled(gtk::GraphicsOffloadEnabled::Enabled);
#[cfg(feature = "gtk_v4_16")]
{
offload.set_black_background(true);
}
window.set_child(Some(&offload)); window.set_child(Some(&offload));
} }
#[cfg(not(feature = "gtk_v4_14"))] #[cfg(not(feature = "gtk_v4_14"))]