xserver: Branch 'input-hotplug' - 5 commits

Daniel Stone daniels at kemper.freedesktop.org
Tue Aug 15 15:26:37 EEST 2006


 dix/events.c           |   47 +++++++++++++++++-------
 exa/exa_render.c       |   93 ++++++++++++++++++++++++++++++++++++++++---------
 hw/kdrive/src/kinput.c |   21 +++--------
 3 files changed, 116 insertions(+), 45 deletions(-)

New commits:
diff-tree 47c1c948e69cfba950ad37a3133fa2db0bd0ff2c (from 34228d8b280ef105a0c60b8de5dacf70a5ce24b5)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 15 15:25:16 2006 +0300

    kdrive/input: only run special key behaviours on non-XKB
    Only attempt to manually deal with special key behaviours (e.g. terminating
    the server) when not using XKB, and leave locking behaviour up to GKVE.

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index fc4592a..278bbf7 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1927,23 +1927,14 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo   
 	else
 	    type = KeyPress;
 	
-        /* HRNGH */
-	switch (KEYCOL1(ki, key_code)) 
-	{
-	case XK_Num_Lock:
-	case XK_Scroll_Lock:
-	case XK_Shift_Lock:
-	case XK_Caps_Lock:
-	    if (type == KeyRelease)
-		return;
-	    if (IsKeyDown (ki, key_code))
-		type = KeyRelease;
-	    else
-		type = KeyPress;
+#ifdef XKB
+        if (noXkbExtension)
+#endif
+        {
+            KdCheckSpecialKeys(ki, type, key_code);
+            KdHandleKeyboardEvent(ki, type, key_code);
 	}
 	
-        KdCheckSpecialKeys(ki, type, key_code);
-        KdHandleKeyboardEvent(ki, type, key_code);
         nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code);
 #ifdef DEBUG
         ErrorF("KdEnqueueKeyboardEvent: got %d events from GKE\n", nEvents);
diff-tree 34228d8b280ef105a0c60b8de5dacf70a5ce24b5 (from d003bada3352ec7d734498c4c732904876a9d1e2)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 15 15:23:53 2006 +0300

    GPE: fix absolute button events / GKVE: (non-XKB) don't repeat lock keys
    Fix absolute button events in GPE, where we would previously send valuator
    events without bumping numEvents accordingly, causing the core event to
    go missing.
    In the non-XKB path in GKVE, implement proper lock behaviour (one press to
    enable, one press to disable, discard releases).
    Fix debug_events prototype.

diff --git a/dix/events.c b/dix/events.c
index f1e2fd8..6eb1257 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -113,6 +113,7 @@ of the copyright holder.
 #endif
 
 #include <X11/X.h>
+#include <X11/keysym.h>
 #include "misc.h"
 #include "resource.h"
 #define NEED_EVENTS
@@ -210,7 +211,7 @@ Mask DontPropagateMasks[DNPMCOUNT];
 static int DontPropagateRefCnts[DNPMCOUNT];
 
 #ifdef DEBUG
-static debug_events = 0;
+static int debug_events = 0;
 #endif
 _X_EXPORT InputInfo inputInfo;
 
@@ -4711,6 +4712,7 @@ int GetKeyboardValuatorEvents(xEvent *ev
                               int key_code, int num_valuators,
                               int *valuators) {
     int numEvents = 0, numRepeatEvents = 0, ms = 0, first_valuator = 0, i = 0;
+    KeySym sym = pDev->key->curKeySyms.map[key_code * pDev->key->curKeySyms.mapWidth];
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
     xEvent *repeatEvents = NULL;
@@ -4740,11 +4742,28 @@ int GetKeyboardValuatorEvents(xEvent *ev
         numEvents += (num_valuators / 6) + 1;
     }
 
+#ifdef XKB
+    if (noXkbExtension)
+#endif
+    {
+        switch (sym) {
+            case XK_Num_Lock:
+            case XK_Caps_Lock:
+            case XK_Scroll_Lock:
+            case XK_Shift_Lock:
+                if (type == KeyRelease)
+                    return 0;
+                else if (type == KeyPress &&
+                         (pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
+                        type = KeyRelease;
+        }
+    }
+
     /* Handle core repeating, via press/release/press/release.
      * FIXME: In theory, if you're repeating with two keyboards,
      *        you could get unbalanced events here. */
     if (type == KeyPress &&
-        ((pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)) {
+        (((pDev->key->down[key_code >> 3] & (key_code & 7))) & 1)) {
         if (!pDev->kbdfeed->ctrl.autoRepeat ||
             pDev->key->modifierMap[key_code] ||
             !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
@@ -4760,7 +4779,7 @@ int GetKeyboardValuatorEvents(xEvent *ev
                                                    num_valuators, valuators);
             events += numEvents;
         }
-    }
+    
 
     ms = GetTimeInMillis();
 
@@ -4942,6 +4961,7 @@ GetPointerEvents(xEvent *events, DeviceI
     deviceValuator *xv = NULL;
     AxisInfoPtr axes = NULL;
     xEvent *ev = NULL;
+    Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
     DeviceIntPtr cp = inputInfo.pointer;
 
     if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
@@ -4961,14 +4981,13 @@ GetPointerEvents(xEvent *events, DeviceI
     else
         numEvents = 1;
 
-    if (type == MotionNotify) {
-        if (num_valuators > 2) {
-            if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
-                num_valuators = MAX_VALUATOR_EVENTS;
-            numEvents += (num_valuators / 6) + 1;
-        }
-        else if (num_valuators < 2)
-            return 0;
+    if (num_valuators > 2 && sendValuators) {
+        if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS;
+        numEvents += (num_valuators / 6) + 1;
+    }
+    else if (type == MotionNotify && num_valuators < 2) {
+        return 0;
     }
 
     ms = GetTimeInMillis();
@@ -5067,8 +5086,7 @@ GetPointerEvents(xEvent *events, DeviceI
         kbp->detail = pDev->button->map[buttons];
     }
 
-    if (num_valuators > 2 && (type == MotionNotify ||
-                              flags & POINTER_ABSOLUTE)) {
+    if (num_valuators > 2 && sendValuators) {
         kbp->deviceid |= MORE_EVENTS;
         while (first_valuator < num_valuators) {
             xv = (deviceValuator *) ++events;
@@ -5106,6 +5124,9 @@ GetPointerEvents(xEvent *events, DeviceI
     if (pDev->coreEvents) {
         events++;
         events->u.u.type = type;
+#ifdef DEBUG
+        ErrorF("GPE: core type is %d\n", type);
+#endif
         events->u.keyButtonPointer.time = ms;
         events->u.keyButtonPointer.rootX = kbp->root_x;
         events->u.keyButtonPointer.rootY = kbp->root_y;
diff-tree d003bada3352ec7d734498c4c732904876a9d1e2 (from parents)
Merge: d6433be3cca807dd78fbb1f45d9ba0212283083d a815b9b990e068f02d9cbba2b17f2cc3a30a9310
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Aug 12 22:48:55 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree a815b9b990e068f02d9cbba2b17f2cc3a30a9310 (from parents)
Merge: 37943e2f1abc6709ff739000372b0394d5cd18c5 984babe86bf82002b4d6589b2750c7b5a5489bd5
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Sat Aug 12 21:58:33 2006 +0300

    Merge branch 'master' of git+ssh://gsap7@git.freedesktop.org/git/xorg/xserver

diff-tree 37943e2f1abc6709ff739000372b0394d5cd18c5 (from e641000b98e7c2e92e3c801eaa42aa15d5c16ad0)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Sat Aug 12 20:54:33 2006 +0300

    Call exaTryComponentAlphaHelper() for solid src also.
    
    Also, rename to exaTryMagicTwoPassCompositeHelper() as it is now called for
    non-component-alpha masks also, and add function description from
    http://anholt.livejournal.com/32058.html.

diff --git a/exa/exa_render.c b/exa/exa_render.c
index 2187af8..9affb9f 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -452,24 +452,72 @@ exaTryDriverComposite(CARD8		op,
     return 1;
 }
 
+/**
+ * exaTryMagicTwoPassCompositeHelper implements PictOpOver using two passes of
+ * simpler operations PictOpOutReverse and PictOpAdd. Mainly used for component
+ * alpha and limited 1-tmu cards.
+ *
+ * From http://anholt.livejournal.com/32058.html:
+ *
+ * The trouble is that component-alpha rendering requires two different sources
+ * for blending: one for the source value to the blender, which is the
+ * per-channel multiplication of source and mask, and one for the source alpha
+ * for multiplying with the destination channels, which is the multiplication
+ * of the source channels by the mask alpha. So the equation for Over is:
+ *
+ * dst.A = src.A * mask.A + (1 - (src.A * mask.A)) * dst.A
+ * dst.R = src.R * mask.R + (1 - (src.A * mask.R)) * dst.R
+ * dst.G = src.G * mask.G + (1 - (src.A * mask.G)) * dst.G
+ * dst.B = src.B * mask.B + (1 - (src.A * mask.B)) * dst.B
+ *
+ * But we can do some simpler operations, right? How about PictOpOutReverse,
+ * which has a source factor of 0 and dest factor of (1 - source alpha). We
+ * can get the source alpha value (srca.X = src.A * mask.X) out of the texture
+ * blenders pretty easily. So we can do a component-alpha OutReverse, which
+ * gets us:
+ *
+ * dst.A = 0 + (1 - (src.A * mask.A)) * dst.A
+ * dst.R = 0 + (1 - (src.A * mask.R)) * dst.R
+ * dst.G = 0 + (1 - (src.A * mask.G)) * dst.G
+ * dst.B = 0 + (1 - (src.A * mask.B)) * dst.B
+ *
+ * OK. And if an op doesn't use the source alpha value for the destination
+ * factor, then we can do the channel multiplication in the texture blenders
+ * to get the source value, and ignore the source alpha that we wouldn't use.
+ * We've supported this in the Radeon driver for a long time. An example would
+ * be PictOpAdd, which does:
+ *
+ * dst.A = src.A * mask.A + dst.A
+ * dst.R = src.R * mask.R + dst.R
+ * dst.G = src.G * mask.G + dst.G
+ * dst.B = src.B * mask.B + dst.B
+ *
+ * Hey, this looks good! If we do a PictOpOutReverse and then a PictOpAdd right
+ * after it, we get:
+ *
+ * dst.A = src.A * mask.A + ((1 - (src.A * mask.A)) * dst.A)
+ * dst.R = src.R * mask.R + ((1 - (src.A * mask.R)) * dst.R)
+ * dst.G = src.G * mask.G + ((1 - (src.A * mask.G)) * dst.G)
+ * dst.B = src.B * mask.B + ((1 - (src.A * mask.B)) * dst.B)
+ */
+
 static int
-exaTryComponentAlphaHelper(CARD8 op,
-			   PicturePtr pSrc,
-			   PicturePtr pMask,
-			   PicturePtr pDst,
-			   INT16 xSrc,
-			   INT16 ySrc,
-			   INT16 xMask,
-			   INT16 yMask,
-			   INT16 xDst,
-			   INT16 yDst,
-			   CARD16 width,
-			   CARD16 height)
+exaTryMagicTwoPassCompositeHelper(CARD8 op,
+				  PicturePtr pSrc,
+				  PicturePtr pMask,
+				  PicturePtr pDst,
+				  INT16 xSrc,
+				  INT16 ySrc,
+				  INT16 xMask,
+				  INT16 yMask,
+				  INT16 xDst,
+				  INT16 yDst,
+				  CARD16 width,
+				  CARD16 height)
 {
     ExaScreenPriv (pDst->pDrawable->pScreen);
 
     assert(op == PictOpOver);
-    assert(pMask->componentAlpha == TRUE);
 
     if (pExaScr->info->CheckComposite &&
 	(!(*pExaScr->info->CheckComposite)(PictOpOutReverse, pSrc, pMask,
@@ -580,19 +628,30 @@ exaComposite(CARD8	op,
 	(!pMask || !pMask->repeat || pMask->repeat == RepeatNormal) &&
 	!pSrc->alphaMap && (!pMask || !pMask->alphaMap) && !pDst->alphaMap)
     {
+	Bool isSrcSolid;
+
 	ret = exaTryDriverComposite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask,
 				    yMask, xDst, yDst, width, height);
 	if (ret == 1)
 	    goto done;
 
+	/* For generic masks and solid src pictures, mach64 can do Over in two
+	 * passes, similar to the component-alpha case.
+	 */
+	isSrcSolid = pSrc->pDrawable->width == 1 &&
+		     pSrc->pDrawable->height == 1 &&
+		     pSrc->repeat;
+
 	/* If we couldn't do the Composite in a single pass, and it was a
 	 * component-alpha Over, see if we can do it in two passes with
 	 * an OutReverse and then an Add.
 	 */
-	if (ret == -1 && pMask && pMask->componentAlpha && op == PictOpOver) {
-	    ret = exaTryComponentAlphaHelper(op, pSrc, pMask, pDst, xSrc, ySrc,
-					     xMask, yMask, xDst, yDst,
-					     width, height);
+	if (ret == -1 && op == PictOpOver && pMask &&
+	    (pMask->componentAlpha || isSrcSolid)) {
+	    ret = exaTryMagicTwoPassCompositeHelper(op, pSrc, pMask, pDst,
+						    xSrc, ySrc,
+						    xMask, yMask, xDst, yDst,
+						    width, height);
 	    if (ret == 1)
 		goto done;
 	}



More information about the xorg-commit mailing list