2023-07-02 03:09:24 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gskvulkaninsetshadowopprivate.h"
|
|
|
|
|
2023-07-03 13:57:30 +00:00
|
|
|
#include "gskvulkanprivate.h"
|
2023-07-15 09:39:18 +00:00
|
|
|
#include "gskvulkanshaderopprivate.h"
|
2023-07-02 03:09:24 +00:00
|
|
|
#include "gsk/gskroundedrectprivate.h"
|
|
|
|
|
2023-07-03 13:57:30 +00:00
|
|
|
#include "vulkan/resources/inset-shadow.vert.h"
|
|
|
|
|
2023-07-02 03:09:24 +00:00
|
|
|
typedef struct _GskVulkanInsetShadowOp GskVulkanInsetShadowOp;
|
|
|
|
|
|
|
|
struct _GskVulkanInsetShadowOp
|
|
|
|
{
|
2023-07-15 09:39:18 +00:00
|
|
|
GskVulkanShaderOp op;
|
2023-07-02 03:09:24 +00:00
|
|
|
|
|
|
|
GskRoundedRect outline;
|
|
|
|
GdkRGBA color;
|
|
|
|
graphene_point_t offset;
|
|
|
|
float spread;
|
|
|
|
float blur_radius;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
gsk_vulkan_inset_shadow_op_finish (GskVulkanOp *op)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-07-05 04:32:52 +00:00
|
|
|
static void
|
|
|
|
gsk_vulkan_inset_shadow_op_print (GskVulkanOp *op,
|
|
|
|
GString *string,
|
|
|
|
guint indent)
|
|
|
|
{
|
|
|
|
GskVulkanInsetShadowOp *self = (GskVulkanInsetShadowOp *) op;
|
|
|
|
|
|
|
|
print_indent (string, indent);
|
|
|
|
print_rounded_rect (string, &self->outline);
|
|
|
|
g_string_append (string, "inset-shadow ");
|
|
|
|
if (self->blur_radius > 0)
|
|
|
|
g_string_append_printf (string, "blur %gpx ", self->blur_radius);
|
|
|
|
print_newline (string);
|
|
|
|
}
|
|
|
|
|
2023-07-02 03:09:24 +00:00
|
|
|
static void
|
2023-07-08 19:28:56 +00:00
|
|
|
gsk_vulkan_inset_shadow_op_collect_vertex_data (GskVulkanOp *op,
|
|
|
|
guchar *data)
|
2023-07-02 03:09:24 +00:00
|
|
|
{
|
|
|
|
GskVulkanInsetShadowOp *self = (GskVulkanInsetShadowOp *) op;
|
2023-07-15 09:39:18 +00:00
|
|
|
GskVulkanInsetShadowInstance *instance = (GskVulkanInsetShadowInstance *) (data + ((GskVulkanShaderOp *) op)->vertex_offset);
|
2023-07-02 03:09:24 +00:00
|
|
|
|
|
|
|
gsk_rounded_rect_to_float (&self->outline, graphene_point_zero (), instance->outline);
|
|
|
|
gsk_vulkan_rgba_to_float (&self->color, instance->color);
|
|
|
|
gsk_vulkan_point_to_float (&self->offset, instance->offset);
|
|
|
|
instance->spread = self->spread;
|
|
|
|
instance->blur_radius = self->blur_radius;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gsk_vulkan_inset_shadow_op_reserve_descriptor_sets (GskVulkanOp *op,
|
|
|
|
GskVulkanRender *render)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-07-15 09:39:18 +00:00
|
|
|
static const GskVulkanShaderOpClass GSK_VULKAN_INSET_SHADOW_OP_CLASS = {
|
|
|
|
{
|
|
|
|
GSK_VULKAN_OP_SIZE (GskVulkanInsetShadowOp),
|
2023-07-15 20:19:20 +00:00
|
|
|
GSK_VULKAN_STAGE_SHADER,
|
2023-07-15 09:39:18 +00:00
|
|
|
gsk_vulkan_inset_shadow_op_finish,
|
|
|
|
gsk_vulkan_inset_shadow_op_print,
|
|
|
|
gsk_vulkan_shader_op_count_vertex_data,
|
|
|
|
gsk_vulkan_inset_shadow_op_collect_vertex_data,
|
|
|
|
gsk_vulkan_inset_shadow_op_reserve_descriptor_sets,
|
|
|
|
gsk_vulkan_shader_op_command
|
|
|
|
},
|
2023-07-02 03:09:24 +00:00
|
|
|
"inset-shadow",
|
2023-07-15 11:28:08 +00:00
|
|
|
0,
|
2023-07-02 03:09:24 +00:00
|
|
|
&gsk_vulkan_inset_shadow_info,
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2023-07-09 18:28:12 +00:00
|
|
|
gsk_vulkan_inset_shadow_op (GskVulkanRender *render,
|
2023-07-15 10:47:35 +00:00
|
|
|
GskVulkanShaderClip clip,
|
2023-07-02 03:09:24 +00:00
|
|
|
const GskRoundedRect *outline,
|
|
|
|
const graphene_point_t *offset,
|
|
|
|
const GdkRGBA *color,
|
|
|
|
const graphene_point_t *shadow_offset,
|
|
|
|
float spread,
|
|
|
|
float blur_radius)
|
|
|
|
{
|
|
|
|
GskVulkanInsetShadowOp *self;
|
|
|
|
|
2023-07-15 11:28:08 +00:00
|
|
|
self = (GskVulkanInsetShadowOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_INSET_SHADOW_OP_CLASS, clip, NULL);
|
2023-07-02 03:09:24 +00:00
|
|
|
|
|
|
|
self->outline = *outline;
|
|
|
|
gsk_rounded_rect_offset (&self->outline, offset->x, offset->y);
|
|
|
|
self->color = *color;
|
|
|
|
self->offset = *shadow_offset;
|
|
|
|
self->spread = spread;
|
|
|
|
self->blur_radius = blur_radius;
|
|
|
|
}
|
|
|
|
|