[gtk/wip/chergert/glproto: 212/526] helper to dump framebuffer after each batch
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto: 212/526] helper to dump framebuffer after each batch
- Date: Tue, 16 Feb 2021 01:14:29 +0000 (UTC)
commit 2b072618b1be1fabbe0302ee0132eed6865285ad
Author: Christian Hergert <chergert redhat com>
Date: Sun Jan 10 09:22:10 2021 -0800
helper to dump framebuffer after each batch
it would be nice to integrate this later into the profiler so that we can
debug what happened during the draw process (albeit at very slow overhead).
gsk/next/gskglcommandqueue.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
---
diff --git a/gsk/next/gskglcommandqueue.c b/gsk/next/gskglcommandqueue.c
index 02b8e60b78..3c8f0eb415 100644
--- a/gsk/next/gskglcommandqueue.c
+++ b/gsk/next/gskglcommandqueue.c
@@ -165,6 +165,30 @@ G_STATIC_ASSERT (sizeof (GskGLCommandBatch) == 32);
G_DEFINE_TYPE (GskGLCommandQueue, gsk_gl_command_queue, G_TYPE_OBJECT)
+static void
+gsk_gl_command_queue_capture_png (GskGLCommandQueue *self,
+ const char *filename,
+ guint width,
+ guint height)
+{
+ cairo_surface_t *surface;
+ gpointer data;
+ guint stride;
+
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
+ g_assert (filename != NULL);
+
+ stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
+ data = g_malloc_n (height, stride);
+
+ glReadPixels (0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, data);
+ surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, width, height, stride);
+ cairo_surface_write_to_png (surface, filename);
+
+ cairo_surface_destroy (surface);
+ g_free (data);
+}
+
static void
gsk_gl_command_queue_save (GskGLCommandQueue *self)
{
@@ -631,6 +655,7 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self)
guint program = 0;
guint16 width = 0;
guint16 height = 0;
+ guint count = 0;
g_return_if_fail (GSK_IS_GL_COMMAND_QUEUE (self));
g_return_if_fail (self->in_draw == FALSE);
@@ -676,6 +701,8 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self)
g_assert (batch->any.next_batch_index != next_batch_index);
+ count++;
+
switch (batch->any.kind)
{
case GSK_GL_COMMAND_KIND_CLEAR:
@@ -752,6 +779,18 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self)
g_assert_not_reached ();
}
+#if 0
+ if (batch->any.kind == GSK_GL_COMMAND_KIND_DRAW ||
+ batch->any.kind == GSK_GL_COMMAND_KIND_CLEAR)
+ {
+ char filename[32];
+ g_snprintf (filename, sizeof filename,
+ "capture%u_batch%d_kind%u.png",
+ count++, next_batch_index, batch->any.kind);
+ gsk_gl_command_queue_capture_png (self, filename, width, height);
+ }
+#endif
+
next_batch_index = batch->any.next_batch_index;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]