Revert "gl renderer: Limit texture node size to clip"
authorTimm Bäder <mail@baedert.org>
Mon, 19 Mar 2018 07:08:31 +0000 (08:08 +0100)
committerTimm Bäder <mail@baedert.org>
Tue, 20 Mar 2018 08:37:59 +0000 (09:37 +0100)
This reverts commit 0234e8e2c94ff6b0c6f4dfcd0c940910a97eca11.

This broke partially clipped-away nodes when they are being transformed,
e.g. by a rotation

gsk/gl/gskglrenderer.c

index f6137b76367e79928977865348cb121115ce7efa..b5f0e7dde51452aa6db41ac61a03fc8c9fd7c882 100644 (file)
@@ -551,24 +551,17 @@ render_color_node (GskGLRenderer       *self,
 }
 
 static inline void
-render_texture_node (GskGLRenderer   *self,
-                     GskRenderNode   *node,
-                     RenderOpBuilder *builder)
+render_texture_node (GskGLRenderer       *self,
+                     GskRenderNode       *node,
+                     RenderOpBuilder     *builder)
 {
-  float min_x = builder->dx + node->bounds.origin.x;
-  float min_y = builder->dy + node->bounds.origin.y;
-  float max_x = min_x + node->bounds.size.width;
-  float max_y = min_y + node->bounds.size.height;
+  const float min_x = builder->dx + node->bounds.origin.x;
+  const float min_y = builder->dy + node->bounds.origin.y;
+  const float max_x = min_x + node->bounds.size.width;
+  const float max_y = min_y + node->bounds.size.height;
   GdkTexture *texture = gsk_texture_node_get_texture (node);
   int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST;
   int texture_id;
-  const GskRoundedRect *clip = &builder->current_clip;
-  graphene_rect_t node_bounds = node->bounds;
-  float tx1, ty1, tx2, ty2; /* texture coords */
-
-  /* Offset the node position and apply the modelview here already */
-  graphene_rect_offset (&node_bounds, builder->dx, builder->dy);
-  graphene_matrix_transform_bounds (&builder->current_modelview, &node_bounds, &node_bounds);
 
   get_gl_scaling_filters (node, &gl_min_filter, &gl_mag_filter);
 
@@ -579,49 +572,15 @@ render_texture_node (GskGLRenderer   *self,
   ops_set_program (builder, &self->blit_program);
   ops_set_texture (builder, texture_id);
 
-  if (!graphene_rect_contains_rect (&clip->bounds, &node_bounds))
-    {
-      const float scale_x = node->bounds.size.width / gdk_texture_get_width (texture);
-      const float scale_y = node->bounds.size.height / gdk_texture_get_height (texture);
-      graphene_matrix_t inverse_transform;
-      graphene_rect_t intersection;
-      graphene_rect_intersection (&clip->bounds, &node_bounds, &intersection);
-
-      /* The texture is completely outside of the current clip bounds */
-      if (graphene_rect_equal (&intersection, graphene_rect_zero ()))
-        return;
-
-      tx1 = (intersection.origin.x - node_bounds.origin.x) / gdk_texture_get_width (texture) / scale_x;
-      ty1 = (intersection.origin.y - node_bounds.origin.y) / gdk_texture_get_height (texture) / scale_y;
-      tx2 = tx1 + (intersection.size.width / gdk_texture_get_width (texture)) / scale_x;
-      ty2 = ty1 + (intersection.size.height / gdk_texture_get_height (texture)) / scale_y;
-
-      /* Invert intersection again, since we will apply the modelview once more in the shader */
-      graphene_matrix_inverse (&builder->current_modelview, &inverse_transform);
-      graphene_matrix_transform_bounds (&inverse_transform, &intersection, &intersection);
-
-      min_x = intersection.origin.x;
-      min_y = intersection.origin.y;
-      max_x = min_x + intersection.size.width;
-      max_y = min_y + intersection.size.height;
-    }
-  else
-    {
-      /* The whole thing */
-      tx1 = 0;
-      ty1 = 0;
-      tx2 = 1;
-      ty2 = 1;
-    }
 
   ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
-    { { min_x, min_y }, { tx1, ty1 }, },
-    { { min_x, max_y }, { tx1, ty2 }, },
-    { { max_x, min_y }, { tx2, ty1 }, },
+    { { min_x, min_y }, { 0, 0 }, },
+    { { min_x, max_y }, { 0, 1 }, },
+    { { max_x, min_y }, { 1, 0 }, },
 
-    { { max_x, max_y }, { tx2, ty2 }, },
-    { { min_x, max_y }, { tx1, ty2 }, },
-    { { max_x, min_y }, { tx2, ty1 }, },
+    { { max_x, max_y }, { 1, 1 }, },
+    { { min_x, max_y }, { 0, 1 }, },
+    { { max_x, min_y }, { 1, 0 }, },
   });
 }