Module: wine Branch: master Commit: f3fab963938dad74cda7c469d5b44305c93ec82b URL: http://source.winehq.org/git/wine.git/?a=commit;h=f3fab963938dad74cda7c469d5...
Author: Huw Davies huw@codeweavers.com Date: Wed Nov 16 11:20:50 2011 +0000
gdi32: Add a helper to return the maximum level to use for a given anti-aliasing format.
---
dlls/gdi32/freetype.c | 44 +++++++++++++++++++++++++------------------- 1 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 06350be..9ec7785 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -5038,6 +5038,17 @@ static inline BOOL is_identity_MAT2(const MAT2 *matrix) return !memcmp(matrix, &identity, sizeof(MAT2)); }
+static inline BYTE get_max_level( UINT format ) +{ + switch( format ) + { + case GGO_GRAY2_BITMAP: return 4; + case GGO_GRAY4_BITMAP: return 16; + case GGO_GRAY8_BITMAP: return 64; + } + return 255; +} + static DWORD get_glyph_outline(GdiFont *incoming_font, UINT glyph, UINT format, LPGLYPHMETRICS lpgm, DWORD buflen, LPVOID buf, const MAT2* lpmat) @@ -5337,7 +5348,7 @@ static DWORD get_glyph_outline(GdiFont *incoming_font, UINT glyph, UINT format, case GGO_GRAY8_BITMAP: case WINE_GGO_GRAY16_BITMAP: { - unsigned int mult, row, col; + unsigned int max_level, row, col; BYTE *start, *ptr;
width = lpgm->gmBlackBoxX; @@ -5347,6 +5358,8 @@ static DWORD get_glyph_outline(GdiFont *incoming_font, UINT glyph, UINT format,
if(!buf || !buflen) break;
+ max_level = get_max_level( format ); + switch(ft_face->glyph->format) { case ft_glyph_format_bitmap: { @@ -5379,29 +5392,22 @@ static DWORD get_glyph_outline(GdiFont *incoming_font, UINT glyph, UINT format,
pFT_Outline_Get_Bitmap(library, &ft_face->glyph->outline, &ft_bitmap);
- if(format == GGO_GRAY2_BITMAP) - mult = 4; - else if(format == GGO_GRAY4_BITMAP) - mult = 16; - else if(format == GGO_GRAY8_BITMAP) - mult = 64; - else /* format == WINE_GGO_GRAY16_BITMAP */ - return needed; - break; + if (max_level != 255) + { + for (row = 0, start = buf; row < height; row++) + { + for (col = 0, ptr = start; col < width; col++, ptr++) + *ptr = (((int)*ptr) * max_level + 128) / 256; + start += pitch; + } + } + return needed; } + default: FIXME("loaded glyph format %x\n", ft_face->glyph->format); return GDI_ERROR; } - - start = buf; - for(row = 0; row < height; row++) { - ptr = start; - for(col = 0; col < width; col++, ptr++) { - *ptr = (((int)*ptr) * mult + 128) / 256; - } - start += pitch; - } break; }