[PATCH] dwrite: Avoid repeated method calls during run rendering

Nikolay Sivov nsivov at codeweavers.com
Tue Jul 11 08:57:40 CDT 2017


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---

Currently it's making 6 calls per glyph when 2 per run is enough.

 dlls/dwrite/dwrite_private.h |  1 +
 dlls/dwrite/font.c           |  2 ++
 dlls/dwrite/freetype.c       | 11 ++++-------
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 7694b796c2..9530399974 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -260,6 +260,7 @@ extern WCHAR bidi_get_mirrored_char(WCHAR) DECLSPEC_HIDDEN;
 /* FreeType integration */
 struct dwrite_glyphbitmap {
     IDWriteFontFace4 *fontface;
+    DWORD simulations;
     FLOAT emsize;
     BOOL nohint;
     UINT16 index;
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index 0332587eb6..114833a077 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -4862,6 +4862,7 @@ static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *a
 
     memset(&glyph_bitmap, 0, sizeof(glyph_bitmap));
     glyph_bitmap.fontface = fontface;
+    glyph_bitmap.simulations = IDWriteFontFace4_GetSimulations(fontface);
     glyph_bitmap.emsize = analysis->run.fontEmSize;
     glyph_bitmap.nohint = is_natural_rendering_mode(analysis->rendering_mode);
     if (analysis->flags & RUNANALYSIS_USE_TRANSFORM)
@@ -4954,6 +4955,7 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis)
 
     memset(&glyph_bitmap, 0, sizeof(glyph_bitmap));
     glyph_bitmap.fontface = fontface;
+    glyph_bitmap.simulations = IDWriteFontFace4_GetSimulations(fontface);
     glyph_bitmap.emsize = analysis->run.fontEmSize;
     glyph_bitmap.nohint = is_natural_rendering_mode(analysis->rendering_mode);
     glyph_bitmap.type = analysis->texture_type;
diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c
index 2ad513e537..934ca80a51 100644
--- a/dlls/dwrite/freetype.c
+++ b/dlls/dwrite/freetype.c
@@ -636,7 +636,6 @@ static BOOL is_face_scalable(IDWriteFontFace4 *fontface)
 
 static BOOL get_glyph_transform(struct dwrite_glyphbitmap *bitmap, FT_Matrix *ret)
 {
-    USHORT simulations = IDWriteFontFace4_GetSimulations(bitmap->fontface);
     FT_Matrix m;
 
     ret->xx = 1 << 16;
@@ -646,10 +645,10 @@ static BOOL get_glyph_transform(struct dwrite_glyphbitmap *bitmap, FT_Matrix *re
 
     /* Some fonts provide mostly bitmaps and very few outlines, for example for .notdef.
        Disable transform if that's the case. */
-    if (!is_face_scalable(bitmap->fontface) || (!bitmap->m && simulations == 0))
+    if (!is_face_scalable(bitmap->fontface) || (!bitmap->m && bitmap->simulations == 0))
         return FALSE;
 
-    if (simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE) {
+    if (bitmap->simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE) {
         m.xx =  1 << 16;
         m.xy = (1 << 16) / 3;
         m.yx =  0;
@@ -667,7 +666,6 @@ static BOOL get_glyph_transform(struct dwrite_glyphbitmap *bitmap, FT_Matrix *re
 
 void freetype_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap)
 {
-    USHORT simulations = IDWriteFontFace4_GetSimulations(bitmap->fontface);
     FTC_ImageTypeRec imagetype;
     FT_BBox bbox = { 0 };
     BOOL needs_transform;
@@ -688,7 +686,7 @@ void freetype_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap)
             FT_Glyph glyph_copy;
 
             if (pFT_Glyph_Copy(glyph, &glyph_copy) == 0) {
-                if (simulations & DWRITE_FONT_SIMULATIONS_BOLD)
+                if (bitmap->simulations & DWRITE_FONT_SIMULATIONS_BOLD)
                     embolden_glyph(glyph_copy, bitmap->emsize);
 
                 /* Includes oblique and user transform. */
@@ -826,7 +824,6 @@ static BOOL freetype_get_aa_glyph_bitmap(struct dwrite_glyphbitmap *bitmap, FT_G
 
 BOOL freetype_get_glyph_bitmap(struct dwrite_glyphbitmap *bitmap)
 {
-    USHORT simulations = IDWriteFontFace4_GetSimulations(bitmap->fontface);
     FTC_ImageTypeRec imagetype;
     BOOL needs_transform;
     BOOL ret = FALSE;
@@ -847,7 +844,7 @@ BOOL freetype_get_glyph_bitmap(struct dwrite_glyphbitmap *bitmap)
 
         if (needs_transform) {
             if (pFT_Glyph_Copy(glyph, &glyph_copy) == 0) {
-                if (simulations & DWRITE_FONT_SIMULATIONS_BOLD)
+                if (bitmap->simulations & DWRITE_FONT_SIMULATIONS_BOLD)
                     embolden_glyph(glyph_copy, bitmap->emsize);
 
                 /* Includes oblique and user transform. */
-- 
2.13.2




More information about the wine-patches mailing list