Add GDK_GL env var and GdkGLFlags
This moves the GDK_ALWAYS_USE_GL env var to GDK_GL=always. It also changes GDK_DEBUG=nogl to GDK_GL=disable, as GDK_DEBUG is really only about debug loggin. It also adds some completely new flags: software-draw-gl: Always use software fallback for drawing gl content to a cairo_t. This disables the fastpaths that exist for drawing directly to a window and instead reads back the pixels into a cairo image surface. software-draw-surface: Always use software fallback for drawing cairo surfaces onto a gl-using window. This disables e.g. texture-from-pixmap on X11. software-draw: Enables both the above.
This commit is contained in:
parent
7fde5213b0
commit
90a5fa80af
16
gdk/gdk.c
16
gdk/gdk.c
@ -134,6 +134,14 @@ static GMutex gdk_threads_mutex;
|
|||||||
static GCallback gdk_threads_lock = NULL;
|
static GCallback gdk_threads_lock = NULL;
|
||||||
static GCallback gdk_threads_unlock = NULL;
|
static GCallback gdk_threads_unlock = NULL;
|
||||||
|
|
||||||
|
static const GDebugKey gdk_gl_keys[] = {
|
||||||
|
{"disable", GDK_GL_FLAGS_DISABLE},
|
||||||
|
{"always", GDK_GL_FLAGS_ALWAYS},
|
||||||
|
{"software-draw", GDK_GL_FLAGS_SOFTWARE_DRAW_GL | GDK_GL_FLAGS_SOFTWARE_DRAW_SURFACE},
|
||||||
|
{"software-draw-gl", GDK_GL_FLAGS_SOFTWARE_DRAW_GL},
|
||||||
|
{"software-draw-surface", GDK_GL_FLAGS_SOFTWARE_DRAW_SURFACE},
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
static const GDebugKey gdk_debug_keys[] = {
|
static const GDebugKey gdk_debug_keys[] = {
|
||||||
{"events", GDK_DEBUG_EVENTS},
|
{"events", GDK_DEBUG_EVENTS},
|
||||||
@ -149,7 +157,6 @@ static const GDebugKey gdk_debug_keys[] = {
|
|||||||
{"eventloop", GDK_DEBUG_EVENTLOOP},
|
{"eventloop", GDK_DEBUG_EVENTLOOP},
|
||||||
{"frames", GDK_DEBUG_FRAMES},
|
{"frames", GDK_DEBUG_FRAMES},
|
||||||
{"settings", GDK_DEBUG_SETTINGS},
|
{"settings", GDK_DEBUG_SETTINGS},
|
||||||
{"nogl", GDK_DEBUG_NOGL},
|
|
||||||
{"opengl", GDK_DEBUG_OPENGL},
|
{"opengl", GDK_DEBUG_OPENGL},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -248,6 +255,7 @@ void
|
|||||||
gdk_pre_parse_libgtk_only (void)
|
gdk_pre_parse_libgtk_only (void)
|
||||||
{
|
{
|
||||||
const char *rendering_mode;
|
const char *rendering_mode;
|
||||||
|
const gchar *gl_string;
|
||||||
|
|
||||||
gdk_initialized = TRUE;
|
gdk_initialized = TRUE;
|
||||||
|
|
||||||
@ -268,6 +276,12 @@ gdk_pre_parse_libgtk_only (void)
|
|||||||
}
|
}
|
||||||
#endif /* G_ENABLE_DEBUG */
|
#endif /* G_ENABLE_DEBUG */
|
||||||
|
|
||||||
|
gl_string = getenv("GDK_GL");
|
||||||
|
if (gl_string != NULL)
|
||||||
|
_gdk_gl_flags = g_parse_debug_string (gl_string,
|
||||||
|
(GDebugKey *) gdk_gl_keys,
|
||||||
|
G_N_ELEMENTS (gdk_gl_keys));
|
||||||
|
|
||||||
if (getenv ("GDK_NATIVE_WINDOWS"))
|
if (getenv ("GDK_NATIVE_WINDOWS"))
|
||||||
{
|
{
|
||||||
g_warning ("The GDK_NATIVE_WINDOWS environment variable is not supported in GTK3.\n"
|
g_warning ("The GDK_NATIVE_WINDOWS environment variable is not supported in GTK3.\n"
|
||||||
|
@ -335,7 +335,8 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
|||||||
|
|
||||||
/* For direct paint of non-alpha renderbuffer, we can
|
/* For direct paint of non-alpha renderbuffer, we can
|
||||||
just do a bitblit */
|
just do a bitblit */
|
||||||
if (source_type == GL_RENDERBUFFER &&
|
if ((_gdk_gl_flags & GDK_GL_FLAGS_SOFTWARE_DRAW_GL) == 0 &&
|
||||||
|
source_type == GL_RENDERBUFFER &&
|
||||||
alpha_size == 0 &&
|
alpha_size == 0 &&
|
||||||
direct_window != NULL &&
|
direct_window != NULL &&
|
||||||
direct_window->current_paint.use_gl &&
|
direct_window->current_paint.use_gl &&
|
||||||
@ -415,7 +416,8 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
|
|||||||
|
|
||||||
}
|
}
|
||||||
/* For direct paint of alpha or non-alpha textures we can use texturing */
|
/* For direct paint of alpha or non-alpha textures we can use texturing */
|
||||||
else if (source_type == GL_TEXTURE &&
|
else if ((_gdk_gl_flags & GDK_GL_FLAGS_SOFTWARE_DRAW_GL) == 0 &&
|
||||||
|
source_type == GL_TEXTURE &&
|
||||||
direct_window != NULL &&
|
direct_window != NULL &&
|
||||||
direct_window->current_paint.use_gl &&
|
direct_window->current_paint.use_gl &&
|
||||||
trivial_transform &&
|
trivial_transform &&
|
||||||
@ -602,7 +604,8 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
|
|||||||
guint target;
|
guint target;
|
||||||
|
|
||||||
paint_context = gdk_gl_context_get_current ();
|
paint_context = gdk_gl_context_get_current ();
|
||||||
if (paint_context &&
|
if ((_gdk_gl_flags & GDK_GL_FLAGS_SOFTWARE_DRAW_SURFACE) == 0 &&
|
||||||
|
paint_context &&
|
||||||
GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface &&
|
GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface &&
|
||||||
GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface (paint_context, surface, region))
|
GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface (paint_context, surface, region))
|
||||||
return;
|
return;
|
||||||
|
@ -34,4 +34,5 @@ GList *_gdk_default_filters = NULL;
|
|||||||
gchar *_gdk_display_name = NULL;
|
gchar *_gdk_display_name = NULL;
|
||||||
gchar *_gdk_display_arg_name = NULL;
|
gchar *_gdk_display_arg_name = NULL;
|
||||||
gboolean _gdk_disable_multidevice = FALSE;
|
gboolean _gdk_disable_multidevice = FALSE;
|
||||||
|
guint _gdk_gl_flags = 0;
|
||||||
GdkRenderingMode _gdk_rendering_mode = GDK_RENDERING_MODE_SIMILAR;
|
GdkRenderingMode _gdk_rendering_mode = GDK_RENDERING_MODE_SIMILAR;
|
||||||
|
@ -85,10 +85,17 @@ typedef enum {
|
|||||||
GDK_DEBUG_EVENTLOOP = 1 << 10,
|
GDK_DEBUG_EVENTLOOP = 1 << 10,
|
||||||
GDK_DEBUG_FRAMES = 1 << 11,
|
GDK_DEBUG_FRAMES = 1 << 11,
|
||||||
GDK_DEBUG_SETTINGS = 1 << 12,
|
GDK_DEBUG_SETTINGS = 1 << 12,
|
||||||
GDK_DEBUG_NOGL = 1 << 13,
|
GDK_DEBUG_OPENGL = 1 << 13,
|
||||||
GDK_DEBUG_OPENGL = 1 << 14
|
|
||||||
} GdkDebugFlag;
|
} GdkDebugFlag;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GDK_GL_FLAGS_DISABLE = 1 << 0,
|
||||||
|
GDK_GL_FLAGS_ALWAYS = 1 << 1,
|
||||||
|
GDK_GL_FLAGS_SOFTWARE_DRAW_GL = 1 << 2,
|
||||||
|
GDK_GL_FLAGS_SOFTWARE_DRAW_SURFACE = 1 << 3,
|
||||||
|
} GdkGLFlags;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GDK_RENDERING_MODE_SIMILAR = 0,
|
GDK_RENDERING_MODE_SIMILAR = 0,
|
||||||
GDK_RENDERING_MODE_IMAGE,
|
GDK_RENDERING_MODE_IMAGE,
|
||||||
@ -99,6 +106,7 @@ extern GList *_gdk_default_filters;
|
|||||||
extern GdkWindow *_gdk_parent_root;
|
extern GdkWindow *_gdk_parent_root;
|
||||||
|
|
||||||
extern guint _gdk_debug_flags;
|
extern guint _gdk_debug_flags;
|
||||||
|
extern guint _gdk_gl_flags;
|
||||||
extern GdkRenderingMode _gdk_rendering_mode;
|
extern GdkRenderingMode _gdk_rendering_mode;
|
||||||
|
|
||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
|
@ -287,16 +287,11 @@ create_surface_accumulator (GSignalInvocationHint *ihint,
|
|||||||
|
|
||||||
static GQuark quark_pointer_window = 0;
|
static GQuark quark_pointer_window = 0;
|
||||||
|
|
||||||
static gboolean always_use_gl = FALSE;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_window_class_init (GdkWindowClass *klass)
|
gdk_window_class_init (GdkWindowClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
if (g_getenv ("GDK_ALWAYS_USE_GL"))
|
|
||||||
always_use_gl = TRUE;
|
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
object_class->finalize = gdk_window_finalize;
|
object_class->finalize = gdk_window_finalize;
|
||||||
@ -1424,7 +1419,7 @@ gdk_window_new (GdkWindow *parent,
|
|||||||
G_CALLBACK (device_removed_cb), window);
|
G_CALLBACK (device_removed_cb), window);
|
||||||
|
|
||||||
|
|
||||||
if (always_use_gl)
|
if ((_gdk_gl_flags & (GDK_GL_FLAGS_ALWAYS | GDK_GL_FLAGS_DISABLE)) == GDK_GL_FLAGS_ALWAYS)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
@ -2730,7 +2725,7 @@ gdk_window_ref_impl_surface (GdkWindow *window)
|
|||||||
GdkGLContext *
|
GdkGLContext *
|
||||||
gdk_window_get_paint_gl_context (GdkWindow *window, GError **error)
|
gdk_window_get_paint_gl_context (GdkWindow *window, GError **error)
|
||||||
{
|
{
|
||||||
if (_gdk_debug_flags & GDK_DEBUG_NOGL)
|
if (_gdk_gl_flags & GDK_GL_FLAGS_DISABLE)
|
||||||
{
|
{
|
||||||
g_set_error_literal (error, GDK_GL_ERROR,
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
|
Loading…
Reference in New Issue
Block a user