gpu: Always pass a clip region to render()

This way, we can remove the code that checks for its existence in that
function, making the code simpler.
This commit is contained in:
Benjamin Otte 2024-08-03 14:06:56 +02:00
parent add5dec4a9
commit dbeddd4417
2 changed files with 22 additions and 25 deletions

View File

@ -639,35 +639,17 @@ gsk_gpu_frame_record (GskGpuFrame *self,
{
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
GskRenderPassType pass_type = texture ? GSK_RENDER_PASS_EXPORT : GSK_RENDER_PASS_PRESENT;
int i;
priv->timestamp = timestamp;
gsk_gpu_cache_set_time (gsk_gpu_device_get_cache (priv->device), timestamp);
if (clip)
for (i = 0; i < cairo_region_num_rectangles (clip); i++)
{
int i;
cairo_rectangle_int_t rect;
for (i = 0; i < cairo_region_num_rectangles (clip); i++)
{
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (clip, i, &rect);
gsk_gpu_node_processor_process (self, target, target_color_state, &rect, node, viewport, pass_type);
}
}
else
{
gsk_gpu_node_processor_process (self,
target,
target_color_state,
&(cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (target),
gsk_gpu_image_get_height (target)
},
node,
viewport,
pass_type);
cairo_region_get_rectangle (clip, i, &rect);
gsk_gpu_node_processor_process (self, target, target_color_state, &rect, node, viewport, pass_type);
}
if (texture)

View File

@ -264,6 +264,7 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
guchar *data;
GdkTexture *texture;
GdkTextureDownloader downloader;
cairo_region_t *clip_region;
GskGpuFrame *frame;
max_size = gsk_gpu_device_get_max_image_size (priv->device);
@ -304,12 +305,17 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
else
color_state = GDK_COLOR_STATE_SRGB;
clip_region = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (image),
gsk_gpu_image_get_height (image)
});
frame = gsk_gpu_renderer_create_frame (self);
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
image,
color_state,
NULL,
clip_region,
root,
&GRAPHENE_RECT_INIT (rounded_viewport->origin.x + x,
rounded_viewport->origin.y + y,
@ -317,6 +323,7 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
image_height),
&texture);
g_object_unref (frame);
cairo_region_destroy (clip_region);
g_assert (texture);
gdk_texture_downloader_init (&downloader, texture);
@ -352,6 +359,7 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer,
GdkTexture *texture;
graphene_rect_t rounded_viewport;
GdkColorState *color_state;
cairo_region_t *clip_region;
gsk_gpu_device_maybe_gc (priv->device);
@ -376,16 +384,23 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer,
frame = gsk_gpu_renderer_create_frame (self);
clip_region = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (image),
gsk_gpu_image_get_height (image)
});
texture = NULL;
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
image,
color_state,
NULL,
clip_region,
root,
&rounded_viewport,
&texture);
cairo_region_destroy (clip_region);
g_object_unref (frame);
g_object_unref (image);