mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
73ac2d0a1c
Because GL flips its shit sometimes (ie when it's the framebuffer), pass the height of the target as the flip variable, so commands that need to operate on the pixels can flip the y axis around this value.
93 lines
2.3 KiB
C
93 lines
2.3 KiB
C
#include "config.h"
|
|
|
|
#include "gskgpuscissoropprivate.h"
|
|
|
|
#include "gskgpuopprivate.h"
|
|
#include "gskgpuprintprivate.h"
|
|
|
|
typedef struct _GskGpuScissorOp GskGpuScissorOp;
|
|
|
|
struct _GskGpuScissorOp
|
|
{
|
|
GskGpuOp op;
|
|
|
|
cairo_rectangle_int_t rect;
|
|
};
|
|
|
|
static void
|
|
gsk_gpu_scissor_op_finish (GskGpuOp *op)
|
|
{
|
|
}
|
|
|
|
static void
|
|
gsk_gpu_scissor_op_print (GskGpuOp *op,
|
|
GskGpuFrame *frame,
|
|
GString *string,
|
|
guint indent)
|
|
{
|
|
GskGpuScissorOp *self = (GskGpuScissorOp *) op;
|
|
|
|
gsk_gpu_print_op (string, indent, "scissor");
|
|
gsk_gpu_print_int_rect (string, &self->rect);
|
|
gsk_gpu_print_newline (string);
|
|
}
|
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
static GskGpuOp *
|
|
gsk_gpu_scissor_op_vk_command (GskGpuOp *op,
|
|
GskGpuFrame *frame,
|
|
VkRenderPass render_pass,
|
|
VkFormat format,
|
|
VkCommandBuffer command_buffer)
|
|
{
|
|
GskGpuScissorOp *self = (GskGpuScissorOp *) op;
|
|
|
|
vkCmdSetScissor (command_buffer,
|
|
0,
|
|
1,
|
|
&(VkRect2D) {
|
|
{ self->rect.x, self->rect.y },
|
|
{ self->rect.width, self->rect.height },
|
|
});
|
|
|
|
return op->next;
|
|
}
|
|
#endif
|
|
|
|
static GskGpuOp *
|
|
gsk_gpu_scissor_op_gl_command (GskGpuOp *op,
|
|
GskGpuFrame *frame,
|
|
gsize flip_y)
|
|
{
|
|
GskGpuScissorOp *self = (GskGpuScissorOp *) op;
|
|
|
|
if (flip_y)
|
|
glScissor (self->rect.x, flip_y - self->rect.y - self->rect.height, self->rect.width, self->rect.height);
|
|
else
|
|
glScissor (self->rect.x, self->rect.y, self->rect.width, self->rect.height);
|
|
|
|
return op->next;
|
|
}
|
|
|
|
static const GskGpuOpClass GSK_GPU_SCISSOR_OP_CLASS = {
|
|
GSK_GPU_OP_SIZE (GskGpuScissorOp),
|
|
GSK_GPU_STAGE_COMMAND,
|
|
gsk_gpu_scissor_op_finish,
|
|
gsk_gpu_scissor_op_print,
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
gsk_gpu_scissor_op_vk_command,
|
|
#endif
|
|
gsk_gpu_scissor_op_gl_command
|
|
};
|
|
|
|
void
|
|
gsk_gpu_scissor_op (GskGpuFrame *frame,
|
|
const cairo_rectangle_int_t *rect)
|
|
{
|
|
GskGpuScissorOp *self;
|
|
|
|
self = (GskGpuScissorOp *) gsk_gpu_op_alloc (frame, &GSK_GPU_SCISSOR_OP_CLASS);
|
|
|
|
self->rect = *rect;
|
|
}
|