From: Byeongsik Jeon Subject: [PATCH 5/5] gdi32: Remove needTransform variable of freetype_get_glyph_outline() Message-Id: <20210204075206.326528-5-bsjeon@hanmail.net> Date: Thu, 4 Feb 2021 16:52:06 +0900 In-Reply-To: <20210204075206.326528-1-bsjeon@hanmail.net> References: <20210204075206.326528-1-bsjeon@hanmail.net> Signed-off-by: Byeongsik Jeon --- dlls/gdi32/freetype.c | 52 ++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 620fc62a96a..2535faad03a 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -2644,8 +2644,8 @@ enum matrices_index matrix_unrotated }; -static BOOL get_transform_matrices( struct gdi_font *font, BOOL vertical, const MAT2 *user_transform, - FT_Matrix matrices[3] ) +static FT_Matrix *get_transform_matrices( struct gdi_font *font, BOOL vertical, const MAT2 *user_transform, + FT_Matrix matrices[3] ) { static const FT_Matrix identity_mat = { (1 << 16), 0, 0, (1 << 16) }; BOOL needs_transform = FALSE; @@ -2744,7 +2744,7 @@ static BOOL get_transform_matrices( struct gdi_font *font, BOOL vertical, const 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) @@ -2841,12 +2841,11 @@ static FT_Vector get_advance_metric( struct gdi_font *font, FT_Pos base_advance, return adv; } -static FT_BBox get_transformed_bbox( const FT_Glyph_Metrics *metrics, - BOOL needs_transform, const FT_Matrix metrices[3] ) +static FT_BBox get_transformed_bbox( const FT_Glyph_Metrics *metrics, const FT_Matrix *matrices ) { FT_BBox bbox = { 0, 0, 0, 0 }; - if (!needs_transform) + if (!matrices) { bbox.xMin = (metrics->horiBearingX) & -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.y = metrics->horiBearingY - yc * metrics->height; 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) { 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, - BOOL vertical, BOOL vertical_metrics, - BOOL needs_transform, const FT_Matrix matrices[3], + BOOL vertical, BOOL vertical_metrics, const FT_Matrix *matrices, GLYPHMETRICS *gm, ABC *abc ) { FT_Vector adv, vec, origin; FT_Fixed base_advance = vertical_metrics ? metrics->vertAdvance : metrics->horiAdvance; - if (!needs_transform) + if (!matrices) { adv = get_advance_metric( font, base_advance, NULL ); 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 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 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.buffer = buf; - if (needs_transform) + if (matrices) pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] ); 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, - BOOL fake_bold, BOOL needs_transform, FT_Matrix matrices[3], + BOOL fake_bold, const FT_Matrix *matrices, DWORD buflen, BYTE *buf ) { 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.buffer = buf; - if (needs_transform) + if (matrices) pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] ); 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, - BOOL fake_bold, BOOL needs_transform, FT_Matrix matrices[3], + BOOL fake_bold, const FT_Matrix *matrices, GLYPHMETRICS *gm, DWORD buflen, BYTE *buf ) { 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 (needed > buflen) return GDI_ERROR; - if (needs_transform) + if (matrices) pFT_Outline_Transform( &glyph->outline, &matrices[matrix_vert] ); 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_BBox bbox; FT_Int load_flags = get_load_flags(format); - FT_Matrix matrices[3]; - BOOL needsTransform = FALSE; + FT_Matrix transform_matrices[3], *matrices = NULL; BOOL vertical_metrics; 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; - 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)); /* 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)) 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; 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 ); */ } - bbox = get_transformed_bbox( &metrics, needsTransform, matrices ); - compute_metrics( font, bbox, &metrics, tategaki, vertical_metrics, needsTransform, matrices, - lpgm, abc ); + bbox = get_transformed_bbox( &metrics, matrices ); + compute_metrics( font, bbox, &metrics, tategaki, vertical_metrics, matrices, lpgm, abc ); switch (format) { @@ -3569,21 +3565,21 @@ static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *font, UINT glyph case GGO_BITMAP: 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_GRAY4_BITMAP: case GGO_GRAY8_BITMAP: case WINE_GGO_GRAY16_BITMAP: 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_HBGR_BITMAP: case WINE_GGO_VRGB_BITMAP: case WINE_GGO_VBGR_BITMAP: 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: 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 (needsTransform && buf) + if (matrices && buf) pFT_Outline_Transform( outline, &matrices[matrix_vert] ); 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 (needsTransform && buf) + if (matrices && buf) pFT_Outline_Transform( outline, &matrices[matrix_vert] ); needed = get_bezier_glyph_outline(outline, buflen, NULL); -- 2.30.0