mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
gpu: Simplify the blur op a bit
I was looking through it and thought this looks better. It's also 21 lineas of code less.
This commit is contained in:
parent
a52ae238ab
commit
6a986f03b6
@ -53,37 +53,6 @@ static const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = {
|
|||||||
gsk_gpu_blur_setup_vao
|
gsk_gpu_blur_setup_vao
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
|
||||||
gsk_gpu_blur_op_full (GskGpuFrame *frame,
|
|
||||||
GskGpuShaderClip clip,
|
|
||||||
GdkColorState *ccs,
|
|
||||||
float opacity,
|
|
||||||
const graphene_point_t *offset,
|
|
||||||
guint32 variation,
|
|
||||||
const GskGpuShaderImage *image,
|
|
||||||
const graphene_vec2_t *blur_direction,
|
|
||||||
const GdkColor *blur_color)
|
|
||||||
{
|
|
||||||
GskGpuBlurInstance *instance;
|
|
||||||
GdkColorState *alt;
|
|
||||||
|
|
||||||
alt = gsk_gpu_color_states_find (ccs, blur_color);
|
|
||||||
|
|
||||||
gsk_gpu_shader_op_alloc (frame,
|
|
||||||
&GSK_GPU_BLUR_OP_CLASS,
|
|
||||||
gsk_gpu_color_states_create (ccs, TRUE, alt, variation & VARIATION_COLORIZE ? FALSE : TRUE),
|
|
||||||
variation,
|
|
||||||
clip,
|
|
||||||
(GskGpuImage *[1]) { image->image },
|
|
||||||
(GskGpuSampler[1]) { image->sampler },
|
|
||||||
&instance);
|
|
||||||
|
|
||||||
gsk_gpu_rect_to_float (image->coverage, offset, instance->rect);
|
|
||||||
gsk_gpu_rect_to_float (image->bounds, offset, instance->tex_rect);
|
|
||||||
graphene_vec2_to_float (blur_direction, instance->blur_direction);
|
|
||||||
gsk_gpu_color_to_float (blur_color, alt, opacity, instance->blur_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gsk_gpu_blur_op (GskGpuFrame *frame,
|
gsk_gpu_blur_op (GskGpuFrame *frame,
|
||||||
GskGpuShaderClip clip,
|
GskGpuShaderClip clip,
|
||||||
@ -93,19 +62,20 @@ gsk_gpu_blur_op (GskGpuFrame *frame,
|
|||||||
const GskGpuShaderImage *image,
|
const GskGpuShaderImage *image,
|
||||||
const graphene_vec2_t *blur_direction)
|
const graphene_vec2_t *blur_direction)
|
||||||
{
|
{
|
||||||
GdkColor blur_color;
|
GskGpuBlurInstance *instance;
|
||||||
|
|
||||||
gdk_color_init (&blur_color, ccs, (float[]) { 1, 1, 1, 1 });
|
gsk_gpu_shader_op_alloc (frame,
|
||||||
gsk_gpu_blur_op_full (frame,
|
&GSK_GPU_BLUR_OP_CLASS,
|
||||||
clip,
|
gsk_gpu_color_states_create_equal (TRUE, TRUE),
|
||||||
ccs,
|
0,
|
||||||
opacity,
|
clip,
|
||||||
offset,
|
(GskGpuImage *[1]) { image->image },
|
||||||
0,
|
(GskGpuSampler[1]) { image->sampler },
|
||||||
image,
|
&instance);
|
||||||
blur_direction,
|
|
||||||
&blur_color);
|
gsk_gpu_rect_to_float (image->coverage, offset, instance->rect);
|
||||||
gdk_color_finish (&blur_color);
|
gsk_gpu_rect_to_float (image->bounds, offset, instance->tex_rect);
|
||||||
|
graphene_vec2_to_float (blur_direction, instance->blur_direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -118,14 +88,23 @@ gsk_gpu_blur_shadow_op (GskGpuFrame *frame,
|
|||||||
const graphene_vec2_t *blur_direction,
|
const graphene_vec2_t *blur_direction,
|
||||||
const GdkColor *shadow_color)
|
const GdkColor *shadow_color)
|
||||||
{
|
{
|
||||||
gsk_gpu_blur_op_full (frame,
|
GskGpuBlurInstance *instance;
|
||||||
clip,
|
GdkColorState *alt;
|
||||||
ccs,
|
|
||||||
opacity,
|
alt = gsk_gpu_color_states_find (ccs, shadow_color);
|
||||||
offset,
|
|
||||||
VARIATION_COLORIZE,
|
gsk_gpu_shader_op_alloc (frame,
|
||||||
image,
|
&GSK_GPU_BLUR_OP_CLASS,
|
||||||
blur_direction,
|
gsk_gpu_color_states_create (ccs, TRUE, alt, FALSE),
|
||||||
shadow_color);
|
VARIATION_COLORIZE,
|
||||||
|
clip,
|
||||||
|
(GskGpuImage *[1]) { image->image },
|
||||||
|
(GskGpuSampler[1]) { image->sampler },
|
||||||
|
&instance);
|
||||||
|
|
||||||
|
gsk_gpu_rect_to_float (image->coverage, offset, instance->rect);
|
||||||
|
gsk_gpu_rect_to_float (image->bounds, offset, instance->tex_rect);
|
||||||
|
graphene_vec2_to_float (blur_direction, instance->blur_direction);
|
||||||
|
gsk_gpu_color_to_float (shadow_color, alt, opacity, instance->blur_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ run (out vec4 color,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (VARIATION_COLORIZE)
|
if (VARIATION_COLORIZE)
|
||||||
color = _blur_color * sum.a / coefficient_sum;
|
color = output_color_alpha (_blur_color, sum.a / coefficient_sum);
|
||||||
else
|
else
|
||||||
color = sum / coefficient_sum;
|
color = sum / coefficient_sum;
|
||||||
position = _pos;
|
position = _pos;
|
||||||
|
Loading…
Reference in New Issue
Block a user