AlpenStep stuff with Fred Kiefer's help:

- Added support for 32 bit surfaces when it's possible (use of Xrender extension..).
- Modified the Cairo backend to take advantage of that: we can now draw windows with partial transparency.
- Fixed a bug in the Cairo backend (copy of a surface to itself) using the cairo "groups". Scrolling is still wrong, but we're closer to something good ;-)


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@25441 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicolas Roard 2007-09-02 14:23:03 +00:00
parent 0848c69b72
commit 09ce663feb
7 changed files with 166 additions and 16 deletions

View file

@ -1,3 +1,14 @@
2007-09-02 Nicolas Roard <nicolas@roard.com>
* configure:
* configure.ac:
* config.h.in: added checking for Xrender extension
* Source/x11/context.c: Now check for 32 bit surface + alpha channel
* Source/cairo/XGCairoSurface.m: Modified to get the correct visual,
not the default one
* Source/cairo/CairoGState.m: Use cairo groups to allow recopy on the
same surface
2007-08-21 Fred Kiefer <FredKiefer@gmx.de>
* Source/art/ftfont.m,

View file

@ -1080,13 +1080,14 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
}
cairo_save(_ct);
cairo_push_group (_ct);
cairo_new_path(_ct);
_set_op(_ct, op);
src = cairo_get_target(source->_ct);
if (src == cairo_get_target(_ct))
{
/*
NSRect targetRect;
targetRect.origin = aPoint;
@ -1094,14 +1095,15 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
if (!NSIsEmptyRect(NSIntersectionRect(aRect, targetRect)))
{
NSLog(@"Copy onto self");
// NSLog(@"Copy onto self");
/*
NSLog(NSStringFromRect(aRect));
NSLog(NSStringFromPoint(aPoint));
NSLog(@"src %p(%p,%@) des %p(%p,%@)",
source,cairo_get_target(source->_ct),NSStringFromSize([source->_surface size]),
self,cairo_get_target(_ct),NSStringFromSize([_surface size]));
}
*/
}
}
// Undo flipping in gui
@ -1109,13 +1111,17 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
{
aPoint.y -= NSHeight(aRect);
}
{
NSRect newRect;
newRect.origin = aPoint;
newRect.size = aRect.size;
[ctm boundingRectFor: newRect result: &newRect];
aPoint = newRect.origin;
}
//aPoint = [ctm transformPoint: aPoint];
[source->ctm boundingRectFor: aRect result: &aRect];
@ -1153,6 +1159,11 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
{
cairo_paint(_ct);
}
cairo_pop_group_to_source (_ct);
cairo_paint(_ct);
cairo_restore(_ct);
}

View file

@ -33,6 +33,8 @@
{
Display *dpy;
Drawable drawable;
Visual* visual;
XWindowAttributes attributes;
gsDevice = device;
@ -55,12 +57,22 @@
GSWINDEVICE->buffer);
}
*/
if (!XGetWindowAttributes (dpy, GSWINDEVICE->ident, &attributes))
{
visual = DefaultVisual (dpy, DefaultScreen (dpy));
}
else
{
visual = attributes.visual;
}
_surface = cairo_xlib_surface_create(dpy,
drawable,
DefaultVisual(dpy, DefaultScreen(dpy)),
GSWINDEVICE->xframe.size.width,
GSWINDEVICE->xframe.size.height);
drawable,
visual,
GSWINDEVICE->xframe.size.width,
GSWINDEVICE->xframe.size.height);
return self;
}

View file

@ -42,6 +42,9 @@
#include "x11/wraster.h"
#ifdef XRENDER
#include <X11/extensions/Xrender.h>
#endif
extern void _wraster_change_filter(int type);
@ -822,15 +825,42 @@ bestContext(Display *dpy, int screen_number, RContext *context)
rvinfo.class = TrueColor;
rvinfo.screen = screen_number;
flags = VisualClassMask | VisualScreenMask;
#ifdef XRENDER
rvinfo.depth = 32;
flags = VisualClassMask | VisualScreenMask | VisualDepthMask;
vinfo = XGetVisualInfo(dpy, flags, &rvinfo, &numvis);
if (vinfo) { /* look for a TrueColor, 24-bit or more (pref 24) */
for (i=numvis-1, best = -1; i>=0; i--) {
if (vinfo[i].depth == 24) best = i;
else if (vinfo[i].depth>24 && best<0) best = i;
}
}
if (vinfo)
{
for (i=numvis-1, best = -1; i>=0; i--)
{
XRenderPictFormat* pictFormat =
XRenderFindVisualFormat (dpy, vinfo[i].visual);
if ((pictFormat->type == PictTypeDirect)
&& (pictFormat->direct.alphaMask))
{
best = i;
}
}
}
#endif
if (best == -1)
{
flags = VisualClassMask | VisualScreenMask;
vinfo = XGetVisualInfo(dpy, flags, &rvinfo, &numvis);
if (vinfo)
{ /* look for a TrueColor, 24-bit or more (pref 24) */
for (i=numvis-1, best = -1; i>=0; i--)
{
if (vinfo[i].depth == 24) best = i;
else if (vinfo[i].depth>24 && best<0) best = i;
}
}
}
#if 0
if (best == -1) { /* look for a DirectColor, 24-bit or more (pref 24) */

View file

@ -123,5 +123,8 @@
/* Define if you have X11 XShm extensions */
#undef XSHM
/* Define if you have X11 Xrender extensions */
#undef XRENDER
/* Define to 1 if the X Window System is missing or not being used. */
#undef X_DISPLAY_MISSING

71
configure vendored
View file

@ -6879,6 +6879,76 @@ _ACEOF
fi
#--------------------------------------------------------------------
# XRender support
#--------------------------------------------------------------------
have_xrender=no
for ac_header in X11/extensions/Xrender.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <X11/Xlib.h>
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
eval "$as_ac_Header=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_Header=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
ac_res=`eval echo '${'$as_ac_Header'}'`
{ echo "$as_me:$LINENO: result: $ac_res" >&5
echo "${ECHO_T}$ac_res" >&6; }
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
have_xrender=yes
fi
done
if test "$ac_cv_header_X11_extensions_Xrender_h" = yes; then
cat >>confdefs.h <<\_ACEOF
#define XRENDER 1
_ACEOF
fi
#--------------------------------------------------------------------
# Window's graphics library
#--------------------------------------------------------------------
@ -8000,6 +8070,7 @@ echo "${ECHO_T}$CAIRO_GLITZ_LIBS" >&6; }
fi
#--------------------------------------------------------------------
# Glitz libraries
#--------------------------------------------------------------------

View file

@ -290,6 +290,17 @@ if test "$ac_cv_header_X11_extensions_XShm_h" = yes -a "$ac_cv_func_shmctl" = ye
AC_DEFINE(XSHM,1,[Define if you have X11 XShm extensions])
fi
#--------------------------------------------------------------------
# XRender support
#--------------------------------------------------------------------
have_xrender=no
AC_CHECK_HEADERS(X11/extensions/Xrender.h,
have_xrender=yes,,
[#include <X11/Xlib.h>])
if test "$ac_cv_header_X11_extensions_Xrender_h" = yes; then
AC_DEFINE(XRENDER,1,[Define if you have X11 XRender extension])
fi
#--------------------------------------------------------------------
# Window's graphics library
#--------------------------------------------------------------------
@ -371,6 +382,7 @@ PKG_CHECK_MODULES(CAIRO_WIN32, cairo-win32, have_cairo_win32=yes, have_cairo_win
PKG_CAIRO_GLITZ=no
PKG_CHECK_MODULES(CAIRO_GLITZ, cairo-glitz, have_cairo_glitz=yes, have_cairo_glitz=no)
#--------------------------------------------------------------------
# Glitz libraries
#--------------------------------------------------------------------