gdi32: Add a helper function to determine anti-aliasing flags.

oldstable
Alexandre Julliard 2011-11-17 12:01:58 +01:00
parent 5282ffadad
commit 1b63d5a610
3 changed files with 27 additions and 17 deletions

View File

@ -157,19 +157,6 @@ static void draw_glyph( dibdrv_physdev *pdev, const POINT *origin, const GLYPHME
release_wine_region( pdev->clip ); release_wine_region( pdev->clip );
} }
static inline UINT get_aa_flags( dibdrv_physdev *pdev )
{
LOGFONTW lf;
if (pdev->dib.bit_count <= 8) return GGO_BITMAP;
GetObjectW( GetCurrentObject( pdev->dev.hdc, OBJ_FONT ), sizeof(lf), &lf );
if (lf.lfQuality == NONANTIALIASED_QUALITY) return GGO_BITMAP;
/* FIXME, check gasp and user prefs */
return GGO_GRAY4_BITMAP;
}
static const BYTE masks[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; static const BYTE masks[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
static const int padding[4] = {0, 3, 2, 1}; static const int padding[4] = {0, 3, 2, 1};
@ -181,10 +168,10 @@ static const int padding[4] = {0, 3, 2, 1};
* For non-antialiased bitmaps convert them to the 17-level format * For non-antialiased bitmaps convert them to the 17-level format
* using only values 0 or 16. * using only values 0 or 16.
*/ */
static DWORD get_glyph_bitmap( dibdrv_physdev *pdev, UINT index, GLYPHMETRICS *metrics, static DWORD get_glyph_bitmap( dibdrv_physdev *pdev, UINT index, UINT aa_flags, GLYPHMETRICS *metrics,
struct gdi_image_bits *image ) struct gdi_image_bits *image )
{ {
UINT aa_flags = get_aa_flags( pdev ), ggo_flags = aa_flags | GGO_GLYPH_INDEX; UINT ggo_flags = aa_flags | GGO_GLYPH_INDEX;
static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} }; static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} };
UINT indices[3] = {0, 0, 0x20}; UINT indices[3] = {0, 0, 0x20};
int i, x, y; int i, x, y;
@ -253,7 +240,7 @@ BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
const RECT *rect, LPCWSTR str, UINT count, const INT *dx ) const RECT *rect, LPCWSTR str, UINT count, const INT *dx )
{ {
dibdrv_physdev *pdev = get_dibdrv_pdev(dev); dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
UINT i; UINT aa_flags, i;
POINT origin; POINT origin;
DWORD err; DWORD err;
HRGN saved_clip = NULL; HRGN saved_clip = NULL;
@ -274,6 +261,7 @@ BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
DeleteObject( clip ); DeleteObject( clip );
} }
aa_flags = get_font_aa_flags( dev->hdc );
origin.x = x; origin.x = x;
origin.y = y; origin.y = y;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -281,7 +269,7 @@ BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
GLYPHMETRICS metrics; GLYPHMETRICS metrics;
struct gdi_image_bits image; struct gdi_image_bits image;
err = get_glyph_bitmap( pdev, (UINT)str[i], &metrics, &image ); err = get_glyph_bitmap( pdev, (UINT)str[i], aa_flags, &metrics, &image );
if (err) continue; if (err) continue;
if (image.ptr) draw_glyph( pdev, &origin, &metrics, &image ); if (image.ptr) draw_glyph( pdev, &origin, &metrics, &image );

View File

@ -258,6 +258,25 @@ static void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, NEWTEXTMETRIC
} }
UINT get_font_aa_flags( HDC hdc )
{
LOGFONTW lf;
if (GetObjectType( hdc ) == OBJ_MEMDC)
{
BITMAP bm;
GetObjectW( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bm), &bm );
if (bm.bmBitsPixel <= 8) return GGO_BITMAP;
}
else if (GetDeviceCaps( hdc, BITSPIXEL ) <= 8) return GGO_BITMAP;
GetObjectW( GetCurrentObject( hdc, OBJ_FONT ), sizeof(lf), &lf );
if (lf.lfQuality == NONANTIALIASED_QUALITY) return GGO_BITMAP;
/* FIXME, check gasp and user prefs */
return GGO_GRAY4_BITMAP;
}
/*********************************************************************** /***********************************************************************
* GdiGetCodePage (GDI32.@) * GdiGetCodePage (GDI32.@)
*/ */

View File

@ -278,6 +278,9 @@ extern BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size ) DE
/* enhmetafile.c */ /* enhmetafile.c */
extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk ) DECLSPEC_HIDDEN; extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk ) DECLSPEC_HIDDEN;
/* font.c */
extern UINT get_font_aa_flags( HDC hdc ) DECLSPEC_HIDDEN;
/* freetype.c */ /* freetype.c */
/* Undocumented structure filled in by GdiRealizationInfo */ /* Undocumented structure filled in by GdiRealizationInfo */