[PATCH 1/3] rootless: ROOTLESS_PROTECT_ALPHA is always set, so unifdef it.

Jamey Sharp jamey at minilop.net
Thu Jul 15 09:28:49 PDT 2010


The settings for each platform in rootlessConfig.h were misleading. On
Apple builds, ROOTLESS_PROTECT_ALPHA was defined to TRUE; on Windows it
was defined to NO. Both cases enabled alpha channel protection though,
because the test in rootlessGC.c was a simple #ifdef.

Colin Harrison says that for Xming builds he's always patched it to
define ROOTLESS_PROTECT_ALPHA to TRUE for Windows as well, and that
unconditionally enabling alpha-channel protection would be appropriate.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
Cc: Jeremy Huddleston <jeremyhu at apple.com>
Cc: Jon TURNEY <jon.turney at dronecode.org.uk>
Cc: Colin Harrison <colin.harrison at virgin.net>
---
 miext/rootless/README.txt       |   34 ++++++++++++++++------------------
 miext/rootless/rootlessConfig.h |    2 --
 miext/rootless/rootlessGC.c     |   15 +++++----------
 3 files changed, 21 insertions(+), 30 deletions(-)

diff --git a/miext/rootless/README.txt b/miext/rootless/README.txt
index 754715d..cea2c01 100644
--- a/miext/rootless/README.txt
+++ b/miext/rootless/README.txt
@@ -76,13 +76,12 @@ rootlessConfig.h to specify compile time options for its platform.
         The following compile-time options are defined in 
 rootlessConfig.h:
 
-      o ROOTLESS_PROTECT_ALPHA: By default for a color bit depth of 24 and
-        32 bits per pixel, fb will overwrite the "unused" 8 bits to optimize
-        drawing speed. If this is true, the alpha channel of frames is
-        protected and is not modified when drawing to them. The bits 
-        containing the alpha channel are defined by the macro 
-        RootlessAlphaMask(bpp), which should return a bit mask for 
-        various bits per pixel.
+      o RootlessAlphaMask(bpp): By default for a color bit depth of 24 and 32
+        bits per pixel, fb will overwrite the "unused" 8 bits to optimize
+        drawing speed. Rootless ensures that the alpha channel of frames is
+        protected and is not modified when drawing to them. The bits
+        containing the alpha channel are defined by this macro, which should
+        return a bit mask for various bits per pixel.
 
       o ROOTLESS_REDISPLAY_DELAY: Time in milliseconds between updates to
         the underlying window server. Most operations will be buffered until
@@ -126,17 +125,16 @@ functions should be used instead of fb.
 
 Alpha Channel Protection
 
-	If the bits per pixel is greater then the color bit depth, the contents 
-of the extra bits are undefined by the X11 protocol. Some window systems 
-will use these extra bits as an alpha channel. The generic rootless layer can 
-be configured to protect these bits and make sure they are not modified by 
-other parts of the X server. To protect the alpha channel 
-ROOTLESS_PROTECT_ALPHA and RootlessAlphaMask(bpp) must be 
-set appropriately as described under the compile time options. This 
-ensures that the X11 graphics primitives do not overwrite the alpha 
-channel in an attempt to optimize drawing. In addition, the window 
-functions PaintWindow() and Composite() must be replaced by alpha 
-channel safe variants. These are provided in rootless/safeAlpha.
+        If the bits per pixel is greater then the color bit depth, the
+contents of the extra bits are undefined by the X11 protocol. Some window
+systems will use these extra bits as an alpha channel. The generic rootless
+layer will protect these bits and make sure they are not modified by other
+parts of the X server. To protect the alpha channel RootlessAlphaMask(bpp)
+must be set appropriately as described under the compile time options. This
+ensures that the X11 graphics primitives do not overwrite the alpha channel
+in an attempt to optimize drawing. In addition, the window functions
+PaintWindow() and Composite() must be replaced by alpha channel safe
+variants. These are provided in rootless/safeAlpha.
 
 
 Credits
diff --git a/miext/rootless/rootlessConfig.h b/miext/rootless/rootlessConfig.h
index a6c0d25..222be53 100644
--- a/miext/rootless/rootlessConfig.h
+++ b/miext/rootless/rootlessConfig.h
@@ -36,7 +36,6 @@
 
 #ifdef __APPLE__
 
-# define ROOTLESS_PROTECT_ALPHA TRUE
 # define ROOTLESS_REDISPLAY_DELAY 10
 # define ROOTLESS_RESIZE_GRAVITY TRUE
 /*# define ROOTLESSDEBUG*/
@@ -50,7 +49,6 @@
 
 #if defined(__CYGWIN__) || defined(WIN32)
 
-# define ROOTLESS_PROTECT_ALPHA NO
 # define ROOTLESS_REDISPLAY_DELAY 10
 # undef  ROOTLESS_RESIZE_GRAVITY
 /*# define ROOTLESSDEBUG*/
diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c
index 68a9dc7..a9cb413 100644
--- a/miext/rootless/rootlessGC.c
+++ b/miext/rootless/rootlessGC.c
@@ -148,12 +148,11 @@ static GCOps rootlessGCOps = {
 };
 
 /*
-   If ROOTLESS_PROTECT_ALPHA is set, we have to make sure that the alpha
-   channel of the on screen windows is always opaque. fb makes this harder
-   than it would otherwise be by noticing that a planemask of 0x00ffffff
-   includes all bits when depth==24, and so it "optimizes" the planemask to
-   0xffffffff. We work around this by temporarily setting depth=bpp while
-   changing the GC.
+   We have to make sure that the alpha channel of the on screen windows is
+   always opaque. fb makes this harder than it would otherwise be by
+   noticing that a planemask of 0x00ffffff includes all bits when
+   depth==24, and so it "optimizes" the planemask to 0xffffffff. We work
+   around this by temporarily setting depth=bpp while changing the GC.
 
    So the normal situation (in 32 bit mode) is that the planemask is
    0x00ffffff and thus fb leaves the alpha channel alone. The rootless
@@ -331,7 +330,6 @@ RootlessValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 
     if (pDrawable->type == DRAWABLE_WINDOW)
     {
-#ifdef ROOTLESS_PROTECT_ALPHA
         unsigned int depth = pDrawable->depth;
 
         // We force a planemask so fb doesn't overwrite the alpha channel.
@@ -340,9 +338,6 @@ RootlessValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
         pGC->planemask &= ~RootlessAlphaMask(pDrawable->bitsPerPixel);
         VALIDATE_GC(pGC, changes | GCPlaneMask, pDrawable);
         pDrawable->depth = depth;
-#else
-        VALIDATE_GC(pGC, changes, pDrawable);
-#endif
     } else {
         pGC->funcs->ValidateGC(pGC, changes, pDrawable);
     }
-- 
1.7.0



More information about the xorg-devel mailing list