Turn off Antialiasing for Rendering with Palette - Take 2

Glenn Wurster glenn at electric.ath.cx
Sun Dec 5 19:57:01 CST 2004


Alright, I've rewritten the patch to split up the cache to avoid
potential problems.  I've also moved the antialias disable check into
the GDI code (which means I need to pass a boolean into the ExtTextOut
backend functions).  The combination of these two modifications,
however, means that the patch is rather large, even though most of it
is straightforward.

Please let me know if there is anything that still needs to be done in
order for it to get accepted.

Authors:
  Doug Paul <doug at elemental.ath.cx>,
  Glenn Wurster <gwurster at scs.carleton.ca>

Description:
* When we are working with text in a palette BITMAP, we need to
disable antialiasing.  Antialiasing results in a lot of extra colour
values which are not mapped in the palette, causing bad display
artifacts.

Changelog:
 * Disable font antialiasing when working with a palette BITMAP.

Glenn.

Index: dlls/gdi/font.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/font.c,v
retrieving revision 1.3
diff -u -r1.3 font.c
--- dlls/gdi/font.c	8 Sep 2004 01:37:24 -0000	1.3
+++ dlls/gdi/font.c	6 Dec 2004 00:02:13 -0000
@@ -1690,8 +1690,30 @@
 {
     BOOL ret = FALSE;
     DC * dc = DC_GetDCUpdate( hdc );
+    BOOL antialias = TRUE;
+
     if (dc)
     {
+        do {
+            BITMAPOBJ *bmp;
+            HBITMAP hBitmap;
+
+            hBitmap = GetCurrentObject( hdc, OBJ_BITMAP );
+            bmp = (BITMAPOBJ *)GDI_GetObjPtr( hBitmap, BITMAP_MAGIC );
+            if (!(bmp && bmp->dib)) {
+                TRACE("bitmap is not a DIB\n");
+                GDI_ReleaseObj( hBitmap );
+                break;
+            }
+
+            if (bmp->dib->dsBmih.biBitCount <= 8) {
+                TRACE("Disabling antialiasing\n");
+                antialias = FALSE;
+            }
+
+            GDI_ReleaseObj( hBitmap );
+        } while (0);
+
         if(PATH_IsPathOpen(dc->path))
             FIXME("called on an open path\n");
         else if(dc->funcs->pExtTextOut)
@@ -1708,11 +1730,11 @@
                               lpReorderedString, count, NULL );
 
                 ret = dc->funcs->pExtTextOut(dc->physDev,x,y,flags|ETO_IGNORELANGUAGE,
-                                             lprect,lpReorderedString,count,lpDx,dc->breakExtra);
+                                             lprect,lpReorderedString,count,lpDx,dc->breakExtra,antialias);
                 HeapFree(GetProcessHeap(), 0, lpReorderedString);
             } else
                 ret = dc->funcs->pExtTextOut(dc->physDev,x,y,flags,lprect,str,count,
-                                             lpDx,dc->breakExtra);
+                                             lpDx,dc->breakExtra,antialias);
         }
         GDI_ReleaseObj( hdc );
     }
Index: dlls/gdi/gdi_private.h
===================================================================
RCS file: /home/wine/wine/dlls/gdi/gdi_private.h,v
retrieving revision 1.17
diff -u -r1.17 gdi_private.h
--- dlls/gdi/gdi_private.h	23 Nov 2004 12:19:24 -0000	1.17
+++ dlls/gdi/gdi_private.h	6 Dec 2004 00:02:13 -0000
@@ -79,7 +79,7 @@
     INT      (*pExtEscape)(PHYSDEV,INT,INT,LPCVOID,INT,LPVOID);
     BOOL     (*pExtFloodFill)(PHYSDEV,INT,INT,COLORREF,UINT);
     INT      (*pExtSelectClipRgn)(PHYSDEV,HRGN,INT);
-    BOOL     (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*,INT);
+    BOOL     (*pExtTextOut)(PHYSDEV,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*,INT,BOOL);
     BOOL     (*pFillPath)(PHYSDEV);
     BOOL     (*pFillRgn)(PHYSDEV,HRGN,HBRUSH);
     BOOL     (*pFlattenPath)(PHYSDEV);
Index: dlls/gdi/enhmfdrv/enhmetafiledrv.h
===================================================================
RCS file: /home/wine/wine/dlls/gdi/enhmfdrv/enhmetafiledrv.h,v
retrieving revision 1.18
diff -u -r1.18 enhmetafiledrv.h
--- dlls/gdi/enhmfdrv/enhmetafiledrv.h	4 Mar 2004 20:41:13 -0000	1.18
+++ dlls/gdi/enhmfdrv/enhmetafiledrv.h	6 Dec 2004 00:02:13 -0000
@@ -78,7 +78,8 @@
 extern INT      EMFDRV_ExtSelectClipRgn( PHYSDEV dev, HRGN hrgn, INT mode );
 extern BOOL     EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y,
                                    UINT flags, const RECT *lprect, LPCWSTR str,
-                                   UINT count, const INT *lpDx, INT breakExtra );
+                                   UINT count, const INT *lpDx, INT breakExtra,
+                                   BOOL antialias );
 extern BOOL     EMFDRV_FillPath( PHYSDEV dev );
 extern BOOL     EMFDRV_FillRgn( PHYSDEV dev, HRGN hrgn, HBRUSH hbrush );
 extern BOOL     EMFDRV_FlattenPath( PHYSDEV dev );
Index: dlls/gdi/enhmfdrv/graphics.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/enhmfdrv/graphics.c,v
retrieving revision 1.15
diff -u -r1.15 graphics.c
--- dlls/gdi/enhmfdrv/graphics.c	30 Nov 2004 21:38:59 -0000	1.15
+++ dlls/gdi/enhmfdrv/graphics.c	6 Dec 2004 00:02:14 -0000
@@ -708,7 +708,7 @@
  */
 BOOL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
 			const RECT *lprect, LPCWSTR str, UINT count,
-			const INT *lpDx, INT breakExtra )
+			const INT *lpDx, INT breakExtra, BOOL antialias )
 {
     EMREXTTEXTOUTW *pemr;
     DWORD nSize;
Index: dlls/gdi/mfdrv/metafiledrv.h
===================================================================
RCS file: /home/wine/wine/dlls/gdi/mfdrv/metafiledrv.h,v
retrieving revision 1.14
diff -u -r1.14 metafiledrv.h
--- dlls/gdi/mfdrv/metafiledrv.h	4 Mar 2004 20:41:13 -0000	1.14
+++ dlls/gdi/mfdrv/metafiledrv.h	6 Dec 2004 00:02:14 -0000
@@ -84,7 +84,8 @@
 extern INT  MFDRV_ExtSelectClipRgn( PHYSDEV dev, HRGN hrgn, INT mode );
 extern BOOL MFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y,
                               UINT flags, const RECT *lprect, LPCWSTR str,
-                              UINT count, const INT *lpDx, INT breakExtra );
+                              UINT count, const INT *lpDx, INT breakExtra,
+                              BOOL antialias );
 extern BOOL MFDRV_FillPath( PHYSDEV dev );
 extern BOOL MFDRV_FillRgn( PHYSDEV dev, HRGN hrgn, HBRUSH hbrush );
 extern BOOL MFDRV_FlattenPath( PHYSDEV dev );
Index: dlls/gdi/mfdrv/text.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/mfdrv/text.c,v
retrieving revision 1.11
diff -u -r1.11 text.c
--- dlls/gdi/mfdrv/text.c	8 Sep 2004 01:37:24 -0000	1.11
+++ dlls/gdi/mfdrv/text.c	6 Dec 2004 00:02:14 -0000
@@ -74,7 +74,7 @@
 BOOL
 MFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
                   const RECT *lprect, LPCWSTR str, UINT count,
-                  const INT *lpDx, INT breakExtra )
+                  const INT *lpDx, INT breakExtra, BOOL antialias )
 {
     RECT16	rect16;
     LPINT16	lpdx16 = NULL;
Index: dlls/wineps/psdrv.h
===================================================================
RCS file: /home/wine/wine/dlls/wineps/psdrv.h,v
retrieving revision 1.54
diff -u -r1.54 psdrv.h
--- dlls/wineps/psdrv.h	2 Nov 2004 19:25:51 -0000	1.54
+++ dlls/wineps/psdrv.h	6 Dec 2004 00:02:16 -0000
@@ -470,7 +470,7 @@
 extern INT PSDRV_EndPage( PSDRV_PDEVICE *physDev );
 extern BOOL PSDRV_ExtTextOut( PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
 				const RECT *lprect, LPCWSTR str, UINT count,
-				const INT *lpDx, INT breakExtra );
+				const INT *lpDx, INT breakExtra, BOOL antialias );
 extern BOOL PSDRV_GetCharWidth( PSDRV_PDEVICE *physDev, UINT firstChar, UINT lastChar,
 				  LPINT buffer );
 extern BOOL PSDRV_GetTextExtentPoint( PSDRV_PDEVICE *physDev, LPCWSTR str, INT count,
Index: dlls/wineps/text.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps/text.c,v
retrieving revision 1.24
diff -u -r1.24 text.c
--- dlls/wineps/text.c	22 Sep 2004 02:46:39 -0000	1.24
+++ dlls/wineps/text.c	6 Dec 2004 00:02:16 -0000
@@ -40,7 +40,7 @@
  */
 BOOL PSDRV_ExtTextOut( PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags,
 		       const RECT *lprect, LPCWSTR str, UINT count,
-		       const INT *lpDx, INT breakExtra )
+		       const INT *lpDx, INT breakExtra, BOOL antialias )
 {
     BOOL bResult = TRUE;
     BOOL bClipped = FALSE;
Index: dlls/x11drv/text.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/text.c,v
retrieving revision 1.13
diff -u -r1.13 text.c
--- dlls/x11drv/text.c	11 Aug 2004 23:45:34 -0000	1.13
+++ dlls/x11drv/text.c	6 Dec 2004 00:02:18 -0000
@@ -43,7 +43,7 @@
 BOOL
 X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
                    const RECT *lprect, LPCWSTR wstr, UINT count,
-                   const INT *lpDx, INT breakExtra )
+                   const INT *lpDx, INT breakExtra, BOOL antialias )
 {
     unsigned int i;
     fontObject*		pfo;
@@ -61,7 +61,7 @@
     INT                 charExtra;
 
     if(physDev->has_gdi_font)
-        return X11DRV_XRender_ExtTextOut(physDev, x, y, flags, lprect, wstr, count, lpDx, breakExtra);
+        return X11DRV_XRender_ExtTextOut(physDev, x, y, flags, lprect, wstr, count, lpDx, breakExtra, antialias);
 
     if (!X11DRV_SetupGCForText( physDev )) return TRUE;
 
Index: dlls/x11drv/x11drv.h
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/x11drv.h,v
retrieving revision 1.36
diff -u -r1.36 x11drv.h
--- dlls/x11drv/x11drv.h	16 Sep 2004 19:10:14 -0000	1.36
+++ dlls/x11drv/x11drv.h	6 Dec 2004 00:02:18 -0000
@@ -173,7 +173,8 @@
 				   COLORREF color, UINT fillType );
 extern BOOL X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y,
 				 UINT flags, const RECT *lprect,
-				 LPCWSTR str, UINT count, const INT *lpDx, INT breakExtra );
+				 LPCWSTR str, UINT count, const INT *lpDx,
+				 INT breakExtra, BOOL antialias );
 extern LONG X11DRV_SetBitmapBits( HBITMAP hbitmap, const void *bits, LONG count );
 extern void X11DRV_SetDeviceClipping( X11DRV_PDEVICE *physDev, HRGN vis_rgn, HRGN clip_rgn );
 extern INT X11DRV_SetDIBitsToDevice( X11DRV_PDEVICE *physDev, INT xDest,
@@ -233,7 +234,8 @@
 extern void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE*);
 extern BOOL X11DRV_XRender_ExtTextOut(X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
 				      const RECT *lprect, LPCWSTR wstr,
-				      UINT count, const INT *lpDx, INT breakExtra);
+				      UINT count, const INT *lpDx,
+                                      INT breakExtra, BOOL antialias);
 extern void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev);
 
 extern void X11DRV_OpenGL_Init(Display *display);
Index: dlls/x11drv/xrender.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/xrender.c,v
retrieving revision 1.52
diff -u -r1.52 xrender.c
--- dlls/x11drv/xrender.c	30 Nov 2004 21:38:58 -0000	1.52
+++ dlls/x11drv/xrender.c	6 Dec 2004 00:02:20 -0000
@@ -67,18 +67,23 @@
 
 #define INITIAL_REALIZED_BUF_SIZE 128
 
-typedef enum { AA_None, AA_Grey, AA_RGB, AA_BGR, AA_VRGB, AA_VBGR } AA_Type;
+typedef enum { AA_None = 0, AA_Grey, AA_RGB, AA_BGR, AA_VRGB, AA_VBGR, AA_MAXVALUE } AA_Type;
 
 typedef struct
 {
-    LFANDSIZE lfsz;
-    AA_Type aa;
     GlyphSet glyphset;
     XRenderPictFormat *font_format;
     int nrealized;
     BOOL *realized;
     void **bitmaps;
     XGlyphInfo *gis;
+} gsCacheEntryFormat;
+
+typedef struct
+{
+    LFANDSIZE lfsz;
+    AA_Type aa_default;
+    gsCacheEntryFormat * format[AA_MAXVALUE];
     UINT count;
     INT next;
 } gsCacheEntry;
@@ -292,27 +297,39 @@
 
 static void FreeEntry(int entry)
 {
-    int i;
+    int i, format;
 
-    if(glyphsetCache[entry].glyphset) {
-	wine_tsx11_lock();
-	pXRenderFreeGlyphSet(gdi_display, glyphsetCache[entry].glyphset);
-	wine_tsx11_unlock();
-	glyphsetCache[entry].glyphset = 0;
-    }
-    if(glyphsetCache[entry].nrealized) {
-	HeapFree(GetProcessHeap(), 0, glyphsetCache[entry].realized);
-	glyphsetCache[entry].realized = NULL;
-	if(glyphsetCache[entry].bitmaps) {
-	    for(i = 0; i < glyphsetCache[entry].nrealized; i++)
-		if(glyphsetCache[entry].bitmaps[i])
-		    HeapFree(GetProcessHeap(), 0, glyphsetCache[entry].bitmaps[i]);
-	    HeapFree(GetProcessHeap(), 0, glyphsetCache[entry].bitmaps);
-	    glyphsetCache[entry].bitmaps = NULL;
-	    HeapFree(GetProcessHeap(), 0, glyphsetCache[entry].gis);
-	    glyphsetCache[entry].gis = NULL;
-	}
-	glyphsetCache[entry].nrealized = 0;
+    for(format = 0; format < AA_MAXVALUE; format++) {
+        gsCacheEntryFormat * formatEntry;
+
+        if( !glyphsetCache[entry].format[format] )
+            continue;
+
+        formatEntry = glyphsetCache[entry].format[format];
+
+        if(formatEntry->glyphset) {
+            wine_tsx11_lock();
+            pXRenderFreeGlyphSet(gdi_display, formatEntry->glyphset);
+            wine_tsx11_unlock();
+            formatEntry->glyphset = 0;
+        }
+        if(formatEntry->nrealized) {
+            HeapFree(GetProcessHeap(), 0, formatEntry->realized);
+            formatEntry->realized = NULL;
+            if(formatEntry->bitmaps) {
+                for(i = 0; i < formatEntry->nrealized; i++)
+                    if(formatEntry->bitmaps[i])
+                        HeapFree(GetProcessHeap(), 0, formatEntry->bitmaps[i]);
+                HeapFree(GetProcessHeap(), 0, formatEntry->bitmaps);
+                formatEntry->bitmaps = NULL;
+                HeapFree(GetProcessHeap(), 0, formatEntry->gis);
+                formatEntry->gis = NULL;
+            }
+            formatEntry->nrealized = 0;
+        }
+
+        HeapFree(GetProcessHeap(), 0, formatEntry);
+        glyphsetCache[entry].format[format] = NULL;
     }
 }
 
@@ -386,6 +403,7 @@
 static int GetCacheEntry(LFANDSIZE *plfsz)
 {
     int ret;
+    int format;
     gsCacheEntry *entry;
 
     if((ret = LookupEntry(plfsz)) != -1) return ret;
@@ -393,15 +411,15 @@
     ret = AllocEntry();
     entry = glyphsetCache + ret;
     entry->lfsz = *plfsz;
-    assert(entry->nrealized == 0);
+    for( format = 0; format < AA_MAXVALUE; format++ ) {
+        assert( !entry->format[format] );
+    }
 
     if(antialias)
-        entry->aa = AA_Grey;
+        entry->aa_default = AA_Grey;
     else
-        entry->aa = AA_None;
+        entry->aa_default = AA_None;
 
-    entry->font_format = NULL;
-    entry->glyphset = 0;
     return ret;
 }
 
@@ -528,7 +546,7 @@
  *
  * Helper to ExtTextOut.  Must be called inside xrender_cs
  */
-static BOOL UploadGlyph(X11DRV_PDEVICE *physDev, int glyph)
+static BOOL UploadGlyph(X11DRV_PDEVICE *physDev, int glyph, AA_Type format)
 {
     unsigned int buflen;
     char *buf;
@@ -536,52 +554,61 @@
     GLYPHMETRICS gm;
     XGlyphInfo gi;
     gsCacheEntry *entry = glyphsetCache + physDev->xrender->cache_index;
+    gsCacheEntryFormat *formatEntry;
     UINT ggo_format = GGO_GLYPH_INDEX;
     XRenderPictFormat pf;
 
-    if(entry->nrealized <= glyph) {
-        entry->nrealized = (glyph / 128 + 1) * 128;
+    /* If there is nothing for the current type, we create the entry. */
+    if( !entry->format[format] ) {
+        entry->format[format] = HeapAlloc(GetProcessHeap(),
+                                          HEAP_ZERO_MEMORY,
+                                          sizeof(gsCacheEntryFormat));
+    }
+    formatEntry = entry->format[format];
 
-	if (entry->realized)
-	    entry->realized = HeapReAlloc(GetProcessHeap(),
+    if(formatEntry->nrealized <= glyph) {
+        formatEntry->nrealized = (glyph / 128 + 1) * 128;
+
+	if (formatEntry->realized)
+	    formatEntry->realized = HeapReAlloc(GetProcessHeap(),
 				      HEAP_ZERO_MEMORY,
-				      entry->realized,
-				      entry->nrealized * sizeof(BOOL));
+				      formatEntry->realized,
+				      formatEntry->nrealized * sizeof(BOOL));
 	else
-	    entry->realized = HeapAlloc(GetProcessHeap(),
+	    formatEntry->realized = HeapAlloc(GetProcessHeap(),
 				      HEAP_ZERO_MEMORY,
-				      entry->nrealized * sizeof(BOOL));
+				      formatEntry->nrealized * sizeof(BOOL));
 
 	if(!X11DRV_XRender_Installed) {
-	  if (entry->bitmaps)
-	    entry->bitmaps = HeapReAlloc(GetProcessHeap(),
+	  if (formatEntry->bitmaps)
+	    formatEntry->bitmaps = HeapReAlloc(GetProcessHeap(),
 				      HEAP_ZERO_MEMORY,
-				      entry->bitmaps,
-				      entry->nrealized * sizeof(entry->bitmaps[0]));
+				      formatEntry->bitmaps,
+				      formatEntry->nrealized * sizeof(formatEntry->bitmaps[0]));
 	  else
-	    entry->bitmaps = HeapAlloc(GetProcessHeap(),
+	    formatEntry->bitmaps = HeapAlloc(GetProcessHeap(),
 				      HEAP_ZERO_MEMORY,
-				      entry->nrealized * sizeof(entry->bitmaps[0]));
+				      formatEntry->nrealized * sizeof(formatEntry->bitmaps[0]));
 
-	  if (entry->gis)
-	    entry->gis = HeapReAlloc(GetProcessHeap(),
+	  if (formatEntry->gis)
+	    formatEntry->gis = HeapReAlloc(GetProcessHeap(),
 				   HEAP_ZERO_MEMORY,
-				   entry->gis,
-				   entry->nrealized * sizeof(entry->gis[0]));
+				   formatEntry->gis,
+				   formatEntry->nrealized * sizeof(formatEntry->gis[0]));
 	  else
-	    entry->gis = HeapAlloc(GetProcessHeap(),
+	    formatEntry->gis = HeapAlloc(GetProcessHeap(),
 				   HEAP_ZERO_MEMORY,
-				   entry->nrealized * sizeof(entry->gis[0]));
+				   formatEntry->nrealized * sizeof(formatEntry->gis[0]));
 	}
     }
 
-    switch(entry->aa) {
+    switch(format) {
     case AA_Grey:
 	ggo_format |= WINE_GGO_GRAY16_BITMAP;
 	break;
 
     default:
-        ERR("aa = %d - not implemented\n", entry->aa);
+        ERR("aa = %d - not implemented\n", format);
     case AA_None:
         ggo_format |= GGO_BITMAP;
 	break;
@@ -590,8 +617,9 @@
     buflen = GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, 0, NULL,
 			      NULL);
     if(buflen == GDI_ERROR) {
-        if(entry->aa != AA_None) {
-            entry->aa = AA_None;
+        if(format != AA_None) {
+            format = AA_None;
+            entry->aa_default = AA_None;
             ggo_format &= ~WINE_GGO_GRAY16_BITMAP;
             ggo_format |= GGO_BITMAP;
             buflen = GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, 0, NULL,
@@ -604,15 +632,15 @@
         TRACE("Turning off antialiasing for this monochrome font\n");
     }
 
-    if(entry->glyphset == 0 && X11DRV_XRender_Installed) {
-        switch(entry->aa) {
+    if(formatEntry->glyphset == 0 && X11DRV_XRender_Installed) {
+        switch(format) {
 	case AA_Grey:
 	    pf.depth = 8;
 	    pf.direct.alphaMask = 0xff;
 	    break;
 
 	default:
-	    ERR("aa = %d - not implemented\n", entry->aa);
+	    ERR("aa = %d - not implemented\n", format);
 	case AA_None:
 	    pf.depth = 1;
 	    pf.direct.alphaMask = 1;
@@ -623,21 +651,21 @@
 	pf.direct.alpha = 0;
 
 	wine_tsx11_lock();
-	entry->font_format = pXRenderFindFormat(gdi_display,
+	formatEntry->font_format = pXRenderFindFormat(gdi_display,
 						PictFormatType |
 						PictFormatDepth |
 						PictFormatAlpha |
 						PictFormatAlphaMask,
 						&pf, 0);
 
-	entry->glyphset = pXRenderCreateGlyphSet(gdi_display, entry->font_format);
+	formatEntry->glyphset = pXRenderCreateGlyphSet(gdi_display, formatEntry->font_format);
 	wine_tsx11_unlock();
     }
 
 
     buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen);
     GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, buflen, buf, NULL);
-    entry->realized[glyph] = TRUE;
+    formatEntry->realized[glyph] = TRUE;
 
     TRACE("buflen = %d. Got metrics: %dx%d adv=%d,%d origin=%ld,%ld\n",
 	  buflen,
@@ -656,7 +684,7 @@
 	char output[300];
 	unsigned char *line;
 
-	if(entry->aa == AA_None) {
+	if(format == AA_None) {
 	    pitch = ((gi.width + 31) / 32) * 4;
 	    for(i = 0; i < gi.height; i++) {
 	        line = buf + i * pitch;
@@ -686,8 +714,8 @@
 	}
     }
 
-    if(entry->glyphset) {
-        if(entry->aa == AA_None && BitmapBitOrder(gdi_display) != MSBFirst) {
+    if(formatEntry->glyphset) {
+        if(format == AA_None && BitmapBitOrder(gdi_display) != MSBFirst) {
 	    unsigned char *byte = buf, c;
 	    int i = buflen;
 
@@ -704,13 +732,13 @@
 	}
 	gid = glyph;
         wine_tsx11_lock();
-	pXRenderAddGlyphs(gdi_display, entry->glyphset, &gid, &gi, 1,
+	pXRenderAddGlyphs(gdi_display, formatEntry->glyphset, &gid, &gi, 1,
 			  buf, buflen);
 	wine_tsx11_unlock();
 	HeapFree(GetProcessHeap(), 0, buf);
     } else {
-        entry->bitmaps[glyph] = buf;
-	memcpy(&entry->gis[glyph], &gi, sizeof(gi));
+        formatEntry->bitmaps[glyph] = buf;
+	memcpy(&formatEntry->gis[glyph], &gi, sizeof(gi));
     }
     return TRUE;
 }
@@ -961,7 +989,7 @@
  */
 BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
 				const RECT *lprect, LPCWSTR wstr, UINT count,
-				const INT *lpDx, INT breakExtra )
+				const INT *lpDx, INT breakExtra, BOOL antialias )
 {
     XRenderColor col;
     unsigned int idx;
@@ -978,6 +1006,7 @@
     const WORD *glyphs;
     POINT pt;
     gsCacheEntry *entry;
+    gsCacheEntryFormat *formatEntry;
     BOOL retv = FALSE;
     HDC hdc = physDev->hdc;
     int textPixel, backgroundPixel;
@@ -1278,13 +1307,18 @@
 
     EnterCriticalSection(&xrender_cs);
     entry = glyphsetCache + physDev->xrender->cache_index;
+    entry->aa_default = antialias;
+    formatEntry = entry->format[entry->aa_default];
 
     for(idx = 0; idx < count; idx++) {
-        if(glyphs[idx] >= entry->nrealized || entry->realized[glyphs[idx]] == FALSE) {
-	    UploadGlyph(physDev, glyphs[idx]);
+        if( !formatEntry ) {
+	    UploadGlyph(physDev, glyphs[idx], entry->aa_default);
+            formatEntry = entry->format[entry->aa_default];
+        } else if( glyphs[idx] >= formatEntry->nrealized || formatEntry->realized[glyphs[idx]] == FALSE) {
+	    UploadGlyph(physDev, glyphs[idx], entry->aa_default);
 	}
     }
-
+    assert(formatEntry);
 
     TRACE("Writing %s at %ld,%ld\n", debugstr_wn(wstr,count),
           physDev->org.x + x, physDev->org.y + y);
@@ -1295,7 +1329,7 @@
 	    pXRenderCompositeString16(gdi_display, render_op,
 				      physDev->xrender->tile_pict,
 				      physDev->xrender->pict,
-				      entry->font_format, entry->glyphset,
+				      formatEntry->font_format, formatEntry->glyphset,
 				      0, 0, physDev->org.x + x, physDev->org.y + y,
 				      glyphs, count);
 
@@ -1305,7 +1339,7 @@
 	        pXRenderCompositeString16(gdi_display, render_op,
 					  physDev->xrender->tile_pict,
 					  physDev->xrender->pict,
-					  entry->font_format, entry->glyphset,
+					  formatEntry->font_format, formatEntry->glyphset,
 					  0, 0, physDev->org.x + x + xoff,
 					  physDev->org.y + y + yoff,
 					  glyphs + idx, 1);
@@ -1321,36 +1355,36 @@
         wine_tsx11_lock();
 	XSetForeground( gdi_display, physDev->gc, textPixel );
 
-	if(entry->aa == AA_None) {
+	if(entry->aa_default == AA_None) {
 	    for(idx = 0; idx < count; idx++) {
 	        SharpGlyphMono(physDev, physDev->org.x + x + xoff,
 			       physDev->org.y + y + yoff,
-			       entry->bitmaps[glyphs[idx]],
-			       &entry->gis[glyphs[idx]]);
+			       formatEntry->bitmaps[glyphs[idx]],
+			       &formatEntry->gis[glyphs[idx]]);
 		if(deltas) {
 		    offset += X11DRV_XWStoDS(physDev, deltas[idx]);
 		    xoff = offset * cosEsc;
 		    yoff = offset * -sinEsc;
 
 		} else {
-		    xoff += entry->gis[glyphs[idx]].xOff;
-		    yoff += entry->gis[glyphs[idx]].yOff;
+		    xoff += formatEntry->gis[glyphs[idx]].xOff;
+		    yoff += formatEntry->gis[glyphs[idx]].yOff;
 		}
 	    }
 	} else if(physDev->depth == 1) {
 	    for(idx = 0; idx < count; idx++) {
 	        SharpGlyphGray(physDev, physDev->org.x + x + xoff,
 			       physDev->org.y + y + yoff,
-			       entry->bitmaps[glyphs[idx]],
-			       &entry->gis[glyphs[idx]]);
+			       formatEntry->bitmaps[glyphs[idx]],
+			       &formatEntry->gis[glyphs[idx]]);
 		if(deltas) {
 		    offset += X11DRV_XWStoDS(physDev, deltas[idx]);
 		    xoff = offset * cosEsc;
 		    yoff = offset * -sinEsc;
 
 		} else {
-		    xoff += entry->gis[glyphs[idx]].xOff;
-		    yoff += entry->gis[glyphs[idx]].yOff;
+		    xoff += formatEntry->gis[glyphs[idx]].xOff;
+		    yoff += formatEntry->gis[glyphs[idx]].yOff;
 		}
 		    
 	    }
@@ -1369,21 +1403,21 @@
 	    TRACE("drawable %dx%d\n", w, h);
 
 	    for(idx = 0; idx < count; idx++) {
-	        if(extents.left > cur.x - entry->gis[glyphs[idx]].x)
-		    extents.left = cur.x - entry->gis[glyphs[idx]].x;
-		if(extents.top > cur.y - entry->gis[glyphs[idx]].y)
-		    extents.top = cur.y - entry->gis[glyphs[idx]].y;
-		if(extents.right < cur.x - entry->gis[glyphs[idx]].x + entry->gis[glyphs[idx]].width)
-		    extents.right = cur.x - entry->gis[glyphs[idx]].x + entry->gis[glyphs[idx]].width;
-		if(extents.bottom < cur.y - entry->gis[glyphs[idx]].y + entry->gis[glyphs[idx]].height)
-		    extents.bottom = cur.y - entry->gis[glyphs[idx]].y + entry->gis[glyphs[idx]].height;
+	        if(extents.left > cur.x - formatEntry->gis[glyphs[idx]].x)
+		    extents.left = cur.x - formatEntry->gis[glyphs[idx]].x;
+		if(extents.top > cur.y - formatEntry->gis[glyphs[idx]].y)
+		    extents.top = cur.y - formatEntry->gis[glyphs[idx]].y;
+		if(extents.right < cur.x - formatEntry->gis[glyphs[idx]].x + formatEntry->gis[glyphs[idx]].width)
+		    extents.right = cur.x - formatEntry->gis[glyphs[idx]].x + formatEntry->gis[glyphs[idx]].width;
+		if(extents.bottom < cur.y - formatEntry->gis[glyphs[idx]].y + formatEntry->gis[glyphs[idx]].height)
+		    extents.bottom = cur.y - formatEntry->gis[glyphs[idx]].y + formatEntry->gis[glyphs[idx]].height;
 		if(deltas) {
 		    offset += X11DRV_XWStoDS(physDev, deltas[idx]);
 		    cur.x = offset * cosEsc;
 		    cur.y = offset * -sinEsc;
 		} else {
-		    cur.x += entry->gis[glyphs[idx]].xOff;
-		    cur.y += entry->gis[glyphs[idx]].yOff;
+		    cur.x += formatEntry->gis[glyphs[idx]].xOff;
+		    cur.y += formatEntry->gis[glyphs[idx]].yOff;
 		}
 	    }
 	    TRACE("glyph extents %ld,%ld - %ld,%ld drawable x,y %ld,%ld\n", extents.left, extents.top,
@@ -1451,16 +1485,16 @@
 	    for(idx = 0; idx < count; idx++) {
 	        SmoothGlyphGray(image, xoff + image_off_x - extents.left,
 				yoff + image_off_y - extents.top,
-				entry->bitmaps[glyphs[idx]],
-				&entry->gis[glyphs[idx]],
+				formatEntry->bitmaps[glyphs[idx]],
+				&formatEntry->gis[glyphs[idx]],
 				physDev->textPixel);
 		if(deltas) {
 		    offset += X11DRV_XWStoDS(physDev, deltas[idx]);
 		    xoff = offset * cosEsc;
 		    yoff = offset * -sinEsc;
 		} else {
-		    xoff += entry->gis[glyphs[idx]].xOff;
-		    yoff += entry->gis[glyphs[idx]].yOff;
+		    xoff += formatEntry->gis[glyphs[idx]].xOff;
+		    yoff += formatEntry->gis[glyphs[idx]].yOff;
 		}
 		    
 	    }
@@ -1669,7 +1703,7 @@
 #endif
     pXRenderComposite(gdi_display, PictOpOver, src_pict, 0, dst_pict,
                       xSrc, ySrc, 0, 0,
-                      xDst + devDst->org.x, yDst + devDst->org.y, widthDst, heightDst);
+                      xDst + devDst->org.x, yDst + devDst->org.y, widthSrc, heightSrc);
 
 
     pXRenderFreePicture(gdi_display, src_pict);



More information about the wine-patches mailing list