gdi32: Remove needTransform variable of freetype_get_glyph_outline().

Signed-off-by: Byeongsik Jeon <bsjeon@hanmail.net>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Byeongsik Jeon 2021-03-08 14:40:49 +00:00 committed by Alexandre Julliard
parent bb86ae80c8
commit 56b16ff466
1 changed files with 24 additions and 28 deletions

View File

@ -2644,7 +2644,7 @@ enum matrices_index
matrix_unrotated matrix_unrotated
}; };
static BOOL get_transform_matrices( struct gdi_font *font, BOOL vertical, const MAT2 *user_transform, static FT_Matrix *get_transform_matrices( struct gdi_font *font, BOOL vertical, const MAT2 *user_transform,
FT_Matrix matrices[3] ) FT_Matrix matrices[3] )
{ {
static const FT_Matrix identity_mat = { (1 << 16), 0, 0, (1 << 16) }; static const FT_Matrix identity_mat = { (1 << 16), 0, 0, (1 << 16) };
@ -2744,7 +2744,7 @@ static BOOL get_transform_matrices( struct gdi_font *font, BOOL vertical, const
needs_transform = TRUE; needs_transform = TRUE;
} }
return needs_transform; return needs_transform ? matrices : NULL;
} }
static BOOL get_bold_glyph_outline(FT_GlyphSlot glyph, LONG ppem, FT_Glyph_Metrics *metrics) static BOOL get_bold_glyph_outline(FT_GlyphSlot glyph, LONG ppem, FT_Glyph_Metrics *metrics)
@ -2841,12 +2841,11 @@ static FT_Vector get_advance_metric( struct gdi_font *font, FT_Pos base_advance,
return adv; return adv;
} }
static FT_BBox get_transformed_bbox( const FT_Glyph_Metrics *metrics, static FT_BBox get_transformed_bbox( const FT_Glyph_Metrics *metrics, const FT_Matrix *matrices )
BOOL needs_transform, const FT_Matrix metrices[3] )
{ {
FT_BBox bbox = { 0, 0, 0, 0 }; FT_BBox bbox = { 0, 0, 0, 0 };
if (!needs_transform) if (!matrices)
{ {
bbox.xMin = (metrics->horiBearingX) & -64; bbox.xMin = (metrics->horiBearingX) & -64;
bbox.xMax = (metrics->horiBearingX + metrics->width + 63) & -64; bbox.xMax = (metrics->horiBearingX + metrics->width + 63) & -64;
@ -2865,7 +2864,7 @@ static FT_BBox get_transformed_bbox( const FT_Glyph_Metrics *metrics,
vec.x = metrics->horiBearingX + xc * metrics->width; vec.x = metrics->horiBearingX + xc * metrics->width;
vec.y = metrics->horiBearingY - yc * metrics->height; vec.y = metrics->horiBearingY - yc * metrics->height;
TRACE( "Vec %ld, %ld\n", vec.x, vec.y ); TRACE( "Vec %ld, %ld\n", vec.x, vec.y );
pFT_Vector_Transform( &vec, &metrices[matrix_vert] ); pFT_Vector_Transform( &vec, &matrices[matrix_vert] );
if (xc == 0 && yc == 0) if (xc == 0 && yc == 0)
{ {
bbox.xMin = bbox.xMax = vec.x; bbox.xMin = bbox.xMax = vec.x;
@ -2891,14 +2890,13 @@ static FT_BBox get_transformed_bbox( const FT_Glyph_Metrics *metrics,
} }
static void compute_metrics( struct gdi_font *font, FT_BBox bbox, const FT_Glyph_Metrics *metrics, static void compute_metrics( struct gdi_font *font, FT_BBox bbox, const FT_Glyph_Metrics *metrics,
BOOL vertical, BOOL vertical_metrics, BOOL vertical, BOOL vertical_metrics, const FT_Matrix *matrices,
BOOL needs_transform, const FT_Matrix matrices[3],
GLYPHMETRICS *gm, ABC *abc ) GLYPHMETRICS *gm, ABC *abc )
{ {
FT_Vector adv, vec, origin; FT_Vector adv, vec, origin;
FT_Fixed base_advance = vertical_metrics ? metrics->vertAdvance : metrics->horiAdvance; FT_Fixed base_advance = vertical_metrics ? metrics->vertAdvance : metrics->horiAdvance;
if (!needs_transform) if (!matrices)
{ {
adv = get_advance_metric( font, base_advance, NULL ); adv = get_advance_metric( font, base_advance, NULL );
gm->gmCellIncX = adv.x >> 6; gm->gmCellIncX = adv.x >> 6;
@ -2972,7 +2970,7 @@ static void compute_metrics( struct gdi_font *font, FT_BBox bbox, const FT_Glyph
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 DWORD get_mono_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, static DWORD get_mono_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox,
BOOL fake_bold, BOOL needs_transform, FT_Matrix matrices[3], BOOL fake_bold, const FT_Matrix *matrices,
DWORD buflen, BYTE *buf ) DWORD buflen, BYTE *buf )
{ {
DWORD width = (bbox.xMax - bbox.xMin ) >> 6; DWORD width = (bbox.xMax - bbox.xMin ) >> 6;
@ -3020,7 +3018,7 @@ static DWORD get_mono_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox,
ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO; ft_bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
ft_bitmap.buffer = buf; ft_bitmap.buffer = buf;
if (needs_transform) if (matrices)
pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] ); pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] );
pFT_Outline_Translate( &glyph->outline, -bbox.xMin, -bbox.yMin ); pFT_Outline_Translate( &glyph->outline, -bbox.xMin, -bbox.yMin );
@ -3038,7 +3036,7 @@ static DWORD get_mono_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox,
} }
static DWORD get_antialias_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT format, static DWORD get_antialias_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT format,
BOOL fake_bold, BOOL needs_transform, FT_Matrix matrices[3], BOOL fake_bold, const FT_Matrix *matrices,
DWORD buflen, BYTE *buf ) DWORD buflen, BYTE *buf )
{ {
DWORD width = (bbox.xMax - bbox.xMin ) >> 6; DWORD width = (bbox.xMax - bbox.xMin ) >> 6;
@ -3086,7 +3084,7 @@ static DWORD get_antialias_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT
ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY; ft_bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
ft_bitmap.buffer = buf; ft_bitmap.buffer = buf;
if (needs_transform) if (matrices)
pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] ); pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] );
pFT_Outline_Translate( &glyph->outline, -bbox.xMin, -bbox.yMin ); pFT_Outline_Translate( &glyph->outline, -bbox.xMin, -bbox.yMin );
@ -3116,7 +3114,7 @@ static DWORD get_antialias_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT
} }
static DWORD get_subpixel_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT format, static DWORD get_subpixel_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT format,
BOOL fake_bold, BOOL needs_transform, FT_Matrix matrices[3], BOOL fake_bold, const FT_Matrix *matrices,
GLYPHMETRICS *gm, DWORD buflen, BYTE *buf ) GLYPHMETRICS *gm, DWORD buflen, BYTE *buf )
{ {
DWORD width = (bbox.xMax - bbox.xMin ) >> 6; DWORD width = (bbox.xMax - bbox.xMin ) >> 6;
@ -3194,7 +3192,7 @@ static DWORD get_subpixel_glyph_bitmap( FT_GlyphSlot glyph, FT_BBox bbox, UINT f
if (!buf || !buflen) return needed; if (!buf || !buflen) return needed;
if (needed > buflen) return GDI_ERROR; if (needed > buflen) return GDI_ERROR;
if (needs_transform) if (matrices)
pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] ); pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] );
pFT_Render_Glyph( glyph, render_mode ); pFT_Render_Glyph( glyph, render_mode );
@ -3501,8 +3499,7 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
FT_Error err; FT_Error err;
FT_BBox bbox; FT_BBox bbox;
FT_Int load_flags = get_load_flags(format); FT_Int load_flags = get_load_flags(format);
FT_Matrix matrices[3]; FT_Matrix transform_matrices[3], *matrices = NULL;
BOOL needsTransform = FALSE;
BOOL vertical_metrics; BOOL vertical_metrics;
TRACE("%p, %04x, %08x, %p, %08x, %p, %p\n", font, glyph, format, lpgm, buflen, buf, lpmat); TRACE("%p, %04x, %08x, %p, %08x, %p, %p\n", font, glyph, format, lpgm, buflen, buf, lpmat);
@ -3513,7 +3510,7 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
format &= ~GGO_UNHINTED; format &= ~GGO_UNHINTED;
needsTransform = get_transform_matrices( font, tategaki, lpmat, matrices ); matrices = get_transform_matrices( font, tategaki, lpmat, transform_matrices );
vertical_metrics = (tategaki && FT_HAS_VERTICAL(ft_face)); vertical_metrics = (tategaki && FT_HAS_VERTICAL(ft_face));
/* there is a freetype bug where vertical metrics are only /* there is a freetype bug where vertical metrics are only
@ -3521,7 +3518,7 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
if (vertical_metrics && FT_SimpleVersion < FT_VERSION_VALUE(2, 4, 0)) if (vertical_metrics && FT_SimpleVersion < FT_VERSION_VALUE(2, 4, 0))
vertical_metrics = FALSE; vertical_metrics = FALSE;
if (needsTransform || format != GGO_BITMAP) load_flags |= FT_LOAD_NO_BITMAP; if (matrices || format != GGO_BITMAP) load_flags |= FT_LOAD_NO_BITMAP;
if (vertical_metrics) load_flags |= FT_LOAD_VERTICAL_LAYOUT; if (vertical_metrics) load_flags |= FT_LOAD_VERTICAL_LAYOUT;
err = pFT_Load_Glyph(ft_face, glyph, load_flags); err = pFT_Load_Glyph(ft_face, glyph, load_flags);
@ -3558,9 +3555,8 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
/* metrics.width = min( metrics.width, ptm->tmMaxCharWidth << 6 ); */ /* metrics.width = min( metrics.width, ptm->tmMaxCharWidth << 6 ); */
} }
bbox = get_transformed_bbox( &metrics, needsTransform, matrices ); bbox = get_transformed_bbox( &metrics, matrices );
compute_metrics( font, bbox, &metrics, tategaki, vertical_metrics, needsTransform, matrices, compute_metrics( font, bbox, &metrics, tategaki, vertical_metrics, matrices, lpgm, abc );
lpgm, abc );
switch (format) switch (format)
{ {
@ -3569,21 +3565,21 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
case GGO_BITMAP: case GGO_BITMAP:
return get_mono_glyph_bitmap( ft_face->glyph, bbox, font->fake_bold, return get_mono_glyph_bitmap( ft_face->glyph, bbox, font->fake_bold,
needsTransform, matrices, buflen, buf ); matrices, buflen, buf );
case GGO_GRAY2_BITMAP: case GGO_GRAY2_BITMAP:
case GGO_GRAY4_BITMAP: case GGO_GRAY4_BITMAP:
case GGO_GRAY8_BITMAP: case GGO_GRAY8_BITMAP:
case WINE_GGO_GRAY16_BITMAP: case WINE_GGO_GRAY16_BITMAP:
return get_antialias_glyph_bitmap( ft_face->glyph, bbox, format, font->fake_bold, return get_antialias_glyph_bitmap( ft_face->glyph, bbox, format, font->fake_bold,
needsTransform, matrices, buflen, buf ); matrices, buflen, buf );
case WINE_GGO_HRGB_BITMAP: case WINE_GGO_HRGB_BITMAP:
case WINE_GGO_HBGR_BITMAP: case WINE_GGO_HBGR_BITMAP:
case WINE_GGO_VRGB_BITMAP: case WINE_GGO_VRGB_BITMAP:
case WINE_GGO_VBGR_BITMAP: case WINE_GGO_VBGR_BITMAP:
return get_subpixel_glyph_bitmap( ft_face->glyph, bbox, format, font->fake_bold, return get_subpixel_glyph_bitmap( ft_face->glyph, bbox, format, font->fake_bold,
needsTransform, matrices, lpgm, buflen, buf ); matrices, lpgm, buflen, buf );
case GGO_NATIVE: case GGO_NATIVE:
if (ft_face->glyph->format == ft_glyph_format_outline) if (ft_face->glyph->format == ft_glyph_format_outline)
@ -3593,7 +3589,7 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
if (buflen == 0) buf = NULL; if (buflen == 0) buf = NULL;
if (needsTransform && buf) if (matrices && buf)
pFT_Outline_Transform( outline, &matrices[matrix_vert] ); pFT_Outline_Transform( outline, &matrices[matrix_vert] );
needed = get_native_glyph_outline(outline, buflen, NULL); needed = get_native_glyph_outline(outline, buflen, NULL);
@ -3613,7 +3609,7 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph
if (buflen == 0) buf = NULL; if (buflen == 0) buf = NULL;
if (needsTransform && buf) if (matrices && buf)
pFT_Outline_Transform( outline, &matrices[matrix_vert] ); pFT_Outline_Transform( outline, &matrices[matrix_vert] );
needed = get_bezier_glyph_outline(outline, buflen, NULL); needed = get_bezier_glyph_outline(outline, buflen, NULL);