mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-09 12:10:09 +00:00
macos: use GdkMacosBuffer for storing damage region
The GdkMacosBuffer object already has storage for tracking the damage region as it is used in GdkMacosCairoContext to manually copy regions from the front buffer to the back buffer. This makes the GdkMacosGLContext also use that field so that we can easily drop old damage regions when the buffer is lost. This happens during resizes, monitor changes, etc.
This commit is contained in:
parent
42f9ea07e2
commit
50e2a8239b
@ -38,8 +38,6 @@ struct _GdkMacosGLContext
|
|||||||
{
|
{
|
||||||
GdkGLContext parent_instance;
|
GdkGLContext parent_instance;
|
||||||
|
|
||||||
cairo_region_t *damage;
|
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||||
CGLContextObj cgl_context;
|
CGLContextObj cgl_context;
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
|
@ -469,6 +469,7 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
|||||||
buffer = _gdk_macos_surface_get_buffer (GDK_MACOS_SURFACE (surface));
|
buffer = _gdk_macos_surface_get_buffer (GDK_MACOS_SURFACE (surface));
|
||||||
|
|
||||||
_gdk_macos_buffer_set_flipped (buffer, TRUE);
|
_gdk_macos_buffer_set_flipped (buffer, TRUE);
|
||||||
|
_gdk_macos_buffer_set_damage (buffer, region);
|
||||||
|
|
||||||
/* Create our render target and bind it */
|
/* Create our render target and bind it */
|
||||||
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
||||||
@ -476,9 +477,6 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
|
|||||||
|
|
||||||
GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->begin_frame (context, prefers_high_depth, region);
|
GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->begin_frame (context, prefers_high_depth, region);
|
||||||
|
|
||||||
g_clear_pointer (&self->damage, cairo_region_destroy);
|
|
||||||
self->damage = g_steal_pointer (©);
|
|
||||||
|
|
||||||
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
gdk_gl_context_make_current (GDK_GL_CONTEXT (self));
|
||||||
CHECK_GL (NULL, glBindFramebuffer (GL_FRAMEBUFFER, self->fbo));
|
CHECK_GL (NULL, glBindFramebuffer (GL_FRAMEBUFFER, self->fbo));
|
||||||
}
|
}
|
||||||
@ -531,8 +529,6 @@ gdk_macos_gl_context_surface_resized (GdkDrawContext *draw_context)
|
|||||||
|
|
||||||
g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
|
g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
|
||||||
|
|
||||||
g_clear_pointer (&self->damage, cairo_region_destroy);
|
|
||||||
|
|
||||||
if (self->cgl_context != NULL)
|
if (self->cgl_context != NULL)
|
||||||
CGLUpdateContext (self->cgl_context);
|
CGLUpdateContext (self->cgl_context);
|
||||||
}
|
}
|
||||||
@ -587,9 +583,16 @@ static cairo_region_t *
|
|||||||
gdk_macos_gl_context_get_damage (GdkGLContext *context)
|
gdk_macos_gl_context_get_damage (GdkGLContext *context)
|
||||||
{
|
{
|
||||||
GdkMacosGLContext *self = (GdkMacosGLContext *)context;
|
GdkMacosGLContext *self = (GdkMacosGLContext *)context;
|
||||||
|
const cairo_region_t *damage;
|
||||||
|
GdkMacosBuffer *buffer;
|
||||||
|
GdkSurface *surface;
|
||||||
|
|
||||||
if (self->damage)
|
g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
|
||||||
return cairo_region_copy (self->damage);
|
|
||||||
|
if ((surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context))) &&
|
||||||
|
(buffer = GDK_MACOS_SURFACE (surface)->front) &&
|
||||||
|
(damage = _gdk_macos_buffer_get_damage (buffer)))
|
||||||
|
return cairo_region_copy (damage);
|
||||||
|
|
||||||
return GDK_GL_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->get_damage (context);
|
return GDK_GL_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->get_damage (context);
|
||||||
}
|
}
|
||||||
@ -619,8 +622,6 @@ gdk_macos_gl_context_dispose (GObject *gobject)
|
|||||||
CGLDestroyContext (cgl_context);
|
CGLDestroyContext (cgl_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_pointer (&self->damage, cairo_region_destroy);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gdk_macos_gl_context_parent_class)->dispose (gobject);
|
G_OBJECT_CLASS (gdk_macos_gl_context_parent_class)->dispose (gobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user