[gtk/fix-clipped-texture] gl: Fixed clipped offscreen rendering




commit dff2aa20ff33d84a5b7320a9506ad19165251f7d
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Feb 9 20:28:42 2021 -0500

    gl: Fixed clipped offscreen rendering
    
    When we are rendering a texture node to an offscreen,
    and we have a clip, we must force the offscreen rendering.
    Otherwise, the code will notice: Hey, it already is a texture
    node, so no need to render it to a texture again. But when
    clipping is involved, that is exactly what we want to do.
    
    Testcase included.
    
    Fixes: #3651

 gsk/gl/gskglrenderer.c                             |  11 +--
 testsuite/gsk/compare/rounded-clip-in-clip-3d.node | 109 +++++++++++++++++++++
 testsuite/gsk/compare/rounded-clip-in-clip-3d.png  | Bin 0 -> 1218 bytes
 testsuite/gsk/meson.build                          |   1 +
 4 files changed, 112 insertions(+), 9 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 5a15bf5911..a68b45e663 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -1741,7 +1741,6 @@ render_rounded_clip_node (GskGLRenderer       *self,
           return;
         }
 
-      /* TODO: Intersect current and new clip */
       ops_push_clip (builder, &transformed_clip);
       gsk_gl_renderer_add_render_ops (self, child, builder);
       ops_pop_clip (builder);
@@ -1750,19 +1749,13 @@ render_rounded_clip_node (GskGLRenderer       *self,
     {
       gboolean is_offscreen;
       TextureRegion region;
-      /* NOTE: We are *not* transforming the clip by the current modelview here.
-       *       We instead draw the untransformed clip to a texture and then transform
-       *       that texture.
-       *
-       *       We do, however, apply the scale factor to the child clip of course.
-       */
+
       ops_push_clip (builder, &transformed_clip);
       if (!add_offscreen_ops (self, builder, &node->bounds,
                               child,
                               &region, &is_offscreen,
-                              0))
+                              FORCE_OFFSCREEN))
         g_assert_not_reached ();
-
       ops_pop_clip (builder);
 
       ops_set_program (builder, &self->programs->blit_program);
diff --git a/testsuite/gsk/compare/rounded-clip-in-clip-3d.node 
b/testsuite/gsk/compare/rounded-clip-in-clip-3d.node
new file mode 100644
index 0000000000..f2023fef7a
--- /dev/null
+++ b/testsuite/gsk/compare/rounded-clip-in-clip-3d.node
@@ -0,0 +1,109 @@
+                      clip {
+                        child: transform {
+                          child: transform {
+                            child: container {
+                              transform {
+                                child: container {
+                                  transform {
+                                    child: container {
+                                      rounded-clip {
+                                        child: texture {
+                                          bounds: 0 0 198 198;
+texture: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA+gAAAPoCAIAAADCwUOzAAAQ3ElEQVR42u3WMQEAAAQAQeTQ\
+vyYVjIa7CD99TnQAAAC/lQQAAGDcAQAA4w4AAMYdAAAw7gAAgHEHAADjDgAAGHcAAMC4AwCA\
+cQcAAIw7AAAYdwAAwLgDAADGHQAAjDsAAGDcAQAA4w4AAMYdAAAw7gAAgHEHAADjDgAAGHcA\
+ADDuAACAcQcAAIw7AAAYdwAAwLgDAADGHQAAjDsAAGDcAQDAuAMAAMYdAAAw7gAAYNwBAADj\
+DgAAGHcAADDuAACAcQcAAIw7AAAYdwAAwLgDAIBxBwAAjDsAAGDcAQDAuAMAAMYdAAAw7gAA\
+YNwBAADjDgAAxh0AADDuAACAcQcAAOMOAAAYdwAAwLgDAIBxBwAAjDsAAGDcAQDAuAMAAMYd\
+AACMOwAAYNwBAADjDgAAxh0AADDuAACAcQcAAOMOAAAYdwAAMO4AAIBxBwAAjDsAABh3AADA\
+uAMAAMYdAACMOwAAYNwBAADjDgAAxh0AADDuAABg3AEAAOMOAAAYdwAAMO4AAIBxBwAAjDsA\
+ABh3AADAuAMAgHEHAACMOwAAYNwBAMC4AwAAxh0AADDuAABg3AEAAOMOAAAYdwAAMO4AAIBx\
+BwAA4w4AABh3AADAuAMAgHEHAACMOwAAYNwBAMC4AwAAxh0AAIw7AABg3AEAAOMOAADGHQAA\
+MO4AAIBxBwAA4w4AABh3AADAuAMAgHEHAACMOwAAGHcAAMC4AwAAxh0AAIw7AABg3AEAAOMO\
+AADGHQAAMO4AAGDcAQAA4w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gAAxh0AADDuAABg\
+3AEAAOMOAAAYdwAAMO4AAIBxBwAAjDsAABh3AADAuAMAgHEHAACMOwAAYNwBAMC4AwAAxh0A\
+ADDuAABg3AEAAOMOAAAYdwAAMO4AAIBxBwAA4w4AABh3AADAuAMAgHEHAACMOwAAYNwBAMC4\
+AwAAxh0AAIw7AABg3AEAAOMOAADGHQAAMO4AAIBxBwAA4w4AABh3AADAuAMAgHEHAACMOwAA\
+GHcAAMC4AwAAxh0AAIw7AABg3AEAAOMOAADGHQAAMO4AAGDcAQAA4w4AABh3AAAw7gAAgHEH\
+AACMOwAAGHcAAMC4AwAAxh0AAIw7AABg3AEAwLgDAADGHQAAMO4AAGDcAQAA4w4AABh3AAAw\
+7gAAgHEHAADjDgAAGHcAAMC4AwCAcQcAAIw7AABg3AEAwLgDAADGHQAAMO4AAGDcAQAA4w4A\
+AMYdAAAw7gAAgHEHAADjDgAAGHcAAMC4AwCAcQcAAIw7AAAYdwAAwLgDAADGHQAAjDsAAGDc\
+AQAA4w4AAMYdAAAw7gAAgHEHAADjDgAAGHcAADDuAACAcQcAAIw7AAAYdwAAwLgDAADGHQAA\
+jDsAAGDcAQDAuAMAAMYdAAAw7gAAYNwBAADjDgAAGHcAADDuAACAcQcAAIw7AAAYdwAAwLgD\
+AIBxBwAAjDsAAGDcAQDAuAMAAMYdAAAw7gAAYNwBAADjDgAAxh0AADDuAACAcQcAAOMOAAAY\
+dwAAwLgDAIBxBwAAjDsAAGDcAQDAuAMAAMYdAACMOwAAYNwBAADjDgAAxh0AADDuAACAcQcA\
+AOMOAAAYdwAAMO4AAIBxBwAAjDsAABh3AADAuAMAADcL5yQI6xyudn0AAAAASUVORK5CYII=\
+");
+                                        }
+                                        clip: 0 0 198 198 / 99;
+                                      }
+                                    }
+                                    transform: translate(1, 1);
+                                  }
+                                }
+                                transform: translate(1007, 756);
+                              }
+                            }
+                            transform: translate(15, 15);
+                          }
+                          transform: translate(0, 50);
+                        }
+                        clip: 0 0 1253 873;
+                      }
diff --git a/testsuite/gsk/compare/rounded-clip-in-clip-3d.png 
b/testsuite/gsk/compare/rounded-clip-in-clip-3d.png
new file mode 100644
index 0000000000..5a67919156
Binary files /dev/null and b/testsuite/gsk/compare/rounded-clip-in-clip-3d.png differ
diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build
index dbe7b9710c..1c45056104 100644
--- a/testsuite/gsk/meson.build
+++ b/testsuite/gsk/meson.build
@@ -75,6 +75,7 @@ compare_render_tests = [
   'clip-in-rounded-clip1',
   'clip-in-rounded-clip2',
   'clip-in-rounded-clip3',
+  'rounded-clip-in-clip-3d', # not really 3d, but cairo fails it
   'issue-3615'
 ]
 


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