mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
gl renderer: Keep track of border program state
This commit is contained in:
parent
f978bf057f
commit
c9af94f6db
@ -340,7 +340,6 @@ render_border_node (GskGLRenderer *self,
|
||||
graphene_rect_t transformed_clip;
|
||||
graphene_rect_t intersection;
|
||||
GskRoundedRect child_clip;
|
||||
RenderOp op;
|
||||
struct {
|
||||
float w;
|
||||
float h;
|
||||
@ -379,12 +378,7 @@ render_border_node (GskGLRenderer *self,
|
||||
|
||||
prev_clip = ops_set_clip (builder, &child_clip);
|
||||
|
||||
op.op = OP_CHANGE_BORDER;
|
||||
op.border.widths[0] = widths[0];
|
||||
op.border.widths[1] = widths[1];
|
||||
op.border.widths[2] = widths[2];
|
||||
op.border.widths[3] = widths[3];
|
||||
ops_add (builder, &op);
|
||||
ops_set_border (builder, widths);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -392,7 +386,7 @@ render_border_node (GskGLRenderer *self,
|
||||
}
|
||||
|
||||
/* Top */
|
||||
ops_set_color (builder, &colors[0]);
|
||||
ops_set_border_color (builder, &colors[0]);
|
||||
ops_draw (builder, (const GskQuadVertex[6]) {
|
||||
{ { min_x, min_y }, { 0, 1 }, }, /* Upper left */
|
||||
{ { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, }, /* Lower left */
|
||||
@ -404,7 +398,7 @@ render_border_node (GskGLRenderer *self,
|
||||
});
|
||||
|
||||
/* Right */
|
||||
ops_set_color (builder, &colors[1]);
|
||||
ops_set_border_color (builder, &colors[1]);
|
||||
ops_draw (builder, (const GskQuadVertex[6]) {
|
||||
{ { max_x - sizes[1].w, min_y + sizes[1].h }, { 0, 1 }, }, /* Upper left */
|
||||
{ { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, }, /* Lower left */
|
||||
@ -416,7 +410,7 @@ render_border_node (GskGLRenderer *self,
|
||||
});
|
||||
|
||||
/* Bottom */
|
||||
ops_set_color (builder, &colors[2]);
|
||||
ops_set_border_color (builder, &colors[2]);
|
||||
ops_draw (builder, (const GskQuadVertex[6]) {
|
||||
{ { min_x + sizes[3].w, max_y - sizes[3].h }, { 0, 1 }, }, /* Upper left */
|
||||
{ { min_x, max_y }, { 0, 0 }, }, /* Lower left */
|
||||
@ -428,7 +422,7 @@ render_border_node (GskGLRenderer *self,
|
||||
});
|
||||
|
||||
/* Left */
|
||||
ops_set_color (builder, &colors[3]);
|
||||
ops_set_border_color (builder, &colors[3]);
|
||||
ops_draw (builder, (const GskQuadVertex[6]) {
|
||||
{ { min_x, min_y }, { 0, 1 }, }, /* Upper left */
|
||||
{ { min_x, max_y }, { 0, 0 }, }, /* Lower left */
|
||||
@ -1537,13 +1531,20 @@ gsk_gl_renderer_render_ops (GskGLRenderer *self,
|
||||
case OP_CHANGE_COLOR:
|
||||
OP_PRINT (" -> Color: (%f, %f, %f, %f)", op->color.red, op->color.green, op->color.blue, op->color.alpha);
|
||||
g_assert (program == &self->color_program || program == &self->coloring_program ||
|
||||
program == &self->shadow_program || program == &self->border_program);
|
||||
program == &self->shadow_program);
|
||||
/* TODO: We use color.color_location here and this is right for all three of the programs above,
|
||||
* but that's just a coincidence. */
|
||||
glUniform4f (program->color.color_location,
|
||||
op->color.red, op->color.green, op->color.blue, op->color.alpha);
|
||||
break;
|
||||
|
||||
case OP_CHANGE_BORDER_COLOR:
|
||||
OP_PRINT (" -> Border color (%f, %f, %f, %f)",
|
||||
op->border.color[0], op->border.color[1], op->border.color[2], op->border.color[3]);
|
||||
g_assert (program == &self->border_program);
|
||||
glUniform4fv (program->border.color_location, 1, op->border.color);
|
||||
break;
|
||||
|
||||
case OP_CHANGE_CLIP:
|
||||
OP_PRINT (" -> Clip (%f, %f, %f, %f) (%f, %f, %f, %f), (%f, %f, %f, %f)",
|
||||
op->clip.bounds.origin.x, op->clip.bounds.origin.y,
|
||||
|
@ -1,5 +1,14 @@
|
||||
#include "gskglrenderopsprivate.h"
|
||||
|
||||
static inline void
|
||||
rgba_to_float (const GdkRGBA *c,
|
||||
float *f)
|
||||
{
|
||||
f[0] = c->red;
|
||||
f[1] = c->green;
|
||||
f[2] = c->blue;
|
||||
f[3] = c->alpha;
|
||||
}
|
||||
|
||||
void
|
||||
ops_set_program (RenderOpBuilder *builder,
|
||||
@ -275,6 +284,44 @@ ops_set_color_matrix (RenderOpBuilder *builder,
|
||||
g_array_append_val (builder->render_ops, op);
|
||||
}
|
||||
|
||||
void
|
||||
ops_set_border (RenderOpBuilder *builder,
|
||||
const float *widths)
|
||||
{
|
||||
RenderOp op;
|
||||
|
||||
if (memcmp (&builder->program_state[builder->current_program->index].border.widths,
|
||||
widths, sizeof (float) * 4) == 0)
|
||||
return;
|
||||
|
||||
memcpy (&builder->program_state[builder->current_program->index].border.widths,
|
||||
widths, sizeof (float) * 4);
|
||||
|
||||
op.op = OP_CHANGE_BORDER;
|
||||
op.border.widths[0] = widths[0];
|
||||
op.border.widths[1] = widths[1];
|
||||
op.border.widths[2] = widths[2];
|
||||
op.border.widths[3] = widths[3];
|
||||
g_array_append_val (builder->render_ops, op);
|
||||
}
|
||||
|
||||
void
|
||||
ops_set_border_color (RenderOpBuilder *builder,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
RenderOp op;
|
||||
op.op = OP_CHANGE_BORDER_COLOR;
|
||||
rgba_to_float (color, op.border.color);
|
||||
|
||||
if (memcmp (&op.border.color, &builder->program_state[builder->current_program->index].border.color,
|
||||
sizeof (float) * 4) == 0)
|
||||
return;
|
||||
|
||||
rgba_to_float (color, builder->program_state[builder->current_program->index].border.color);
|
||||
|
||||
g_array_append_val (builder->render_ops, op);
|
||||
}
|
||||
|
||||
void
|
||||
ops_draw (RenderOpBuilder *builder,
|
||||
const GskQuadVertex vertex_data[GL_N_VERTICES])
|
||||
|
@ -30,8 +30,9 @@ enum {
|
||||
OP_CHANGE_INSET_SHADOW = 14,
|
||||
OP_CHANGE_OUTSET_SHADOW = 15,
|
||||
OP_CHANGE_BORDER = 16,
|
||||
OP_CLEAR = 17,
|
||||
OP_DRAW = 18,
|
||||
OP_CHANGE_BORDER_COLOR = 17,
|
||||
OP_CLEAR = 18,
|
||||
OP_DRAW = 19,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@ -159,6 +160,7 @@ typedef struct
|
||||
} shadow;
|
||||
struct {
|
||||
float widths[4];
|
||||
float color[4];
|
||||
} border;
|
||||
};
|
||||
} RenderOp;
|
||||
@ -179,6 +181,10 @@ typedef struct
|
||||
graphene_matrix_t matrix;
|
||||
graphene_vec4_t offset;
|
||||
} color_matrix;
|
||||
struct {
|
||||
float widths[4];
|
||||
float color[4];
|
||||
} border;
|
||||
};
|
||||
} program_state[GL_N_PROGRAMS];
|
||||
|
||||
@ -230,6 +236,12 @@ void ops_set_color_matrix (RenderOpBuilder *builder,
|
||||
const graphene_matrix_t *matrix,
|
||||
const graphene_vec4_t *offset);
|
||||
|
||||
void ops_set_border (RenderOpBuilder *builder,
|
||||
const float *widths);
|
||||
|
||||
void ops_set_border_color (RenderOpBuilder *builder,
|
||||
const GdkRGBA *color);
|
||||
|
||||
void ops_draw (RenderOpBuilder *builder,
|
||||
const GskQuadVertex vertex_data[GL_N_VERTICES]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user