| 1 | /* GTK - The GIMP Toolkit |
| 2 | * |
| 3 | * Copyright (C) 2023 Red Hat, Inc. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | * Author: |
| 19 | * Matthias Clasen <[email protected]> |
| 20 | */ |
| 21 | |
| 22 | #include "config.h"cxx . . $ `<file>/build/config.h`/ |
| 23 | |
| 24 | #include "gtkbinlayout.h"cxx . . $ `<file>/gtk/gtkbinlayout.h`/ |
| 25 | #include "gtkgraphicsoffload.h"cxx . . $ `<file>/gtk/gtkgraphicsoffload.h`/ |
| 26 | #include "gtksnapshotprivate.h"cxx . . $ `<file>/gtk/gtksnapshotprivate.h`/ |
| 27 | #include "gtkwidgetprivate.h"cxx . . $ `<file>/gtk/gtkwidgetprivate.h`/ |
| 28 | #include "gtkprivate.h"cxx . . $ `<file>/gtk/gtkprivate.h`/ |
| 29 | #include "gdk/gdksurfaceprivate.h"cxx . . $ `<file>/gdk/gdksurfaceprivate.h`/ |
| 30 | #include "gdk/gdksubsurfaceprivate.h"cxx . . $ `<file>/gdk/gdksubsurfaceprivate.h`/ |
| 31 | #include "gdk/gdkrgbaprivate.h"cxx . . $ `<file>/gdk/gdkrgbaprivate.h`/ |
| 32 | #include "gtktypebuiltins.h"cxx . . $ `<file>/build/gtk/gtktypebuiltins.h`/ |
| 33 | |
| 34 | /** |
| 35 | * GtkGraphicsOffload: |
| 36 | * |
| 37 | * Bypasses gsk rendering by passing the content of its child directly to the compositor. |
| 38 | * |
| 39 | * Graphics offload is an optimization to reduce overhead and battery use that is |
| 40 | * most useful for video content. It only works on some platforms and in certain |
| 41 | * situations. GTK will automatically fall back to normal rendering if it doesn't. |
| 42 | * |
| 43 | * Graphics offload is most efficient if there are no controls drawn on top of the |
| 44 | * video content. |
| 45 | * |
| 46 | * You should consider using graphics offload for your main widget if it shows |
| 47 | * frequently changing content (such as a video, or a VM display) and you provide |
| 48 | * the content in the form of dmabuf textures (see [[email protected]]), |
| 49 | * in particular if it may be fullscreen. |
| 50 | * |
| 51 | * Numerous factors can prohibit graphics offload: |
| 52 | * |
| 53 | * - Unsupported platforms. Currently, graphics offload only works on Linux with Wayland. |
| 54 | * |
| 55 | * - Clipping, such as rounded corners that cause the video content to not be rectangular |
| 56 | * |
| 57 | * - Unsupported dmabuf formats (see [[email protected]_dmabuf_formats]) |
| 58 | * |
| 59 | * - Translucent video content (content with an alpha channel, even if it isn't used) |
| 60 | * |
| 61 | * - Transforms that are more complex than translations and scales |
| 62 | * |
| 63 | * - Filters such as opacity, grayscale or similar |
| 64 | * |
| 65 | * To investigate problems related graphics offload, GTK offers debug flags to print |
| 66 | * out information about graphics offload and dmabuf use: |
| 67 | * |
| 68 | * GDK_DEBUG=offload |
| 69 | * GDK_DEBUG=dmabuf |
| 70 | * |
| 71 | * The GTK inspector provides a visual debugging tool for graphics offload. |
| 72 | * |
| 73 | * Since: 4.14 |
| 74 | */ |
| 75 | |
| 76 | struct _GtkGraphicsOffloadcxx . . $ _GtkGraphicsOffload# |
| 77 | { |
| 78 | GtkWidgetcxx . . $ GtkWidget# parent_instancecxx . . $ _GtkGraphicsOffload#parent_instance.; |
| 79 | |
| 80 | GtkWidgetcxx . . $ GtkWidget# *childcxx . . $ _GtkGraphicsOffload#child.; |
| 81 | |
| 82 | GdkSubsurfacecxx . . $ GdkSubsurface# *subsurfacecxx . . $ _GtkGraphicsOffload#subsurface.; |
| 83 | |
| 84 | GtkGraphicsOffloadEnabledcxx . . $ GtkGraphicsOffloadEnabled# enabledcxx . . $ _GtkGraphicsOffload#enabled.; |
| 85 | gbooleancxx . . $ gboolean# black_backgroundcxx . . $ _GtkGraphicsOffload#black_background.; |
| 86 | }; |
| 87 | |
| 88 | struct _GtkGraphicsOffloadClasscxx . . $ _GtkGraphicsOffloadClass# |
| 89 | { |
| 90 | GtkWidgetClasscxx . . $ GtkWidgetClass# parent_classcxx . . $ _GtkGraphicsOffloadClass#parent_class.; |
| 91 | }; |
| 92 | |
| 93 | enumcxx . . $ $anonymous_type_4c1939768a8365ce_0# |
| 94 | { |
| 95 | PROP_0cxx . . $ PROP_0., |
| 96 | PROP_CHILDcxx . . $ PROP_CHILD., |
| 97 | PROP_ENABLEDcxx . . $ PROP_ENABLED., |
| 98 | PROP_BLACK_BACKGROUNDcxx . . $ PROP_BLACK_BACKGROUND., |
| 99 | LAST_PROPcxx . . $ LAST_PROP., |
| 100 | }; |
| 101 | |
| 102 | static GParamSpeccxx . . $ GParamSpec# *propertiescxx . . $ properties.[LAST_PROPcxx . . $ LAST_PROP.] = { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, }; |
| 103 | |
| 104 | G_DEFINE_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:1834:9`! (GtkGraphicsOffload, gtk_graphics_offload, GTK_TYPE_WIDGETcxx . . $ `gtk/gtkwidget.h:43:9`!) |
| 105 | |
| 106 | static void |
| 107 | gtk_graphics_offload_initcxx . . $ gtk_graphics_offload_init(aa178cb5a2f714b6). (GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self) |
| 108 | { |
| 109 | self->enabledcxx . . $ _GtkGraphicsOffload#enabled. = GTK_GRAPHICS_OFFLOAD_ENABLEDcxx . . $ GTK_GRAPHICS_OFFLOAD_ENABLED.; |
| 110 | } |
| 111 | |
| 112 | static void |
| 113 | gtk_graphics_offload_disposecxx . . $ gtk_graphics_offload_dispose(6087475fa43034d3). (GObjectcxx . . $ GObject# *object) |
| 114 | { |
| 115 | GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self = GTK_GRAPHICS_OFFLOADcxx . . $ GTK_GRAPHICS_OFFLOAD(997389679c29b42e). (object); |
| 116 | |
| 117 | g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (&self->child, gtk_widget_unparent); |
| 118 | |
| 119 | G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (gtk_graphics_offload_parent_class)->disposecxx . . $ _GObjectClass#dispose. (object); |
| 120 | } |
| 121 | |
| 122 | static void |
| 123 | gtk_graphics_offload_set_propertycxx . . $ gtk_graphics_offload_set_property(d7c4bb29f36c0dc4). (GObjectcxx . . $ GObject# *object, |
| 124 | guintcxx . . $ guint# property_id, |
| 125 | const GValuecxx . . $ GValue# *value, |
| 126 | GParamSpeccxx . . $ GParamSpec# *pspec) |
| 127 | { |
| 128 | GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self = GTK_GRAPHICS_OFFLOADcxx . . $ GTK_GRAPHICS_OFFLOAD(997389679c29b42e). (object); |
| 129 | |
| 130 | switch (property_id) |
| 131 | { |
| 132 | case PROP_CHILDcxx . . $ PROP_CHILD.: |
| 133 | gtk_graphics_offload_set_childcxx . . $ gtk_graphics_offload_set_child(ee3ceabc02ead0db). (self, g_value_get_objectcxx . . $ g_value_get_object(e12dff36056c2cce). (value)); |
| 134 | break; |
| 135 | |
| 136 | case PROP_ENABLEDcxx . . $ PROP_ENABLED.: |
| 137 | gtk_graphics_offload_set_enabledcxx . . $ gtk_graphics_offload_set_enabled(eff682f21dd4970b). (self, g_value_get_enumcxx . . $ g_value_get_enum(f890c5c75ead5b21). (value)); |
| 138 | break; |
| 139 | |
| 140 | case PROP_BLACK_BACKGROUNDcxx . . $ PROP_BLACK_BACKGROUND.: |
| 141 | gtk_graphics_offload_set_black_backgroundcxx . . $ gtk_graphics_offload_set_black_background(5f8ae89241250521). (self, g_value_get_booleancxx . . $ g_value_get_boolean(f890c5c75ead5b21). (value)); |
| 142 | break; |
| 143 | |
| 144 | default: |
| 145 | G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, property_id, pspec); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | static void |
| 150 | gtk_graphics_offload_get_propertycxx . . $ gtk_graphics_offload_get_property(cee2c52f22407c66). (GObjectcxx . . $ GObject# *object, |
| 151 | guintcxx . . $ guint# property_id, |
| 152 | GValuecxx . . $ GValue# *value, |
| 153 | GParamSpeccxx . . $ GParamSpec# *pspec) |
| 154 | { |
| 155 | GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self = GTK_GRAPHICS_OFFLOADcxx . . $ GTK_GRAPHICS_OFFLOAD(997389679c29b42e). (object); |
| 156 | |
| 157 | switch (property_id) |
| 158 | { |
| 159 | case PROP_CHILDcxx . . $ PROP_CHILD.: |
| 160 | g_value_set_objectcxx . . $ g_value_set_object(e945b84c1e9702f). (value, gtk_graphics_offload_get_childcxx . . $ gtk_graphics_offload_get_child(d5265ea7c51f4f0f). (self)); |
| 161 | break; |
| 162 | |
| 163 | case PROP_ENABLEDcxx . . $ PROP_ENABLED.: |
| 164 | g_value_set_enumcxx . . $ g_value_set_enum(b698c61e8e30c4ea). (value, gtk_graphics_offload_get_enabledcxx . . $ gtk_graphics_offload_get_enabled(d18e9f22eac9bda7). (self)); |
| 165 | break; |
| 166 | |
| 167 | case PROP_BLACK_BACKGROUNDcxx . . $ PROP_BLACK_BACKGROUND.: |
| 168 | g_value_set_booleancxx . . $ g_value_set_boolean(b698c61e8e30c4ea). (value, gtk_graphics_offload_get_black_backgroundcxx . . $ gtk_graphics_offload_get_black_background(f10c70b81a7061d4). (self)); |
| 169 | break; |
| 170 | |
| 171 | default: |
| 172 | G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (object, property_id, pspec); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | static void |
| 177 | sync_subsurfacecxx . . $ sync_subsurface(aa178cb5a2f714b6). (GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self) |
| 178 | { |
| 179 | GtkWidgetcxx . . $ GtkWidget# *widget = GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self); |
| 180 | |
| 181 | if (gtk_widget_get_realizedcxx . . $ gtk_widget_get_realized(9247ef2dc26c5426). (widget) && self->enabledcxx . . $ _GtkGraphicsOffload#enabled. != GTK_GRAPHICS_OFFLOAD_DISABLEDcxx . . $ GTK_GRAPHICS_OFFLOAD_DISABLED.) |
| 182 | { |
| 183 | if (!self->subsurfacecxx . . $ _GtkGraphicsOffload#subsurface.) |
| 184 | self->subsurfacecxx . . $ _GtkGraphicsOffload#subsurface. = gdk_surface_create_subsurfacecxx . . $ gdk_surface_create_subsurface(e0f4cf05cf5c49a1). (gtk_widget_get_surfacecxx . . $ gtk_widget_get_surface(f29b3bfced39beb6). (widget)); |
| 185 | } |
| 186 | else |
| 187 | { |
| 188 | g_clear_objectcxx . . $ `<external>/1341695927569185362/gobject.h:695:9`! (&self->subsurface); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | static void |
| 193 | gtk_graphics_offload_realizecxx . . $ gtk_graphics_offload_realize(d7cf858254b37903). (GtkWidgetcxx . . $ GtkWidget# *widget) |
| 194 | { |
| 195 | GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self = GTK_GRAPHICS_OFFLOADcxx . . $ GTK_GRAPHICS_OFFLOAD(997389679c29b42e). (widget); |
| 196 | |
| 197 | GTK_WIDGET_CLASScxx . . $ `gtk/gtkwidget.h:45:9`! (gtk_graphics_offload_parent_class)->realizecxx . . $ _GtkWidgetClass#realize. (widget); |
| 198 | |
| 199 | sync_subsurfacecxx . . $ sync_subsurface(aa178cb5a2f714b6). (self); |
| 200 | } |
| 201 | |
| 202 | static void |
| 203 | gtk_graphics_offload_unrealizecxx . . $ gtk_graphics_offload_unrealize(d7cf858254b37903). (GtkWidgetcxx . . $ GtkWidget# *widget) |
| 204 | { |
| 205 | GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self = GTK_GRAPHICS_OFFLOADcxx . . $ GTK_GRAPHICS_OFFLOAD(997389679c29b42e). (widget); |
| 206 | |
| 207 | GTK_WIDGET_CLASScxx . . $ `gtk/gtkwidget.h:45:9`! (gtk_graphics_offload_parent_class)->unrealizecxx . . $ _GtkWidgetClass#unrealize. (widget); |
| 208 | |
| 209 | sync_subsurfacecxx . . $ sync_subsurface(aa178cb5a2f714b6). (self); |
| 210 | } |
| 211 | |
| 212 | static void |
| 213 | gtk_graphics_offload_snapshotcxx . . $ gtk_graphics_offload_snapshot(80012d1141bb3efa). (GtkWidgetcxx . . $ GtkWidget# *widget, |
| 214 | GtkSnapshotcxx . . $ GtkSnapshot# *snapshot) |
| 215 | { |
| 216 | GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self = GTK_GRAPHICS_OFFLOADcxx . . $ GTK_GRAPHICS_OFFLOAD(997389679c29b42e). (widget); |
| 217 | |
| 218 | if (self->subsurfacecxx . . $ _GtkGraphicsOffload#subsurface.) |
| 219 | gtk_snapshot_push_subsurfacecxx . . $ gtk_snapshot_push_subsurface(cc6f8626482450cd). (snapshot, self->subsurfacecxx . . $ _GtkGraphicsOffload#subsurface.); |
| 220 | |
| 221 | if (self->black_backgroundcxx . . $ _GtkGraphicsOffload#black_background.) |
| 222 | gtk_snapshot_append_colorcxx . . $ gtk_snapshot_append_color(402330aed7850122). (snapshot, |
| 223 | &GDK_RGBA_BLACKcxx . . $ `gdk/gdkrgbaprivate.h:40:9`!, |
| 224 | &GRAPHENE_RECT_INITcxx . . $ `<external>/7539008420172022992/graphene-rect.h:50:9`! (0, 0, |
| 225 | gtk_widget_get_width (widget), |
| 226 | gtk_widget_get_height (widget))); |
| 227 | |
| 228 | if (self->childcxx . . $ _GtkGraphicsOffload#child.) |
| 229 | gtk_widget_snapshot_childcxx . . $ gtk_widget_snapshot_child(70f87a8b59fe0054). (widget, self->childcxx . . $ _GtkGraphicsOffload#child., snapshot); |
| 230 | |
| 231 | if (self->subsurfacecxx . . $ _GtkGraphicsOffload#subsurface.) |
| 232 | gtk_snapshot_popcxx . . $ gtk_snapshot_pop(afbd0a0317d5665f). (snapshot); |
| 233 | } |
| 234 | |
| 235 | static void |
| 236 | gtk_graphics_offload_class_initcxx . . $ gtk_graphics_offload_class_init(6c6f5ff12c5bc5ab). (GtkGraphicsOffloadClasscxx . . $ GtkGraphicsOffloadClass# *class) |
| 237 | { |
| 238 | GObjectClasscxx . . $ GObjectClass# *object_class = G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (class); |
| 239 | GtkWidgetClasscxx . . $ GtkWidgetClass# *widget_class = GTK_WIDGET_CLASScxx . . $ `gtk/gtkwidget.h:45:9`! (class); |
| 240 | |
| 241 | object_class->disposecxx . . $ _GObjectClass#dispose. = gtk_graphics_offload_disposecxx . . $ gtk_graphics_offload_dispose(6087475fa43034d3).; |
| 242 | object_class->set_propertycxx . . $ _GObjectClass#set_property. = gtk_graphics_offload_set_propertycxx . . $ gtk_graphics_offload_set_property(d7c4bb29f36c0dc4).; |
| 243 | object_class->get_propertycxx . . $ _GObjectClass#get_property. = gtk_graphics_offload_get_propertycxx . . $ gtk_graphics_offload_get_property(cee2c52f22407c66).; |
| 244 | |
| 245 | widget_class->realizecxx . . $ _GtkWidgetClass#realize. = gtk_graphics_offload_realizecxx . . $ gtk_graphics_offload_realize(d7cf858254b37903).; |
| 246 | widget_class->unrealizecxx . . $ _GtkWidgetClass#unrealize. = gtk_graphics_offload_unrealizecxx . . $ gtk_graphics_offload_unrealize(d7cf858254b37903).; |
| 247 | widget_class->snapshotcxx . . $ _GtkWidgetClass#snapshot. = gtk_graphics_offload_snapshotcxx . . $ gtk_graphics_offload_snapshot(80012d1141bb3efa).; |
| 248 | |
| 249 | /** |
| 250 | * GtkGraphicsOffload:child: |
| 251 | * |
| 252 | * The child widget. |
| 253 | * |
| 254 | * Since: 4.14 |
| 255 | */ |
| 256 | propertiescxx . . $ properties.[PROP_CHILDcxx . . $ PROP_CHILD.] = g_param_spec_objectcxx . . $ g_param_spec_object(faf99966f027a127). ("child", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 257 | GTK_TYPE_WIDGETcxx . . $ `gtk/gtkwidget.h:43:9`!, |
| 258 | GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`! | G_PARAM_EXPLICIT_NOTIFYcxx . . $ G_PARAM_EXPLICIT_NOTIFY. | G_PARAM_STATIC_STRINGScxx . . $ `<external>/7453068347527694854/gparam.h:187:9`!); |
| 259 | |
| 260 | /** |
| 261 | * GtkGraphicsOffload:enabled: |
| 262 | * |
| 263 | * Whether graphics offload is enabled. |
| 264 | * |
| 265 | * Since: 4.14 |
| 266 | */ |
| 267 | propertiescxx . . $ properties.[PROP_ENABLEDcxx . . $ PROP_ENABLED.] = g_param_spec_enumcxx . . $ g_param_spec_enum(bfeb217b5dc6c0ac). ("enabled", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 268 | GTK_TYPE_GRAPHICS_OFFLOAD_ENABLEDcxx . . $ `build/gtk/gtktypebuiltins.h:270:9`!, |
| 269 | GTK_GRAPHICS_OFFLOAD_ENABLEDcxx . . $ GTK_GRAPHICS_OFFLOAD_ENABLED., |
| 270 | GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`! | G_PARAM_EXPLICIT_NOTIFYcxx . . $ G_PARAM_EXPLICIT_NOTIFY. | G_PARAM_STATIC_STRINGScxx . . $ `<external>/7453068347527694854/gparam.h:187:9`!); |
| 271 | |
| 272 | /** |
| 273 | * GtkGraphicsOffload:black-background: |
| 274 | * |
| 275 | * Whether to draw a black background. |
| 276 | * |
| 277 | * Since: 4.16 |
| 278 | */ |
| 279 | propertiescxx . . $ properties.[PROP_BLACK_BACKGROUNDcxx . . $ PROP_BLACK_BACKGROUND.] = g_param_spec_booleancxx . . $ g_param_spec_boolean(315d86b79c0116e0). ("black-background", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 280 | FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!, |
| 281 | GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`! | G_PARAM_EXPLICIT_NOTIFYcxx . . $ G_PARAM_EXPLICIT_NOTIFY. | G_PARAM_STATIC_STRINGScxx . . $ `<external>/7453068347527694854/gparam.h:187:9`!); |
| 282 | |
| 283 | g_object_class_install_propertiescxx . . $ g_object_class_install_properties(569d03e6a4088541). (object_class, LAST_PROPcxx . . $ LAST_PROP., propertiescxx . . $ properties.); |
| 284 | |
| 285 | gtk_widget_class_set_layout_manager_typecxx . . $ gtk_widget_class_set_layout_manager_type(2a839cbf4b1b4191). (widget_class, GTK_TYPE_BIN_LAYOUTcxx . . $ `gtk/gtkbinlayout.h:23:9`!); |
| 286 | gtk_widget_class_set_css_namecxx . . $ gtk_widget_class_set_css_name(6333614c746ab65a). (widget_class, "graphicsoffload"); |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * gtk_graphics_offload_new: |
| 291 | * @child: (nullable): the child widget |
| 292 | * |
| 293 | * Creates a new GtkGraphicsOffload widget. |
| 294 | * |
| 295 | * Returns: the new widget |
| 296 | * |
| 297 | * Since: 4.14 |
| 298 | */ |
| 299 | GtkWidgetcxx . . $ GtkWidget# * |
| 300 | gtk_graphics_offload_newcxx . . $ gtk_graphics_offload_new(ef973e1b01680070). (GtkWidgetcxx . . $ GtkWidget# *child) |
| 301 | { |
| 302 | return g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_GRAPHICS_OFFLOADcxx . . $ `gtk/gtkgraphicsoffload.h:32:9`!, |
| 303 | "child", child, |
| 304 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * gtk_graphics_offload_set_child: |
| 309 | * @self: a `GtkGraphicsOffload` |
| 310 | * @child: (nullable): the child widget |
| 311 | * |
| 312 | * Sets the child of @self. |
| 313 | * |
| 314 | * Since: 4.14 |
| 315 | */ |
| 316 | void |
| 317 | gtk_graphics_offload_set_childcxx . . $ gtk_graphics_offload_set_child(ee3ceabc02ead0db). (GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self, |
| 318 | GtkWidgetcxx . . $ GtkWidget# *child) |
| 319 | { |
| 320 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_GRAPHICS_OFFLOAD (self)); |
| 321 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (child == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || self->child == child || (GTK_IS_WIDGETcxx . . $ `gtk/gtkwidget.h:46:9`! (child) &>k_widget_get_parent (child) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)); |
| 322 | |
| 323 | if (self->childcxx . . $ _GtkGraphicsOffload#child. == child) |
| 324 | return; |
| 325 | |
| 326 | g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (&self->child, gtk_widget_unparent); |
| 327 | |
| 328 | if (child) |
| 329 | { |
| 330 | self->childcxx . . $ _GtkGraphicsOffload#child. = child; |
| 331 | gtk_widget_set_parentcxx . . $ gtk_widget_set_parent(4f261c0971c30e7). (child, GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self)); |
| 332 | } |
| 333 | |
| 334 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_CHILDcxx . . $ PROP_CHILD.]); |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * gtk_graphics_offload_get_child: |
| 339 | * @self: a `GtkGraphicsOffload` |
| 340 | * |
| 341 | * Gets the child of @self. |
| 342 | * |
| 343 | * Returns: (nullable) (transfer none): the child widget |
| 344 | * |
| 345 | * Since: 4.14 |
| 346 | */ |
| 347 | GtkWidgetcxx . . $ GtkWidget# * |
| 348 | gtk_graphics_offload_get_childcxx . . $ gtk_graphics_offload_get_child(d5265ea7c51f4f0f). (GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self) |
| 349 | { |
| 350 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_GRAPHICS_OFFLOAD (self), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 351 | |
| 352 | return self->childcxx . . $ _GtkGraphicsOffload#child.; |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * gtk_graphics_offload_set_enabled: |
| 357 | * @self: a `GtkGraphicsOffload` |
| 358 | * @enabled: whether to enable offload |
| 359 | * |
| 360 | * Sets whether this GtkGraphicsOffload widget will attempt |
| 361 | * to offload the content of its child widget. |
| 362 | * |
| 363 | * Since: 4.14 |
| 364 | */ |
| 365 | void |
| 366 | gtk_graphics_offload_set_enabledcxx . . $ gtk_graphics_offload_set_enabled(eff682f21dd4970b). (GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self, |
| 367 | GtkGraphicsOffloadEnabledcxx . . $ GtkGraphicsOffloadEnabled# enabled) |
| 368 | { |
| 369 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_GRAPHICS_OFFLOAD (self)); |
| 370 | |
| 371 | if (self->enabledcxx . . $ _GtkGraphicsOffload#enabled. == enabled) |
| 372 | return; |
| 373 | |
| 374 | self->enabledcxx . . $ _GtkGraphicsOffload#enabled. = enabled; |
| 375 | |
| 376 | sync_subsurfacecxx . . $ sync_subsurface(aa178cb5a2f714b6). (self); |
| 377 | gtk_widget_queue_drawcxx . . $ gtk_widget_queue_draw(d7cf858254b37903). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self)); |
| 378 | |
| 379 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_ENABLEDcxx . . $ PROP_ENABLED.]); |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * gtk_graphics_offload_get_enabled: |
| 384 | * @self: a `GtkGraphicsOffload` |
| 385 | * |
| 386 | * Returns whether offload is enabled for @self. |
| 387 | * |
| 388 | * Returns: whether offload is enabled |
| 389 | * |
| 390 | * Since: 4.14 |
| 391 | */ |
| 392 | GtkGraphicsOffloadEnabledcxx . . $ GtkGraphicsOffloadEnabled# |
| 393 | gtk_graphics_offload_get_enabledcxx . . $ gtk_graphics_offload_get_enabled(d18e9f22eac9bda7). (GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self) |
| 394 | { |
| 395 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_GRAPHICS_OFFLOAD (self), TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!); |
| 396 | |
| 397 | return self->enabledcxx . . $ _GtkGraphicsOffload#enabled.; |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * gtk_graphics_offload_set_black_background: |
| 402 | * @self: a `GtkGraphicsOffload` |
| 403 | * @value: whether to draw a black background behind the content |
| 404 | * |
| 405 | * Sets whether this GtkGraphicsOffload widget will draw a black |
| 406 | * background. |
| 407 | * |
| 408 | * A main use case for this is **_letterboxing_** where black bars are |
| 409 | * visible next to the content if the aspect ratio of the content does |
| 410 | * not match the dimensions of the monitor. |
| 411 | * |
| 412 | * Using this property for letterboxing instead of CSS allows compositors |
| 413 | * to show content with maximum efficiency, using direct scanout to avoid |
| 414 | * extra copies in the compositor. |
| 415 | * |
| 416 | * On Wayland, this is implemented using the |
| 417 | * [single-pixel buffer](https://wayland.app/protocols/single-pixel-buffer-v1) |
| 418 | * protocol. |
| 419 | * |
| 420 | * Since: 4.16 |
| 421 | */ |
| 422 | void |
| 423 | gtk_graphics_offload_set_black_backgroundcxx . . $ gtk_graphics_offload_set_black_background(5f8ae89241250521). (GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self, |
| 424 | gbooleancxx . . $ gboolean# value) |
| 425 | { |
| 426 | g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_GRAPHICS_OFFLOAD (self)); |
| 427 | |
| 428 | if (self->black_backgroundcxx . . $ _GtkGraphicsOffload#black_background. == value) |
| 429 | return; |
| 430 | |
| 431 | self->black_backgroundcxx . . $ _GtkGraphicsOffload#black_background. = value; |
| 432 | |
| 433 | gtk_widget_queue_drawcxx . . $ gtk_widget_queue_draw(d7cf858254b37903). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self)); |
| 434 | |
| 435 | g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), propertiescxx . . $ properties.[PROP_BLACK_BACKGROUNDcxx . . $ PROP_BLACK_BACKGROUND.]); |
| 436 | } |
| 437 | |
| 438 | /** |
| 439 | * gtk_graphics_offload_get_black_background: |
| 440 | * @self: a `GtkGraphicsOffload` |
| 441 | * |
| 442 | * Returns whether the widget draws a black background. |
| 443 | * |
| 444 | * See [[email protected]_black_background]. |
| 445 | * |
| 446 | * Returns: `TRUE` if black background is drawn |
| 447 | * |
| 448 | * Since: 4.16 |
| 449 | */ |
| 450 | gbooleancxx . . $ gboolean# |
| 451 | gtk_graphics_offload_get_black_backgroundcxx . . $ gtk_graphics_offload_get_black_background(f10c70b81a7061d4). (GtkGraphicsOffloadcxx . . $ GtkGraphicsOffload# *self) |
| 452 | { |
| 453 | g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_GRAPHICS_OFFLOAD (self), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 454 | |
| 455 | return self->black_backgroundcxx . . $ _GtkGraphicsOffload#black_background.; |
| 456 | } |