[pango/pango2: 212/301] More matrix work
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 212/301] More matrix work
- Date: Wed, 22 Jun 2022 15:53:40 +0000 (UTC)
commit 09f47e67b18afcbfefc4fb4741bbc031d026598e
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 11 21:56:39 2022 -0400
More matrix work
Call it ctm everywhere, and add it to the key
we use for caching fontsets.
pango/pango-font-face-private.h | 4 ++--
pango/pango-font-face.c | 6 +++---
pango/pango-fontmap.c | 28 ++++++++++++++++++++++++----
pango/pango-fontset-cached-private.h | 4 ++--
pango/pango-fontset-cached.c | 12 ++++++------
pango/pango-hbface.c | 4 ++--
pango/pango-userface.c | 4 ++--
7 files changed, 41 insertions(+), 21 deletions(-)
---
diff --git a/pango/pango-font-face-private.h b/pango/pango-font-face-private.h
index 7fc0aafb8..c184d552a 100644
--- a/pango/pango-font-face-private.h
+++ b/pango/pango-font-face-private.h
@@ -51,7 +51,7 @@ struct _PangoFontFaceClass
PangoFont * (* create_font) (PangoFontFace *face,
const PangoFontDescription *desc,
float dpi,
- const PangoMatrix *matrix);
+ const PangoMatrix *ctm);
};
#define PANGO_FONT_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FACE,
PangoFontFaceClass))
@@ -61,7 +61,7 @@ const char * pango_font_face_get_faceid (PangoFontFace *fac
PangoFont * pango_font_face_create_font (PangoFontFace *face,
const PangoFontDescription *desc,
float dpi,
- const PangoMatrix *matrix);
+ const PangoMatrix *ctm);
static inline void
pango_font_face_set_name (PangoFontFace *face,
diff --git a/pango/pango-font-face.c b/pango/pango-font-face.c
index a7a7514f4..2144a3ebe 100644
--- a/pango/pango-font-face.c
+++ b/pango/pango-font-face.c
@@ -94,7 +94,7 @@ static PangoFont *
pango_font_face_default_create_font (PangoFontFace *face,
const PangoFontDescription *desc,
float dpi,
- const PangoMatrix *matrix)
+ const PangoMatrix *ctm)
{
return NULL;
}
@@ -250,11 +250,11 @@ PangoFont *
pango_font_face_create_font (PangoFontFace *face,
const PangoFontDescription *desc,
float dpi,
- const PangoMatrix *matrix)
+ const PangoMatrix *ctm)
{
g_return_val_if_fail (PANGO_IS_FONT_FACE (face), NULL);
- return PANGO_FONT_FACE_GET_CLASS (face)->create_font (face, desc, dpi, matrix);
+ return PANGO_FONT_FACE_GET_CLASS (face)->create_font (face, desc, dpi, ctm);
}
/*< private >
diff --git a/pango/pango-fontmap.c b/pango/pango-fontmap.c
index 1753d703d..dc90cf2b1 100644
--- a/pango/pango-fontmap.c
+++ b/pango/pango-fontmap.c
@@ -133,13 +133,31 @@ pango_font_map_list_model_init (GListModelInterface *iface)
/* The number of fontsets we keep in the fontset cache */
#define FONTSET_CACHE_SIZE 256
+#define FNV_32_PRIME ((guint32)0x01000193)
#define FNV1_32_INIT ((guint32)0x811c9dc5)
+static guint32
+hash_bytes_fnv (unsigned char *buffer,
+ int len,
+ guint32 hval)
+{
+ while (len--)
+ {
+ hval *= FNV_32_PRIME;
+ hval ^= *buffer++;
+ }
+
+ return hval;
+}
+
static guint
pango_fontset_cached_hash (const PangoFontsetCached *fontset)
{
guint32 hash = FNV1_32_INIT;
+ if (fontset->ctm)
+ hash = hash_bytes_fnv ((unsigned char *)(fontset->ctm), sizeof (double) * 4, hash);
+
return (hash ^
GPOINTER_TO_UINT (fontset->language) ^
#ifdef HAVE_CAIRO
@@ -156,6 +174,8 @@ pango_fontset_cached_equal (const PangoFontsetCached *a,
#ifdef HAVE_CAIRO
cairo_font_options_equal (a->font_options, b->font_options) &&
#endif
+ (a->ctm == b->ctm ||
+ (a->ctm && b->ctm && memcmp (a->ctm, b->ctm, 4 * sizeof (double)) == 0)) &&
pango_font_description_equal (a->description, b->description);
}
@@ -470,7 +490,7 @@ pango_font_map_default_load_fontset (PangoFontMap *self,
{
PangoFontsetCached lookup;
PangoFontsetCached *fontset;
- const PangoMatrix *matrix;
+ const PangoMatrix *ctm;
const char *family_name;
char **families;
PangoFontDescription *copy;
@@ -485,9 +505,11 @@ pango_font_map_default_load_fontset (PangoFontMap *self,
language = pango_context_get_language (context);
family_name = pango_font_description_get_family (description);
+ ctm = pango_context_get_matrix (context);
lookup.language = language;
lookup.description = (PangoFontDescription *)description;
+ lookup.ctm = ctm;
#ifdef HAVE_CAIRO
lookup.font_options = (cairo_font_options_t *)pango_cairo_context_get_merged_font_options (context);
#endif
@@ -496,9 +518,7 @@ pango_font_map_default_load_fontset (PangoFontMap *self,
if (fontset)
goto done;
- matrix = pango_context_get_matrix (context);
-
- fontset = pango_fontset_cached_new (description, language, self->dpi, matrix);
+ fontset = pango_fontset_cached_new (description, language, self->dpi, ctm);
#ifdef HAVE_CAIRO
fontset->font_options = cairo_font_options_copy (pango_cairo_context_get_merged_font_options (context));
#endif
diff --git a/pango/pango-fontset-cached-private.h b/pango/pango-fontset-cached-private.h
index ccf28cebc..4b7a37f7e 100644
--- a/pango/pango-fontset-cached-private.h
+++ b/pango/pango-fontset-cached-private.h
@@ -39,7 +39,7 @@ struct _PangoFontsetCached
PangoLanguage *language;
PangoFontDescription *description;
float dpi;
- const PangoMatrix *matrix;
+ const PangoMatrix *ctm;
GList cache_link;
GHashTable *cache;
@@ -59,7 +59,7 @@ GType pango_fontset_cached_get_type (void) G_GNUC_CONST;
PangoFontsetCached * pango_fontset_cached_new (const PangoFontDescription *description,
PangoLanguage *language,
float dpi,
- const PangoMatrix *matrix);
+ const PangoMatrix *ctm);
void pango_fontset_cached_add_face (PangoFontsetCached *self,
PangoFontFace *face);
diff --git a/pango/pango-fontset-cached.c b/pango/pango-fontset-cached.c
index 5743a8279..665775d04 100644
--- a/pango/pango-fontset-cached.c
+++ b/pango/pango-fontset-cached.c
@@ -119,7 +119,7 @@ pango_fontset_cached_get_font (PangoFontset *fontset,
retval = pango_font_face_create_font (face,
self->description,
self->dpi,
- self->matrix);
+ self->ctm);
#ifdef HAVE_CAIRO
pango_cairo_font_set_font_options (retval, self->font_options);
#endif
@@ -156,7 +156,7 @@ pango_fontset_cached_get_first_font (PangoFontsetCached *self)
font = pango_font_face_create_font (face,
self->description,
self->dpi,
- self->matrix);
+ self->ctm);
#ifdef HAVE_CAIRO
pango_cairo_font_set_font_options (font, self->font_options);
#endif
@@ -213,7 +213,7 @@ pango_fontset_cached_foreach (PangoFontset *fontset,
else if (PANGO_IS_GENERIC_FAMILY (item))
{
PangoFontFace *face = pango_generic_family_find_face (PANGO_GENERIC_FAMILY (item),
self->description, self->language, 0);
- font = pango_font_face_create_font (face, self->description, self->dpi, self->matrix);
+ font = pango_font_face_create_font (face, self->description, self->dpi, self->ctm);
#ifdef HAVE_CAIRO
pango_cairo_font_set_font_options (font, self->font_options);
#endif
@@ -246,7 +246,7 @@ PangoFontsetCached *
pango_fontset_cached_new (const PangoFontDescription *description,
PangoLanguage *language,
float dpi,
- const PangoMatrix *matrix)
+ const PangoMatrix *ctm)
{
PangoFontsetCached *self;
@@ -254,7 +254,7 @@ pango_fontset_cached_new (const PangoFontDescription *description,
self->language = language;
self->description = pango_font_description_copy (description);
self->dpi = dpi;
- self->matrix = matrix;
+ self->ctm = ctm;
return self;
}
@@ -268,7 +268,7 @@ pango_fontset_cached_add_face (PangoFontsetCached *self,
font = pango_font_face_create_font (face,
self->description,
self->dpi,
- self->matrix);
+ self->ctm);
#ifdef HAVE_CAIRO
pango_cairo_font_set_font_options (font, self->font_options);
#endif
diff --git a/pango/pango-hbface.c b/pango/pango-hbface.c
index e180f0d44..937c22cd9 100644
--- a/pango/pango-hbface.c
+++ b/pango/pango-hbface.c
@@ -446,11 +446,11 @@ static PangoFont *
pango_hb_face_create_font (PangoFontFace *face,
const PangoFontDescription *desc,
float dpi,
- const PangoMatrix *matrix)
+ const PangoMatrix *ctm)
{
PangoHbFace *self = PANGO_HB_FACE (face);
- return PANGO_FONT (pango_hb_font_new_for_description (self, desc, dpi, matrix));
+ return PANGO_FONT (pango_hb_font_new_for_description (self, desc, dpi, ctm));
}
static void
diff --git a/pango/pango-userface.c b/pango/pango-userface.c
index e4388bbab..7e6f702b3 100644
--- a/pango/pango-userface.c
+++ b/pango/pango-userface.c
@@ -249,11 +249,11 @@ static PangoFont *
pango_user_face_create_font (PangoFontFace *face,
const PangoFontDescription *desc,
float dpi,
- const PangoMatrix *matrix)
+ const PangoMatrix *ctm)
{
PangoUserFace *self = PANGO_USER_FACE (face);
- return PANGO_FONT (pango_user_font_new_for_description (self, desc, dpi, matrix));
+ return PANGO_FONT (pango_user_font_new_for_description (self, desc, dpi, ctm));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]