From f2151f1b0dcbfec23488a29a7ea887fbfd53b760 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Fri, 29 May 2009 14:09:41 -0700 Subject: [PATCH] XQuartz: Fix alpha to be 1 (screenshots bug, etc) This is related to: bc964ff1e3f3d8ab590eab40d767c6241e9480d4 XQuartz: Stab at fixing the alpha 0/1 bug (screenshots, etc) by pulling in some old code that got gutted from rootless. which was on the 1.4 branch and implemented in fbPaintWindow. Now that fbPaintWindow is gone, this is now in miPaintWindow(). (cherry picked from commit 032173f693f75385a40e144ffe2b7b5378bb6f2e) --- configure.ac | 2 +- mi/miexpose.c | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index daddd094a..696e03f65 100644 --- a/configure.ac +++ b/configure.ac @@ -1666,7 +1666,7 @@ if test "x$XQUARTZ" = xyes; then AC_CHECK_LIB([Xplugin],[xp_init],[:]) - CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA" + CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DROOTLESS_SAFEALPHA -DNO_ALLOCA" PKG_CHECK_MODULES(XPBPROXY, [applewmproto >= 1.2] [applewm >= 1.2] xfixes fixesproto x11) diff --git a/mi/miexpose.c b/mi/miexpose.c index 2c43d9824..6ce56ee85 100644 --- a/mi/miexpose.c +++ b/mi/miexpose.c @@ -522,7 +522,7 @@ void miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) { ScreenPtr pScreen = pWin->drawable.pScreen; - ChangeGCVal gcval[5]; + ChangeGCVal gcval[6]; BITS32 gcmask; GCPtr pGC; int i; @@ -590,18 +590,35 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) gcval[0].val = GXcopy; gcmask = GCFunction; +#ifdef ROOTLESS_SAFEALPHA +/* Bit mask for alpha channel with a particular number of bits per + * pixel. Note that we only care for 32bpp data. Mac OS X uses planar + * alpha for 16bpp. + */ +#define RootlessAlphaMask(bpp) ((bpp) == 32 ? 0xFF000000 : 0) +#endif + if (solid) { +#ifdef ROOTLESS_SAFEALPHA + gcval[1].val = fill.pixel | RootlessAlphaMask(pWin->drawable.bitsPerPixel); +#else gcval[1].val = fill.pixel; +#endif gcval[2].val = FillSolid; gcmask |= GCForeground | GCFillStyle; } else { - gcval[1].val = FillTiled; - gcval[2].ptr = (pointer)fill.pixmap; - gcval[3].val = tile_x_off; - gcval[4].val = tile_y_off; + int c=1; +#ifdef ROOTLESS_SAFEALPHA + gcval[c++].val = ((CARD32)-1) & ~RootlessAlphaMask(pWin->drawable.bitsPerPixel); + gcmask |= GCPlaneMask; +#endif + gcval[c++].val = FillTiled; + gcval[c++].ptr = (pointer)fill.pixmap; + gcval[c++].val = tile_x_off; + gcval[c++].val = tile_y_off; gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin; }