mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 14:00:09 +00:00
gsk: Change the border op api
Pass the ccs, opacity and GdkColors to the op to let it make decisions about color conversion. Also, reorder the offset to follow the same order as the color ops. Update the callers.
This commit is contained in:
parent
3d55d733dc
commit
f3ffa99f6a
@ -97,19 +97,29 @@ static const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS = {
|
||||
void
|
||||
gsk_gpu_border_op (GskGpuFrame *frame,
|
||||
GskGpuShaderClip clip,
|
||||
GskGpuColorStates color_states,
|
||||
const GskRoundedRect *outline,
|
||||
GdkColorState *ccs,
|
||||
float opacity,
|
||||
const graphene_point_t *offset,
|
||||
const GskRoundedRect *outline,
|
||||
const graphene_point_t *inside_offset,
|
||||
const float widths[4],
|
||||
const float colors[4][4])
|
||||
const GdkColor colors[4])
|
||||
{
|
||||
GskGpuBorderInstance *instance;
|
||||
guint i;
|
||||
GdkColorState *alt;
|
||||
|
||||
if (GDK_IS_DEFAULT_COLOR_STATE (colors[0].color_state) &&
|
||||
gdk_color_state_equal (colors[0].color_state, colors[1].color_state) &&
|
||||
gdk_color_state_equal (colors[0].color_state, colors[2].color_state) &&
|
||||
gdk_color_state_equal (colors[0].color_state, colors[3].color_state))
|
||||
alt = colors[0].color_state;
|
||||
else
|
||||
alt = ccs;
|
||||
|
||||
gsk_gpu_shader_op_alloc (frame,
|
||||
&GSK_GPU_BORDER_OP_CLASS,
|
||||
color_states,
|
||||
gsk_gpu_color_states_create (ccs, TRUE, alt, FALSE),
|
||||
0,
|
||||
clip,
|
||||
NULL,
|
||||
@ -121,7 +131,7 @@ gsk_gpu_border_op (GskGpuFrame *frame,
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
instance->border_widths[i] = widths[i];
|
||||
gsk_gpu_vec4_to_float (colors[i], &instance->border_colors[4 * i]);
|
||||
gsk_gpu_color_to_float (&colors[i], alt, opacity, &instance->border_colors[4 * i]);
|
||||
}
|
||||
instance->offset[0] = inside_offset->x;
|
||||
instance->offset[1] = inside_offset->y;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "gskgputypesprivate.h"
|
||||
#include "gsktypes.h"
|
||||
#include "gdkcolorprivate.h"
|
||||
|
||||
#include <graphene.h>
|
||||
|
||||
@ -9,12 +10,13 @@ G_BEGIN_DECLS
|
||||
|
||||
void gsk_gpu_border_op (GskGpuFrame *frame,
|
||||
GskGpuShaderClip clip,
|
||||
GskGpuColorStates color_states,
|
||||
const GskRoundedRect *outline,
|
||||
GdkColorState *ccs,
|
||||
float opacity,
|
||||
const graphene_point_t *offset,
|
||||
const GskRoundedRect *outline,
|
||||
const graphene_point_t *inside_offset,
|
||||
const float widths[4],
|
||||
const float colors[4][4]);
|
||||
const GdkColor colors[4]);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -1626,24 +1626,24 @@ gsk_gpu_node_processor_add_border_node (GskGpuNodeProcessor *self,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
const GdkRGBA *rgbas;
|
||||
float colors[4][4];
|
||||
gsize i;
|
||||
GdkColor colors[4];
|
||||
|
||||
rgbas = gsk_border_node_get_colors (node);
|
||||
for (i = 0; i < G_N_ELEMENTS (colors); i++)
|
||||
{
|
||||
gdk_color_state_from_rgba (GDK_COLOR_STATE_SRGB, &rgbas[i], colors[i]);
|
||||
colors[i][3] *= self->opacity;
|
||||
}
|
||||
for (int i = 0; i < 4; i++)
|
||||
gdk_color_init_from_rgba (&colors[i], &rgbas[i]);
|
||||
|
||||
gsk_gpu_border_op (self->frame,
|
||||
gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, &node->bounds),
|
||||
gsk_gpu_node_processor_color_states_for_rgba (self),
|
||||
gsk_border_node_get_outline (node),
|
||||
self->ccs,
|
||||
self->opacity,
|
||||
&self->offset,
|
||||
gsk_border_node_get_outline (node),
|
||||
graphene_point_zero (),
|
||||
gsk_border_node_get_widths (node),
|
||||
colors);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
gdk_color_finish (&colors[i]);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -2117,25 +2117,24 @@ gsk_gpu_node_processor_add_inset_shadow_node (GskGpuNodeProcessor *self,
|
||||
|
||||
if (blur_radius < 0.01)
|
||||
{
|
||||
float color[4];
|
||||
GdkColor colors[4];
|
||||
|
||||
gdk_color_state_from_rgba (GDK_COLOR_STATE_SRGB, rgba, color);
|
||||
color[3] *= self->opacity;
|
||||
for (int i = 0; i < 4; i++)
|
||||
gdk_color_init_from_rgba (&colors[i], rgba);
|
||||
|
||||
gsk_gpu_border_op (self->frame,
|
||||
gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, &node->bounds),
|
||||
gsk_gpu_node_processor_color_states_for_rgba (self),
|
||||
gsk_inset_shadow_node_get_outline (node),
|
||||
self->ccs,
|
||||
self->opacity,
|
||||
&self->offset,
|
||||
gsk_inset_shadow_node_get_outline (node),
|
||||
&GRAPHENE_POINT_INIT (gsk_inset_shadow_node_get_dx (node),
|
||||
gsk_inset_shadow_node_get_dy (node)),
|
||||
(float[4]) { spread, spread, spread, spread },
|
||||
(float[4][4]) {
|
||||
{ color[0], color[1], color[2], color[3] },
|
||||
{ color[0], color[1], color[2], color[3] },
|
||||
{ color[0], color[1], color[2], color[3] },
|
||||
{ color[0], color[1], color[2], color[3] }
|
||||
});
|
||||
colors);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
gdk_color_finish (&colors[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2170,28 +2169,26 @@ gsk_gpu_node_processor_add_outset_shadow_node (GskGpuNodeProcessor *self,
|
||||
if (blur_radius < 0.01)
|
||||
{
|
||||
GskRoundedRect outline;
|
||||
float color[4];
|
||||
GdkColor colors[4];
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
gdk_color_init_from_rgba (&colors[i], rgba);
|
||||
|
||||
gsk_rounded_rect_init_copy (&outline, gsk_outset_shadow_node_get_outline (node));
|
||||
gsk_rounded_rect_shrink (&outline, -spread, -spread, -spread, -spread);
|
||||
graphene_rect_offset (&outline.bounds, dx, dy);
|
||||
|
||||
gdk_color_state_from_rgba (GDK_COLOR_STATE_SRGB, rgba, color);
|
||||
color[3] *= self->opacity;
|
||||
|
||||
gsk_gpu_border_op (self->frame,
|
||||
gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, &node->bounds),
|
||||
gsk_gpu_node_processor_color_states_for_rgba (self),
|
||||
&outline,
|
||||
self->ccs,
|
||||
self->opacity,
|
||||
&self->offset,
|
||||
&outline,
|
||||
&GRAPHENE_POINT_INIT (-dx, -dy),
|
||||
(float[4]) { spread, spread, spread, spread },
|
||||
(float[4][4]) {
|
||||
{ color[0], color[1], color[2], color[3] },
|
||||
{ color[0], color[1], color[2], color[3] },
|
||||
{ color[0], color[1], color[2], color[3] },
|
||||
{ color[0], color[1], color[2], color[3] }
|
||||
});
|
||||
colors);
|
||||
for (int i = 0; i < 4; i++)
|
||||
gdk_color_finish (&colors[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user