summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-05-10 03:51:00 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-05-10 03:51:00 +0000
commitfc92ee6d2a1f9d06053d432c911865a7cbc05d25 (patch)
treec795acded7c31c6e024e38c4927fc7b3e615929e
parent91b20d0e1ac51e5502f58f0e561791ab6c7f356e (diff)
downloadpango-fc92ee6d2a1f9d06053d432c911865a7cbc05d25.tar.gz
Fix memory leak by freeing correct list.
Tue May 9 03:22:11 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (pango_layout_check_lines): Fix memory leak by freeing correct list. * pango/pango-context.c (pango_context_get_font_description): Change to return a pointer to the context's font description instead of a copy. Not quite 100% kosher but a lot more efficient than the previous. (Should we just refcount font descriptions and get it over with?)
-rw-r--r--ChangeLog14
-rw-r--r--ChangeLog.pre-1-014
-rw-r--r--ChangeLog.pre-1-1014
-rw-r--r--ChangeLog.pre-1-214
-rw-r--r--ChangeLog.pre-1-414
-rw-r--r--ChangeLog.pre-1-614
-rw-r--r--ChangeLog.pre-1-814
-rw-r--r--pango/pango-layout.c2
-rw-r--r--pango/pango-types.h2
-rw-r--r--pango/pangox.c120
10 files changed, 172 insertions, 50 deletions
diff --git a/ChangeLog b/ChangeLog
index 2e094388..1e39e913 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Tue May 9 22:09:42 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h (PANGO_SCALE): Change PANGO_SCALE
+ from 1000 to 1024. Wee! Optimization! Actual performance
+ increase is ~1-2% probably not worth keeping it 1024,
+ but I'll leave it this way for a little bit.
+
+ * pango/pango-layout.c (pango_layout_unref): Free the
+ actual layout structure as well.
+
+ * pango/pangox.c: Various optimizations of the code for
+ looking up characters. (mark a few functions inline,
+ precompute signficiant quantities)
+
Tue May 9 03:22:11 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_check_lines): Fix
diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0
index 2e094388..1e39e913 100644
--- a/ChangeLog.pre-1-0
+++ b/ChangeLog.pre-1-0
@@ -1,3 +1,17 @@
+Tue May 9 22:09:42 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h (PANGO_SCALE): Change PANGO_SCALE
+ from 1000 to 1024. Wee! Optimization! Actual performance
+ increase is ~1-2% probably not worth keeping it 1024,
+ but I'll leave it this way for a little bit.
+
+ * pango/pango-layout.c (pango_layout_unref): Free the
+ actual layout structure as well.
+
+ * pango/pangox.c: Various optimizations of the code for
+ looking up characters. (mark a few functions inline,
+ precompute signficiant quantities)
+
Tue May 9 03:22:11 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_check_lines): Fix
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 2e094388..1e39e913 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,17 @@
+Tue May 9 22:09:42 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h (PANGO_SCALE): Change PANGO_SCALE
+ from 1000 to 1024. Wee! Optimization! Actual performance
+ increase is ~1-2% probably not worth keeping it 1024,
+ but I'll leave it this way for a little bit.
+
+ * pango/pango-layout.c (pango_layout_unref): Free the
+ actual layout structure as well.
+
+ * pango/pangox.c: Various optimizations of the code for
+ looking up characters. (mark a few functions inline,
+ precompute signficiant quantities)
+
Tue May 9 03:22:11 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_check_lines): Fix
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index 2e094388..1e39e913 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,3 +1,17 @@
+Tue May 9 22:09:42 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h (PANGO_SCALE): Change PANGO_SCALE
+ from 1000 to 1024. Wee! Optimization! Actual performance
+ increase is ~1-2% probably not worth keeping it 1024,
+ but I'll leave it this way for a little bit.
+
+ * pango/pango-layout.c (pango_layout_unref): Free the
+ actual layout structure as well.
+
+ * pango/pangox.c: Various optimizations of the code for
+ looking up characters. (mark a few functions inline,
+ precompute signficiant quantities)
+
Tue May 9 03:22:11 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_check_lines): Fix
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 2e094388..1e39e913 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,17 @@
+Tue May 9 22:09:42 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h (PANGO_SCALE): Change PANGO_SCALE
+ from 1000 to 1024. Wee! Optimization! Actual performance
+ increase is ~1-2% probably not worth keeping it 1024,
+ but I'll leave it this way for a little bit.
+
+ * pango/pango-layout.c (pango_layout_unref): Free the
+ actual layout structure as well.
+
+ * pango/pangox.c: Various optimizations of the code for
+ looking up characters. (mark a few functions inline,
+ precompute signficiant quantities)
+
Tue May 9 03:22:11 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_check_lines): Fix
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 2e094388..1e39e913 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,17 @@
+Tue May 9 22:09:42 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h (PANGO_SCALE): Change PANGO_SCALE
+ from 1000 to 1024. Wee! Optimization! Actual performance
+ increase is ~1-2% probably not worth keeping it 1024,
+ but I'll leave it this way for a little bit.
+
+ * pango/pango-layout.c (pango_layout_unref): Free the
+ actual layout structure as well.
+
+ * pango/pangox.c: Various optimizations of the code for
+ looking up characters. (mark a few functions inline,
+ precompute signficiant quantities)
+
Tue May 9 03:22:11 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_check_lines): Fix
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 2e094388..1e39e913 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,17 @@
+Tue May 9 22:09:42 2000 Owen Taylor <otaylor@redhat.com>
+
+ * pango/pango-types.h (PANGO_SCALE): Change PANGO_SCALE
+ from 1000 to 1024. Wee! Optimization! Actual performance
+ increase is ~1-2% probably not worth keeping it 1024,
+ but I'll leave it this way for a little bit.
+
+ * pango/pango-layout.c (pango_layout_unref): Free the
+ actual layout structure as well.
+
+ * pango/pangox.c: Various optimizations of the code for
+ looking up characters. (mark a few functions inline,
+ precompute signficiant quantities)
+
Tue May 9 03:22:11 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_check_lines): Fix
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 4e695581..a90688ec 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -150,6 +150,8 @@ pango_layout_unref (PangoLayout *layout)
pango_attr_list_unref (layout->attrs);
if (layout->text)
g_free (layout->text);
+
+ g_free (layout);
}
}
diff --git a/pango/pango-types.h b/pango/pango-types.h
index 346d858f..8c518cb4 100644
--- a/pango/pango-types.h
+++ b/pango/pango-types.h
@@ -54,7 +54,7 @@ struct _PangoRectangle
int height;
};
-#define PANGO_SCALE 1000
+#define PANGO_SCALE 1024
/* Macros to translate from extents rectangles to ascent/descent/lbearing/rbearing
*/
diff --git a/pango/pangox.c b/pango/pangox.c
index 34cd0d46..d45989bf 100644
--- a/pango/pangox.c
+++ b/pango/pangox.c
@@ -70,6 +70,9 @@ struct _PangoXSubfontInfo
{
char *xlfd;
XFontStruct *font_struct;
+ gboolean is_1byte;
+ int range_byte1;
+ int range_byte2;
};
struct _PangoXMetricsInfo
@@ -259,6 +262,44 @@ PangoFontMapClass pango_x_font_map_class = {
pango_x_font_map_list_families
};
+static inline PangoXSubfontInfo *
+pango_x_find_subfont (PangoFont *font,
+ PangoXSubfont subfont_index)
+{
+ PangoXFont *xfont = (PangoXFont *)font;
+
+ if (subfont_index < 1 || subfont_index > xfont->n_subfonts)
+ {
+ g_warning ("Invalid subfont %d", subfont_index);
+ return NULL;
+ }
+
+ return xfont->subfonts[subfont_index-1];
+}
+
+static void
+pango_x_make_font_struct (PangoFont *font, PangoXSubfontInfo *info)
+{
+ PangoXFont *xfont = (PangoXFont *)font;
+
+ info->font_struct = XLoadQueryFont (xfont->display, info->xlfd);
+ if (!info->font_struct)
+ g_warning ("Cannot load font for XLFD '%s\n", info->xlfd);
+
+ info->is_1byte = (info->font_struct->min_byte1 == 0 && info->font_struct->max_byte1 == 0);
+ info->range_byte1 = info->font_struct->max_byte1 - info->font_struct->min_byte1 + 1;
+ info->range_byte2 = info->font_struct->max_char_or_byte2 - info->font_struct->min_char_or_byte2 + 1;
+}
+
+static inline XFontStruct *
+pango_x_get_font_struct (PangoFont *font, PangoXSubfontInfo *info)
+{
+ if (!info->font_struct)
+ pango_x_make_font_struct (font, info);
+
+ return info->font_struct;
+}
+
static PangoFontMap *
pango_x_font_map_for_display (Display *display)
{
@@ -2025,9 +2066,22 @@ gboolean
pango_x_has_glyph (PangoFont *font,
PangoGlyph glyph)
{
- g_return_val_if_fail (font != NULL, FALSE);
+ PangoXSubfontInfo *subfont;
+ XCharStruct *cs;
- return pango_x_find_glyph (font, glyph, NULL, NULL);
+ guint16 char_index = PANGO_X_GLYPH_INDEX (glyph);
+ guint16 subfont_index = PANGO_X_GLYPH_SUBFONT (glyph);
+
+ subfont = pango_x_find_subfont (font, subfont_index);
+ if (!subfont)
+ return FALSE;
+
+ cs = pango_x_get_per_char (font, subfont, char_index);
+
+ if (cs && (cs->lbearing != cs->rbearing || cs->width != 0))
+ return TRUE;
+ else
+ return FALSE;
}
static void
@@ -2172,36 +2226,6 @@ pango_x_font_find_shaper (PangoFont *font,
/* Utility functions */
-static XFontStruct *
-pango_x_get_font_struct (PangoFont *font, PangoXSubfontInfo *info)
-{
- PangoXFont *xfont = (PangoXFont *)font;
-
- if (!info->font_struct)
- {
- info->font_struct = XLoadQueryFont (xfont->display, info->xlfd);
- if (!info->font_struct)
- g_warning ("Cannot load font for XLFD '%s\n", info->xlfd);
- }
-
- return info->font_struct;
-}
-
-static PangoXSubfontInfo *
-pango_x_find_subfont (PangoFont *font,
- PangoXSubfont subfont_index)
-{
- PangoXFont *xfont = (PangoXFont *)font;
-
- if (subfont_index < 1 || subfont_index > xfont->n_subfonts)
- {
- g_warning ("Invalid subfont %d", subfont_index);
- return NULL;
- }
-
- return xfont->subfonts[subfont_index-1];
-}
-
static XCharStruct *
pango_x_get_per_char (PangoFont *font,
PangoXSubfontInfo *subfont,
@@ -2210,32 +2234,30 @@ pango_x_get_per_char (PangoFont *font,
XFontStruct *fs;
int index;
- guint8 byte1;
- guint8 byte2;
-
- byte1 = char_index / 256;
- byte2 = char_index % 256;
+ int byte1;
+ int byte2;
fs = pango_x_get_font_struct (font, subfont);
if (!fs)
return NULL;
-
- if ((fs->min_byte1 == 0) && (fs->max_byte1 == 0))
+
+ if (subfont->is_1byte)
{
- if (byte2 < fs->min_char_or_byte2 || byte2 > fs->max_char_or_byte2)
+ index = (int)char_index - fs->min_char_or_byte2;
+ if (index < 0 || index >= subfont->range_byte2)
return NULL;
-
- index = byte2 - fs->min_char_or_byte2;
}
else
{
- if (byte1 < fs->min_byte1 || byte1 > fs->max_byte1 ||
- byte2 < fs->min_char_or_byte2 || byte2 > fs->max_char_or_byte2)
- return FALSE;
-
- index = ((byte1 - fs->min_byte1) *
- (fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1)) +
- byte2 - fs->min_char_or_byte2;
+ byte1 = (int)(char_index / 256) - fs->min_byte1;
+ if (byte1 < 0 || byte1 >= subfont->range_byte1)
+ return NULL;
+
+ byte2 = (int)(char_index % 256) - fs->min_char_or_byte2;
+ if (byte2 < 0 || byte2 >= subfont->range_byte2)
+ return NULL;
+
+ index = byte1 * subfont->range_byte2 + byte2;
}
if (fs->per_char)