gl renderer: Track border width state separately

This commit is contained in:
Timm Bäder 2018-12-05 10:44:11 +01:00
parent 57efdcfbbe
commit 3ce45508e1
3 changed files with 45 additions and 18 deletions

View File

@ -663,7 +663,8 @@ render_border_node (GskGLRenderer *self,
}
ops_set_program (builder, &self->border_program);
ops_set_border (builder, widths, &outline);
ops_set_border_width (builder, widths);
ops_set_border (builder, &outline);
for (i = 0; i < 4; i ++)
{
@ -1879,8 +1880,7 @@ apply_border_op (const Program *program,
float widths[4];
float heights[4];
int i;
OP_PRINT (" -> Border (%f, %f, %f, %f)",
op->border.widths[0], op->border.widths[1], op->border.widths[2], op->border.widths[3]);
OP_PRINT (" -> Border Outline");
outline[0] = o->bounds.origin.x;
outline[1] = o->bounds.origin.y;
@ -1893,12 +1893,21 @@ apply_border_op (const Program *program,
heights[i] = o->corner[i].height;
}
glUniform4fv (program->border.widths_location, 1, op->border.widths);
glUniform4fv (program->border.outline_location, 1, outline);
glUniform4fv (program->border.corner_widths_location, 1, widths);
glUniform4fv (program->border.corner_heights_location, 1, heights);
}
static inline void
apply_border_width_op (const Program *program,
const RenderOp *op)
{
OP_PRINT (" -> Border width (%f, %f, %f, %f)",
op->border.widths[0], op->border.widths[1], op->border.widths[2], op->border.widths[3]);
glUniform4fv (program->border.widths_location, 1, op->border.widths);
}
static inline void
apply_border_color_op (const Program *program,
const RenderOp *op)
@ -2608,6 +2617,10 @@ gsk_gl_renderer_render_ops (GskGLRenderer *self,
apply_border_op (program, op);
break;
case OP_CHANGE_BORDER_WIDTH:
apply_border_width_op (program, op);
break;
case OP_CHANGE_UNBLURRED_OUTSET_SHADOW:
apply_unblurred_outset_shadow_op (program, op);
break;

View File

@ -537,28 +537,40 @@ ops_set_color_matrix (RenderOpBuilder *builder,
void
ops_set_border (RenderOpBuilder *builder,
const float *widths,
const GskRoundedRect *outline)
{
RenderOp op;
if (memcmp (&builder->current_program_state->border.widths,
widths, sizeof (float) * 4) == 0 &&
memcmp (&builder->current_program_state->border.outline,
if (memcmp (&builder->current_program_state->border.outline,
outline, sizeof (GskRoundedRect)) == 0)
return;
memcpy (&builder->program_state[builder->current_program->index].border.widths,
widths, sizeof (float) * 4);
builder->current_program_state->border.outline = *outline;
op.op = OP_CHANGE_BORDER;
op.border.outline = *outline;
g_array_append_val (builder->render_ops, op);
}
void
ops_set_border_width (RenderOpBuilder *builder,
const float *widths)
{
RenderOp op;
if (memcmp (builder->current_program_state->border.widths,
widths, sizeof (float) * 4) == 0)
return;
memcpy (&builder->current_program_state->border.widths,
widths, sizeof (float) * 4);
op.op = OP_CHANGE_BORDER_WIDTH;
op.border.widths[0] = widths[0];
op.border.widths[1] = widths[1];
op.border.widths[2] = widths[2];
op.border.widths[3] = widths[3];
op.border.outline = *outline;
g_array_append_val (builder->render_ops, op);
}

View File

@ -50,11 +50,12 @@ enum {
OP_CHANGE_OUTSET_SHADOW = 15,
OP_CHANGE_BORDER = 16,
OP_CHANGE_BORDER_COLOR = 17,
OP_CHANGE_CROSS_FADE = 18,
OP_CHANGE_UNBLURRED_OUTSET_SHADOW = 19,
OP_CLEAR = 20,
OP_DRAW = 21,
OP_DUMP_FRAMEBUFFER = 22,
OP_CHANGE_BORDER_WIDTH = 18,
OP_CHANGE_CROSS_FADE = 19,
OP_CHANGE_UNBLURRED_OUTSET_SHADOW = 20,
OP_CLEAR = 21,
OP_DRAW = 22,
OP_DUMP_FRAMEBUFFER = 23,
};
typedef struct
@ -310,8 +311,9 @@ void ops_set_color_matrix (RenderOpBuilder *builder,
const graphene_vec4_t *offset);
void ops_set_border (RenderOpBuilder *builder,
const float *widths,
const GskRoundedRect *outline);
void ops_set_border_width (RenderOpBuilder *builder,
const float *widths);
void ops_set_border_color (RenderOpBuilder *builder,
const GdkRGBA *color);