[PATCH xserver] damage: Add screen func called before damage event delivery

Keith Packard keithp at keithp.com
Fri Sep 16 04:37:21 UTC 2016


This lets the video driver flush rendering to the kernel before the
client receives a damage event to a pixmap which the client has direct
rendering access to.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 damageext/damageext.c |  1 +
 glamor/glamor.c       | 20 ++++++++++++++++++++
 miext/damage/damage.c | 19 +++++++++++++++++--
 miext/damage/damage.h |  5 +++++
 4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/damageext/damageext.c b/damageext/damageext.c
index 86b54ee..547f048 100644
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -98,6 +98,7 @@ DamageExtNotify(DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes)
     damageGetGeometry(pDrawable, &x, &y, &w, &h);
 
     UpdateCurrentTimeIf();
+    DamageFlushDrawable(pDrawable);
     ev = (xDamageNotifyEvent) {
         .type = DamageEventBase + XDamageNotify,
         .level = pDamageExt->level,
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 903f6bd..7030e69 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -35,6 +35,7 @@
 
 #include "glamor_priv.h"
 #include "mipict.h"
+#include "damage.h"
 
 DevPrivateKeyRec glamor_screen_private_key;
 DevPrivateKeyRec glamor_pixmap_private_key;
@@ -346,6 +347,21 @@ fallback:
 }
 
 
+static void
+glamor_flush_screen(ScreenPtr screen)
+{
+    glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+    glamor_make_current(glamor_priv);
+    glFlush();
+}
+
+static void
+glamor_damage_flush_drawable(DrawablePtr drawable)
+{
+    glamor_flush_screen(drawable->pScreen);
+}
+
 /**
  * Creates any pixmaps used internally by glamor, since those can't be
  * allocated at ScreenInit time.
@@ -355,6 +371,7 @@ glamor_create_screen_resources(ScreenPtr screen)
 {
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
     Bool ret = TRUE;
+    DamageScreenFuncsPtr damage_funcs;
 
     screen->CreateScreenResources =
         glamor_priv->saved_procs.create_screen_resources;
@@ -362,6 +379,9 @@ glamor_create_screen_resources(ScreenPtr screen)
         ret = screen->CreateScreenResources(screen);
     screen->CreateScreenResources = glamor_create_screen_resources;
 
+    damage_funcs = DamageGetScreenFuncs(screen);
+    if (damage_funcs)
+        damage_funcs->Flush = glamor_damage_flush_drawable;
     return ret;
 }
 
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 17c2abf..bb79020 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -1897,8 +1897,13 @@ DamageSetReportAfterOp(DamagePtr pDamage, Bool reportAfter)
 DamageScreenFuncsPtr
 DamageGetScreenFuncs(ScreenPtr pScreen)
 {
-    damageScrPriv(pScreen);
-    return &pScrPriv->funcs;
+    if (dixPrivateKeyRegistered(damageScrPrivateKey)) {
+        damageScrPriv(pScreen);
+
+        if (pScrPriv)
+            return &pScrPriv->funcs;
+    }
+    return NULL;
 }
 
 void
@@ -1943,3 +1948,13 @@ DamageReportDamage(DamagePtr pDamage, RegionPtr pDamageRegion)
         break;
     }
 }
+
+void
+DamageFlushDrawable(DrawablePtr pDrawable)
+{
+    ScreenPtr pScreen = pDrawable->pScreen;
+    damageScrPriv(pScreen);
+
+    if (pScrPriv->funcs.Flush)
+        (*pScrPriv->funcs.Flush)(pDrawable);
+}
diff --git a/miext/damage/damage.h b/miext/damage/damage.h
index 525b2db..47a3a00 100644
--- a/miext/damage/damage.h
+++ b/miext/damage/damage.h
@@ -45,12 +45,14 @@ typedef void (*DamageScreenCreateFunc) (DamagePtr);
 typedef void (*DamageScreenRegisterFunc) (DrawablePtr, DamagePtr);
 typedef void (*DamageScreenUnregisterFunc) (DrawablePtr, DamagePtr);
 typedef void (*DamageScreenDestroyFunc) (DamagePtr);
+typedef void (*DamageScreenFlushFunc) (DrawablePtr);
 
 typedef struct _damageScreenFuncs {
     DamageScreenCreateFunc Create;
     DamageScreenRegisterFunc Register;
     DamageScreenUnregisterFunc Unregister;
     DamageScreenDestroyFunc Destroy;
+    DamageScreenFlushFunc Flush;
 } DamageScreenFuncsRec, *DamageScreenFuncsPtr;
 
 extern _X_EXPORT void miDamageCreate(DamagePtr);
@@ -112,4 +114,7 @@ extern _X_EXPORT void
 
 extern _X_EXPORT DamageScreenFuncsPtr DamageGetScreenFuncs(ScreenPtr);
 
+extern _X_EXPORT void
+DamageFlushDrawable(DrawablePtr pDrawable);
+
 #endif                          /* _DAMAGE_H_ */
-- 
2.9.3



More information about the xorg-devel mailing list