apply_clip_op (const Program *program,
const OpClip *op)
{
- OP_PRINT (" -> Clip: %s", gsk_rounded_rect_to_string (&op->clip));
glUniform4fv (program->clip_rect_bounds_location, 1, (float *)&op->clip.bounds);
- glUniform2fv (program->clip_rect_corners_location, 4, (float *)&op->clip.corner);
+
+ if (op->send_corners)
+ {
+ OP_PRINT (" -> Clip: %s", gsk_rounded_rect_to_string (&op->clip));
+ glUniform2fv (program->clip_rect_corners_location, 4, (float *)&op->clip.corner);
+ }
+ else
+ {
+ OP_PRINT (" -> clip: %f, %f, %f, %f",
+ op->clip.bounds.origin.x, op->clip.bounds.origin.y,
+ op->clip.bounds.size.width, op->clip.bounds.size.height);
+ }
}
static inline void
return memcmp (a, b, sizeof (graphene_rect_t)) == 0;
}
+static inline gboolean
+rounded_rect_corners_equal (const GskRoundedRect *r1,
+ const GskRoundedRect *r2)
+{
+ int i;
+
+ if (!r1)
+ return FALSE;
+
+ for (i = 0; i < 4; i ++)
+ if (r1->corner[i].width != r2->corner[i].width ||
+ r1->corner[i].height != r2->corner[i].height)
+ return FALSE;
+
+ return TRUE;
+}
+
static inline ProgramState *
get_current_program_state (RenderOpBuilder *builder)
{
opc = ops_begin (builder, OP_CHANGE_CLIP);
opc->clip = *builder->current_clip;
+ opc->send_corners = !rounded_rect_corners_equal (builder->current_clip, &program_state->clip);
program_state->clip = *builder->current_clip;
}
OpClip *op;
if (current_program_state &&
- memcmp (¤t_program_state->clip, clip,sizeof (GskRoundedRect)) == 0)
+ rounded_rect_equal (¤t_program_state->clip, clip))
return;
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_CLIP)))
- op = op_buffer_add (&builder->render_ops, OP_CHANGE_CLIP);
+ {
+ op = op_buffer_add (&builder->render_ops, OP_CHANGE_CLIP);
+ op->send_corners = !current_program_state ||
+ !rounded_rect_corners_equal (¤t_program_state->clip, clip);
+ }
+ else
+ {
+ /* If the op before sent the corners, this one needs, too */
+ op->send_corners |= !current_program_state ||
+ !rounded_rect_corners_equal (¤t_program_state->clip, clip);
+ }
op->clip = *clip;
- if (builder->current_program != NULL)
+ if (current_program_state)
current_program_state->clip = *clip;
}