[gtk] gl renderer: add render ops for dumping the framebuffer



commit 74dd05b45e0730bace32c7d6c57768ae9bbac29f
Author: Timm Bäder <mail baedert org>
Date:   Sun Dec 2 08:12:09 2018 +0100

    gl renderer: add render ops for dumping the framebuffer
    
    So offscreen rendering can be properly debugged.

 gsk/gl/gskglrenderer.c         |  4 ++++
 gsk/gl/gskglrenderops.c        | 17 +++++++++++++++++
 gsk/gl/gskglrenderopsprivate.h | 10 ++++++++++
 3 files changed, 31 insertions(+)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index b7c7ebdc7d..89be24fadc 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -2562,6 +2562,10 @@ gsk_gl_renderer_render_ops (GskGLRenderer *self,
           glDrawArrays (GL_TRIANGLES, op->draw.vao_offset, op->draw.vao_size);
           break;
 
+        case OP_DUMP_FRAMEBUFFER:
+          dump_framebuffer (op->dump.filename, op->dump.width, op->dump.height);
+          break;
+
         default:
           g_warn_if_reached ();
         }
diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c
index 21dbb59029..c391578567 100644
--- a/gsk/gl/gskglrenderops.c
+++ b/gsk/gl/gskglrenderops.c
@@ -17,6 +17,23 @@ rgba_to_float (const GdkRGBA *c,
   f[3] = c->alpha;
 }
 
+/* Debugging only! */
+void
+ops_dump_framebuffer (RenderOpBuilder *builder,
+                      const char      *filename,
+                      int              width,
+                      int              height)
+{
+  RenderOp op;
+
+  op.op = OP_DUMP_FRAMEBUFFER;
+  op.dump.filename = g_strdup (filename);
+  op.dump.width = width;
+  op.dump.height = height;
+
+  g_array_append_val (builder->render_ops, op);
+}
+
 float
 ops_get_scale (const RenderOpBuilder *builder)
 {
diff --git a/gsk/gl/gskglrenderopsprivate.h b/gsk/gl/gskglrenderopsprivate.h
index 97ce3a28b1..38b66744e4 100644
--- a/gsk/gl/gskglrenderopsprivate.h
+++ b/gsk/gl/gskglrenderopsprivate.h
@@ -54,6 +54,7 @@ enum {
   OP_CHANGE_UNBLURRED_OUTSET_SHADOW = 19,
   OP_CLEAR                  =  20,
   OP_DRAW                   =  21,
+  OP_DUMP_FRAMEBUFFER       =  22,
 };
 
 typedef struct
@@ -207,6 +208,11 @@ typedef struct
       float progress;
       int source2;
     } cross_fade;
+    struct {
+      char *filename;
+      int width;
+      int height;
+    } dump;
   };
 } RenderOp;
 
@@ -258,6 +264,10 @@ typedef struct
 } RenderOpBuilder;
 
 
+void              ops_dump_framebuffer   (RenderOpBuilder         *builder,
+                                          const char              *filename,
+                                          int                      width,
+                                          int                      height);
 
 void              ops_finish             (RenderOpBuilder         *builder);
 void              ops_push_modelview     (RenderOpBuilder         *builder,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]