[gtk/another-attempt-to-fix-shadertoy: 2/2] glarea: Flip our texture




commit 0f9a6f4b62e5308225c2c3ed2c9bee6b2a58be4f
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Sep 27 12:33:13 2020 -0400

    glarea: Flip our texture
    
    The texture that produce is upside-down, compared to what
    GSK expects, so flip things around with a transform.
    
    This fixes the shadertoy demo being upside-down after a
    recent fix to avoid downloading and reuploading the texture.

 gtk/gtkglarea.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
index 4cb815e1d9..3387a36ca2 100644
--- a/gtk/gtkglarea.c
+++ b/gtk/gtkglarea.c
@@ -744,11 +744,18 @@ gtk_gl_area_snapshot (GtkWidget   *widget,
                                             texture->height,
                                             release_texture, texture);
 
+      /* Our texture is rendered by OpenGL, so it is upside down,
+       * compared to what GSK expects, so flip it back.
+       */
+      gtk_snapshot_save (snapshot);
+      gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (0, gtk_widget_get_height (widget)));
+      gtk_snapshot_scale (snapshot, 1, -1);
       gtk_snapshot_append_texture (snapshot,
                                    texture->holder,
                                    &GRAPHENE_RECT_INIT (0, 0,
                                                         gtk_widget_get_width (widget),
                                                         gtk_widget_get_height (widget)));
+      gtk_snapshot_restore (snapshot);
 
       g_object_unref (texture->holder);
     }


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