Nikolay Sivov : dwrite: Use separate argument for cache key for get_bbox/get_bitmap calls.

Alexandre Julliard julliard at winehq.org
Tue Dec 7 15:58:44 CST 2021


Module: wine
Branch: master
Commit: 4ae2058e0b557aa9462441220eac8897170230b2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4ae2058e0b557aa9462441220eac8897170230b2

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue Dec  7 15:59:44 2021 +0300

dwrite: Use separate argument for cache key for get_bbox/get_bitmap calls.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dwrite/dwrite_private.h |  7 +++----
 dlls/dwrite/font.c           | 12 +++++-------
 dlls/dwrite/freetype.c       | 20 ++++++++++----------
 dlls/dwrite/layout.c         |  3 +--
 4 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index e0373dc2891..ba634c99917 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -444,7 +444,6 @@ extern HRESULT bidi_computelevels(const WCHAR*,UINT32,UINT8,UINT8*,UINT8*) DECLS
 
 struct dwrite_glyphbitmap
 {
-    void *key;
     DWORD simulations;
     float emsize;
     BOOL nohint;
@@ -735,8 +734,8 @@ struct font_backend_funcs
     UINT16 (CDECL *get_glyph_count)(font_object_handle object);
     INT32 (CDECL *get_glyph_advance)(font_object_handle object, float em_size, UINT16 glyph,
             DWRITE_MEASURING_MODE measuring_mode, BOOL *has_contours);
-    void (CDECL *get_glyph_bbox)(struct dwrite_glyphbitmap *bitmap_desc);
-    BOOL (CDECL *get_glyph_bitmap)(struct dwrite_glyphbitmap *bitmap_desc);
+    void (CDECL *get_glyph_bbox)(void *key, struct dwrite_glyphbitmap *bitmap_desc);
+    BOOL (CDECL *get_glyph_bitmap)(void *key, struct dwrite_glyphbitmap *bitmap_desc);
     void (CDECL *get_design_glyph_metrics)(font_object_handle object, UINT16 upem, UINT16 ascent, unsigned int simulations,
             UINT16 glyph, DWRITE_GLYPH_METRICS *metrics);
 };
@@ -744,4 +743,4 @@ struct font_backend_funcs
 extern void init_font_backend(void) DECLSPEC_HIDDEN;
 extern void release_font_backend(void) DECLSPEC_HIDDEN;
 
-extern void dwrite_fontface_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap) DECLSPEC_HIDDEN;
+extern void dwrite_fontface_get_glyph_bbox(IDWriteFontFace *fontface, struct dwrite_glyphbitmap *bitmap) DECLSPEC_HIDDEN;
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index 76abedde770..205b2f8c0f1 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -47,9 +47,9 @@ static const FLOAT RECOMMENDED_NATURAL_PPEM = 20.0f;
 
 static const struct font_backend_funcs *font_funcs;
 
-void dwrite_fontface_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap)
+void dwrite_fontface_get_glyph_bbox(IDWriteFontFace *fontface, struct dwrite_glyphbitmap *bitmap)
 {
-    font_funcs->get_glyph_bbox(bitmap);
+    font_funcs->get_glyph_bbox(fontface, bitmap);
 }
 
 struct cache_key
@@ -5836,7 +5836,6 @@ static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *a
         WARN("failed to get IDWriteFontFace4, 0x%08x\n", hr);
 
     memset(&glyph_bitmap, 0, sizeof(glyph_bitmap));
-    glyph_bitmap.key = fontface;
     glyph_bitmap.simulations = IDWriteFontFace4_GetSimulations(fontface);
     glyph_bitmap.emsize = analysis->run.fontEmSize;
     glyph_bitmap.nohint = is_natural_rendering_mode(analysis->rendering_mode);
@@ -5848,7 +5847,7 @@ static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *a
         UINT32 bitmap_size;
 
         glyph_bitmap.glyph = analysis->run.glyphIndices[i];
-        font_funcs->get_glyph_bbox(&glyph_bitmap);
+        font_funcs->get_glyph_bbox(fontface, &glyph_bitmap);
 
         bitmap_size = get_glyph_bitmap_pitch(analysis->rendering_mode, bbox->right - bbox->left) *
             (bbox->bottom - bbox->top);
@@ -5927,7 +5926,6 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis)
     origin.x = origin.y = 0.0f;
 
     memset(&glyph_bitmap, 0, sizeof(glyph_bitmap));
-    glyph_bitmap.key = fontface;
     glyph_bitmap.simulations = IDWriteFontFace4_GetSimulations(fontface);
     glyph_bitmap.emsize = analysis->run.fontEmSize;
     glyph_bitmap.nohint = is_natural_rendering_mode(analysis->rendering_mode);
@@ -5948,7 +5946,7 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis)
         BOOL is_1bpp;
 
         glyph_bitmap.glyph = analysis->run.glyphIndices[i];
-        font_funcs->get_glyph_bbox(&glyph_bitmap);
+        font_funcs->get_glyph_bbox(fontface, &glyph_bitmap);
 
         if (IsRectEmpty(bbox))
             continue;
@@ -5958,7 +5956,7 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis)
 
         glyph_bitmap.pitch = get_glyph_bitmap_pitch(analysis->rendering_mode, width);
         memset(src, 0, height * glyph_bitmap.pitch);
-        is_1bpp = font_funcs->get_glyph_bitmap(&glyph_bitmap);
+        is_1bpp = font_funcs->get_glyph_bitmap(fontface, &glyph_bitmap);
 
         OffsetRect(bbox, analysis->origins[i].x, analysis->origins[i].y);
 
diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c
index a2304f264d5..dede7c46c9c 100644
--- a/dlls/dwrite/freetype.c
+++ b/dlls/dwrite/freetype.c
@@ -572,7 +572,7 @@ static BOOL is_face_scalable(void *key)
         return FALSE;
 }
 
-static BOOL get_glyph_transform(struct dwrite_glyphbitmap *bitmap, FT_Matrix *ret)
+static BOOL get_glyph_transform(void *key, struct dwrite_glyphbitmap *bitmap, FT_Matrix *ret)
 {
     FT_Matrix m;
 
@@ -583,7 +583,7 @@ 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->key) || (!bitmap->m && bitmap->simulations == 0))
+    if (!is_face_scalable(key) || (!bitmap->m && !bitmap->simulations))
         return FALSE;
 
     if (bitmap->simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE) {
@@ -602,7 +602,7 @@ static BOOL get_glyph_transform(struct dwrite_glyphbitmap *bitmap, FT_Matrix *re
     return TRUE;
 }
 
-static void CDECL freetype_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap)
+static void CDECL freetype_get_glyph_bbox(void *key, struct dwrite_glyphbitmap *bitmap)
 {
     FTC_ImageTypeRec imagetype;
     FT_BBox bbox = { 0 };
@@ -612,9 +612,9 @@ static void CDECL freetype_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap)
 
     RtlEnterCriticalSection(&freetype_cs);
 
-    needs_transform = get_glyph_transform(bitmap, &m);
+    needs_transform = get_glyph_transform(key, bitmap, &m);
 
-    imagetype.face_id = bitmap->key;
+    imagetype.face_id = key;
     imagetype.width = 0;
     imagetype.height = bitmap->emsize;
     imagetype.flags = needs_transform ? FT_LOAD_NO_BITMAP : FT_LOAD_DEFAULT;
@@ -734,7 +734,7 @@ static BOOL freetype_get_aa_glyph_bitmap(struct dwrite_glyphbitmap *bitmap, FT_G
     return ret;
 }
 
-static BOOL CDECL freetype_get_glyph_bitmap(struct dwrite_glyphbitmap *bitmap)
+static BOOL CDECL freetype_get_glyph_bitmap(void *key, struct dwrite_glyphbitmap *bitmap)
 {
     FTC_ImageTypeRec imagetype;
     BOOL needs_transform;
@@ -744,9 +744,9 @@ static BOOL CDECL freetype_get_glyph_bitmap(struct dwrite_glyphbitmap *bitmap)
 
     RtlEnterCriticalSection(&freetype_cs);
 
-    needs_transform = get_glyph_transform(bitmap, &m);
+    needs_transform = get_glyph_transform(key, bitmap, &m);
 
-    imagetype.face_id = bitmap->key;
+    imagetype.face_id = key;
     imagetype.width = 0;
     imagetype.height = bitmap->emsize;
     imagetype.flags = needs_transform ? FT_LOAD_NO_BITMAP : FT_LOAD_DEFAULT;
@@ -865,12 +865,12 @@ static INT32 CDECL null_get_glyph_advance(font_object_handle object, float emsiz
     return 0;
 }
 
-static void CDECL null_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap)
+static void CDECL null_get_glyph_bbox(void *key, struct dwrite_glyphbitmap *bitmap)
 {
     SetRectEmpty(&bitmap->bbox);
 }
 
-static BOOL CDECL null_get_glyph_bitmap(struct dwrite_glyphbitmap *bitmap)
+static BOOL CDECL null_get_glyph_bitmap(void *key, struct dwrite_glyphbitmap *bitmap)
 {
     return FALSE;
 }
diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c
index b2e71e7f436..b7ab855d1f1 100644
--- a/dlls/dwrite/layout.c
+++ b/dlls/dwrite/layout.c
@@ -3945,7 +3945,6 @@ static void layout_get_erun_bbox(struct dwrite_textlayout *layout, struct layout
         glyph_run.glyphOffsets = &regular->run.glyphOffsets[start_glyph];
 
         memset(&glyph_bitmap, 0, sizeof(glyph_bitmap));
-        glyph_bitmap.key = glyph_run.fontFace;
         glyph_bitmap.simulations = IDWriteFontFace_GetSimulations(glyph_run.fontFace);
         glyph_bitmap.emsize = glyph_run.fontEmSize;
         glyph_bitmap.nohint = layout->measuringmode == DWRITE_MEASURING_MODE_NATURAL;
@@ -3967,7 +3966,7 @@ static void layout_get_erun_bbox(struct dwrite_textlayout *layout, struct layout
             D2D1_RECT_F glyph_bbox;
 
             glyph_bitmap.glyph = glyph_run.glyphIndices[i];
-            dwrite_fontface_get_glyph_bbox(&glyph_bitmap);
+            dwrite_fontface_get_glyph_bbox(glyph_run.fontFace, &glyph_bitmap);
 
             glyph_bbox.left = bbox->left;
             glyph_bbox.top = bbox->top;




More information about the wine-cvs mailing list