diff --git a/gdk/gdkdrawcontext.c b/gdk/gdkdrawcontext.c index cf64745790..5bb00de148 100644 --- a/gdk/gdkdrawcontext.c +++ b/gdk/gdkdrawcontext.c @@ -420,6 +420,22 @@ region_get_pixels (cairo_region_t *region) } #endif +void +gdk_draw_context_end_frame_full (GdkDrawContext *context, + const graphene_rect_t *opaque) +{ + GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context); + + GDK_DRAW_CONTEXT_GET_CLASS (context)->end_frame (context, priv->frame_region); + + gdk_profiler_set_int_counter (pixels_counter, region_get_pixels (priv->frame_region)); + + g_clear_pointer (&priv->color_state, gdk_color_state_unref); + g_clear_pointer (&priv->frame_region, cairo_region_destroy); + g_clear_object (&priv->surface->paint_context); + priv->depth = GDK_N_DEPTHS; +} + /** * gdk_draw_context_end_frame: * @context: a `GdkDrawContext` @@ -459,14 +475,7 @@ gdk_draw_context_end_frame (GdkDrawContext *context) return; } - GDK_DRAW_CONTEXT_GET_CLASS (context)->end_frame (context, priv->frame_region); - - gdk_profiler_set_int_counter (pixels_counter, region_get_pixels (priv->frame_region)); - - g_clear_pointer (&priv->color_state, gdk_color_state_unref); - g_clear_pointer (&priv->frame_region, cairo_region_destroy); - g_clear_object (&priv->surface->paint_context); - priv->depth = GDK_N_DEPTHS; + gdk_draw_context_end_frame_full (context, NULL); } /** diff --git a/gdk/gdkdrawcontextprivate.h b/gdk/gdkdrawcontextprivate.h index 7a140c95cf..32dbff4614 100644 --- a/gdk/gdkdrawcontextprivate.h +++ b/gdk/gdkdrawcontextprivate.h @@ -25,6 +25,8 @@ #include "gdkcolorstateprivate.h" #include "gdkmemoryformatprivate.h" +#include + G_BEGIN_DECLS #define GDK_DRAW_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAW_CONTEXT, GdkDrawContextClass)) @@ -58,6 +60,8 @@ void gdk_draw_context_surface_resized (GdkDrawContext void gdk_draw_context_begin_frame_full (GdkDrawContext *context, GdkMemoryDepth depth, const cairo_region_t *region); +void gdk_draw_context_end_frame_full (GdkDrawContext *context, + const graphene_rect_t *opaque); void gdk_draw_context_empty_frame (GdkDrawContext *context); diff --git a/gsk/broadway/gskbroadwayrenderer.c b/gsk/broadway/gskbroadwayrenderer.c index a65f24dbf7..6ec184a0e3 100644 --- a/gsk/broadway/gskbroadwayrenderer.c +++ b/gsk/broadway/gskbroadwayrenderer.c @@ -946,7 +946,7 @@ gsk_broadway_renderer_render (GskRenderer *renderer, self->nodes = NULL; self->node_textures = NULL; - gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->draw_context)); + gdk_draw_context_end_frame_full (GDK_DRAW_CONTEXT (self->draw_context), NULL); if (self->last_node_lookup) g_hash_table_unref (self->last_node_lookup); diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index bd02c50888..b59605d684 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -363,6 +363,7 @@ gsk_gl_renderer_render (GskRenderer *renderer, GskGLRenderJob *job; GdkSurface *surface; gboolean clear_framebuffer; + graphene_rect_t opaque; float scale; g_assert (GSK_IS_GL_RENDERER (renderer)); @@ -398,7 +399,10 @@ gsk_gl_renderer_render (GskRenderer *renderer, gsk_gl_driver_end_frame (self->driver); gsk_gl_render_job_free (job); - gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->context)); + if (gsk_render_node_get_opaque_rect (root, &opaque)) + gdk_draw_context_end_frame_full (GDK_DRAW_CONTEXT (self->context), &opaque); + else + gdk_draw_context_end_frame_full (GDK_DRAW_CONTEXT (self->context), NULL); gsk_gl_driver_after_frame (self->driver); diff --git a/gsk/gpu/gskgpuframe.c b/gsk/gpu/gskgpuframe.c index 90c789a005..8d057fe08d 100644 --- a/gsk/gpu/gskgpuframe.c +++ b/gsk/gpu/gskgpuframe.c @@ -87,10 +87,11 @@ gsk_gpu_frame_default_begin (GskGpuFrame *self, } static void -gsk_gpu_frame_default_end (GskGpuFrame *self, - GdkDrawContext *context) +gsk_gpu_frame_default_end (GskGpuFrame *self, + GdkDrawContext *context, + const graphene_rect_t *opaque) { - gdk_draw_context_end_frame (context); + gdk_draw_context_end_frame_full (context, opaque); } static void @@ -208,10 +209,11 @@ gsk_gpu_frame_begin (GskGpuFrame *self, } void -gsk_gpu_frame_end (GskGpuFrame *self, - GdkDrawContext *context) +gsk_gpu_frame_end (GskGpuFrame *self, + GdkDrawContext *context, + const graphene_rect_t *opaque) { - GSK_GPU_FRAME_GET_CLASS (self)->end (self, context); + GSK_GPU_FRAME_GET_CLASS (self)->end (self, context, opaque); } GskGpuDevice * diff --git a/gsk/gpu/gskgpuframeprivate.h b/gsk/gpu/gskgpuframeprivate.h index 8b993a0f21..b416e7d75b 100644 --- a/gsk/gpu/gskgpuframeprivate.h +++ b/gsk/gpu/gskgpuframeprivate.h @@ -32,7 +32,8 @@ struct _GskGpuFrameClass GdkMemoryDepth depth, const cairo_region_t *region); void (* end) (GskGpuFrame *self, - GdkDrawContext *context); + GdkDrawContext *context, + const graphene_rect_t *opaque); GskGpuImage * (* upload_texture) (GskGpuFrame *self, gboolean with_mipmap, GdkTexture *texture); @@ -68,7 +69,8 @@ void gsk_gpu_frame_begin (GskGpuF GdkMemoryDepth depth, const cairo_region_t *region); void gsk_gpu_frame_end (GskGpuFrame *self, - GdkDrawContext *context); + GdkDrawContext *context, + const graphene_rect_t *opaque); GdkDrawContext * gsk_gpu_frame_get_context (GskGpuFrame *self) G_GNUC_PURE; GskGpuDevice * gsk_gpu_frame_get_device (GskGpuFrame *self) G_GNUC_PURE; diff --git a/gsk/gpu/gskgpurenderer.c b/gsk/gpu/gskgpurenderer.c index 270d0168f9..d222a77775 100644 --- a/gsk/gpu/gskgpurenderer.c +++ b/gsk/gpu/gskgpurenderer.c @@ -420,6 +420,7 @@ gsk_gpu_renderer_render (GskRenderer *renderer, GskGpuFrame *frame; GskGpuImage *backbuffer; cairo_region_t *render_region; + graphene_rect_t opaque; double scale; GdkMemoryDepth depth; @@ -456,7 +457,10 @@ gsk_gpu_renderer_render (GskRenderer *renderer, ), NULL); - gsk_gpu_frame_end (frame, priv->context); + if (gsk_render_node_get_opaque_rect (root, &opaque)) + gsk_gpu_frame_end (frame, priv->context, &opaque); + else + gsk_gpu_frame_end (frame, priv->context, NULL); gsk_gpu_device_queue_gc (priv->device); } diff --git a/gsk/gskcairorenderer.c b/gsk/gskcairorenderer.c index ad9918b40a..d97f5a34d6 100644 --- a/gsk/gskcairorenderer.c +++ b/gsk/gskcairorenderer.c @@ -159,6 +159,7 @@ gsk_cairo_renderer_render (GskRenderer *renderer, const cairo_region_t *region) { GskCairoRenderer *self = GSK_CAIRO_RENDERER (renderer); + graphene_rect_t opaque; cairo_t *cr; gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->cairo_context), @@ -188,7 +189,10 @@ gsk_cairo_renderer_render (GskRenderer *renderer, cairo_destroy (cr); - gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->cairo_context)); + if (gsk_render_node_get_opaque_rect (root, &opaque)) + gdk_draw_context_end_frame_full (GDK_DRAW_CONTEXT (self->cairo_context), &opaque); + else + gdk_draw_context_end_frame_full (GDK_DRAW_CONTEXT (self->cairo_context), NULL); } static void