[cairo] pycairo: patch: make double buffered windows work

Bertram Felgenhauer bf3 at mail.inf.tu-dresden.de
Mon Aug 8 17:01:51 PDT 2005


Hi,

here's a fix for a bug that prevented drawing to double buffered
windows in pycairo used with pre-2.8 gtk+. There was no query
for existing back buffers so all drawing was done to the front
buffer, and got lost when the back buffer was drawn to the screen.

paniq tested the patch. (there was a discussion on IRC about this).

Bertram
-------------- next part --------------
Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/pycairo/ChangeLog,v
retrieving revision 1.161
diff -u -r1.161 ChangeLog
--- ChangeLog	8 Aug 2005 12:16:35 -0000	1.161
+++ ChangeLog	8 Aug 2005 23:47:28 -0000
@@ -1,3 +1,8 @@
+2005-08-09  Bertram Felgenhauer <int-e at gmx.de>
+
+	* cairo/cairogtkmodule.c (gdk_cairo_create): Query windows for
+	backbuffers to make double buffering work.
+
 2005-08-08  Steve Chaplin  <steve1097 at yahoo.com.au>
 
 	* NEWS : change titles to "Overview of changes from pycairo x.x.x to
Index: cairo/cairogtkmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairogtkmodule.c,v
retrieving revision 1.31
diff -u -r1.31 cairogtkmodule.c
--- cairo/cairogtkmodule.c	1 Aug 2005 10:25:47 -0000	1.31
+++ cairo/cairogtkmodule.c	8 Aug 2005 23:47:28 -0000
@@ -91,14 +91,24 @@
  * gdk_cairo_create() will be available in gtk 2.8
  */
 static cairo_t *
-gdk_cairo_create (GdkDrawable *drawable)
+gdk_cairo_create (GdkDrawable *target)
 {
     int width, height;
+    int x_off=0, y_off=0;
     cairo_t *cr = NULL;
     cairo_surface_t *surface = NULL;
-    GdkVisual *visual = gdk_drawable_get_visual (drawaograms/Xserver/PEX5/ddpex/mi/include/Attic/miNurbs.h,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/include/Attic/mipex.h,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/include/Attic/miPick.h,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/include/Attic/miRender.h,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/include/Attic/miStrMacro.h,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/include/Attic/miStruct.h,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/include/Attic/miText.h,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/include/Attic/miWks.h,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/include/Attic/mixform.h,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level0
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level0/Attic
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level0/Attic/README,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/Imakefile,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/mi52stubs.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/miDDCtoGC.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/miLevel1.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/miListUtil.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/miLvl1Tab.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/miPck1Prim.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/miRndFArea.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/miRndMarkr.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/miRndPLine.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/miRndText.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level1/Attic/miRndTStrip.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/ddContext.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/Imakefile,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miBldXform.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miCellArray.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miClip.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miConvert.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miCopy.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miDestroy.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miFillArea.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miInquire.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miLight.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miLvl2Tab.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miMarkers.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miNCurve.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miNSTrim.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miNSurf.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miNurbs.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miOCs.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miPickPrim.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miPolyLine.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miQuadMesh.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miReplace.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miSearch.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miSOFAS.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miTestOCs.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miText.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miTrans.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/miTriStrip.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level2/Attic/pexOCParse.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level3
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level3/Attic
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level3/Attic/Imakefile,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level3/Attic/miRender.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level3/Attic/miRndrPick.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic/css_ex_str.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic/css_plain.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic/css_tbls.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic/Imakefile,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic/miDynamics.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic/miPick.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic/miSC.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic/miStruct.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic/miTraverse.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/level4/Attic/miWks.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/Imakefile,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miClrApLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miColrLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miDCueLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miEdgeLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miFont.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miFontLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miIntLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miLightLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miLineLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miLUTProcs.ci,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miMarkLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miMisc.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miNS.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miPattLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miTextLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miUtils.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/ddpex/mi/shared/Attic/miViewLUT.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/Attic
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/Attic/Imakefile,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/dispatch
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/dispatch/Attic
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/dispatch/Attic/dipexBuf.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/dispatch/Attic/dipexExt.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/dispatch/Attic/dipexParse.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/dispatch/Attic/Imakefile,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/dispatch/Attic/pexDump.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/dispatch/Attic/pexError.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/dispatch/Attic/pexUtils.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/Imakefile,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexAccBuf.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexFont.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexInfo.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexLut.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexNs.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexPc.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexPhigs.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexPick.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexRndr.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexRndrPick.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexSc.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexStr.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/objects/Attic/pexTM.c,v
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/swap
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/swap/Attic
/home/srv/cvs.freedesktop.org/cvs/dri/xc/xc/programs/Xserver/PEX5/dipex/swap/Attic/check.c,v
/home/srv/cvsa>
 
Index: src/cairo-clip-private.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-clip-private.h,v
retrieving revision 1.2
diff -p -u -r1.2 cairo-clip-private.h
--- src/cairo-clip-private.h	8 Aug 2005 20:46:11 -0000	1.2
+++ src/cairo-clip-private.h	9 Aug 2005 00:23:29 -0000
@@ -49,6 +49,7 @@ struct _cairo_clip_path {
     cairo_path_fixed_t	path;
     cairo_fill_rule_t	fill_rule;
     double		tolerance;
+    cairo_antialias_t	antialias;
     cairo_clip_path_t	*prev;
 };
 
@@ -100,6 +101,7 @@ _cairo_clip_clip (cairo_clip_t       *cl
 		  cairo_path_fixed_t *path,
 		  cairo_fill_rule_t   fill_rule,
 		  double              tolerance,
+		  cairo_antialias_t   antialias,
 		  cairo_surface_t    *target);
 
 cairo_private cairo_status_t
Index: src/cairo-clip.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-clip.c,v
retrieving revision 1.2
diff -p -u -r1.2 cairo-clip.c
--- src/cairo-clip.c	8 Aug 2005 20:46:11 -0000	1.2
+++ src/cairo-clip.c	9 Aug 2005 00:23:29 -0000
@@ -246,6 +246,7 @@ _cairo_clip_intersect_path (cairo_clip_t
 			    cairo_path_fixed_t *path,
 			    cairo_fill_rule_t   fill_rule,
 			    double              tolerance,
+			    cairo_antialias_t   antialias,
 			    cairo_surface_t    *target)
 {
     cairo_clip_path_t *clip_path;
@@ -265,6 +266,7 @@ _cairo_clip_intersect_path (cairo_clip_t
     clip_path->ref_count = 1;
     clip_path->fill_rule = fill_rule;
     clip_path->tolerance = tolerance;
+    clip_path->antialias = antialias;
     clip_path->prev = clip->path;
     clip->path = clip_path;
     clip->serial = _cairo_surface_allocate_clip_serial (target);
@@ -339,9 +341,10 @@ _cairo_clip_intersect_region (cairo_clip
 }
 
 static cairo_status_t
-_cairo_clip_intersect_mask (cairo_clip_t    *clip,
-			    cairo_traps_t   *traps,
-			    cairo_surface_t *target)
+_cairo_clip_intersect_mask (cairo_clip_t      *clip,
+			    cairo_traps_t     *traps,
+			    cairo_antialias_t antialias,
+			    cairo_surface_t   *target)
 {
     cairo_pattern_union_t pattern;
     cairo_box_t extents;
@@ -375,6 +378,7 @@ _cairo_clip_intersect_mask (cairo_clip_t
     status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_IN,
 						  &pattern.base,
 						  surface,
+						  antialias,
 						  0, 0,
 						  0, 0,
 						  surface_rect.width,
@@ -429,6 +433,7 @@ _cairo_clip_clip (cairo_clip_t       *cl
 		  cairo_path_fixed_t *path,
 		  cairo_fill_rule_t   fill_rule,
 		  double              tolerance,
+		  cairo_antialias_t   antialias,
 		  cairo_surface_t    *target)
 {
     cairo_status_t status;
@@ -436,7 +441,7 @@ _cairo_clip_clip (cairo_clip_t       *cl
     
     status = _cairo_clip_intersect_path (clip,
 					 path, fill_rule, tolerance,
-					 target);
+					 antialias, target);
     if (status != CAIRO_INT_STATUS_UNSUPPORTED)
 	return status;
 
@@ -452,7 +457,7 @@ _cairo_clip_clip (cairo_clip_t       *cl
     if (status != CAIRO_INT_STATUS_UNSUPPORTED)
 	goto bail;
 
-    status = _cairo_clip_intersect_mask (clip, &traps, target);
+    status = _cairo_clip_intersect_mask (clip, &traps, antialias, target);
 	
  bail:
     _cairo_traps_fini (&traps);
Index: src/cairo-glitz-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-glitz-surface.c,v
retrieving revision 1.55
diff -p -u -r1.55 cairo-glitz-surface.c
--- src/cairo-glitz-surface.c	5 Aug 2005 01:44:29 -0000	1.55
+++ src/cairo-glitz-surface.c	9 Aug 2005 00:23:30 -0000
@@ -936,6 +936,7 @@ static cairo_int_status_t
 _cairo_glitz_surface_composite_trapezoids (cairo_operator_t  op,
 					   cairo_pattern_t   *pattern,
 					   void		     *abstract_dst,
+					   cairo_antialias_t antialias,
 					   int		     src_x,
 					   int		     src_y,
 					   int		     dst_x,
Index: src/cairo-gstate-private.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate-private.h,v
retrieving revision 1.15
diff -p -u -r1.15 cairo-gstate-private.h
--- src/cairo-gstate-private.h	5 Aug 2005 05:45:59 -0000	1.15
+++ src/cairo-gstate-private.h	9 Aug 2005 00:23:30 -0000
@@ -42,6 +42,7 @@ struct _cairo_gstate {
     cairo_operator_t operator;
     
     double tolerance;
+    cairo_antialias_t antialias;
 
     /* stroke style */
     double line_width;
Index: src/cairo-gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate.c,v
retrieving revision 1.162
diff -p -u -r1.162 cairo-gstate.c
--- src/cairo-gstate.c	8 Aug 2005 21:13:50 -0000	1.162
+++ src/cairo-gstate.c	9 Aug 2005 00:23:31 -0000
@@ -92,6 +92,7 @@ _cairo_gstate_init (cairo_gstate_t  *gst
     gstate->operator = CAIRO_GSTATE_OPERATOR_DEFAULT;
 
     gstate->tolerance = CAIRO_GSTATE_TOLERANCE_DEFAULT;
+    gstate->antialias = CAIRO_GSTATE_ANTIALIAS_DEFAULT;
 
     gstate->line_width = CAIRO_GSTATE_LINE_WIDTH_DEFAULT;
     gstate->line_cap = CAIRO_GSTATE_LINE_CAP_DEFAULT;
@@ -1234,6 +1235,11 @@ _composite_trap_region_solid (cairo_clip
     return status;
 }
 
+typedef struct {
+    cairo_traps_t *traps;
+    cairo_antialias_t antialias;
+} cairo_composite_traps_info_t;
+
 static cairo_status_t
 _composite_traps_draw_func (void                    *closure,
 			    cairo_operator_t         operator,
@@ -1243,24 +1249,24 @@ _composite_traps_draw_func (void        
 			    int                      dst_y,
 			    const cairo_rectangle_t *extents)
 {
-    cairo_traps_t *traps = closure;
+    cairo_composite_traps_info_t *info = closure;
     cairo_pattern_union_t pattern;
     cairo_status_t status;
     
     if (dst_x != 0 || dst_y != 0)
-	_cairo_traps_translate (traps, - dst_x, - dst_y);
+	_cairo_traps_translate (info->traps, - dst_x, - dst_y);
 
     _cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE);
     if (!src)
 	src = &pattern.base;
     
     status = _cairo_surface_composite_trapezoids (operator,
-						  src, dst,
+						  src, dst, info->antialias,
 						  extents->x,         extents->y,
 						  extents->x - dst_x, extents->y - dst_y,
 						  extents->width,     extents->height,
-						  traps->traps,
-						  traps->num_traps);
+						  info->traps->traps,
+						  info->traps->num_traps);
     _cairo_pattern_fini (&pattern.base);
 
     return status;
@@ -1285,11 +1291,13 @@ _cairo_surface_clip_and_composite_trapez
 					      cairo_operator_t operator,
 					      cairo_surface_t *dst,
 					      cairo_traps_t *traps,
-					      cairo_clip_t *clip)
+					      cairo_clip_t *clip,
+					      cairo_antialias_t antialias)
 {
     cairo_status_t status;
     pixman_region16_t *trap_region;
     cairo_rectangle_t extents;
+    cairo_composite_traps_info_t traps_info;
     
     if (traps->num_traps == 0)
 	return CAIRO_STATUS_SUCCESS;
@@ -1350,10 +1358,12 @@ _cairo_surface_clip_and_composite_trapez
 	    goto out;
     }
 
+    traps_info.traps = traps;
+    traps_info.antialias = antialias;
+
     status = _cairo_gstate_clip_and_composite (clip, operator, src,
-					       _composite_traps_draw_func, traps,
-					       dst,
-					       &extents);
+					       _composite_traps_draw_func, &traps_info,
+					       dst, &extents);
 
  out:
     if (trap_region)
@@ -1376,7 +1386,8 @@ _cairo_gstate_clip_and_composite_trapezo
 							 gstate->operator,
 							 gstate->target,
 							 traps,
-							 &gstate->clip);
+							 &gstate->clip,
+							 gstate->antialias);
 
   _cairo_pattern_fini (&pattern.base);
 
@@ -1545,7 +1556,7 @@ _cairo_gstate_clip (cairo_gstate_t *gsta
 {
     return _cairo_clip_clip (&gstate->clip,
 			     path, gstate->fill_rule, gstate->tolerance,
-			     gstate->target);
+			     gstate->antialias, gstate->target);
 }
 
 static void
@@ -2005,3 +2016,19 @@ _cairo_gstate_glyph_path (cairo_gstate_t
     free (transformed_glyphs);
     return status;
 }
+
+cairo_private cairo_status_t
+_cairo_gstate_set_antialias (cairo_gstate_t *gstate,
+			     cairo_antialias_t antialias)
+{
+    gstate->antialias = antialias;
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+cairo_private cairo_antialias_t
+_cairo_gstate_get_antialias (cairo_gstate_t *gstate)
+{
+    return gstate->antialias;
+}
+
Index: src/cairo-image-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-image-surface.c,v
retrieving revision 1.56
diff -p -u -r1.56 cairo-image-surface.c
--- src/cairo-image-surface.c	8 Aug 2005 20:46:11 -0000	1.56
+++ src/cairo-image-surface.c	9 Aug 2005 00:23:32 -0000
@@ -655,34 +655,6 @@ _cairo_image_surface_fill_rectangles (vo
     return CAIRO_STATUS_SUCCESS;
 }
 
-static pixman_image_t *
-_create_mask_image (int width,
-		    int height)
-{
-    pixman_image_t *image;
-    pixman_color_t pixman_color = { 0, 0, 0, 0 }; /* transparent */
-    pixman_rectangle_t rect;
-    pixman_format_t *format;
-
-    format = pixman_format_create (PIXMAN_FORMAT_NAME_A8);
-    if (!format)
-	return NULL;
-
-    image = pixman_image_create (format, width, height);
-    if (!image)
-	return NULL;
-    
-    rect.x = 0;
-    rect.y = 0;
-    rect.width = width;
-    rect.height = height;
-    
-    pixman_fill_rectangles (PIXMAN_OPERATOR_SRC, image,
-			    &pixman_color, &rect, 1);
-
-    return image;
-}
-
 static cairo_bool_t
 _cairo_image_surface_is_alpha_only (cairo_image_surface_t *surface)
 {
@@ -701,6 +673,7 @@ static cairo_int_status_t
 _cairo_image_surface_composite_trapezoids (cairo_operator_t	operator,
 					   cairo_pattern_t	*pattern,
 					   void			*abstract_dst,
+					   cairo_antialias_t	antialias,
 					   int			src_x,
 					   int			src_y,
 					   int			dst_x,
@@ -715,6 +688,9 @@ _cairo_image_surface_composite_trapezoid
     cairo_image_surface_t	*src;
     cairo_int_status_t		status;
     pixman_image_t		*mask;
+    pixman_format_t		*format;
+    pixman_bits_t		*mask_data;
+    int				mask_stride;
 
     /* Special case adding trapezoids onto a mask surface; we want to avoid
      * creating an intermediate temporary mask unecessarily.
@@ -732,7 +708,8 @@ _cairo_image_surface_composite_trapezoid
     if (operator == CAIRO_OPERATOR_ADD &&
 	_cairo_pattern_is_opaque_solid (pattern) &&
 	_cairo_image_surface_is_alpha_only (dst) &&
-	!dst->has_clip)
+	!dst->has_clip &&
+	antialias != CAIRO_ANTIALIAS_NONE)
     {
 	pixman_add_trapezoids (dst->pixman_image, 0, 0,
 			       (pixman_trapezoid_t *) traps, num_traps);
@@ -750,10 +727,34 @@ _cairo_image_surface_composite_trapezoid
     if (status)
 	goto CLEANUP_SOURCE;
 
-    mask = _create_mask_image (width, height);
+    switch (antialias) {
+    case CAIRO_ANTIALIAS_NONE:
+	format = pixman_format_create (PIXMAN_FORMAT_NAME_A1);
+	mask_stride = ((width + 7)/8);
+ 	break;
+    default:
+	format = pixman_format_create (PIXMAN_FORMAT_NAME_A8);
+	mask_stride = width;
+ 	break;
+    }
+    if (!format) {
+	status = CAIRO_STATUS_NO_MEMORY;
+	goto CLEANUP_SOURCE;
+    }
+
+    mask_data = calloc (1, mask_stride * height);
+    if (!mask_data) {
+	status = CAIRO_STATUS_NO_MEMORY;
+	pixman_format_destroy (format);
+	goto CLEANUP_SOURCE;
+    }
+
+    mask = pixman_image_create_for_data (mask_data, format, width, height,
+					 1, mask_stride);
+    pixman_format_destroy (format);
     if (!mask) {
 	status = CAIRO_STATUS_NO_MEMORY;
-	goto CLEANUP_MASK;
+	goto CLEANUP_IMAGE_DATA;
     }
 
     /* XXX: The pixman_trapezoid_t cast is evil and needs to go away
@@ -771,9 +772,11 @@ _cairo_image_surface_composite_trapezoid
 		      dst_x, dst_y,
 		      width, height);
 	
- CLEANUP_MASK:
     pixman_image_destroy (mask);
 
+ CLEANUP_IMAGE_DATA:
+    free (mask_data);
+
  CLEANUP_SOURCE:
     _cairo_pattern_release_surface (pattern, &src->base, &attributes);
 
Index: src/cairo-meta-surface-private.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-meta-surface-private.h,v
retrieving revision 1.2
diff -p -u -r1.2 cairo-meta-surface-private.h
--- src/cairo-meta-surface-private.h	13 Jul 2005 19:32:51 -0000	1.2
+++ src/cairo-meta-surface-private.h	9 Aug 2005 00:23:32 -0000
@@ -77,6 +77,7 @@ typedef struct _cairo_command_composite_
     cairo_command_type_t	type;
     cairo_operator_t		operator;
     cairo_pattern_union_t	pattern;
+    cairo_antialias_t		antialias;
     int				x_src;
     int				y_src;
     int				x_dst;
@@ -99,6 +100,7 @@ typedef struct _cairo_command_intersect_
     cairo_path_fixed_t		path;
     cairo_fill_rule_t		fill_rule;
     double			tolerance;
+    cairo_antialias_t		antialias;
 } cairo_command_intersect_clip_path_t;
 
 typedef struct _cairo_command_show_glyphs {
@@ -123,6 +125,7 @@ typedef struct _cairo_command_fill_path 
     cairo_path_fixed_t		path;
     cairo_fill_rule_t		fill_rule;
     double			tolerance;
+    cairo_antialias_t		antialias;
 } cairo_command_fill_path_t;
 
 typedef union _cairo_command {
Index: src/cairo-meta-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-meta-surface.c,v
retrieving revision 1.7
diff -p -u -r1.7 cairo-meta-surface.c
--- src/cairo-meta-surface.c	5 Aug 2005 05:45:59 -0000	1.7
+++ src/cairo-meta-surface.c	9 Aug 2005 00:23:32 -0000
@@ -217,6 +217,7 @@ static cairo_int_status_t
 _cairo_meta_surface_composite_trapezoids (cairo_operator_t	operator,
 					  cairo_pattern_t	*pattern,
 					  void			*abstract_surface,
+					  cairo_antialias_t	antialias,
 					  int			x_src,
 					  int			y_src,
 					  int			x_dst,
@@ -236,6 +237,7 @@ _cairo_meta_surface_composite_trapezoids
     command->type = CAIRO_COMMAND_COMPOSITE_TRAPEZOIDS;
     command->operator = operator;
     _cairo_pattern_init_copy (&command->pattern.base, pattern);
+    command->antialias = antialias;
     command->x_src = x_src;
     command->y_src = y_src;
     command->x_dst = x_dst;
@@ -267,7 +269,8 @@ static cairo_int_status_t
 _cairo_meta_surface_intersect_clip_path (void		    *dst,
 					 cairo_path_fixed_t *path,
 					 cairo_fill_rule_t   fill_rule,
-					 double		     tolerance)
+					 double		     tolerance,
+					 cairo_antialias_t   antialias)
 {
     cairo_meta_surface_t *meta = dst;
     cairo_command_intersect_clip_path_t *command;
@@ -291,6 +294,7 @@ _cairo_meta_surface_intersect_clip_path 
     }
     command->fill_rule = fill_rule;
     command->tolerance = tolerance;
+    command->antialias = antialias;
 
     if (_cairo_array_append (&meta->commands, &command, 1) == NULL) {
 	if (path)
@@ -494,6 +498,7 @@ _cairo_meta_surface_replay (cairo_surfac
 		(command->composite_trapezoids.operator,
 		 &command->composite_trapezoids.pattern.base,
 		 target,
+		 command->composite_trapezoids.antialias,
 		 command->composite_trapezoids.x_src,
 		 command->composite_trapezoids.y_src,
 		 command->composite_trapezoids.x_dst,
@@ -514,6 +519,7 @@ _cairo_meta_surface_replay (cairo_surfac
 					   command->intersect_clip_path.path_pointer,
 					   command->intersect_clip_path.fill_rule,
 					   command->intersect_clip_path.tolerance,
+					   command->intersect_clip_path.antialias,
 					   target);
 	    break;
 
@@ -566,7 +572,8 @@ _cairo_meta_surface_replay (cairo_surfac
 								   command->fill_path.operator,
 								   target,
 								   &traps,
-								   &clip);
+								   &clip,
+								   command->fill_path.antialias);
 
 	    _cairo_traps_fini (&traps);
 	    break;
Index: src/cairo-path-data-private.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-path-data-private.h,v
retrieving revision 1.8
diff -p -u -r1.8 cairo-path-data-private.h
--- src/cairo-path-data-private.h	5 Aug 2005 17:30:31 -0000	1.8
+++ src/cairo-path-data-private.h	9 Aug 2005 00:23:32 -0000
@@ -38,7 +38,7 @@
 
 #include "cairoint.h"
 
-cairo_private const cairo_path_t _cairo_path_nil;
+extern cairo_private const cairo_path_t _cairo_path_nil;
 
 cairo_private cairo_path_t *
 _cairo_path_data_create (cairo_path_fixed_t *path,
Index: src/cairo-pdf-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-pdf-surface.c,v
retrieving revision 1.55
diff -p -u -r1.55 cairo-pdf-surface.c
--- src/cairo-pdf-surface.c	5 Aug 2005 01:44:29 -0000	1.55
+++ src/cairo-pdf-surface.c	9 Aug 2005 00:23:33 -0000
@@ -1151,6 +1151,7 @@ static cairo_int_status_t
 _cairo_pdf_surface_composite_trapezoids (cairo_operator_t	operator,
 					 cairo_pattern_t	*pattern,
 					 void			*abstract_dst,
+					 cairo_antialias_t	antialias,
 					 int			x_src,
 					 int			y_src,
 					 int			x_dst,
@@ -1334,7 +1335,8 @@ static cairo_int_status_t
 _cairo_pdf_surface_intersect_clip_path (void			*dst,
 					cairo_path_fixed_t	*path,
 					cairo_fill_rule_t	fill_rule,
-					double			tolerance)
+					double			tolerance,
+					cairo_antialias_t	antialias)
 {
     cairo_pdf_surface_t *surface = dst;
     cairo_pdf_document_t *document = surface->document;
Index: src/cairo-ps-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-ps-surface.c,v
retrieving revision 1.45
diff -p -u -r1.45 cairo-ps-surface.c
--- src/cairo-ps-surface.c	28 Jul 2005 16:46:38 -0000	1.45
+++ src/cairo-ps-surface.c	9 Aug 2005 00:23:33 -0000
@@ -272,6 +272,7 @@ static cairo_int_status_t
 _cairo_ps_surface_composite_trapezoids (cairo_operator_t	operator,
 					cairo_pattern_t		*pattern,
 					void			*abstract_dst,
+					cairo_antialias_t	antialias,
 					int			x_src,
 					int			y_src,
 					int			x_dst,
@@ -286,6 +287,7 @@ _cairo_ps_surface_composite_trapezoids (
     return _cairo_surface_composite_trapezoids (operator,
 						pattern,
 						surface->current_page,
+						antialias,
 						x_src,
 						y_src,
 						x_dst,
@@ -324,14 +326,16 @@ static cairo_int_status_t
 _cairo_ps_surface_intersect_clip_path (void		  *dst,
 				       cairo_path_fixed_t *path,
 				       cairo_fill_rule_t   fill_rule,
-				       double		   tolerance)
+				       double		   tolerance,
+				       cairo_antialias_t   antialias)
 {
     cairo_ps_surface_t *surface = dst;
 
     return _cairo_surface_intersect_clip_path (surface->current_page,
 					       path,
 					       fill_rule,
-					       tolerance);
+					       tolerance,
+					       antialias);
 }
 
 static cairo_int_status_t
@@ -929,6 +933,7 @@ static cairo_int_status_t
 _ps_output_composite_trapezoids (cairo_operator_t	operator,
 				 cairo_pattern_t	*pattern,
 				 void			*abstract_dst,
+				 cairo_antialias_t	antialias,
 				 int			x_src,
 				 int			y_src,
 				 int			x_dst,
@@ -1054,7 +1059,8 @@ static cairo_int_status_t
 _ps_output_intersect_clip_path (void		   *abstract_surface,
 				cairo_path_fixed_t *path,
 				cairo_fill_rule_t   fill_rule,
-				double		    tolerance)
+				double		    tolerance,
+				cairo_antialias_t   antialias)
 {
     ps_output_surface_t *surface = abstract_surface;
     cairo_output_stream_t *stream = surface->parent->stream;
Index: src/cairo-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-surface.c,v
retrieving revision 1.90
diff -p -u -r1.90 cairo-surface.c
--- src/cairo-surface.c	8 Aug 2005 20:50:59 -0000	1.90
+++ src/cairo-surface.c	9 Aug 2005 00:23:34 -0000
@@ -991,6 +991,7 @@ static cairo_status_t
 _fallback_composite_trapezoids (cairo_operator_t	operator,
 				cairo_pattern_t		*pattern,
 				cairo_surface_t		*dst,
+				cairo_antialias_t	antialias,
 				int			src_x,
 				int			src_y,
 				int			dst_x,
@@ -1043,6 +1044,7 @@ _fallback_composite_trapezoids (cairo_op
 
     state.image->base.backend->composite_trapezoids (operator, pattern,
 						     &state.image->base,
+						     antialias,
 						     src_x, src_y,
 						     dst_x - state.image_rect.x,
 						     dst_y - state.image_rect.y,
@@ -1060,6 +1062,7 @@ cairo_status_t
 _cairo_surface_composite_trapezoids (cairo_operator_t		operator,
 				     cairo_pattern_t		*pattern,
 				     cairo_surface_t		*dst,
+				     cairo_antialias_t		antialias,
 				     int			src_x,
 				     int			src_y,
 				     int			dst_x,
@@ -1080,6 +1083,7 @@ _cairo_surface_composite_trapezoids (cai
     if (dst->backend->composite_trapezoids) {
 	status = dst->backend->composite_trapezoids (operator,
 						     pattern, dst,
+						     antialias,
 						     src_x, src_y,
 						     dst_x, dst_y,
 						     width, height,
@@ -1089,6 +1093,7 @@ _cairo_surface_composite_trapezoids (cai
     }
 
     return  _fallback_composite_trapezoids (operator, pattern, dst,
+					    antialias,
 					    src_x, src_y,
 					    dst_x, dst_y,
 					    width, height,
@@ -1191,7 +1196,8 @@ _cairo_surface_reset_clip (cairo_surface
 	status = surface->backend->intersect_clip_path (surface,
 							NULL,
 							CAIRO_FILL_RULE_WINDING,
-							0);
+							0,
+							CAIRO_ANTIALIAS_DEFAULT);
 	if (status)
 	    return status;
     }
@@ -1237,7 +1243,8 @@ cairo_int_status_t
 _cairo_surface_intersect_clip_path (cairo_surface_t    *surface,
 				    cairo_path_fixed_t *path,
 				    cairo_fill_rule_t   fill_rule,
-				    double		tolerance)
+				    double		tolerance,
+				    cairo_antialias_t	antialias)
 {
     if (surface->status)
 	return surface->status;
@@ -1250,7 +1257,8 @@ _cairo_surface_intersect_clip_path (cair
     return surface->backend->intersect_clip_path (surface,
 						  path,
 						  fill_rule,
-						  tolerance);
+						  tolerance,
+						  antialias);
 }
 
 static cairo_status_t
@@ -1269,7 +1277,8 @@ _cairo_surface_set_clip_path_recursive (
     return surface->backend->intersect_clip_path (surface,
 						  &clip_path->path,
 						  clip_path->fill_rule,
-						  clip_path->tolerance);
+						  clip_path->tolerance,
+						  clip_path->antialias);
 }
 
 /**
@@ -1299,7 +1308,8 @@ _cairo_surface_set_clip_path (cairo_surf
     status = surface->backend->intersect_clip_path (surface,
 						    NULL,
 						    CAIRO_FILL_RULE_WINDING,
-						    0);
+						    0,
+						    CAIRO_ANTIALIAS_DEFAULT);
     if (status)
 	return status;
 
Index: src/cairo-xcb-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xcb-surface.c,v
retrieving revision 1.45
diff -p -u -r1.45 cairo-xcb-surface.c
--- src/cairo-xcb-surface.c	5 Aug 2005 01:44:29 -0000	1.45
+++ src/cairo-xcb-surface.c	9 Aug 2005 00:23:34 -0000
@@ -942,6 +942,7 @@ static cairo_int_status_t
 _cairo_xcb_surface_composite_trapezoids (cairo_operator_t	operator,
 					 cairo_pattern_t	*pattern,
 					 void			*abstract_dst,
+					 cairo_antialias_t	antialias,
 					 int			src_x,
 					 int			src_y,
 					 int			dst_x,
@@ -980,9 +981,17 @@ _cairo_xcb_surface_composite_trapezoids 
     render_src_x = src_x + render_reference_x - dst_x;
     render_src_y = src_y + render_reference_y - dst_y;
 
+    switch (antialias) {
+    case CAIRO_ANTIALIAS_NONE:
+	render_format = _format_from_cairo (dst->dpy, CAIRO_FORMAT_A1),
+	break;
+    default:
+	render_format = _format_from_cairo (dst->dpy, CAIRO_FORMAT_A8),
+	break;
+    }
+
     /* XXX: The XTrapezoid cast is evil and needs to go away somehow. */
     /* XXX: _format_from_cairo is slow. should cache something. */
-    render_format = _format_from_cairo (dst->dpy, CAIRO_FORMAT_A8),
     status = _cairo_xcb_surface_set_attributes (src, &attributes);
     if (status == CAIRO_STATUS_SUCCESS)
 	XCBRenderTrapezoids (dst->dpy,
Index: src/cairo-xlib-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xlib-surface.c,v
retrieving revision 1.106
diff -p -u -r1.106 cairo-xlib-surface.c
--- src/cairo-xlib-surface.c	8 Aug 2005 21:27:02 -0000	1.106
+++ src/cairo-xlib-surface.c	9 Aug 2005 00:23:35 -0000
@@ -1318,6 +1318,7 @@ static cairo_int_status_t
 _cairo_xlib_surface_composite_trapezoids (cairo_operator_t	operator,
 					  cairo_pattern_t	*pattern,
 					  void			*abstract_dst,
+					  cairo_antialias_t	antialias,
 					  int			src_x,
 					  int			src_y,
 					  int			dst_x,
@@ -1334,6 +1335,7 @@ _cairo_xlib_surface_composite_trapezoids
     composite_operation_t       operation;
     int				render_reference_x, render_reference_y;
     int				render_src_x, render_src_y;
+    XRenderPictFormat		*pict_format;
 
     if (!CAIRO_SURFACE_RENDER_HAS_TRAPEZOIDS (dst))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -1354,6 +1356,15 @@ _cairo_xlib_surface_composite_trapezoids
 	status = CAIRO_INT_STATUS_UNSUPPORTED;
 	goto FAIL;
     }
+
+    switch (antialias) {
+    case CAIRO_ANTIALIAS_NONE:
+	pict_format = XRenderFindStandardFormat (dst->dpy, PictStandardA1);
+	break;
+    default:
+	pict_format = XRenderFindStandardFormat (dst->dpy, PictStandardA8);
+	break;
+    }
 	
     if (traps[0].left.p1.y < traps[0].left.p2.y) {
 	render_reference_x = _cairo_fixed_integer_floor (traps[0].left.p1.x);
@@ -1406,7 +1417,7 @@ _cairo_xlib_surface_composite_trapezoids
 	XRenderCompositeTrapezoids (dst->dpy,
 				    _render_operator (operator),
 				    src->src_picture, dst->dst_picture,
-				    XRenderFindStandardFormat (dst->dpy, PictStandardA8),
+				    pict_format,
 				    render_src_x + attributes.x_offset, 
 				    render_src_y + attributes.y_offset,
 				    (XTrapezoid *) traps, num_traps);
Index: src/cairo.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.c,v
retrieving revision 1.122
diff -p -u -r1.122 cairo.c
--- src/cairo.c	6 Aug 2005 23:38:34 -0000	1.122
+++ src/cairo.c	9 Aug 2005 00:23:36 -0000
@@ -536,6 +536,29 @@ cairo_set_tolerance (cairo_t *cr, double
 }
 
 /**
+ * cairo_set_antialias:
+ * @cr: a #cairo_t
+ * @antialias: the new antialiasing mode
+ * 
+ * Set the antialiasing mode of the rasterizer used for drawing shapes.
+ * This value is a hint, and a particular backend may or may not support
+ * a particular value.  At the current time, no backend supports
+ * %CAIRO_ANTIALIAS_SUBPIXEL when drawing shapes.
+ **/
+void
+cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias)
+{
+    if (cr->status) {
+	_cairo_set_error (cr, cr->status);
+	return;
+    }
+
+    cr->status = _cairo_gstate_set_antialias (cr->gstate, antialias);
+    if (cr->status)
+	_cairo_set_error (cr, cr->status);
+}
+
+/**
  * cairo_set_fill_rule:
  * @cr: a #cairo_t
  * @fill_rule: a fill rule, specified as a #cairo_fill_rule_t
@@ -2082,6 +2105,20 @@ cairo_get_tolerance (cairo_t *cr)
 }
 
 /**
+ * cairo_get_antialias:
+ * @cr: a cairo context
+ * 
+ * Gets the current shape antialiasing mode, as set by cairo_set_shape_antialias().
+ * 
+ * Return value: the current shape antialiasing mode.
+ **/
+cairo_antialias_t
+cairo_get_antialias (cairo_t *cr)
+{
+    return _cairo_gstate_get_antialias (cr->gstate);
+}
+
+/**
  * cairo_get_current_point:
  * @cr: a cairo context
  * @x: return value for X coordinate of the current point
Index: src/cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.145
diff -p -u -r1.145 cairo.h
--- src/cairo.h	5 Aug 2005 01:44:29 -0000	1.145
+++ src/cairo.h	9 Aug 2005 00:23:37 -0000
@@ -288,6 +288,29 @@ void
 cairo_set_tolerance (cairo_t *cr, double tolerance);
 
 /**
+ * cairo_antialias_t:
+ * @CAIRO_ANTIALIAS_DEFAULT: Use the default antialiasing for
+ *   the subsystem and target device
+ * @CAIRO_ANTIALIAS_NONE: Use a bilevel alpha mask
+ * @CAIRO_ANTIALIAS_GRAY: Perform single-color antialiasing (using
+ *  shades of gray for black text on a white background, for example).
+ * @CAIRO_ANTIALIAS_SUBPIXEL: Perform antialiasing by taking
+ *  advantage of the order of subpixel elements on devices
+ *  such as LCD panels
+ * 
+ * Specifies the type of antialiasing to do when rendering text or shapes.
+ **/
+typedef enum _cairo_antialias {
+    CAIRO_ANTIALIAS_DEFAULT,
+    CAIRO_ANTIALIAS_NONE,
+    CAIRO_ANTIALIAS_GRAY,
+    CAIRO_ANTIALIAS_SUBPIXEL
+} cairo_antialias_t;
+
+void
+cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias);
+
+/**
  * cairo_fill_rule_t
  * @CAIRO_FILL_RULE_WINDING: If the path crosses the ray from
  * left-to-right, counts +1. If the path crosses the ray
@@ -660,26 +683,6 @@ typedef enum _cairo_font_weight {
 } cairo_font_weight_t;
 
 /**
- * cairo_antialias_t:
- * @CAIRO_ANTIALIAS_DEFAULT: Use the default antialiasing for
- *   the font subsystem and target device
- * @CAIRO_ANTIALIAS_NONE: Do no antialiasing of fonts; use bilevel text
- * @CAIRO_ANTIALIAS_GRAY: Perform single-color antialiasing (using
- *  shades of gray for black text on a white background, for example).
- * @CAIRO_ANTIALIAS_SUBPIXEL: Perform antialiasing by taking
- *  advantage of the order of subpixel elements on devices
- *  such as LCD panels
- * 
- * Specifies the type of antialiasing to do when rendering text.
- **/
-typedef enum _cairo_antialias {
-    CAIRO_ANTIALIAS_DEFAULT,
-    CAIRO_ANTIALIAS_NONE,
-    CAIRO_ANTIALIAS_GRAY,
-    CAIRO_ANTIALIAS_SUBPIXEL
-} cairo_antialias_t;
-
-/**
  * cairo_subpixel_order_t:
  * @CAIRO_SUBPIXEL_ORDER_DEFAULT: Use the default subpixel order for
  *   for the target device
@@ -920,6 +923,9 @@ cairo_get_source (cairo_t *cr);
 double
 cairo_get_tolerance (cairo_t *cr);
 
+cairo_antialias_t
+cairo_get_antialias (cairo_t *cr);
+
 void
 cairo_get_current_point (cairo_t *cr, double *x, double *y);
 
Index: src/cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.187
diff -p -u -r1.187 cairoint.h
--- src/cairoint.h	8 Aug 2005 20:46:11 -0000	1.187
+++ src/cairoint.h	9 Aug 2005 00:23:37 -0000
@@ -728,6 +728,7 @@ typedef struct _cairo_surface_backend {
     (*composite_trapezoids)	(cairo_operator_t	 operator,
 				 cairo_pattern_t	*pattern,
 				 void			*dst,
+				 cairo_antialias_t	 antialias,
 				 int			 src_x,
 				 int			 src_y,
 				 int			 dst_x,
@@ -778,7 +779,8 @@ typedef struct _cairo_surface_backend {
     (*intersect_clip_path)	(void			*dst,
 				 cairo_path_fixed_t	*path,
 				 cairo_fill_rule_t	fill_rule,
-				 double			tolerance);
+				 double			tolerance,
+				 cairo_antialias_t	antialias);
 
     /* Get the extents of the current surface. For many surface types
      * this will be as simple as { x=0, y=0, width=surface->width,
@@ -1035,6 +1037,7 @@ typedef struct _cairo_traps {
 
 #define CAIRO_GSTATE_OPERATOR_DEFAULT	CAIRO_OPERATOR_OVER
 #define CAIRO_GSTATE_TOLERANCE_DEFAULT	0.1
+#define CAIRO_GSTATE_ANTIALIAS_DEFAULT	CAIRO_ANTIALIAS_DEFAULT
 #define CAIRO_GSTATE_FILL_RULE_DEFAULT	CAIRO_FILL_RULE_WINDING
 #define CAIRO_GSTATE_LINE_WIDTH_DEFAULT	2.0
 #define CAIRO_GSTATE_LINE_CAP_DEFAULT	CAIRO_LINE_CAP_BUTT
@@ -1607,6 +1610,7 @@ cairo_private cairo_status_t
 _cairo_surface_composite_trapezoids (cairo_operator_t	operator,
 				     cairo_pattern_t	*pattern,
 				     cairo_surface_t	*dst,
+				     cairo_antialias_t	antialias,
 				     int		src_x,
 				     int		src_y,
 				     int		dst_x,
@@ -1621,7 +1625,8 @@ _cairo_surface_clip_and_composite_trapez
 					      cairo_operator_t operator,
 					      cairo_surface_t *dst,
 					      cairo_traps_t *traps,
-					      cairo_clip_t *clip);
+					      cairo_clip_t *clip,
+					      cairo_antialias_t antialias);
 
 cairo_private cairo_status_t
 _cairo_surface_copy_page (cairo_surface_t *surface);
@@ -1676,7 +1681,8 @@ cairo_private cairo_int_status_t
 _cairo_surface_intersect_clip_path (cairo_surface_t    *surface,
 				    cairo_path_fixed_t *path,
 				    cairo_fill_rule_t   fill_rule,
-				    double		tolerance);
+				    double		tolerance,
+				    cairo_antialias_t	antialias);
 
 cairo_private cairo_status_t
 _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip);
@@ -1954,6 +1960,13 @@ _cairo_pattern_acquire_surfaces (cairo_p
 				 cairo_surface_attributes_t *src_attributes,
 				 cairo_surface_attributes_t *mask_attributes);
 
+cairo_private cairo_status_t
+_cairo_gstate_set_antialias (cairo_gstate_t *gstate,
+			     cairo_antialias_t antialias);
+
+cairo_private cairo_antialias_t
+_cairo_gstate_get_antialias (cairo_gstate_t *gstate);
+
 
 /* cairo_unicode.c */
 
Index: test/Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/test/Makefile.am,v
retrieving revision 1.73
diff -p -u -r1.73 Makefile.am
--- test/Makefile.am	8 Aug 2005 20:46:12 -0000	1.73
+++ test/Makefile.am	9 Aug 2005 00:23:37 -0000
@@ -42,6 +42,7 @@ text-rotate			\
 transforms			\
 translate-show-surface		\
 trap-clip			\
+unantialiased-shapes		\
 unbounded-operator		\
 user-data			\
 rel-path
@@ -99,6 +100,7 @@ text-antialias-none-ref.png		\
 transforms-ref.png			\
 translate-show-surface-ref.png		\
 trap-clip-ref.png			\
+unantialiased-shapes-ref.png		\
 unbounded-operator-ref.png		\
 rel-path-ref.png
 
@@ -200,6 +202,7 @@ text_rotate_LDADD = $(LDADDS)
 transforms_LDADD = $(LDADDS)
 translate_show_surface_LDADD = $(LDADDS)
 trap_clip_LDADD = $(LDADDS)
+unantialiased_shapes_LDADD = $(LDADDS)
 unbounded_operator_LDADD = $(LDADDS)
 user_data_LDADD = $(LDADDS)
 rel_path_LDADD = $(LDADDS)
Index: test/unantialiased-shapes.c
===================================================================
RCS file: test/unantialiased-shapes.c
diff -N test/unantialiased-shapes.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ test/unantialiased-shapes.c	9 Aug 2005 00:23:38 -0000
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 2005 Billy Biggs
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Billy Biggs not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Billy Biggs makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * BILLY BIGGS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL BILLY BIGGS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Billy Biggs <vektor at dumbterm.net>
+ */
+
+#include "cairo-test.h"
+
+cairo_test_t test = {
+    "unantialiased-shapes",
+    "Test shape drawing without antialiasing",
+    320, 240
+};
+
+/* The star shape from the SVG test suite, from the fill rule test */
+static void
+big_star_path (cairo_t *cr)
+{
+    cairo_move_to (cr, 40, 0);
+    cairo_rel_line_to (cr, 25, 80);
+    cairo_rel_line_to (cr, -65, -50);
+    cairo_rel_line_to (cr, 80, 0);
+    cairo_rel_line_to (cr, -65, 50);
+    cairo_close_path (cr);
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    int i;
+
+    cairo_set_source_rgb (cr, 0, 0, 0);
+    cairo_paint (cr);
+
+    cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+
+    /* Try a circle */
+    cairo_arc (cr, 40, 40, 20, 0, 2 * M_PI);
+    cairo_set_source_rgb (cr, 1, 0, 0);
+    cairo_fill (cr);
+
+    /* Try using clipping to draw a circle */
+    cairo_arc (cr, 100, 40, 20, 0, 2 * M_PI);
+    cairo_clip (cr);
+    cairo_rectangle (cr, 80, 20, 40, 40);
+    cairo_set_source_rgb (cr, 0, 0, 1);
+    cairo_fill (cr);
+
+    /* Reset the clipping */
+    cairo_reset_clip (cr);
+
+    /* Draw a bunch of lines */
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgb (cr, 0, 1, 0);
+    for (i = 0; i < 10; i++) {
+        cairo_move_to (cr, 10, 70 + (i * 4));
+        cairo_line_to (cr, 120, 70 + (i * 18));
+        cairo_stroke (cr);
+    }
+
+    /* Try filling a poly */
+    cairo_translate (cr, 160, 120);
+    cairo_set_source_rgb (cr, 1, 1, 0);
+    big_star_path (cr);
+    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+    cairo_fill (cr);
+    cairo_translate (cr, -160, -120);
+
+    /* How about some curves? */
+    cairo_set_source_rgb (cr, 1, 0, 1);
+    for (i = 0; i < 10; i++) {
+        cairo_move_to (cr, 150, 50 + (i * 5));
+        cairo_curve_to (cr, 250, 50, 200, (i * 10), 300, 50 + (i * 10));
+        cairo_stroke (cr);
+    }
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+    return cairo_test (&test, draw);
+}

--bg08WKrSYDhXBjb5--



More information about the cairo mailing list