[PATCH xserver v3 02/24] present: Preliminary internal flip mode API

Roman Gilg subdiff at gmail.com
Tue Mar 13 15:00:35 UTC 2018


Add some basic function hooks to our future present-internal flip mode API,
that will allow us to share functionality in between modes and move more code
in separate files.

Signed-off-by: Roman Gilg <subdiff at gmail.com>
---
 present/present_priv.h   | 27 ++++++++++++++++++++++++---
 present/present_scmd.c   | 20 ++++++++++++++++++--
 present/present_screen.c |  4 +++-
 3 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/present/present_priv.h b/present/present_priv.h
index 66539e1..8908061 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -85,6 +85,21 @@ struct present_vblank {
     Bool                has_suboptimal; /* whether client can support SuboptimalCopy mode */
 };
 
+/*
+ * Mode hooks
+ */
+typedef Bool (*present_priv_check_flip_ptr)(RRCrtcPtr crtc,
+                                            WindowPtr window,
+                                            PixmapPtr pixmap,
+                                            Bool sync_flip,
+                                            RegionPtr valid,
+                                            int16_t x_off,
+                                            int16_t y_off,
+                                            PresentFlipReason *reason);
+typedef void (*present_priv_check_flip_window_ptr)(WindowPtr window);
+
+typedef void (*present_priv_create_event_id_ptr)(present_vblank_ptr vblank);
+
 typedef struct present_screen_priv {
     CloseScreenProcPtr          CloseScreen;
     ConfigNotifyProcPtr         ConfigNotify;
@@ -105,6 +120,12 @@ typedef struct present_screen_priv {
     Bool                        flip_sync;
 
     present_screen_info_ptr     info;
+
+    /* Mode hooks */
+    present_priv_check_flip_ptr         check_flip;
+    present_priv_check_flip_window_ptr  check_flip_window;
+
+    present_priv_create_event_id_ptr    create_event_id;
 } present_screen_priv_rec, *present_screen_priv_ptr;
 
 #define wrap(priv,real,mem,func) {\
@@ -318,9 +339,6 @@ present_restore_screen_pixmap(ScreenPtr screen);
 void
 present_set_abort_flip(ScreenPtr screen);
 
-void
-present_check_flip_window(WindowPtr window);
-
 RRCrtcPtr
 present_get_crtc(WindowPtr window);
 
@@ -330,6 +348,9 @@ present_query_capabilities(RRCrtcPtr crtc);
 Bool
 present_init(void);
 
+void
+present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv);
+
 /*
  * present_screen.c
  */
diff --git a/present/present_scmd.c b/present/present_scmd.c
index bd92b27..17a1758 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -68,6 +68,12 @@ msc_is_equal_or_after(uint64_t test, uint64_t reference)
     return (int64_t)(test - reference) >= 0;
 }
 
+static void
+present_scmd_create_event_id(present_vblank_ptr vblank)
+{
+    vblank->event_id = ++present_event_id;
+}
+
 static inline PixmapPtr
 present_flip_pending_pixmap(ScreenPtr screen)
 {
@@ -484,7 +490,7 @@ present_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc)
  * 'window' is being reconfigured. Check to see if it is involved
  * in flipping and clean up as necessary
  */
-void
+static void
 present_check_flip_window (WindowPtr window)
 {
     ScreenPtr                   screen = window->drawable.pScreen;
@@ -858,7 +864,8 @@ present_pixmap(WindowPtr window,
     vblank->screen = screen;
     vblank->window = window;
     vblank->pixmap = pixmap;
-    vblank->event_id = ++present_event_id;
+    present_scmd_create_event_id(vblank);
+
     if (pixmap) {
         vblank->kind = PresentCompleteKindPixmap;
         pixmap->refcnt++;
@@ -1038,6 +1045,15 @@ present_vblank_destroy(present_vblank_ptr vblank)
     free(vblank);
 }
 
+void
+present_scmd_init_mode_hooks(present_screen_priv_ptr screen_priv)
+{
+    screen_priv->check_flip         =   &present_check_flip;
+    screen_priv->check_flip_window  =   &present_check_flip_window;
+
+    screen_priv->create_event_id    =   &present_scmd_create_event_id;
+}
+
 Bool
 present_init(void)
 {
diff --git a/present/present_screen.c b/present/present_screen.c
index 9d03c8a..454cc53 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -161,7 +161,7 @@ present_clip_notify(WindowPtr window, int dx, int dy)
     ScreenPtr screen = window->drawable.pScreen;
     present_screen_priv_ptr screen_priv = present_screen_priv(screen);
 
-    present_check_flip_window(window);
+    screen_priv->check_flip_window(window);
     unwrap(screen_priv, screen, ClipNotify)
     if (screen->ClipNotify)
         screen->ClipNotify (window, dx, dy);
@@ -194,6 +194,8 @@ present_screen_init(ScreenPtr screen, present_screen_info_ptr info)
 
         dixSetPrivate(&screen->devPrivates, &present_screen_private_key, screen_priv);
 
+        present_scmd_init_mode_hooks(screen_priv);
+
         present_fake_screen_init(screen);
     }
 
-- 
2.7.4



More information about the xorg-devel mailing list