gl renderer: Don't copy border outline corner sizes around

We already offset + scale the outline and its corners, just pass those
directly to the shader.
This commit is contained in:
Timm Bäder 2019-12-11 18:24:35 +01:00
parent 4744bb9099
commit ab04c74ec9
3 changed files with 8 additions and 25 deletions

View 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);

View 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;

View 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) -