[gtk/wip/baedert/transforms6: 10/18] gl renderer: Flip the framebuffer when dumping it
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/transforms6: 10/18] gl renderer: Flip the framebuffer when dumping it
- Date: Sat, 19 Jan 2019 12:40:31 +0000 (UTC)
commit adbcb0c73cf627da65b9634fb0eaa1f727123cbc
Author: Timm Bäder <mail baedert org>
Date: Wed Dec 12 09:23:23 2018 +0100
gl renderer: Flip the framebuffer when dumping it
gsk/gl/gskglrenderer.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index d79bdd6168..4eac8a0c62 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -134,16 +134,27 @@ print_render_node_tree (GskRenderNode *root, int level)
static void G_GNUC_UNUSED
dump_framebuffer (const char *filename, int w, int h)
{
- int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, w);
+ const int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, w);
guchar *data = g_malloc (h * stride);
+ guchar *flipped = g_malloc (h * stride);
cairo_surface_t *s;
+ int i;
glReadPixels (0, 0, w, h, GL_BGRA, GL_UNSIGNED_BYTE, data);
- s = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, w, h, stride);
+ for (i = 0; i < h; i ++)
+ {
+ memcpy (flipped + (stride * i),
+ data + ((h - 1 - i) * stride),
+ stride);
+
+ }
+ g_free (data);
+
+ s = cairo_image_surface_create_for_data (flipped, CAIRO_FORMAT_ARGB32, w, h, stride);
cairo_surface_write_to_png (s, filename);
cairo_surface_destroy (s);
- g_free (data);
+ g_free (flipped);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]