From b7c2528ad1d4fff3bbb4717bb1848e03dd65eb70 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 31 Oct 2023 19:19:32 -0400 Subject: [PATCH] gsk: Prepare subsurface offload Use a GskOffloadInfo to update subsurfaces (and collect info about them). Pass that info to both the diff and the render vfuncs. --- gsk/broadway/gskbroadwayrenderer.c | 3 ++- gsk/gl/gskglrenderer.c | 3 ++- gsk/gskcairorenderer.c | 3 ++- gsk/gskrenderer.c | 22 ++++++++++++---------- gsk/gskrendererprivate.h | 4 +++- gsk/vulkan/gskvulkanrenderer.c | 3 ++- 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/gsk/broadway/gskbroadwayrenderer.c b/gsk/broadway/gskbroadwayrenderer.c index c89f471b02..ea9ae84e24 100644 --- a/gsk/broadway/gskbroadwayrenderer.c +++ b/gsk/broadway/gskbroadwayrenderer.c @@ -919,7 +919,8 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer, static void gsk_broadway_renderer_render (GskRenderer *renderer, GskRenderNode *root, - const cairo_region_t *update_area) + const cairo_region_t *update_area, + GskOffload *offload) { GskBroadwayRenderer *self = GSK_BROADWAY_RENDERER (renderer); diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index f2ae830aff..2730f2466f 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -272,7 +272,8 @@ update_area_requires_clear (GdkSurface *surface, static void gsk_gl_renderer_render (GskRenderer *renderer, GskRenderNode *root, - const cairo_region_t *update_area) + const cairo_region_t *update_area, + GskOffload *offload) { GskGLRenderer *self = (GskGLRenderer *)renderer; cairo_region_t *render_region; diff --git a/gsk/gskcairorenderer.c b/gsk/gskcairorenderer.c index 71725f4b2f..3ea2f08b1b 100644 --- a/gsk/gskcairorenderer.c +++ b/gsk/gskcairorenderer.c @@ -152,7 +152,8 @@ gsk_cairo_renderer_render_texture (GskRenderer *renderer, static void gsk_cairo_renderer_render (GskRenderer *renderer, GskRenderNode *root, - const cairo_region_t *region) + const cairo_region_t *region, + GskOffload *offload) { GskCairoRenderer *self = GSK_CAIRO_RENDERER (renderer); cairo_t *cr; diff --git a/gsk/gskrenderer.c b/gsk/gskrenderer.c index 7ebb8a8787..6cc43372d2 100644 --- a/gsk/gskrenderer.c +++ b/gsk/gskrenderer.c @@ -41,6 +41,7 @@ #include "gl/gskglrenderer.h" #include "gskprofilerprivate.h" #include "gskrendernodeprivate.h" +#include "gskoffloadprivate.h" #include "gskenumtypes.h" @@ -128,7 +129,8 @@ gsk_renderer_real_render_texture (GskRenderer *self, static void gsk_renderer_real_render (GskRenderer *self, GskRenderNode *root, - const cairo_region_t *region) + const cairo_region_t *region, + GskOffload *offload) { GSK_RENDERER_WARN_NOT_IMPLEMENTED_METHOD (self, render); } @@ -424,6 +426,7 @@ gsk_renderer_render (GskRenderer *renderer, { GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer); cairo_region_t *clip; + GskOffload *offload = NULL; g_return_if_fail (GSK_IS_RENDERER (renderer)); g_return_if_fail (priv->is_realized); @@ -433,6 +436,11 @@ gsk_renderer_render (GskRenderer *renderer, if (priv->surface == NULL) return; + priv->root_node = gsk_render_node_ref (root); + + if (!GSK_RENDERER_DEBUG_CHECK (renderer, OFFLOAD_DISABLE)) + offload = gsk_offload_new (priv->surface, root); + if (region == NULL || priv->prev_node == NULL || GSK_RENDERER_DEBUG_CHECK (renderer, FULL_REDRAW)) { clip = cairo_region_create_rectangle (&(GdkRectangle) { @@ -444,18 +452,11 @@ gsk_renderer_render (GskRenderer *renderer, else { clip = cairo_region_copy (region); - gsk_render_node_diff (priv->prev_node, root, clip, NULL); - if (cairo_region_is_empty (clip)) - { - cairo_region_destroy (clip); - return; - } + gsk_render_node_diff (priv->prev_node, root, clip, offload); } - priv->root_node = gsk_render_node_ref (root); - - GSK_RENDERER_GET_CLASS (renderer)->render (renderer, root, clip); + GSK_RENDERER_GET_CLASS (renderer)->render (renderer, root, clip, offload); if (GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER)) { @@ -474,6 +475,7 @@ gsk_renderer_render (GskRenderer *renderer, g_clear_pointer (&priv->prev_node, gsk_render_node_unref); cairo_region_destroy (clip); + gsk_offload_free (offload); priv->prev_node = priv->root_node; priv->root_node = NULL; } diff --git a/gsk/gskrendererprivate.h b/gsk/gskrendererprivate.h index 6eba94747a..6d15be4167 100644 --- a/gsk/gskrendererprivate.h +++ b/gsk/gskrendererprivate.h @@ -21,6 +21,7 @@ #include "gskrenderer.h" #include "gskprofilerprivate.h" #include "gskdebugprivate.h" +#include "gskoffloadprivate.h" G_BEGIN_DECLS @@ -47,7 +48,8 @@ struct _GskRendererClass const graphene_rect_t *viewport); void (* render) (GskRenderer *renderer, GskRenderNode *root, - const cairo_region_t *invalid); + const cairo_region_t *invalid, + GskOffload *offload); }; GskProfiler * gsk_renderer_get_profiler (GskRenderer *renderer); diff --git a/gsk/vulkan/gskvulkanrenderer.c b/gsk/vulkan/gskvulkanrenderer.c index 08fcd3b278..d14735c5e1 100644 --- a/gsk/vulkan/gskvulkanrenderer.c +++ b/gsk/vulkan/gskvulkanrenderer.c @@ -349,7 +349,8 @@ gsk_vulkan_renderer_render_texture (GskRenderer *renderer, static void gsk_vulkan_renderer_render (GskRenderer *renderer, GskRenderNode *root, - const cairo_region_t *region) + const cairo_region_t *region, + GskOffload *offload) { GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer); GskVulkanRender *render;