Commit 78e0b35c authored by Dmitry Antipov's avatar Dmitry Antipov

Omit unused frame argument of font API's close function.

* font.h (struct font): Drop frame argument.  Adjust comment.
* font.c (font_clear_cache, font_close_object): Adjust users.
* ftfont.c (ftfont_close):
* ftxfont.c (ftxfont_close):
* macfont.m (macfont_close):
* nsfont.m (nsfont_close):
* w32font.c (w32font_close):
* xfont.c (xfont_close):
* xftfont.c (xftfont_close): Adjust driver-specific close
functions, tweak comments and make functions safe if called
more than once for the same font object.
parent 963ce636
2013-10-25 Dmitry Antipov <dmantipov@yandex.ru>
Omit unused frame argument of font API's close function.
* font.h (struct font): Drop frame argument. Adjust comment.
* font.c (font_clear_cache, font_close_object): Adjust users.
* ftfont.c (ftfont_close):
* ftxfont.c (ftxfont_close):
* macfont.m (macfont_close):
* nsfont.m (nsfont_close):
* w32font.c (w32font_close):
* xfont.c (xfont_close):
* xftfont.c (xftfont_close): Adjust driver-specific close
functions, tweak comments and make functions safe if called
more than once for the same font object.
2013-10-24 Glenn Morris <rgm@gnu.org>
* Makefile.in (abs_top_srcdir): New, set by configure.
......
......@@ -2591,7 +2591,7 @@ font_clear_cache (struct frame *f, Lisp_Object cache, struct font_driver *driver
if (! NILP (AREF (val, FONT_TYPE_INDEX)))
{
eassert (font && driver == font->driver);
driver->close (f, font);
driver->close (font);
}
}
if (driver->free_entity)
......@@ -2892,7 +2892,7 @@ font_close_object (struct frame *f, Lisp_Object font_object)
/* Already closed. */
return;
FONT_ADD_LOG ("close", font_object, Qnil);
font->driver->close (f, font);
font->driver->close (font);
#ifdef HAVE_WINDOW_SYSTEM
eassert (FRAME_DISPLAY_INFO (f)->n_fonts);
FRAME_DISPLAY_INFO (f)->n_fonts--;
......
......@@ -545,8 +545,8 @@ struct font_driver
Lisp_Object (*open) (struct frame *f, Lisp_Object font_entity,
int pixel_size);
/* Close FONT on frame F. */
void (*close) (struct frame *f, struct font *font);
/* Close FONT. */
void (*close) (struct font *font);
/* Optional (if FACE->extra is not used).
Prepare FACE for displaying characters by FONT on frame F by
......
......@@ -498,7 +498,7 @@ static Lisp_Object ftfont_list (struct frame *, Lisp_Object);
static Lisp_Object ftfont_match (struct frame *, Lisp_Object);
static Lisp_Object ftfont_list_family (struct frame *);
static Lisp_Object ftfont_open (struct frame *, Lisp_Object, int);
static void ftfont_close (struct frame *, struct font *);
static void ftfont_close (struct font *);
static int ftfont_has_char (Lisp_Object, int);
static unsigned ftfont_encode_char (struct font *, int);
static int ftfont_text_extents (struct font *, unsigned *, int,
......@@ -1317,7 +1317,7 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
}
static void
ftfont_close (struct frame *f, struct font *font)
ftfont_close (struct font *font)
{
struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
Lisp_Object val, cache;
......
......@@ -260,9 +260,9 @@ ftxfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
}
static void
ftxfont_close (struct frame *f, struct font *font)
ftxfont_close (struct font *font)
{
ftfont_driver.close (f, font);
ftfont_driver.close (font);
}
static int
......
......@@ -1518,7 +1518,7 @@ static CGGlyph macfont_get_glyph_for_cid (struct font *font,
static Lisp_Object macfont_list_family (struct frame *);
static void macfont_free_entity (Lisp_Object);
static Lisp_Object macfont_open (struct frame *, Lisp_Object, int);
static void macfont_close (struct frame *, struct font *);
static void macfont_close (struct font *);
static int macfont_has_char (Lisp_Object, int);
static unsigned macfont_encode_char (struct font *, int);
static int macfont_text_extents (struct font *, unsigned int *, int,
......@@ -2580,23 +2580,28 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
}
static void
macfont_close (struct frame * f, struct font *font)
macfont_close (struct font *font)
{
struct macfont_info *macfont_info = (struct macfont_info *) font;
int i;
block_input ();
CFRelease (macfont_info->macfont);
CGFontRelease (macfont_info->cgfont);
if (macfont_info->screen_font)
CFRelease (macfont_info->screen_font);
macfont_release_cache (macfont_info->cache);
for (i = 0; i < macfont_info->metrics_nrows; i++)
if (macfont_info->metrics[i])
xfree (macfont_info->metrics[i]);
if (macfont_info->metrics)
xfree (macfont_info->metrics);
unblock_input ();
if (macfont_info->cache)
{
int i;
block_input ();
CFRelease (macfont_info->macfont);
CGFontRelease (macfont_info->cgfont);
if (macfont_info->screen_font)
CFRelease (macfont_info->screen_font);
macfont_release_cache (macfont_info->cache);
macfont_info->cache = NULL;
for (i = 0; i < macfont_info->metrics_nrows; i++)
if (macfont_info->metrics[i])
xfree (macfont_info->metrics[i]);
if (macfont_info->metrics)
xfree (macfont_info->metrics);
unblock_input ();
}
}
static int
......
......@@ -624,7 +624,7 @@ but also for ascii (which causes unnecessary font substitution). */
static Lisp_Object nsfont_list_family (struct frame *);
static Lisp_Object nsfont_open (struct frame *f, Lisp_Object font_entity,
int pixel_size);
static void nsfont_close (struct frame *f, struct font *font);
static void nsfont_close (struct font *font);
static int nsfont_has_char (Lisp_Object entity, int c);
static unsigned int nsfont_encode_char (struct font *font, int c);
static int nsfont_text_extents (struct font *font, unsigned int *code,
......@@ -929,29 +929,30 @@ when setting family in ns_spec_to_descriptor(). */
}
/* Close FONT on frame F. */
/* Close FONT. */
static void
nsfont_close (struct frame *f, struct font *font)
nsfont_close (struct font *font)
{
struct nsfont_info *font_info = (struct nsfont_info *)font;
int i;
/* FIXME: this occurs apparently due to same failure to detect same font
that causes need for cache in nsfont_open () */
if (!font_info)
return;
struct nsfont_info *font_info = (struct nsfont_info *) font;
for (i =0; i<0x100; i++)
/* FIXME: font_info may be NULL due to same failure to detect
same font that causes need for cache in nsfont_open. */
if (font_info && font_info->name)
{
xfree (font_info->glyphs[i]);
xfree (font_info->metrics[i]);
}
[font_info->nsfont release];
int i;
for (i = 0; i < 0x100; i++)
{
xfree (font_info->glyphs[i]);
xfree (font_info->metrics[i]);
}
[font_info->nsfont release];
#ifdef NS_IMPL_COCOA
CGFontRelease (font_info->cgfont);
CGFontRelease (font_info->cgfont);
#endif
xfree (font_info->name);
xfree (font_info);
xfree (font_info->name);
font_info->name = NULL;
}
}
......
......@@ -376,26 +376,26 @@ w32font_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
return font_object;
}
/* w32 implementation of close for font_backend.
Close FONT on frame F. */
/* w32 implementation of close for font_backend. */
void
w32font_close (struct frame *f, struct font *font)
w32font_close (struct font *font)
{
int i;
struct w32font_info *w32_font = (struct w32font_info *) font;
/* Delete the GDI font object. */
DeleteObject (w32_font->hfont);
/* Free all the cached metrics. */
if (w32_font->cached_metrics)
if (w32_font->hfont)
{
for (i = 0; i < w32_font->n_cache_blocks; i++)
{
xfree (w32_font->cached_metrics[i]);
}
xfree (w32_font->cached_metrics);
w32_font->cached_metrics = NULL;
/* Delete the GDI font object. */
DeleteObject (w32_font->hfont);
w32_font->hfont = NULL;
/* Free all the cached metrics. */
if (w32_font->cached_metrics)
{
for (i = 0; i < w32_font->n_cache_blocks; i++)
xfree (w32_font->cached_metrics[i]);
xfree (w32_font->cached_metrics);
w32_font->cached_metrics = NULL;
}
}
}
......
......@@ -119,7 +119,7 @@ static Lisp_Object xfont_list (struct frame *, Lisp_Object);
static Lisp_Object xfont_match (struct frame *, Lisp_Object);
static Lisp_Object xfont_list_family (struct frame *);
static Lisp_Object xfont_open (struct frame *, Lisp_Object, int);
static void xfont_close (struct frame *, struct font *);
static void xfont_close (struct font *);
static int xfont_prepare_face (struct frame *, struct face *);
static int xfont_has_char (Lisp_Object, int);
static unsigned xfont_encode_char (struct font *, int);
......@@ -890,11 +890,17 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
}
static void
xfont_close (struct frame *f, struct font *font)
xfont_close (struct font *font)
{
block_input ();
XFreeFont (FRAME_X_DISPLAY (f), ((struct xfont_info *) font)->xfont);
unblock_input ();
struct xfont_info *xfi = (struct xfont_info *) font;
if (xfi->xfont)
{
block_input ();
XFreeFont (xfi->display, xfi->xfont);
unblock_input ();
xfi->xfont = NULL;
}
}
static int
......
......@@ -486,18 +486,26 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
}
static void
xftfont_close (struct frame *f, struct font *font)
xftfont_close (struct font *font)
{
struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
#ifdef HAVE_LIBOTF
if (xftfont_info->otf)
OTF_close (xftfont_info->otf);
{
OTF_close (xftfont_info->otf);
xftfont_info->otf = NULL;
}
#endif
block_input ();
XftUnlockFace (xftfont_info->xftfont);
XftFontClose (xftfont_info->display, xftfont_info->xftfont);
unblock_input ();
if (xftfont_info->xftfont)
{
block_input ();
XftUnlockFace (xftfont_info->xftfont);
XftFontClose (xftfont_info->display, xftfont_info->xftfont);
unblock_input ();
xftfont_info->xftfont = NULL;
}
}
static int
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment