gdk: Add gdk_draw_context_end_frame_full()

... and pass the opaque region of the node.

We don't do anything with it yet, this is just the plumbing.

The original function still exists, it passes NULL which is the value
for no opaque region at all.
This commit is contained in:
Benjamin Otte 2024-08-09 03:39:00 +02:00
parent 4fbfe9b041
commit 0b2275774f
8 changed files with 49 additions and 20 deletions

View File

@ -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);
}
/**

View File

@ -25,6 +25,8 @@
#include "gdkcolorstateprivate.h"
#include "gdkmemoryformatprivate.h"
#include <graphene.h>
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);

View File

@ -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);

View File

@ -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);

View File

@ -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 *

View File

@ -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;

View File

@ -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);
}

View File

@ -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