diff --git a/gsk/gpu/gskgpublendop.c b/gsk/gpu/gskgpublendop.c index 53dd0f1f29..1f2450849d 100644 --- a/gsk/gpu/gskgpublendop.c +++ b/gsk/gpu/gskgpublendop.c @@ -30,6 +30,9 @@ gsk_gpu_blend_op_print (GskGpuOp *op, gsk_gpu_print_op (string, indent, "blend"); switch (self->blend) { + case GSK_GPU_BLEND_NONE: + gsk_gpu_print_string (string, "none"); + break; case GSK_GPU_BLEND_OVER: gsk_gpu_print_string (string, "over"); break; @@ -69,15 +72,25 @@ gsk_gpu_blend_op_gl_command (GskGpuOp *op, switch (self->blend) { + case GSK_GPU_BLEND_NONE: + glDisable (GL_BLEND); + break; + case GSK_GPU_BLEND_OVER: + glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); break; + case GSK_GPU_BLEND_ADD: + glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE); break; + case GSK_GPU_BLEND_CLEAR: + glEnable (GL_BLEND); glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); break; + default: g_assert_not_reached (); break; diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index c5846cf571..42227a00c0 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -693,13 +693,14 @@ gsk_gpu_copy_image (GskGpuFrame *frame, &(cairo_rectangle_int_t) { 0, 0, width, height }, &rect); - /* FIXME: With blend mode SOURCE/OFF we wouldn't need the clear here */ gsk_gpu_render_pass_begin_op (other.frame, copy, &(cairo_rectangle_int_t) { 0, 0, width, height }, - GSK_VEC4_TRANSPARENT, + NULL, GSK_RENDER_PASS_OFFSCREEN); + other.blend = GSK_GPU_BLEND_NONE; + other.pending_globals |= GSK_GPU_GLOBAL_BLEND; gsk_gpu_node_processor_sync_globals (&other, 0); gsk_gpu_node_processor_image_op (&other, @@ -3928,6 +3929,10 @@ gsk_gpu_node_processor_process (GskGpuFrame *frame, gsk_gpu_node_processor_add_node (&self, node); } + + gsk_gpu_render_pass_end_op (frame, + target, + pass_type); } else { @@ -3951,7 +3956,13 @@ gsk_gpu_node_processor_process (GskGpuFrame *frame, if (image != NULL) { - self.blend = GSK_GPU_BLEND_ADD; + gsk_gpu_render_pass_begin_op (frame, + target, + clip, + NULL, + pass_type); + + self.blend = GSK_GPU_BLEND_NONE; self.pending_globals |= GSK_GPU_GLOBAL_BLEND; gsk_gpu_node_processor_sync_globals (&self, 0); @@ -3966,15 +3977,15 @@ gsk_gpu_node_processor_process (GskGpuFrame *frame, &node->bounds, &self.offset, &tex_rect); + + gsk_gpu_render_pass_end_op (frame, + target, + pass_type); + g_object_unref (image); } } - - gsk_gpu_render_pass_end_op (frame, - target, - pass_type); - gsk_gpu_node_processor_finish (&self); } diff --git a/gsk/gpu/gskgputypesprivate.h b/gsk/gpu/gskgputypesprivate.h index 351f56bd8e..0279d159f6 100644 --- a/gsk/gpu/gskgputypesprivate.h +++ b/gsk/gpu/gskgputypesprivate.h @@ -49,6 +49,7 @@ typedef enum { } GskGpuShaderClip; typedef enum { + GSK_GPU_BLEND_NONE, GSK_GPU_BLEND_OVER, GSK_GPU_BLEND_ADD, GSK_GPU_BLEND_CLEAR diff --git a/gsk/gpu/gskvulkandevice.c b/gsk/gpu/gskvulkandevice.c index 80f53a94f2..361f6a66a7 100644 --- a/gsk/gpu/gskvulkandevice.c +++ b/gsk/gpu/gskvulkandevice.c @@ -911,7 +911,14 @@ struct _GskVulkanShaderSpecialization guint32 variation; }; -static VkPipelineColorBlendAttachmentState blend_attachment_states[3] = { +static VkPipelineColorBlendAttachmentState blend_attachment_states[4] = { + [GSK_GPU_BLEND_NONE] = { + .blendEnable = VK_FALSE, + .colorWriteMask = VK_COLOR_COMPONENT_A_BIT + | VK_COLOR_COMPONENT_R_BIT + | VK_COLOR_COMPONENT_G_BIT + | VK_COLOR_COMPONENT_B_BIT + }, [GSK_GPU_BLEND_OVER] = { .blendEnable = VK_TRUE, .colorBlendOp = VK_BLEND_OP_ADD,