gpu: clip to redraw region rects instead of extents

Instead of using the bounds of the clip region, emit individual
renderpasses for each rectangle of the clip region.

The benefit of this depends on how many pixels the clip region covers,
but for widget factory it reduces the required rendering by a huge
amount.

This is now the best clipping renderer - Cairo doesn't clip at all and
GL clips based on the extents.
This commit is contained in:
Benjamin Otte
2024-01-07 20:42:24 +01:00
parent c3cfabfa96
commit 3f3629154c

View File

@@ -514,6 +514,29 @@ copy_texture (gpointer user_data,
*target = g_object_ref (texture);
}
static void
gsk_gpu_frame_record_rect (GskGpuFrame *self,
GskGpuImage *target,
const cairo_rectangle_int_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport)
{
gsk_gpu_render_pass_begin_op (self,
target,
clip,
GSK_RENDER_PASS_PRESENT);
gsk_gpu_node_processor_process (self,
target,
clip,
node,
viewport);
gsk_gpu_render_pass_end_op (self,
target,
GSK_RENDER_PASS_PRESENT);
}
static void
gsk_gpu_frame_record (GskGpuFrame *self,
gint64 timestamp,
@@ -524,38 +547,34 @@ gsk_gpu_frame_record (GskGpuFrame *self,
GdkTexture **texture)
{
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
cairo_rectangle_int_t extents;
priv->timestamp = timestamp;
if (clip)
{
cairo_region_get_extents (clip, &extents);
int i;
for (i = 0; i < cairo_region_num_rectangles (clip); i++)
{
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (clip, i, &rect);
gsk_gpu_frame_record_rect (self, target, &rect, node, viewport);
}
}
else
{
extents = (cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (target),
gsk_gpu_image_get_height (target)
};
gsk_gpu_frame_record_rect (self,
target,
&(cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (target),
gsk_gpu_image_get_height (target)
},
node,
viewport);
}
gsk_gpu_render_pass_begin_op (self,
target,
&extents,
GSK_RENDER_PASS_PRESENT);
gsk_gpu_node_processor_process (self,
target,
&extents,
node,
viewport);
gsk_gpu_render_pass_end_op (self,
target,
GSK_RENDER_PASS_PRESENT);
if (texture)
gsk_gpu_download_op (self, target, TRUE, copy_texture, texture);
}