2023-09-22 08:34:56 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gskgpuclearopprivate.h"
|
|
|
|
|
|
|
|
#include "gskgpuopprivate.h"
|
|
|
|
#include "gskgpuprintprivate.h"
|
|
|
|
/* for gsk_gpu_rgba_to_float() */
|
|
|
|
#include "gskgpushaderopprivate.h"
|
|
|
|
|
|
|
|
typedef struct _GskGpuClearOp GskGpuClearOp;
|
|
|
|
|
|
|
|
struct _GskGpuClearOp
|
|
|
|
{
|
|
|
|
GskGpuOp op;
|
|
|
|
|
|
|
|
cairo_rectangle_int_t rect;
|
2024-06-19 00:17:24 +00:00
|
|
|
float color[4];
|
2023-09-22 08:34:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
gsk_gpu_clear_op_finish (GskGpuOp *op)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gsk_gpu_clear_op_print (GskGpuOp *op,
|
|
|
|
GskGpuFrame *frame,
|
|
|
|
GString *string,
|
|
|
|
guint indent)
|
|
|
|
{
|
|
|
|
GskGpuClearOp *self = (GskGpuClearOp *) op;
|
|
|
|
|
|
|
|
gsk_gpu_print_op (string, indent, "clear");
|
|
|
|
gsk_gpu_print_int_rect (string, &self->rect);
|
2024-06-19 00:17:24 +00:00
|
|
|
gsk_gpu_print_rgba (string, self->color);
|
2023-09-22 08:34:56 +00:00
|
|
|
gsk_gpu_print_newline (string);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
|
|
static GskGpuOp *
|
2023-11-04 02:57:38 +00:00
|
|
|
gsk_gpu_clear_op_vk_command (GskGpuOp *op,
|
|
|
|
GskGpuFrame *frame,
|
|
|
|
GskVulkanCommandState *state)
|
2023-09-22 08:34:56 +00:00
|
|
|
{
|
|
|
|
GskGpuClearOp *self = (GskGpuClearOp *) op;
|
|
|
|
VkClearValue clear_value;
|
|
|
|
|
2024-06-19 00:17:24 +00:00
|
|
|
memcpy (clear_value.color.float32, self->color, sizeof (float) * 4);
|
2023-09-22 08:34:56 +00:00
|
|
|
|
2023-11-04 02:57:38 +00:00
|
|
|
vkCmdClearAttachments (state->vk_command_buffer,
|
2023-09-22 08:34:56 +00:00
|
|
|
1,
|
|
|
|
&(VkClearAttachment) {
|
|
|
|
VK_IMAGE_ASPECT_COLOR_BIT,
|
|
|
|
0,
|
|
|
|
clear_value,
|
|
|
|
},
|
|
|
|
1,
|
|
|
|
&(VkClearRect) {
|
|
|
|
{
|
|
|
|
{ self->rect.x, self->rect.y },
|
|
|
|
{ self->rect.width, self->rect.height },
|
|
|
|
},
|
|
|
|
0,
|
|
|
|
1
|
|
|
|
});
|
|
|
|
|
|
|
|
return op->next;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static GskGpuOp *
|
2023-11-04 02:57:38 +00:00
|
|
|
gsk_gpu_clear_op_gl_command (GskGpuOp *op,
|
|
|
|
GskGpuFrame *frame,
|
|
|
|
GskGLCommandState *state)
|
2023-09-22 08:34:56 +00:00
|
|
|
{
|
|
|
|
GskGpuClearOp *self = (GskGpuClearOp *) op;
|
|
|
|
int scissor[4];
|
|
|
|
|
|
|
|
glGetIntegerv (GL_SCISSOR_BOX, scissor);
|
|
|
|
|
2023-11-04 02:57:38 +00:00
|
|
|
if (state->flip_y)
|
|
|
|
glScissor (self->rect.x, state->flip_y - self->rect.y - self->rect.height, self->rect.width, self->rect.height);
|
2023-09-22 08:34:56 +00:00
|
|
|
else
|
|
|
|
glScissor (self->rect.x, self->rect.y, self->rect.width, self->rect.height);
|
|
|
|
|
2024-06-19 00:17:24 +00:00
|
|
|
glClearColor (self->color[0], self->color[1], self->color[2], self->color[3]);
|
2023-09-22 08:34:56 +00:00
|
|
|
glClear (GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
|
|
glScissor (scissor[0], scissor[1], scissor[2], scissor[3]);
|
|
|
|
|
|
|
|
return op->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GskGpuOpClass GSK_GPU_CLEAR_OP_CLASS = {
|
|
|
|
GSK_GPU_OP_SIZE (GskGpuClearOp),
|
|
|
|
GSK_GPU_STAGE_COMMAND,
|
|
|
|
gsk_gpu_clear_op_finish,
|
|
|
|
gsk_gpu_clear_op_print,
|
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
|
|
gsk_gpu_clear_op_vk_command,
|
|
|
|
#endif
|
|
|
|
gsk_gpu_clear_op_gl_command
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
gsk_gpu_clear_op (GskGpuFrame *frame,
|
|
|
|
const cairo_rectangle_int_t *rect,
|
|
|
|
const GdkRGBA *color)
|
|
|
|
{
|
|
|
|
GskGpuClearOp *self;
|
|
|
|
|
|
|
|
self = (GskGpuClearOp *) gsk_gpu_op_alloc (frame, &GSK_GPU_CLEAR_OP_CLASS);
|
|
|
|
|
|
|
|
self->rect = *rect;
|
2024-06-19 00:17:24 +00:00
|
|
|
gsk_gpu_rgba_to_float (color, self->color);
|
2023-09-22 08:34:56 +00:00
|
|
|
}
|