Merge branch 'gdk-win32-incremental-rendering-fixes' into 'main'

GdkWin32: Incremental rendering fixes

See merge request GNOME/gtk!7655
This commit is contained in:
Luca Bacci 2024-08-28 09:30:29 +00:00
commit 63b68d2f5e
2 changed files with 21 additions and 24 deletions

View File

@ -58,10 +58,6 @@ struct _GdkWin32GLContextWGL
SWAP_METHOD_EXCHANGE,
} swap_method;
/* Note: this member is only set when
* swap_method is exchange */
cairo_region_t *previous_frame_damage;
glAddSwapHintRectWIN_t ptr_glAddSwapHintRectWIN;
};
@ -74,8 +70,6 @@ gdk_win32_gl_context_wgl_dispose (GObject *gobject)
{
GdkWin32GLContextWGL *context_wgl = GDK_WIN32_GL_CONTEXT_WGL (gobject);
g_clear_pointer (&context_wgl->previous_frame_damage, cairo_region_destroy);
if (context_wgl->wgl_context != NULL)
{
if (gdk_win32_private_wglGetCurrentContext () == context_wgl->wgl_context)
@ -113,15 +107,19 @@ gdk_win32_gl_context_wgl_end_frame (GdkDrawContext *draw_context,
else
hdc = display_win32->dummy_context_wgl.hdc;
if (context_wgl->ptr_glAddSwapHintRectWIN)
/* context->old_updated_area[0] contains this frame's updated region
* (what actually changed since the previous frame) */
if (context_wgl->ptr_glAddSwapHintRectWIN &&
GDK_GL_MAX_TRACKED_BUFFERS >= 1 &&
context->old_updated_area[0])
{
int num_rectangles = cairo_region_num_rectangles (painted);
int num_rectangles = cairo_region_num_rectangles (context->old_updated_area[0]);
int scale = surface_win32->surface_scale;
cairo_rectangle_int_t rectangle;
for (int i = 0; i < num_rectangles; i++)
{
cairo_region_get_rectangle (painted, i, &rectangle);
cairo_region_get_rectangle (context->old_updated_area[0], i, &rectangle);
/* glAddSwapHintRectWIN works in OpenGL buffer coordinates and uses OpenGL
* conventions. Coordinates are that of the client-area, but the origin is
@ -156,8 +154,6 @@ gdk_win32_gl_context_wgl_end_frame (GdkDrawContext *draw_context,
}
SwapBuffers (hdc);
context_wgl->previous_frame_damage = cairo_region_copy (painted);
}
static void
@ -177,22 +173,15 @@ gdk_win32_gl_context_wgl_get_damage (GdkGLContext *gl_context)
}
if (self->swap_method == SWAP_METHOD_EXCHANGE &&
self->previous_frame_damage)
GDK_GL_MAX_TRACKED_BUFFERS >= 1 &&
gl_context->old_updated_area[0])
{
return self->previous_frame_damage;
return cairo_region_reference (gl_context->old_updated_area[0]);
}
return GDK_GL_CONTEXT_CLASS (gdk_win32_gl_context_wgl_parent_class)->get_damage (gl_context);
}
static void
gdk_win32_gl_context_wgl_surface_resized (GdkDrawContext *draw_context)
{
GdkWin32GLContextWGL *self = (GdkWin32GLContextWGL*) draw_context;
g_clear_pointer (&self->previous_frame_damage, cairo_region_destroy);
}
static void
gdk_win32_gl_context_wgl_begin_frame (GdkDrawContext *draw_context,
GdkMemoryDepth depth,
@ -1118,7 +1107,7 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
wglMakeCurrent (hdc_current, hglrc_current);
if (context_wgl->swap_method == SWAP_METHOD_UNDEFINED)
g_message ("Unkwown swap method");
g_message ("Unknown swap method");
GDK_NOTE (OPENGL,
g_print ("Created WGL context[%p], pixel_format=%d\n",
@ -1199,7 +1188,6 @@ gdk_win32_gl_context_wgl_class_init (GdkWin32GLContextWGLClass *klass)
draw_context_class->begin_frame = gdk_win32_gl_context_wgl_begin_frame;
draw_context_class->end_frame = gdk_win32_gl_context_wgl_end_frame;
draw_context_class->empty_frame = gdk_win32_gl_context_wgl_empty_frame;
draw_context_class->surface_resized = gdk_win32_gl_context_wgl_surface_resized;
gobject_class->dispose = gdk_win32_gl_context_wgl_dispose;
}

View File

@ -4483,8 +4483,13 @@ _gdk_win32_surface_compute_size (GdkSurface *surface)
if (!impl->drag_move_resize_context.native_move_resize_pending)
{
bool size_changed;
if (GDK_IS_TOPLEVEL (surface) && impl->force_recompute_size)
{
size_changed = width != surface->width ||
height != surface->height;
surface->width = width;
surface->height = height;
gdk_win32_surface_resize (surface, width, height);
@ -4492,11 +4497,15 @@ _gdk_win32_surface_compute_size (GdkSurface *surface)
}
else
{
size_changed = width != impl->next_layout.configured_width ||
height != impl->next_layout.configured_height;
surface->width = impl->next_layout.configured_width;
surface->height = impl->next_layout.configured_height;
}
_gdk_surface_update_size (surface);
if (size_changed)
_gdk_surface_update_size (surface);
}
return FALSE;