diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index 5d9c49bc6e..859e574e9c 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -192,16 +192,6 @@ dump_node (GskRenderNode *node, cairo_surface_destroy (surface); } -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; -} - static inline gboolean node_is_invisible (const GskRenderNode *node) { @@ -1567,7 +1557,7 @@ render_unblurred_inset_shadow_node (GskGLRenderer *self, ops_set_program (builder, &self->inset_shadow_program); op = ops_begin (builder, OP_CHANGE_INSET_SHADOW); - rgba_to_float (gsk_inset_shadow_node_peek_color (node), op->color); + op->color = gsk_inset_shadow_node_peek_color (node); rounded_rect_to_floats (self, builder, gsk_inset_shadow_node_peek_outline (node), op->outline, @@ -1660,7 +1650,7 @@ render_inset_shadow_node (GskGLRenderer *self, /* Actual inset shadow outline drawing */ ops_set_program (builder, &self->inset_shadow_program); op = ops_begin (builder, OP_CHANGE_INSET_SHADOW); - rgba_to_float (gsk_inset_shadow_node_peek_color (node), op->color); + op->color = gsk_inset_shadow_node_peek_color (node); rounded_rect_to_floats (self, builder, &outline_to_blur, op->outline, @@ -1757,7 +1747,7 @@ render_unblurred_outset_shadow_node (GskGLRenderer *self, ops_set_program (builder, &self->unblurred_outset_shadow_program); op = ops_begin (builder, OP_CHANGE_UNBLURRED_OUTSET_SHADOW); - rgba_to_float (gsk_outset_shadow_node_peek_color (node), op->color); + op->color = gsk_outset_shadow_node_peek_color (node); rounded_rect_to_floats (self, builder, outline, @@ -2496,8 +2486,7 @@ apply_color_op (const Program *program, { OP_PRINT (" -> Color: (%f, %f, %f, %f)", op->rgba.red, op->rgba.green, op->rgba.blue, op->rgba.alpha); - glUniform4f (program->color.color_location, - op->rgba.red, op->rgba.green, op->rgba.blue, op->rgba.alpha); + glUniform4fv (program->color.color_location, 1, (float *)op->rgba); } static inline void @@ -2589,7 +2578,7 @@ apply_inset_shadow_op (const Program *program, op->corner_heights[1], op->corner_heights[2], op->corner_heights[3]); - glUniform4fv (program->inset_shadow.color_location, 1, op->color); + glUniform4fv (program->inset_shadow.color_location, 1, (float *)op->color); glUniform2fv (program->inset_shadow.offset_location, 1, op->offset); glUniform1f (program->inset_shadow.spread_location, op->spread); glUniform4fv (program->inset_shadow.outline_location, 1, op->outline); @@ -2602,7 +2591,7 @@ apply_unblurred_outset_shadow_op (const Program *program, const OpShadow *op) { OP_PRINT (" -> unblurred outset shadow"); - glUniform4fv (program->unblurred_outset_shadow.color_location, 1, op->color); + glUniform4fv (program->unblurred_outset_shadow.color_location, 1, (float *)op->color); glUniform2fv (program->unblurred_outset_shadow.offset_location, 1, op->offset); glUniform1f (program->unblurred_outset_shadow.spread_location, op->spread); glUniform4fv (program->unblurred_outset_shadow.outline_location, 1, op->outline); @@ -2684,7 +2673,7 @@ apply_border_color_op (const Program *program, { OP_PRINT (" -> Border color (%f, %f, %f, %f)", op->color[0], op->color[1], op->color[2], op->color[3]); - glUniform4fv (program->border.color_location, 1, op->color); + glUniform4fv (program->border.color_location, 1, (float *)op->color); } static inline void diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c index 1c4f679e43..84774e29aa 100644 --- a/gsk/gl/gskglrenderops.c +++ b/gsk/gl/gskglrenderops.c @@ -41,16 +41,6 @@ ops_finish (RenderOpBuilder *builder) builder->current_viewport = GRAPHENE_RECT_INIT (0, 0, 0, 0); } -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; -} - /* Debugging only! */ void ops_dump_framebuffer (RenderOpBuilder *builder, @@ -594,10 +584,10 @@ ops_set_color (RenderOpBuilder *builder, if (gdk_rgba_equal (color, ¤t_program_state->color)) return; - current_program_state->color = *color; + current_program_state->color = color; op = ops_begin (builder, OP_CHANGE_COLOR); - op->rgba = *color; + op->rgba = color; } void @@ -668,16 +658,15 @@ ops_set_border_color (RenderOpBuilder *builder, { ProgramState *current_program_state = get_current_program_state (builder); OpBorder *op; - float fcolor[4]; - rgba_to_float (color, fcolor); - - if (memcmp (fcolor, ¤t_program_state->border.color, sizeof fcolor) == 0) + if (current_program_state->border.color && + gdk_rgba_equal (color, current_program_state->border.color)) return; op = op_buffer_add (&builder->render_ops, OP_CHANGE_BORDER_COLOR); - memcpy (op->color, fcolor, sizeof (float[4])); - memcpy (current_program_state->border.color, fcolor, sizeof (float[4])); + op->color = color; + + current_program_state->border.color = color; } void diff --git a/gsk/gl/gskglrenderopsprivate.h b/gsk/gl/gskglrenderopsprivate.h index d5a223450e..f095a194ba 100644 --- a/gsk/gl/gskglrenderopsprivate.h +++ b/gsk/gl/gskglrenderopsprivate.h @@ -127,14 +127,14 @@ typedef struct float opacity; /* Per-program state */ union { - GdkRGBA color; + const GdkRGBA *color; struct { graphene_matrix_t matrix; graphene_vec4_t offset; } color_matrix; struct { float widths[4]; - float color[4]; + const GdkRGBA *color; GskRoundedRect outline; } border; }; diff --git a/gsk/gl/opbuffer.h b/gsk/gl/opbuffer.h index ed40775878..210e7ed5c9 100644 --- a/gsk/gl/opbuffer.h +++ b/gsk/gl/opbuffer.h @@ -77,7 +77,7 @@ typedef struct typedef struct { - GdkRGBA rgba; + const GdkRGBA *rgba; } OpColor; typedef struct @@ -135,13 +135,13 @@ typedef struct float corner_heights[4]; float spread; float offset[2]; - float color[4]; + const GdkRGBA *color; } OpShadow; typedef struct { float widths[4]; - float color[4]; + const GdkRGBA *color; GskRoundedRect outline; } OpBorder;