From c910bb13519bdaf827991cbfb2911a45b2063a6f Mon Sep 17 00:00:00 2001 From: Adam Fedor Date: Sat, 3 Aug 2002 03:32:19 +0000 Subject: [PATCH] Merge from 0.8.0 git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@14232 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 26 ++++++++++- Documentation/news.texi | 6 ++- Source/x11/XGServerWindow.m | 10 +++- Source/xlib/XGBitmap.m | 92 ++++++++++++++++++++----------------- Source/xlib/XGGState.m | 2 +- Source/xlib/XGGeometry.m | 9 ++++ Version | 4 +- config.h.in | 3 ++ configure | 80 ++++++++++++++++++++++++++++++++ configure.ac | 5 ++ 10 files changed, 188 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index f63f635..1e9f96f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2002-08-02 Adam Fedor + + * Merge from 0.8.0 into main branch. + +2002-08-01 Adam Fedor + + * Version: 0.8.0 + + * configure.ac: Check for usleep. + * Source/x11/XGServerWindow.m ([XGServer -windowdevice:]): + Use alternate if no usleep. + +2002-07-28 Adam Fedor + + * Source/xlib/XGBitmap.m (_pixmap_combine_alpha): Use + interger arithmatic. (Patch from Jeff Teunissen) + +2002-07-19 Adam Fedor + + * Source/xlib/XGGeometry.m (clipXRectsForCopying): Shift rect + origin to account for clipping. + * Source/xlib/XGGState.m (-setAlphaColor:): Correct colorspace + of alpha color. + 2002-07-17 Adam Fedor * Version: 0.7.9 @@ -11,7 +35,7 @@ * Source/xlib/XGBitmap.m (_pixmap_combine_alpha): Fix and cleanup alpha blending (Rescale by alpha) - (_bitmap_combine_alpha): Idem. (Patch from deek@d2dc.net). + (_bitmap_combine_alpha): Idem. (Patch from Jeff Teunissen). 2002-06-28 Adam Fedor diff --git a/Documentation/news.texi b/Documentation/news.texi index 11880ec..70a2b58 100644 --- a/Documentation/news.texi +++ b/Documentation/news.texi @@ -7,7 +7,7 @@ @include version.texi @end ifset -@section Noteworthy changes in version @samp{0.7.9} +@section Noteworthy changes in version @samp{0.8.0} Bug fixes. @@ -15,6 +15,10 @@ Bug fixes. @c Keep the next line just below the list of changes in most recent version. @ifclear ANNOUNCE-ONLY +@section Noteworthy changes in version @samp{0.7.9} + +Bug fixes. + @section Noteworthy changes in version @samp{0.7.8} Simplified backend selection using --enable-server and diff --git a/Source/x11/XGServerWindow.m b/Source/x11/XGServerWindow.m index 1cd55d2..15dffa0 100644 --- a/Source/x11/XGServerWindow.m +++ b/Source/x11/XGServerWindow.m @@ -538,7 +538,8 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number, int x, y, width, height; gswindow_device_t *window; - window = WINDOW_WITH_TAG(screen); + /* Screen number is negative to avoid conflict with windows */ + window = WINDOW_WITH_TAG(-screen); if (window) return window; @@ -550,7 +551,7 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number, window->ident = RootWindow(dpy, screen); window->root = window->ident; window->type = NSBackingStoreNonretained; - window->number = screen; + window->number = -screen; window->map_state = IsViewable; window->visibility = -1; if (window->ident) @@ -1358,7 +1359,12 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number, */ if (height != window->siz_hints.height) { +#if HAVE_USLEEP usleep(1); +#else + for (x=0; x<10000; x++) + ; +#endif XGetGeometry(dpy, window->ident, &window->root, &x, &y, &width, &height, &window->border, &window->depth); diff --git a/Source/xlib/XGBitmap.m b/Source/xlib/XGBitmap.m index 58eb001..bd30071 100644 --- a/Source/xlib/XGBitmap.m +++ b/Source/xlib/XGBitmap.m @@ -150,18 +150,18 @@ _pixmap_combine_alpha(RContext *context, for (col = 0; col < srect.width; col++) { - unsigned sr, sg, sb, sa; // source - unsigned dr, dg, db, da; // dest - double alpha, ialpha; + unsigned sr, sg, sb, sa; // source + unsigned dr, dg, db, da; // dest + unsigned ialpha; // Get the source pixel information - pixel = XGetPixel (source_im->image, srect.x+col, srect.y+row); - PixelToRGB (pixel, sr, sg, sb); + pixel = XGetPixel(source_im->image, srect.x+col, srect.y+row); + PixelToRGB(pixel, sr, sg, sb); if (source_alpha) { - pixel = XGetPixel(source_alpha->image, - srect.x+col, srect.y+row); + pixel = XGetPixel(source_alpha->image, + srect.x + col, srect.y + row); sa = (pixel >> _ashift) & _amask; } else @@ -173,30 +173,37 @@ _pixmap_combine_alpha(RContext *context, if (fraction < 1.0) sa *= fraction; - alpha = ((double) sa) / _amask; + sr *= sa; + sg *= sa; + sb *= sa; + + ialpha = (_amask - sa); // Now get dest pixel - pixel = XGetPixel(dest_im->image, col, row); - PixelToRGB (pixel, dr, dg, db); + pixel = XGetPixel(dest_im->image, col, row); + PixelToRGB(pixel, dr, dg, db); + dr *= ialpha; + dg *= ialpha; + db *= ialpha; + if (dest_alpha) - { + { pixel = XGetPixel(dest_alpha->image, col, row); da = (pixel >> _ashift) & _amask; - } + } else // no alpha channel, background is opaque da = _amask; - - ialpha = (1.0 - alpha); - dr = (sr * alpha) + (dr * ialpha); - dg = (sg * alpha) + (dg * ialpha); - db = (sb * alpha) + (db * ialpha); + + dr = (sr + dr) / _amask; + dg = (sg + dg) / _amask; + db = (sb + db) / _amask; // calc final alpha if (sa == _amask || da == _amask) da = _amask; else - da = sa + (da * ialpha); + da = sa + ((da * ialpha) / _amask); CLAMP(dr); CLAMP(dg); @@ -857,7 +864,7 @@ _bitmap_combine_alpha(RContext *context, img.a = malloc(img.screen_w); { - unsigned long pixel; + unsigned long pixel; /* Two cases, the *_FAST* method, which is covered in the first a part of the if @@ -911,24 +918,21 @@ _bitmap_combine_alpha(RContext *context, unsigned short sg = (*gptr++ >> (8 - _gwidth)); unsigned short sb = (*bptr++ >> (8 - _bwidth)); unsigned short sa = (*aptr++ >> (8 - _awidth)); - unsigned dr, dg, db, da; - double alpha = (double) sa / ((1 << _rwidth) - 1); + unsigned dr, dg, db, da; // dest if (sa == 0) // dest wouldn't be changed continue; - /* - * Unscale alpha value in each color component - */ - if (sa < _amask) + if (sa == _amask) // source only, don't bother with the rest { - double multiplier = (double) _amask / sa; - - sr *= multiplier; - sg *= multiplier; - sb *= multiplier; + // Yes, this is duplicated code -- but it's worth it. + RGBToPixel(sr, sg, sb, pixel); + XPutPixel(dest_im->image, col, row, pixel); + if (dest_alpha) + XPutPixel(dest_alpha->image, col, row, sa << _ashift); + continue; } - + // get the destination pixel pixel = XGetPixel(dest_im->image, col, row); PixelToRGB(pixel, dr, dg, db); @@ -940,24 +944,28 @@ _bitmap_combine_alpha(RContext *context, } else // no alpha channel, background is opaque da = _amask; - - if (sa == _amask || da == 0) // source only - { - dr = sr; - dg = sg; - db = sb; + + if (da == 0) + { + /* + * Unscale the colors + */ + dr = (sr * _amask) / sa; + dg = (sg * _amask) / sa; + db = (sb * _amask) / sa; da = sa; } else { - double ialpha = (1.0 - alpha); - dr = (sr * alpha) + (dr * ialpha); - dg = (sg * alpha) + (dg * ialpha); - db = (sb * alpha) + (db * ialpha); + unsigned ialpha = _amask - sa; + + dr = (sr * sa + (dr * ialpha)) / _amask; + dg = (sg * sa + (dg * ialpha)) / _amask; + db = (sb * sa + (db * ialpha)) / _amask; if (da == _amask || da == _amask) da = _amask; else - da = sa + (da * ialpha); + da = sa + ((da * ialpha) / _amask); } CLAMP(dr); diff --git a/Source/xlib/XGGState.m b/Source/xlib/XGGState.m index 3b728e5..a1d5e36 100644 --- a/Source/xlib/XGGState.m +++ b/Source/xlib/XGGState.m @@ -260,7 +260,7 @@ static Region emptyRegion; /* Window device isn't set yet */ return; } - color = gsMakeColor(gray_colorspace, value, 0, 0, 0); + color = gsMakeColor(rgb_colorspace, value, value, value, 0); gcv.foreground = xrRGBToPixel(context, color); if (agcntxt == None) agcntxt = XCreateGC(XDPY, draw, GCForeground, &gcv); diff --git a/Source/xlib/XGGeometry.m b/Source/xlib/XGGeometry.m index 928131a..5391aa7 100644 --- a/Source/xlib/XGGeometry.m +++ b/Source/xlib/XGGeometry.m @@ -117,14 +117,23 @@ void clipXRectsForCopying (gswindow_device_t* winA, XRectangle* rectA, gswindow_device_t* winB, XRectangle* rectB) { + XPoint shiftA, shiftB; // First make A smaller. + shiftA.x = rectA->x; + shiftA.y = rectA->y; *rectA = XGIntersectionRect (*rectA, accessibleRectForWindow (winA)); // update size of B with the size of A + rectB->x += rectA->x - shiftA.x; + rectB->y += rectA->y - shiftA.y; rectB->width = MIN (rectA->width, rectB->width); rectB->height = MIN (rectA->height, rectB->height); // now make B smaller + shiftB.x = rectB->x; + shiftB.y = rectB->y; *rectB = XGIntersectionRect (*rectB, accessibleRectForWindow (winB)); // and update size of A with size of B + rectA->x += rectB->x - shiftB.x; + rectA->y += rectB->y - shiftB.y; rectA->width = rectB->width; rectA->height = rectB->height; } diff --git a/Version b/Version index 873e2fa..2e425c1 100644 --- a/Version +++ b/Version @@ -3,8 +3,8 @@ # The version number of this release. GNUSTEP_BACK_MAJOR_VERSION=0 -GNUSTEP_BACK_MINOR_VERSION=7 -GNUSTEP_BACK_SUBMINOR_VERSION=9 +GNUSTEP_BACK_MINOR_VERSION=8 +GNUSTEP_BACK_SUBMINOR_VERSION=0 GNUSTEP_BACK_VERSION=${GNUSTEP_BACK_MAJOR_VERSION}.${GNUSTEP_BACK_MINOR_VERSION}.${GNUSTEP_BACK_SUBMINOR_VERSION} VERSION=${GNUSTEP_BACK_VERSION} diff --git a/config.h.in b/config.h.in index efc99c2..4d3eb14 100644 --- a/config.h.in +++ b/config.h.in @@ -44,6 +44,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the `usleep' function. */ +#undef HAVE_USLEEP + /* Define if you have XftDrawStringUtf8 */ #undef HAVE_UTF8 diff --git a/configure b/configure index d93810c..bd436ad 100755 --- a/configure +++ b/configure @@ -4461,6 +4461,86 @@ _ACEOF fi +#-------------------------------------------------------------------- +# Functions +#-------------------------------------------------------------------- + +for ac_func in usleep +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + #-------------------------------------------------------------------- # Find for JPEG #-------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index f260874..823fcd4 100644 --- a/configure.ac +++ b/configure.ac @@ -195,6 +195,11 @@ if test "x$enable_xim" = "xyes"; then AC_DEFINE(USE_XIM,1,[Define to enable XIM support]) fi +#-------------------------------------------------------------------- +# Functions +#-------------------------------------------------------------------- +AC_HAVE_FUNCS(usleep) + #-------------------------------------------------------------------- # Find for JPEG #--------------------------------------------------------------------