summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-04-11 21:13:47 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-04-11 21:13:47 -0400
commitda6096faaf59e055367a115dc47035f8994f9cae (patch)
tree393ebfe96bb103dee3bfc5360739ef703b5209d1
parent6712106c25cbd9605bed09dc987ef544787e2619 (diff)
downloadgtk+-da6096faaf59e055367a115dc47035f8994f9cae.tar.gz
ngl: Add code to dump shadows
This can be helpful in understanding shadow bugs.
-rw-r--r--gsk/ngl/gsknglshadowlibrary.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gsk/ngl/gsknglshadowlibrary.c b/gsk/ngl/gsknglshadowlibrary.c
index bcf524c8b7..301a3c1624 100644
--- a/gsk/ngl/gsknglshadowlibrary.c
+++ b/gsk/ngl/gsknglshadowlibrary.c
@@ -202,6 +202,31 @@ gsk_ngl_shadow_library_lookup (GskNglShadowLibrary *self,
return ret->texture_id;
}
+#if 0
+static void
+write_shadow_to_png (const Shadow *shadow)
+{
+ int width = shadow->outline.bounds.size.width + (shadow->outline.bounds.origin.x * 2);
+ int height = shadow->outline.bounds.size.height + (shadow->outline.bounds.origin.y * 2);
+ int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
+ guchar *data = g_malloc (height * stride);
+ cairo_surface_t *s;
+ char *filename = g_strdup_printf ("shadow_cache_%d_%d_%d.png",
+ width, height, shadow->texture_id);
+
+ glBindTexture (GL_TEXTURE_2D, shadow->texture_id);
+ glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
+ s = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32,
+ width, height,
+ stride);
+ cairo_surface_write_to_png (s, filename);
+
+ cairo_surface_destroy (s);
+ g_free (data);
+ g_free (filename);
+}
+#endif
+
void
gsk_ngl_shadow_library_begin_frame (GskNglShadowLibrary *self)
{
@@ -211,6 +236,14 @@ gsk_ngl_shadow_library_begin_frame (GskNglShadowLibrary *self)
g_return_if_fail (GSK_IS_NGL_SHADOW_LIBRARY (self));
+#if 0
+ for (i = 0, p = self->shadows->len; i < p; i++)
+ {
+ const Shadow *shadow = &g_array_index (self->shadows, Shadow, i);
+ write_shadow_to_png (shadow);
+ }
+#endif
+
watermark = self->driver->current_frame_id - MAX_UNUSED_FRAMES;
for (i = 0, p = self->shadows->len; i < p; i++)