mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
ngl: Store the shared driver in the display
... instead of some random GL context.
This commit is contained in:
parent
e4f0418003
commit
dd666e4fe4
@ -24,6 +24,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <gdk/gdkglcontextprivate.h>
|
||||
#include <gdk/gdkdisplayprivate.h>
|
||||
#include <gdk/gdktextureprivate.h>
|
||||
#include <gsk/gskdebugprivate.h>
|
||||
#include <gsk/gskglshaderprivate.h>
|
||||
@ -447,30 +448,34 @@ gsk_ngl_driver_new (GskNglCommandQueue *command_queue,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_ngl_driver_from_shared_context:
|
||||
* @context: a shared `GdkGLContext` retrieved with gdk_gl_context_get_shared_context()
|
||||
* gsk_ngl_driver_for_display:
|
||||
* @display: A #GdkDisplay that is known to support GL
|
||||
* @debug_shaders: if debug information for shaders should be displayed
|
||||
* @error: location for error information
|
||||
*
|
||||
* Retrieves a driver for a shared context. Generally this is shared across all GL
|
||||
* Retrieves a driver for a shared display. Generally this is shared across all GL
|
||||
* contexts for a display so that fewer programs are necessary for driving output.
|
||||
*
|
||||
* Returns: (transfer full): a `GskNglDriver` if successful; otherwise %NULL and
|
||||
* @error is set.
|
||||
*/
|
||||
GskNglDriver *
|
||||
gsk_ngl_driver_from_shared_context (GdkGLContext *context,
|
||||
gboolean debug_shaders,
|
||||
GError **error)
|
||||
gsk_ngl_driver_for_display (GdkDisplay *display,
|
||||
gboolean debug_shaders,
|
||||
GError **error)
|
||||
{
|
||||
GdkGLContext *context;
|
||||
GskNglCommandQueue *command_queue = NULL;
|
||||
GskNglDriver *driver;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||
|
||||
if ((driver = g_object_get_data (G_OBJECT (context), "GSK_NGL_DRIVER")))
|
||||
if ((driver = g_object_get_data (G_OBJECT (display), "GSK_NGL_DRIVER")))
|
||||
return g_object_ref (driver);
|
||||
|
||||
context = gdk_display_get_gl_context (display);
|
||||
g_assert (context);
|
||||
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
/* Initially we create a command queue using the shared context. However,
|
||||
@ -484,7 +489,7 @@ gsk_ngl_driver_from_shared_context (GdkGLContext *context,
|
||||
if (!(driver = gsk_ngl_driver_new (command_queue, debug_shaders, error)))
|
||||
goto failure;
|
||||
|
||||
g_object_set_data_full (G_OBJECT (context),
|
||||
g_object_set_data_full (G_OBJECT (display),
|
||||
"GSK_NGL_DRIVER",
|
||||
g_object_ref (driver),
|
||||
g_object_unref);
|
||||
|
@ -136,7 +136,7 @@ struct _GskNglDriver
|
||||
guint in_frame : 1;
|
||||
};
|
||||
|
||||
GskNglDriver *gsk_ngl_driver_from_shared_context (GdkGLContext *context,
|
||||
GskNglDriver *gsk_ngl_driver_for_display (GdkDisplay *display,
|
||||
gboolean debug_shaders,
|
||||
GError **error);
|
||||
GskNglCommandQueue *gsk_ngl_driver_create_command_queue (GskNglDriver *self,
|
||||
|
@ -86,7 +86,6 @@ gsk_ngl_renderer_realize (GskRenderer *renderer,
|
||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||
GskNglRenderer *self = (GskNglRenderer *)renderer;
|
||||
GdkGLContext *context = NULL;
|
||||
GdkGLContext *shared_context;
|
||||
GskNglDriver *driver = NULL;
|
||||
gboolean ret = FALSE;
|
||||
gboolean debug_shaders = FALSE;
|
||||
@ -105,21 +104,12 @@ gsk_ngl_renderer_realize (GskRenderer *renderer,
|
||||
!gdk_gl_context_realize (context, error))
|
||||
goto failure;
|
||||
|
||||
if (!(shared_context = gdk_display_get_gl_context (gdk_surface_get_display (surface))))
|
||||
{
|
||||
g_set_error (error,
|
||||
GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
"Failed to locate shared GL context for driver");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), SHADERS))
|
||||
debug_shaders = TRUE;
|
||||
#endif
|
||||
|
||||
if (!(driver = gsk_ngl_driver_from_shared_context (shared_context, debug_shaders, error)))
|
||||
if (!(driver = gsk_ngl_driver_for_display (gdk_surface_get_display (surface), debug_shaders, error)))
|
||||
goto failure;
|
||||
|
||||
self->command_queue = gsk_ngl_driver_create_command_queue (driver, context);
|
||||
|
Loading…
Reference in New Issue
Block a user