mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 18:30:08 +00:00
renderer: Pass the display as part of the vfunc
We allow realizing renderers without surfaces. But they still need a display, so pass it explicitly.
This commit is contained in:
parent
d21467e2e8
commit
df09975753
@ -35,6 +35,7 @@ G_DEFINE_TYPE (GskBroadwayRenderer, gsk_broadway_renderer, GSK_TYPE_RENDERER)
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gsk_broadway_renderer_realize (GskRenderer *renderer,
|
gsk_broadway_renderer_realize (GskRenderer *renderer,
|
||||||
|
GdkDisplay *display,
|
||||||
GdkSurface *surface,
|
GdkSurface *surface,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
@ -162,6 +162,7 @@ gsk_gl_renderer_new (void)
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gsk_gl_renderer_realize (GskRenderer *renderer,
|
gsk_gl_renderer_realize (GskRenderer *renderer,
|
||||||
|
GdkDisplay *display,
|
||||||
GdkSurface *surface,
|
GdkSurface *surface,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@ -169,7 +170,6 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
|
|||||||
GskGLRenderer *self = (GskGLRenderer *)renderer;
|
GskGLRenderer *self = (GskGLRenderer *)renderer;
|
||||||
GdkGLContext *context = NULL;
|
GdkGLContext *context = NULL;
|
||||||
GskGLDriver *driver = NULL;
|
GskGLDriver *driver = NULL;
|
||||||
GdkDisplay *display;
|
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
gboolean debug_shaders = FALSE;
|
gboolean debug_shaders = FALSE;
|
||||||
GdkGLAPI api;
|
GdkGLAPI api;
|
||||||
@ -182,15 +182,9 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
|
|||||||
g_assert (self->command_queue == NULL);
|
g_assert (self->command_queue == NULL);
|
||||||
|
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
{
|
|
||||||
display = gdk_display_get_default (); /* FIXME: allow different displays somehow ? */
|
|
||||||
context = gdk_display_create_gl_context (display, error);
|
context = gdk_display_create_gl_context (display, error);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
display = gdk_surface_get_display (surface);
|
|
||||||
context = gdk_surface_create_gl_context (surface, error);
|
context = gdk_surface_create_gl_context (surface, error);
|
||||||
}
|
|
||||||
|
|
||||||
if (!context || !gdk_gl_context_realize (context, error))
|
if (!context || !gdk_gl_context_realize (context, error))
|
||||||
goto failure;
|
goto failure;
|
||||||
|
@ -188,18 +188,13 @@ gsk_gpu_renderer_get_frame (GskGpuRenderer *self)
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gsk_gpu_renderer_realize (GskRenderer *renderer,
|
gsk_gpu_renderer_realize (GskRenderer *renderer,
|
||||||
|
GdkDisplay *display,
|
||||||
GdkSurface *surface,
|
GdkSurface *surface,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GskGpuRenderer *self = GSK_GPU_RENDERER (renderer);
|
GskGpuRenderer *self = GSK_GPU_RENDERER (renderer);
|
||||||
GskGpuRendererPrivate *priv = gsk_gpu_renderer_get_instance_private (self);
|
GskGpuRendererPrivate *priv = gsk_gpu_renderer_get_instance_private (self);
|
||||||
GskGpuOptimizations context_optimizations;
|
GskGpuOptimizations context_optimizations;
|
||||||
GdkDisplay *display;
|
|
||||||
|
|
||||||
if (surface)
|
|
||||||
display = gdk_surface_get_display (surface);
|
|
||||||
else
|
|
||||||
display = gdk_display_get_default ();
|
|
||||||
|
|
||||||
priv->device = GSK_GPU_RENDERER_GET_CLASS (self)->get_device (display, error);
|
priv->device = GSK_GPU_RENDERER_GET_CLASS (self)->get_device (display, error);
|
||||||
if (priv->device == NULL)
|
if (priv->device == NULL)
|
||||||
|
@ -50,6 +50,7 @@ G_DEFINE_TYPE (GskCairoRenderer, gsk_cairo_renderer, GSK_TYPE_RENDERER)
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gsk_cairo_renderer_realize (GskRenderer *renderer,
|
gsk_cairo_renderer_realize (GskRenderer *renderer,
|
||||||
|
GdkDisplay *display,
|
||||||
GdkSurface *surface,
|
GdkSurface *surface,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
@ -102,6 +102,7 @@ static GParamSpec *gsk_renderer_properties[N_PROPS];
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gsk_renderer_real_realize (GskRenderer *self,
|
gsk_renderer_real_realize (GskRenderer *self,
|
||||||
|
GdkDisplay *display,
|
||||||
GdkSurface *surface,
|
GdkSurface *surface,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@ -255,6 +256,32 @@ gsk_renderer_is_realized (GskRenderer *renderer)
|
|||||||
return priv->is_realized;
|
return priv->is_realized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gsk_renderer_do_realize (GskRenderer *renderer,
|
||||||
|
GdkDisplay *display,
|
||||||
|
GdkSurface *surface,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer);
|
||||||
|
|
||||||
|
if (surface)
|
||||||
|
priv->surface = g_object_ref (surface);
|
||||||
|
|
||||||
|
if (!GSK_RENDERER_GET_CLASS (renderer)->realize (renderer, display, surface, error))
|
||||||
|
{
|
||||||
|
g_clear_object (&priv->surface);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->is_realized = TRUE;
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (renderer), "realized");
|
||||||
|
if (surface)
|
||||||
|
g_object_notify (G_OBJECT (renderer), "surface");
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gsk_renderer_realize:
|
* gsk_renderer_realize:
|
||||||
* @renderer: a `GskRenderer`
|
* @renderer: a `GskRenderer`
|
||||||
@ -277,21 +304,26 @@ gsk_renderer_realize (GskRenderer *renderer,
|
|||||||
GdkSurface *surface,
|
GdkSurface *surface,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer);
|
|
||||||
|
|
||||||
g_return_val_if_fail (GSK_IS_RENDERER (renderer), FALSE);
|
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 (!gsk_renderer_is_realized (renderer), FALSE);
|
||||||
g_return_val_if_fail (surface == NULL || GDK_IS_SURFACE (surface), FALSE);
|
g_return_val_if_fail (surface == NULL || GDK_IS_SURFACE (surface), FALSE);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
if (surface)
|
if (surface == NULL)
|
||||||
priv->surface = g_object_ref (surface);
|
|
||||||
|
|
||||||
if (!GSK_RENDERER_GET_CLASS (renderer)->realize (renderer, surface, error))
|
|
||||||
{
|
{
|
||||||
g_clear_object (&priv->surface);
|
return gsk_renderer_do_realize (renderer,
|
||||||
return FALSE;
|
gdk_display_get_default (),
|
||||||
|
NULL,
|
||||||
|
error);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return gsk_renderer_do_realize (renderer,
|
||||||
|
gdk_surface_get_display (surface),
|
||||||
|
surface,
|
||||||
|
error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
priv->is_realized = TRUE;
|
priv->is_realized = TRUE;
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ struct _GskRendererClass
|
|||||||
gboolean supports_offload;
|
gboolean supports_offload;
|
||||||
|
|
||||||
gboolean (* realize) (GskRenderer *renderer,
|
gboolean (* realize) (GskRenderer *renderer,
|
||||||
|
GdkDisplay *display,
|
||||||
GdkSurface *surface,
|
GdkSurface *surface,
|
||||||
GError **error);
|
GError **error);
|
||||||
void (* unrealize) (GskRenderer *renderer);
|
void (* unrealize) (GskRenderer *renderer);
|
||||||
|
Loading…
Reference in New Issue
Block a user