diff --git a/gsk/gskrenderer.c b/gsk/gskrenderer.c index 0e52c67000..156c448faf 100644 --- a/gsk/gskrenderer.c +++ b/gsk/gskrenderer.c @@ -293,6 +293,8 @@ gsk_renderer_do_realize (GskRenderer *renderer, * * Since GTK 4.6, the surface may be `NULL`, which allows using * renderers without having to create a surface. + * Since GTK 4.14, it is recommended to use [method@Gsk.Renderer.realize_for_display] + * instead. * * Note that it is mandatory to call [method@Gsk.Renderer.unrealize] before * destroying the renderer. @@ -325,13 +327,33 @@ gsk_renderer_realize (GskRenderer *renderer, } } - priv->is_realized = TRUE; +/** + * gsk_renderer_realize_for_display: + * @renderer: a `GskRenderer` + * @display: the `GdkDisplay` renderer will be used on + * @error: return location for an error + * + * Creates the resources needed by the @renderer to render the scene + * graph. + * + * Note that it is mandatory to call [method@Gsk.Renderer.unrealize] before + * destroying the renderer. + * + * Returns: Whether the renderer was successfully realized + * + * Since: 4.14 + */ +gboolean +gsk_renderer_realize_for_display (GskRenderer *renderer, + GdkDisplay *display, + GError **error) +{ + g_return_val_if_fail (GSK_IS_RENDERER (renderer), FALSE); + g_return_val_if_fail (!gsk_renderer_is_realized (renderer), FALSE); + g_return_val_if_fail (display == NULL || GDK_IS_DISPLAY (display), FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - g_object_notify (G_OBJECT (renderer), "realized"); - if (surface) - g_object_notify (G_OBJECT (renderer), "surface"); - - return TRUE; + return gsk_renderer_do_realize (renderer, display, NULL, error); } /** diff --git a/gsk/gskrenderer.h b/gsk/gskrenderer.h index af73141e2b..97a828b5b7 100644 --- a/gsk/gskrenderer.h +++ b/gsk/gskrenderer.h @@ -47,6 +47,10 @@ GDK_AVAILABLE_IN_ALL gboolean gsk_renderer_realize (GskRenderer *renderer, GdkSurface *surface, GError **error); +GDK_AVAILABLE_IN_4_14 +gboolean gsk_renderer_realize_for_display (GskRenderer *renderer, + GdkDisplay *display, + GError **error); GDK_AVAILABLE_IN_ALL void gsk_renderer_unrealize (GskRenderer *renderer); GDK_AVAILABLE_IN_ALL