drawcontext: Only pass the region that matters

We used to pass 2 regions to GdkDrawCotnext.end_frame() but code was
confusing what they meant. So we now don't do that anymore and only pass
the region that matters: The frame region.
This commit is contained in:
Benjamin Otte 2018-04-23 23:26:14 +02:00
parent fd686afeb2
commit 83ea0b3714
11 changed files with 20 additions and 32 deletions

View File

@ -352,9 +352,7 @@ gdk_draw_context_end_frame (GdkDrawContext *context)
return;
}
GDK_DRAW_CONTEXT_GET_CLASS (context)->end_frame (context,
priv->frame_region,
priv->surface->active_update_area);
GDK_DRAW_CONTEXT_GET_CLASS (context)->end_frame (context, priv->frame_region);
g_clear_pointer (&priv->frame_region, cairo_region_destroy);
g_clear_object (&priv->surface->paint_context);

View File

@ -43,8 +43,7 @@ struct _GdkDrawContextClass
void (* begin_frame) (GdkDrawContext *context,
cairo_region_t *update_area);
void (* end_frame) (GdkDrawContext *context,
cairo_region_t *painted,
cairo_region_t *damage);
cairo_region_t *painted);
void (* surface_resized) (GdkDrawContext *context);
};

View File

@ -326,8 +326,7 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
static void
gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted,
cairo_region_t *damage)
cairo_region_t *painted)
{
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
GdkGLContext *shared;
@ -335,7 +334,7 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
shared = gdk_gl_context_get_shared_context (context);
if (shared)
{
GDK_DRAW_CONTEXT_GET_CLASS (GDK_DRAW_CONTEXT (shared))->end_frame (GDK_DRAW_CONTEXT (shared), painted, damage);
GDK_DRAW_CONTEXT_GET_CLASS (GDK_DRAW_CONTEXT (shared))->end_frame (GDK_DRAW_CONTEXT (shared), painted);
return;
}

View File

@ -401,8 +401,7 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
static void
gdk_vulkan_context_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted,
cairo_region_t *damage)
cairo_region_t *painted)
{
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);

View File

@ -173,8 +173,7 @@ gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context,
static void
gdk_wayland_cairo_context_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted,
cairo_region_t *damage)
cairo_region_t *painted)
{
GdkWaylandCairoContext *self = GDK_WAYLAND_CAIRO_CONTEXT (draw_context);
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);

View File

@ -204,8 +204,7 @@ gdk_wayland_gl_context_get_damage (GdkGLContext *context)
static void
gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted,
cairo_region_t *damage)
cairo_region_t *painted)
{
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
GdkSurface *surface = gdk_gl_context_get_surface (context);
@ -214,7 +213,7 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
EGLSurface egl_surface;
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->end_frame (draw_context, painted, damage);
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->end_frame (draw_context, painted);
if (gdk_gl_context_get_shared_context (context))
return;
@ -226,16 +225,16 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
if (display_wayland->have_egl_swap_buffers_with_damage && damage != NULL)
if (display_wayland->have_egl_swap_buffers_with_damage)
{
int i, j, n_rects = cairo_region_num_rectangles (damage);
int i, j, n_rects = cairo_region_num_rectangles (painted);
EGLint *rects = g_new (EGLint, n_rects * 4);
cairo_rectangle_int_t rect;
int surface_height = gdk_surface_get_height (surface);
for (i = 0, j = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (damage, i, &rect);
cairo_region_get_rectangle (painted, i, &rect);
rects[j++] = rect.x;
rects[j++] = surface_height - rect.height - rect.y;
rects[j++] = rect.width;

View File

@ -61,15 +61,14 @@ gdk_wayland_vulkan_context_create_surface (GdkVulkanContext *context,
static void
gdk_vulkan_context_wayland_end_frame (GdkDrawContext *context,
cairo_region_t *painted,
cairo_region_t *damage)
cairo_region_t *painted)
{
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_vulkan_context_parent_class)->end_frame (context, painted, damage);
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_vulkan_context_parent_class)->end_frame (context, painted);
}
static void

View File

@ -102,8 +102,7 @@ gdk_gl_blit_region (GdkSurface *surface, cairo_region_t *region)
static void
gdk_win32_gl_context_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted,
cairo_region_t *damage)
cairo_region_t *painted)
{
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
GdkWin32GLContext *context_win32 = GDK_WIN32_GL_CONTEXT (context);
@ -112,7 +111,7 @@ gdk_win32_gl_context_end_frame (GdkDrawContext *draw_context,
gboolean can_wait = display->hasWglOMLSyncControl;
cairo_rectangle_int_t whole_window;
GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_parent_class)->end_frame (draw_context, painted, damage);
GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_parent_class)->end_frame (draw_context, painted);
if (gdk_gl_context_get_shared_context (context))
return;

View File

@ -78,8 +78,7 @@ gdk_x11_cairo_context_begin_frame (GdkDrawContext *draw_context,
static void
gdk_x11_cairo_context_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted,
cairo_region_t *damage)
cairo_region_t *painted)
{
GdkX11CairoContext *self = GDK_X11_CAIRO_CONTEXT (draw_context);
cairo_t *cr;

View File

@ -120,8 +120,7 @@ maybe_wait_for_vblank (GdkDisplay *display,
static void
gdk_x11_gl_context_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted,
cairo_region_t *damage)
cairo_region_t *painted)
{
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (context);
@ -133,7 +132,7 @@ gdk_x11_gl_context_end_frame (GdkDrawContext *draw_context,
DrawableInfo *info;
GLXDrawable drawable;
GDK_DRAW_CONTEXT_CLASS (gdk_x11_gl_context_parent_class)->end_frame (draw_context, painted, damage);
GDK_DRAW_CONTEXT_CLASS (gdk_x11_gl_context_parent_class)->end_frame (draw_context, painted);
if (gdk_gl_context_get_shared_context (context))
return;

View File

@ -60,14 +60,13 @@ gdk_x11_vulkan_context_create_surface (GdkVulkanContext *context,
static void
gdk_x11_vulkan_context_end_frame (GdkDrawContext *context,
cairo_region_t *painted,
cairo_region_t *damage)
cairo_region_t *painted)
{
GdkSurface *surface = gdk_draw_context_get_surface (context);
gdk_x11_surface_pre_damage (surface);
GDK_DRAW_CONTEXT_CLASS (gdk_x11_vulkan_context_parent_class)->end_frame (context, painted, damage);
GDK_DRAW_CONTEXT_CLASS (gdk_x11_vulkan_context_parent_class)->end_frame (context, painted);
}
static void