[gtk/wip/baedert/transforms6: 264/273] 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: 264/273] gl renderer: Flip the framebuffer when dumping it
- Date: Wed, 13 Feb 2019 09:15:28 +0000 (UTC)
commit 6064e818c6acb3547b116a7b6aa9d741beb43da2
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 ef2bc59641..4046c399ab 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]