diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index 757262a530..c9aff1420f 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -679,12 +679,24 @@ gsk_gpu_node_processor_image_op (GskGpuNodeProcessor *self, { gsk_gpu_straight_alpha_op (self->frame, gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, rect), + self->opacity, self->desc, descriptor, rect, &self->offset, tex_rect); } + else if (self->opacity < 1.0) + { + gsk_gpu_color_matrix_op_opacity (self->frame, + gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, rect), + self->desc, + descriptor, + rect, + &self->offset, + tex_rect, + self->opacity); + } else { gsk_gpu_texture_op (self->frame, @@ -3561,7 +3573,7 @@ static const struct }, [GSK_TEXTURE_NODE] = { 0, - 0, + GSK_GPU_HANDLE_OPACITY, gsk_gpu_node_processor_add_texture_node, gsk_gpu_node_processor_create_texture_pattern, }, diff --git a/gsk/gpu/gskgpustraightalphaop.c b/gsk/gpu/gskgpustraightalphaop.c index 1509144d85..2d17eab1b2 100644 --- a/gsk/gpu/gskgpustraightalphaop.c +++ b/gsk/gpu/gskgpustraightalphaop.c @@ -54,6 +54,7 @@ static const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS = { void gsk_gpu_straight_alpha_op (GskGpuFrame *frame, GskGpuShaderClip clip, + float opacity, GskGpuDescriptors *desc, guint32 descriptor, const graphene_rect_t *rect, @@ -71,4 +72,5 @@ gsk_gpu_straight_alpha_op (GskGpuFrame *frame, gsk_gpu_rect_to_float (rect, offset, instance->rect); gsk_gpu_rect_to_float (tex_rect, offset, instance->tex_rect); instance->tex_id = descriptor; + instance->opacity = opacity; } diff --git a/gsk/gpu/gskgpustraightalphaopprivate.h b/gsk/gpu/gskgpustraightalphaopprivate.h index ec9ca1ee49..127fc44bfa 100644 --- a/gsk/gpu/gskgpustraightalphaopprivate.h +++ b/gsk/gpu/gskgpustraightalphaopprivate.h @@ -8,6 +8,7 @@ G_BEGIN_DECLS void gsk_gpu_straight_alpha_op (GskGpuFrame *frame, GskGpuShaderClip clip, + float opacity, GskGpuDescriptors *desc, guint32 descriptor, const graphene_rect_t *rect, diff --git a/gsk/gpu/shaders/gskgpustraightalpha.glsl b/gsk/gpu/shaders/gskgpustraightalpha.glsl index dfd32bb69a..c30c30c3a0 100644 --- a/gsk/gpu/shaders/gskgpustraightalpha.glsl +++ b/gsk/gpu/shaders/gskgpustraightalpha.glsl @@ -4,7 +4,7 @@ PASS(0) vec2 _pos; PASS_FLAT(1) Rect _rect; PASS(2) vec2 _tex_coord; PASS_FLAT(3) uint _tex_id; - +PASS_FLAT(4) float _opacity; #ifdef GSK_VERTEX_SHADER @@ -12,6 +12,7 @@ PASS_FLAT(3) uint _tex_id; IN(0) vec4 in_rect; IN(1) vec4 in_tex_rect; IN(2) uint in_tex_id; +IN(3) float in_opacity; void run (out vec2 pos) @@ -24,6 +25,7 @@ run (out vec2 pos) _rect = r; _tex_coord = rect_get_coord (rect_from_gsk (in_tex_rect), pos); _tex_id = in_tex_id; + _opacity = in_opacity; } #endif @@ -37,7 +39,7 @@ run (out vec4 color, out vec2 position) { color = gsk_texture_straight_alpha (_tex_id, _tex_coord) * - rect_coverage (_rect, _pos); + rect_coverage (_rect, _pos) * _opacity; position = _pos; }