[gtk/wip/chergert/for-main: 26/37] macos: use display id when creating CVDisplayLink
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/for-main: 26/37] macos: use display id when creating CVDisplayLink
- Date: Mon, 28 Feb 2022 19:05:59 +0000 (UTC)
commit ecd4c0804d5c9222361006e23ae93e3b391db649
Author: Christian Hergert <christian hergert me>
Date: Fri Feb 25 13:09:31 2022 -0800
macos: use display id when creating CVDisplayLink
Currently we're using a display link that is for all active displays which
is just the display server trying to find some timings that try to overlap
as many as possible.
That was fine for a prototype, but we really need to do better for
situations with mixed frame rate (such as 60hz and 120hz promotion
displays). Additionally, the 144hz external monitor I have will never
reach 144hz using the current design.
This is just the first step in changing this, but the goal is to have
one of these attached to each GdkMacosMonitor which we can then use to
thaw surfaces specific to that monitor.
gdk/macos/gdkdisplaylinksource.c | 15 +++++++--------
gdk/macos/gdkdisplaylinksource.h | 15 ++++++++-------
gdk/macos/gdkmacosdisplay.c | 2 +-
3 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/gdk/macos/gdkdisplaylinksource.c b/gdk/macos/gdkdisplaylinksource.c
index 292b8be519..8b2f1a013f 100644
--- a/gdk/macos/gdkdisplaylinksource.c
+++ b/gdk/macos/gdkdisplaylinksource.c
@@ -147,6 +147,7 @@ gdk_display_link_source_frame_cb (CVDisplayLinkRef display_link,
/**
* gdk_display_link_source_new:
+ * @display_id: the identifier of the monitor
*
* Creates a new `GSource` that will activate the dispatch function upon
* notification from a CVDisplayLink that a new frame should be drawn.
@@ -159,7 +160,7 @@ gdk_display_link_source_frame_cb (CVDisplayLinkRef display_link,
* Returns: (transfer full): A newly created `GSource`
*/
GSource *
-gdk_display_link_source_new (void)
+gdk_display_link_source_new (CGDirectDisplayID display_id)
{
GdkDisplayLinkSource *impl;
GSource *source;
@@ -168,15 +169,13 @@ gdk_display_link_source_new (void)
source = g_source_new (&gdk_display_link_source_funcs, sizeof *impl);
impl = (GdkDisplayLinkSource *)source;
+ impl->display_id = display_id;
- /*
- * Create our link based on currently connected displays.
- * If there are multiple displays, this will be something that tries
- * to work for all of them. In the future, we may want to explore multiple
- * links based on the connected displays.
+ /* Create DisplayLink for timing information for the display in
+ * question so that we can produce graphics for that display at whatever
+ * rate it can provide.
*/
- ret = CVDisplayLinkCreateWithActiveCGDisplays (&impl->display_link);
- if (ret != kCVReturnSuccess)
+ if (CVDisplayLinkCreateWithCGDisplay (display_id, &impl->display_link) != kCVReturnSuccess)
{
g_warning ("Failed to initialize CVDisplayLink!");
return source;
diff --git a/gdk/macos/gdkdisplaylinksource.h b/gdk/macos/gdkdisplaylinksource.h
index ed769b59f8..bff1c91475 100644
--- a/gdk/macos/gdkdisplaylinksource.h
+++ b/gdk/macos/gdkdisplaylinksource.h
@@ -30,17 +30,18 @@ G_BEGIN_DECLS
typedef struct
{
- GSource source;
+ GSource source;
- CVDisplayLinkRef display_link;
- gint64 refresh_interval;
- guint refresh_rate;
+ CGDirectDisplayID display_id;
+ CVDisplayLinkRef display_link;
+ gint64 refresh_interval;
+ guint refresh_rate;
- volatile gint64 presentation_time;
- volatile guint needs_dispatch;
+ volatile gint64 presentation_time;
+ volatile guint needs_dispatch;
} GdkDisplayLinkSource;
-GSource *gdk_display_link_source_new (void);
+GSource *gdk_display_link_source_new (CGDirectDisplayID display_id);
void gdk_display_link_source_pause (GdkDisplayLinkSource *source);
void gdk_display_link_source_unpause (GdkDisplayLinkSource *source);
diff --git a/gdk/macos/gdkmacosdisplay.c b/gdk/macos/gdkmacosdisplay.c
index ae4c86ad63..6c6771f907 100644
--- a/gdk/macos/gdkmacosdisplay.c
+++ b/gdk/macos/gdkmacosdisplay.c
@@ -273,7 +273,7 @@ gdk_macos_display_frame_cb (gpointer data)
static void
gdk_macos_display_load_display_link (GdkMacosDisplay *self)
{
- self->frame_source = gdk_display_link_source_new ();
+ self->frame_source = gdk_display_link_source_new (CGMainDisplayID ());
g_source_set_callback (self->frame_source,
gdk_macos_display_frame_cb,
self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]