gl renderer: Don't copy border outline corner sizes around
authorTimm Bäder <mail@baedert.org>
Wed, 11 Dec 2019 17:24:35 +0000 (18:24 +0100)
committerTimm Bäder <mail@baedert.org>
Tue, 7 Jan 2020 16:27:15 +0000 (17:27 +0100)
We already offset + scale the outline and its corners, just pass those
directly to the shader.

gsk/gl/gskglrenderer.c
gsk/gl/gskglrenderopsprivate.h
gsk/resources/glsl/border.fs.glsl

index 859e574e9c669af1735e171229d7afb18f91575e..0799e1af15fbf7016533fa12dade8585da10fabe 100644 (file)
@@ -2635,26 +2635,10 @@ apply_border_op (const Program  *program,
                  const OpBorder *op)
 {
   const GskRoundedRect *o = &op->outline;
-  float outline[4];
-  float widths[4];
-  float heights[4];
-  int i;
   OP_PRINT (" -> Border Outline");
 
-  outline[0] = o->bounds.origin.x;
-  outline[1] = o->bounds.origin.y;
-  outline[2] = o->bounds.size.width;
-  outline[3] = o->bounds.size.height;
-
-  for (i = 0; i < 4; i ++)
-    {
-      widths[i] = o->corner[i].width;
-      heights[i] = o->corner[i].height;
-    }
-
-  glUniform4fv (program->border.outline_location, 1, outline);
-  glUniform4fv (program->border.corner_widths_location, 1, widths);
-  glUniform4fv (program->border.corner_heights_location, 1, heights);
+  glUniform4fv (program->border.outline_location, 1, (float *)&o->bounds);
+  glUniform2fv (program->border.corner_sizes_location, 4, (float *)&o->corner);
 }
 
 static inline void
@@ -2877,8 +2861,7 @@ gsk_gl_renderer_create_programs (GskGLRenderer  *self,
   INIT_PROGRAM_UNIFORM_LOCATION (border, color);
   INIT_PROGRAM_UNIFORM_LOCATION (border, widths);
   INIT_PROGRAM_UNIFORM_LOCATION (border, outline);
-  INIT_PROGRAM_UNIFORM_LOCATION (border, corner_widths);
-  INIT_PROGRAM_UNIFORM_LOCATION (border, corner_heights);
+  INIT_PROGRAM_UNIFORM_LOCATION (border, corner_sizes);
 
   /* cross fade */
   INIT_PROGRAM_UNIFORM_LOCATION (cross_fade, progress);
index f095a194ba3a1c26e64710ddad54b3176f6606d5..9924969ca4dd2eb14910733cd710a10bb48d8861 100644 (file)
@@ -99,8 +99,7 @@ struct _Program
       int color_location;
       int widths_location;
       int outline_location;
-      int corner_widths_location;
-      int corner_heights_location;
+      int corner_sizes_location;
     } border;
     struct {
       int source2_location;
index 970c5739eac1886940fd6a180f9e33e764a263b2..ea9760717e9a9f9963812e79fa94005d4a7b8f41 100644 (file)
@@ -2,8 +2,7 @@ uniform vec4 u_color;
 uniform vec4 u_widths;
 
 uniform vec4 u_outline;
-uniform vec4 u_corner_widths;
-uniform vec4 u_corner_heights;
+uniform vec2 u_corner_sizes[4];
 
 void main() {
   vec4 bounds = u_outline;
@@ -15,7 +14,9 @@ void main() {
   f.x += u_viewport.x;
   f.y = (u_viewport.y + u_viewport.w) - f.y;
 
-  RoundedRect routside = RoundedRect (bounds, u_corner_widths, u_corner_heights);
+  vec4 corner_widths = vec4(u_corner_sizes[0].x, u_corner_sizes[1].x, u_corner_sizes[2].x, u_corner_sizes[3].x);
+  vec4 corner_heights = vec4(u_corner_sizes[0].y, u_corner_sizes[1].y, u_corner_sizes[2].y, u_corner_sizes[3].y);
+  RoundedRect routside = RoundedRect (bounds, corner_widths, corner_heights);
   RoundedRect rinside = rounded_rect_shrink (routside, u_widths);
 
   float alpha = clamp (rounded_rect_coverage (routside, f.xy) -