[gtk/wip/chergert/macos-fixes: 13/15] macos: be more careful about freezing/thawing surfaces
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/macos-fixes: 13/15] macos: be more careful about freezing/thawing surfaces
- Date: Thu, 3 Feb 2022 21:37:06 +0000 (UTC)
commit bd6d59bbbf49fc3e4562eda747516b83dfc73989
Author: Christian Hergert <christian hergert me>
Date: Tue Feb 1 16:06:08 2022 -0800
macos: be more careful about freezing/thawing surfaces
We need to avoid conflating the managing of frame callbacks from
the freeze/thaw mechanics and ensure we don't perform extra thaw
requests at the wrong time.
gdk/macos/gdkmacosdisplay.c | 12 +++++++-----
gdk/macos/gdkmacossurface-private.h | 2 +-
gdk/macos/gdkmacossurface.c | 16 ++++++++++------
3 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/gdk/macos/gdkmacosdisplay.c b/gdk/macos/gdkmacosdisplay.c
index 5866e03b5e..657fb57558 100644
--- a/gdk/macos/gdkmacosdisplay.c
+++ b/gdk/macos/gdkmacosdisplay.c
@@ -301,10 +301,14 @@ gdk_macos_display_frame_cb (gpointer data)
iter = iter->next;
+ _gdk_macos_surface_publish_timings (surface,
+ source->presentation_time,
+ source->refresh_interval);
+
_gdk_macos_display_remove_frame_callback (self, surface);
- _gdk_macos_surface_thaw (surface,
- source->presentation_time,
- source->refresh_interval);
+
+ if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (surface)))
+ gdk_surface_thaw_updates (GDK_SURFACE (surface));
}
return G_SOURCE_CONTINUE;
@@ -993,8 +997,6 @@ _gdk_macos_display_add_frame_callback (GdkMacosDisplay *self,
*/
g_queue_push_head_link (&self->awaiting_frames, &surface->frame);
- gdk_surface_freeze_updates (GDK_SURFACE (surface));
-
if (self->awaiting_frames.length == 1)
gdk_display_link_source_unpause ((GdkDisplayLinkSource *)self->frame_source);
}
diff --git a/gdk/macos/gdkmacossurface-private.h b/gdk/macos/gdkmacossurface-private.h
index e65505f8a9..ccb8a83179 100644
--- a/gdk/macos/gdkmacossurface-private.h
+++ b/gdk/macos/gdkmacossurface-private.h
@@ -104,7 +104,7 @@ void _gdk_macos_surface_resize (GdkMacosSurface
void _gdk_macos_surface_update_fullscreen_state (GdkMacosSurface *self);
void _gdk_macos_surface_update_position (GdkMacosSurface *self);
void _gdk_macos_surface_show (GdkMacosSurface *self);
-void _gdk_macos_surface_thaw (GdkMacosSurface *self,
+void _gdk_macos_surface_publish_timings (GdkMacosSurface *self,
gint64
predicted_presentation_time,
gint64 refresh_interval);
CGContextRef _gdk_macos_surface_acquire_context (GdkMacosSurface *self,
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index 19a4453212..6374f84e00 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -125,6 +125,8 @@ gdk_macos_surface_hide (GdkSurface *surface)
g_assert (GDK_IS_MACOS_SURFACE (self));
+ _gdk_macos_display_remove_frame_callback (GDK_MACOS_DISPLAY (surface->display), self);
+
was_mapped = GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self));
seat = gdk_display_get_default_seat (surface->display);
@@ -199,7 +201,11 @@ gdk_macos_surface_end_frame (GdkMacosSurface *self)
if ((timings = gdk_frame_clock_get_current_timings (frame_clock)))
self->pending_frame_counter = timings->frame_counter;
- _gdk_macos_display_add_frame_callback (GDK_MACOS_DISPLAY (display), self);
+ if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self)))
+ {
+ _gdk_macos_display_add_frame_callback (GDK_MACOS_DISPLAY (display), self);
+ gdk_surface_freeze_updates (GDK_SURFACE (self));
+ }
}
static void
@@ -718,17 +724,15 @@ _gdk_macos_surface_update_position (GdkMacosSurface *self)
}
void
-_gdk_macos_surface_thaw (GdkMacosSurface *self,
- gint64 presentation_time,
- gint64 refresh_interval)
+_gdk_macos_surface_publish_timings (GdkMacosSurface *self,
+ gint64 presentation_time,
+ gint64 refresh_interval)
{
GdkFrameTimings *timings;
GdkFrameClock *frame_clock;
g_return_if_fail (GDK_IS_MACOS_SURFACE (self));
- gdk_surface_thaw_updates (GDK_SURFACE (self));
-
if (!(frame_clock = gdk_surface_get_frame_clock (GDK_SURFACE (self))))
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]