gdk: Add GDK_RENDERING environment variable
It's useful for debugging rendering issues, both correctness and performance wise. See the added documentation for what it does and how it works.
This commit is contained in:
@ -381,6 +381,41 @@ nevertheless.
|
||||
</para>
|
||||
</formalpara>
|
||||
|
||||
<formalpara>
|
||||
<title><envar>GDK_RENDERING</envar></title>
|
||||
|
||||
<para>
|
||||
If set, selects the way how GDK creates similar surfaces. This affects both the
|
||||
functionality of the function gdk_window_create_similar_surface() as well as the
|
||||
way GDK creates backing surfaces for double buffering. The following values can
|
||||
be used:
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term>similar</term>
|
||||
<listitem><para>Create similar surfaces to the window in use. This is the
|
||||
default behavior when the variable is not set.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>image</term>
|
||||
<listitem><para>Always create image surfaces. This essentially turns off
|
||||
all hardware acceleration inside GTK.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>recording</term>
|
||||
<listitem><para>Always create recording surfaces. This causes bare rendering
|
||||
to the backend without the creation of intermediate surfaces (Pixmaps in X)
|
||||
and will likely cause flicker.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
All other values will be ignored and fall back to the default behavior. More
|
||||
values might be added in the future.
|
||||
</para>
|
||||
</formalpara>
|
||||
|
||||
<formalpara>
|
||||
<title><envar>GDK_BACKEND</envar></title>
|
||||
|
||||
|
||||
13
gdk/gdk.c
13
gdk/gdk.c
@ -215,6 +215,8 @@ gdk_add_option_entries_libgtk_only (GOptionGroup *group)
|
||||
void
|
||||
gdk_pre_parse_libgtk_only (void)
|
||||
{
|
||||
const char *rendering_mode;
|
||||
|
||||
gdk_initialized = TRUE;
|
||||
|
||||
/* We set the fallback program class here, rather than lazily in
|
||||
@ -241,6 +243,17 @@ gdk_pre_parse_libgtk_only (void)
|
||||
g_unsetenv ("GDK_NATIVE_WINDOWS");
|
||||
}
|
||||
|
||||
rendering_mode = g_getenv ("GDK_RENDERING");
|
||||
if (rendering_mode)
|
||||
{
|
||||
if (g_str_equal (rendering_mode, "similar"))
|
||||
_gdk_rendering_mode = GDK_RENDERING_MODE_SIMILAR;
|
||||
else if (g_str_equal (rendering_mode, "image"))
|
||||
_gdk_rendering_mode = GDK_RENDERING_MODE_IMAGE;
|
||||
else if (g_str_equal (rendering_mode, "recording"))
|
||||
_gdk_rendering_mode = GDK_RENDERING_MODE_RECORDING;
|
||||
}
|
||||
|
||||
g_type_init ();
|
||||
|
||||
/* Do any setup particular to the windowing system */
|
||||
|
||||
@ -27,14 +27,13 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdktypes.h"
|
||||
#include "gdkprivate.h"
|
||||
#include "gdkinternals.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
guint _gdk_debug_flags = 0;
|
||||
GList *_gdk_default_filters = NULL;
|
||||
gchar *_gdk_display_name = NULL;
|
||||
gchar *_gdk_display_arg_name = NULL;
|
||||
gboolean _gdk_disable_multidevice = FALSE;
|
||||
|
||||
GdkRenderingMode _gdk_rendering_mode = GDK_RENDERING_MODE_SIMILAR;
|
||||
|
||||
@ -87,10 +87,17 @@ typedef enum {
|
||||
GDK_DEBUG_EVENTLOOP = 1 << 10
|
||||
} GdkDebugFlag;
|
||||
|
||||
typedef enum {
|
||||
GDK_RENDERING_MODE_SIMILAR = 0,
|
||||
GDK_RENDERING_MODE_IMAGE,
|
||||
GDK_RENDERING_MODE_RECORDING
|
||||
} GdkRenderingMode;
|
||||
|
||||
extern GList *_gdk_default_filters;
|
||||
extern GdkWindow *_gdk_parent_root;
|
||||
|
||||
extern guint _gdk_debug_flags;
|
||||
extern GdkRenderingMode _gdk_rendering_mode;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
|
||||
@ -9709,9 +9709,26 @@ gdk_window_create_similar_surface (GdkWindow * window,
|
||||
|
||||
window_surface = _gdk_window_ref_cairo_surface (window);
|
||||
|
||||
surface = cairo_surface_create_similar (window_surface,
|
||||
content,
|
||||
width, height);
|
||||
switch (_gdk_rendering_mode)
|
||||
{
|
||||
case GDK_RENDERING_MODE_RECORDING:
|
||||
{
|
||||
cairo_rectangle_t rect = { 0, 0, width, height };
|
||||
surface = cairo_recording_surface_create (content, &rect);
|
||||
}
|
||||
break;
|
||||
case GDK_RENDERING_MODE_IMAGE:
|
||||
surface = cairo_image_surface_create (content == CAIRO_CONTENT_COLOR ? CAIRO_FORMAT_RGB24 :
|
||||
content == CAIRO_CONTENT_ALPHA ? CAIRO_FORMAT_A8 : CAIRO_FORMAT_ARGB32,
|
||||
width, height);
|
||||
break;
|
||||
case GDK_RENDERING_MODE_SIMILAR:
|
||||
default:
|
||||
surface = cairo_surface_create_similar (window_surface,
|
||||
content,
|
||||
width, height);
|
||||
break;
|
||||
}
|
||||
|
||||
cairo_surface_destroy (window_surface);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user