forked from AuroraMiddleware/gtk
gsk: Reorganize env vars
Get rid of GSK_RENDERING_MODE and add the flags to GSK_DEBUG, following the same pattern we use in gdk now.
This commit is contained in:
parent
c3215de005
commit
ba21a7764b
@ -1723,7 +1723,7 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self,
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_RENDER_MODE_CHECK (SHADERS))
|
||||
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), SHADERS))
|
||||
gsk_shader_builder_add_define (builder, "GSK_DEBUG", "1");
|
||||
#endif
|
||||
|
||||
|
@ -107,7 +107,8 @@ gsk_cairo_renderer_render (GskRenderer *renderer,
|
||||
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
if (GSK_RENDER_MODE_CHECK (GEOMETRY))
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_RENDERER_DEBUG_CHECK (renderer, GEOMETRY))
|
||||
{
|
||||
cairo_save (cr);
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
@ -118,6 +119,7 @@ gsk_cairo_renderer_render (GskRenderer *renderer,
|
||||
cairo_stroke (cr);
|
||||
cairo_restore (cr);
|
||||
}
|
||||
#endif
|
||||
|
||||
gsk_cairo_renderer_do_render (renderer, cr, root);
|
||||
}
|
||||
|
@ -9,19 +9,15 @@ static const GDebugKey gsk_debug_keys[] = {
|
||||
{ "surface", GSK_DEBUG_SURFACE },
|
||||
{ "vulkan", GSK_DEBUG_VULKAN },
|
||||
{ "fallback", GSK_DEBUG_FALLBACK },
|
||||
{ "glyphcache", GSK_DEBUG_GLYPH_CACHE }
|
||||
{ "glyphcache", GSK_DEBUG_GLYPH_CACHE },
|
||||
{ "geometry", GSK_DEBUG_GEOMETRY },
|
||||
{ "full-redraw", GSK_DEBUG_FULL_REDRAW},
|
||||
{ "sync", GSK_DEBUG_SYNC },
|
||||
{ "vulkan-staging-image", GSK_DEBUG_VULKAN_STAGING_IMAGE },
|
||||
{ "vulkan-staging-buffer", GSK_DEBUG_VULKAN_STAGING_BUFFER }
|
||||
};
|
||||
#endif
|
||||
|
||||
static const GDebugKey gsk_rendering_keys[] = {
|
||||
{ "geometry", GSK_RENDERING_MODE_GEOMETRY },
|
||||
{ "shaders", GSK_RENDERING_MODE_SHADERS },
|
||||
{ "sync", GSK_RENDERING_MODE_SYNC },
|
||||
{ "full-redraw", GSK_RENDERING_MODE_FULL_REDRAW},
|
||||
{ "staging-image", GSK_RENDERING_MODE_STAGING_IMAGE },
|
||||
{ "staging-buffer", GSK_RENDERING_MODE_STAGING_BUFFER }
|
||||
};
|
||||
|
||||
static guint gsk_debug_flags;
|
||||
|
||||
static void
|
||||
@ -58,23 +54,3 @@ gsk_get_debug_flags (void)
|
||||
|
||||
return gsk_debug_flags;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsk_check_rendering_flags (GskRenderingMode flags)
|
||||
{
|
||||
static volatile gsize gsk_rendering_flags__set;
|
||||
static guint gsk_rendering_flags;
|
||||
|
||||
if (g_once_init_enter (&gsk_rendering_flags__set))
|
||||
{
|
||||
const char *env = g_getenv ("GSK_RENDERING_MODE");
|
||||
|
||||
gsk_rendering_flags = g_parse_debug_string (env,
|
||||
(GDebugKey *) gsk_rendering_keys,
|
||||
G_N_ELEMENTS (gsk_rendering_keys));
|
||||
|
||||
g_once_init_leave (&gsk_rendering_flags__set, TRUE);
|
||||
}
|
||||
|
||||
return (gsk_rendering_flags & flags) != 0;
|
||||
}
|
||||
|
@ -6,36 +6,30 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
GSK_DEBUG_RENDERER = 1 << 0,
|
||||
GSK_DEBUG_CAIRO = 1 << 1,
|
||||
GSK_DEBUG_OPENGL = 1 << 2,
|
||||
GSK_DEBUG_SHADERS = 1 << 3,
|
||||
GSK_DEBUG_SURFACE = 1 << 4,
|
||||
GSK_DEBUG_VULKAN = 1 << 5,
|
||||
GSK_DEBUG_FALLBACK = 1 << 6,
|
||||
GSK_DEBUG_GLYPH_CACHE = 1 << 7
|
||||
GSK_DEBUG_RENDERER = 1 << 0,
|
||||
GSK_DEBUG_CAIRO = 1 << 1,
|
||||
GSK_DEBUG_OPENGL = 1 << 2,
|
||||
GSK_DEBUG_SHADERS = 1 << 3,
|
||||
GSK_DEBUG_SURFACE = 1 << 4,
|
||||
GSK_DEBUG_VULKAN = 1 << 5,
|
||||
GSK_DEBUG_FALLBACK = 1 << 6,
|
||||
GSK_DEBUG_GLYPH_CACHE = 1 << 7,
|
||||
/* flags below may affect behavior */
|
||||
GSK_DEBUG_GEOMETRY = 1 << 8,
|
||||
GSK_DEBUG_FULL_REDRAW = 1 << 9,
|
||||
GSK_DEBUG_SYNC = 1 << 10,
|
||||
GSK_DEBUG_VULKAN_STAGING_IMAGE = 1 << 11,
|
||||
GSK_DEBUG_VULKAN_STAGING_BUFFER = 1 << 12
|
||||
} GskDebugFlags;
|
||||
|
||||
#define GSK_DEBUG_ANY ((1 << 8) - 1)
|
||||
|
||||
typedef enum {
|
||||
GSK_RENDERING_MODE_GEOMETRY = 1 << 0,
|
||||
GSK_RENDERING_MODE_SHADERS = 1 << 1,
|
||||
GSK_RENDERING_MODE_SYNC = 1 << 2,
|
||||
GSK_RENDERING_MODE_FULL_REDRAW = 1 << 3,
|
||||
GSK_RENDERING_MODE_STAGING_IMAGE = 1 << 4,
|
||||
GSK_RENDERING_MODE_STAGING_BUFFER = 1 << 5
|
||||
} GskRenderingMode;
|
||||
#define GSK_DEBUG_ANY ((1 << 13) - 1)
|
||||
|
||||
GskDebugFlags gsk_get_debug_flags (void);
|
||||
gboolean gsk_check_debug_flags (GskDebugFlags flags);
|
||||
|
||||
gboolean gsk_check_rendering_flags (GskRenderingMode flags);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
|
||||
#define GSK_DEBUG_CHECK(type) G_UNLIKELY (gsk_check_debug_flags (GSK_DEBUG_ ## type))
|
||||
#define GSK_RENDER_MODE_CHECK(type) G_UNLIKELY (gsk_check_rendering_flags (GSK_RENDERING_MODE_ ## type))
|
||||
#define GSK_RENDERER_DEBUG_CHECK(renderer,type) \
|
||||
G_UNLIKELY ((gsk_renderer_get_debug_flags (renderer) & GSK_DEBUG_ ## type) != 0)
|
||||
|
||||
@ -50,7 +44,6 @@ gboolean gsk_check_rendering_flags (GskRenderingMode flags);
|
||||
|
||||
#else
|
||||
|
||||
#define GSK_RENDER_MODE_CHECK(type) 0
|
||||
#define GSK_DEBUG_CHECK(type) 0
|
||||
#define GSK_RENDERER_DEBUG_CHECK(renderer,type) 0
|
||||
#define GSK_NOTE(type,action)
|
||||
|
@ -799,24 +799,24 @@ gsk_renderer_begin_draw_frame (GskRenderer *renderer,
|
||||
g_return_val_if_fail (region != NULL, NULL);
|
||||
g_return_val_if_fail (priv->drawing_context == NULL, NULL);
|
||||
|
||||
if (GSK_RENDER_MODE_CHECK (FULL_REDRAW))
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_RENDERER_DEBUG_CHECK (renderer, FULL_REDRAW))
|
||||
{
|
||||
cairo_region_t *full_window;
|
||||
|
||||
|
||||
full_window = cairo_region_create_rectangle (&(GdkRectangle) {
|
||||
0, 0,
|
||||
gdk_window_get_width (priv->window),
|
||||
gdk_window_get_height (priv->window)
|
||||
});
|
||||
|
||||
|
||||
priv->drawing_context = GSK_RENDERER_GET_CLASS (renderer)->begin_draw_frame (renderer, full_window);
|
||||
|
||||
cairo_region_destroy (full_window);
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->drawing_context = GSK_RENDERER_GET_CLASS (renderer)->begin_draw_frame (renderer, region);
|
||||
}
|
||||
#endif
|
||||
priv->drawing_context = GSK_RENDERER_GET_CLASS (renderer)->begin_draw_frame (renderer, region);
|
||||
|
||||
return priv->drawing_context;
|
||||
}
|
||||
|
@ -239,7 +239,8 @@ gsk_render_node_draw (GskRenderNode *node,
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
if (!GSK_RENDER_MODE_CHECK (GEOMETRY))
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (!GSK_DEBUG_CHECK (GEOMETRY))
|
||||
{
|
||||
GSK_NOTE (CAIRO, g_message ("CLIP = { .x = %g, .y = %g, .width = %g, .height = %g }",
|
||||
node->bounds.origin.x, node->bounds.origin.y,
|
||||
@ -248,6 +249,7 @@ gsk_render_node_draw (GskRenderNode *node,
|
||||
cairo_rectangle (cr, node->bounds.origin.x, node->bounds.origin.y, node->bounds.size.width, node->bounds.size.height);
|
||||
cairo_clip (cr);
|
||||
}
|
||||
#endif
|
||||
|
||||
GSK_NOTE (CAIRO, g_message ("Rendering node %s[%p]",
|
||||
node->name ? node->name : node->node_class->type_name,
|
||||
@ -255,7 +257,8 @@ gsk_render_node_draw (GskRenderNode *node,
|
||||
|
||||
node->node_class->draw (node, cr);
|
||||
|
||||
if (GSK_RENDER_MODE_CHECK (GEOMETRY))
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_DEBUG_CHECK (GEOMETRY))
|
||||
{
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
cairo_rectangle (cr, node->bounds.origin.x - 1, node->bounds.origin.y - 1,
|
||||
@ -264,6 +267,7 @@ gsk_render_node_draw (GskRenderNode *node,
|
||||
cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
#endif
|
||||
|
||||
cairo_restore (cr);
|
||||
|
||||
|
@ -532,9 +532,9 @@ gsk_vulkan_image_new_from_data (GskVulkanUploader *uploader,
|
||||
gsize height,
|
||||
gsize stride)
|
||||
{
|
||||
if (GSK_RENDER_MODE_CHECK (STAGING_BUFFER))
|
||||
if (GSK_DEBUG_CHECK (VULKAN_STAGING_BUFFER))
|
||||
return gsk_vulkan_image_new_from_data_via_staging_buffer (uploader, data, width, height, stride);
|
||||
if (GSK_RENDER_MODE_CHECK (STAGING_IMAGE))
|
||||
else if (GSK_DEBUG_CHECK (VULKAN_STAGING_IMAGE))
|
||||
return gsk_vulkan_image_new_from_data_via_staging_image (uploader, data, width, height, stride);
|
||||
else
|
||||
return gsk_vulkan_image_new_from_data_directly (uploader, data, width, height, stride);
|
||||
|
@ -581,7 +581,7 @@ gsk_vulkan_render_draw (GskVulkanRender *self)
|
||||
GList *l;
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_RENDER_MODE_CHECK (SYNC))
|
||||
if (GSK_RENDERER_DEBUG_CHECK (self->renderer, SYNC))
|
||||
gsk_profiler_timer_begin (gsk_renderer_get_profiler (self->renderer), self->gpu_time_timer);
|
||||
#endif
|
||||
|
||||
@ -612,7 +612,8 @@ gsk_vulkan_render_draw (GskVulkanRender *self)
|
||||
l->next != NULL ? VK_NULL_HANDLE : self->fence);
|
||||
}
|
||||
|
||||
if (GSK_RENDER_MODE_CHECK (SYNC))
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_RENDERER_DEBUG_CHECK (self->renderer, SYNC))
|
||||
{
|
||||
GskProfiler *profiler;
|
||||
gint64 gpu_time;
|
||||
@ -627,6 +628,7 @@ gsk_vulkan_render_draw (GskVulkanRender *self)
|
||||
gpu_time = gsk_profiler_timer_end (profiler, self->gpu_time_timer);
|
||||
gsk_profiler_timer_set (profiler, self->gpu_time_timer, gpu_time);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
|
@ -291,7 +291,7 @@ gsk_vulkan_renderer_init (GskVulkanRenderer *self)
|
||||
self->profile_counters.texture_pixels = gsk_profiler_add_counter (profiler, "texture-pixels", "Texture pixels", TRUE);
|
||||
|
||||
self->profile_timers.cpu_time = gsk_profiler_add_timer (profiler, "cpu-time", "CPU time", FALSE, TRUE);
|
||||
if (GSK_RENDER_MODE_CHECK (SYNC))
|
||||
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), SYNC))
|
||||
self->profile_timers.gpu_time = gsk_profiler_add_timer (profiler, "gpu-time", "GPU time", FALSE, TRUE);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user