From 03ca441bd5834dddb1acfdab118379e9ae645b20 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Thu, 14 Nov 2024 21:37:04 +0200 Subject: [PATCH 1/6] add libXfont2 support with a compile-time switch --- Xext/xf86bigfont.c | 8 + configure.ac | 14 +- dix/dispatch.c | 4 + dix/dixfonts.c | 348 ++++++++++++++++++++++++++++++++++++++-- dix/main.c | 6 + include/dix-config.h.in | 3 + include/dixfont.h | 5 + mi/miglblt.c | 4 + miext/damage/damage.c | 4 + os/utils.c | 4 + 10 files changed, 386 insertions(+), 14 deletions(-) diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index b9fe1bf..17286c3 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -179,7 +179,11 @@ XFree86BigfontExtensionInit() + (unsigned int) (65536.0 / (RAND_MAX + 1.0) * rand()); /* fprintf(stderr, "signature = 0x%08X\n", signature); */ +#ifdef XFONT2 + FontShmdescIndex = xfont2_allocate_font_private_index(); +#else FontShmdescIndex = AllocateFontPrivateIndex(); +#endif #if !defined(CSRG_BASED) && !defined(__CYGWIN__) pagesize = SHMLBA; @@ -511,7 +515,11 @@ ProcXF86BigfontQueryFont(ClientPtr client) } if (pDesc && !badSysCall) { *(CARD32 *) (pCI + nCharInfos) = signature; +#ifdef XFONT2 + if (!xfont2_font_set_private(pFont, FontShmdescIndex, pDesc)) { +#else if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) { +#endif shmdealloc(pDesc); return BadAlloc; } diff --git a/configure.ac b/configure.ac index a30d074..2760049 100644 --- a/configure.ac +++ b/configure.ac @@ -248,6 +248,9 @@ DEFAULT_FONT_PATH="${FONTDIR}/misc/,${FONTDIR}/100dpi/,${FONTDIR}/75dpi/" AC_ARG_WITH(default-font-path, AS_HELP_STRING([--with-default-font-path=PATH], [Comma separated list of font dirs]), [ FONTPATH="$withval" ], [ FONTPATH="${DEFAULT_FONT_PATH}" ]) +AC_ARG_ENABLE(libXfont2, AS_HELP_STRING([--enable-libXfont2], + [Build with libXfont2 (default: disabled)]), + [XFONT2=$enableval], [XFONT2=no]) dnl Extensions. AC_ARG_ENABLE(xres, AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes]) @@ -319,9 +322,18 @@ XEXT_INC='-I$(top_srcdir)/Xext' XEXT_LIB='$(top_builddir)/Xext/libXext.la' XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la' +AM_CONDITIONAL(DEBUG, test "x$DEBUGGING" = xyes) + +if test "x$XFONT2" = xyes; then + AC_DEFINE(XFONT2, 1, [Build with libXfont2]) + XFONT_LIB="xfont2" +else + XFONT_LIB="xfont" +fi + dnl Core modules for most extensions, et al. REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto xproto xtrans xf86bigfontproto [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto inputproto [kbproto >= 1.0.3]" -REQUIRED_LIBS="xfont fontenc" +REQUIRED_LIBS="$XFONT_LIB fontenc" AM_CONDITIONAL(SCREENSAVER, [test "x$SCREENSAVER" = xyes]) if test "x$SCREENSAVER" = xyes; then diff --git a/dix/dispatch.c b/dix/dispatch.c index de15948..13a0568 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1388,7 +1388,11 @@ ProcQueryTextExtents(register ClientPtr client) return (BadLength); length--; } +#ifdef XFONT2 + if (!xfont2_query_text_extents(pFont, length, (unsigned char *) &stuff[1], &info)) +#else if (!QueryTextExtents(pFont, length, (unsigned char *) &stuff[1], &info)) +#endif return (BadAlloc); reply.type = X_Reply; reply.length = 0; diff --git a/dix/dixfonts.c b/dix/dixfonts.c index 667ff21..efd3013 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -55,6 +55,12 @@ Equipment Corporation. #include #include #include + +#ifdef XFONT2 +#include +#include +#endif + #include "scrnintstr.h" #include "resource.h" #include "dixstruct.h" @@ -72,7 +78,11 @@ Equipment Corporation. #define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics +#ifdef XFONT2 +extern void *fosNaturalParams; +#else extern pointer fosNaturalParams; +#endif extern FontPtr defaultFont; @@ -80,7 +90,11 @@ static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; static int num_fpes = 0; +#ifdef XFONT2 +static xfont2_fpe_funcs_rec const **fpe_functions; +#else _X_EXPORT FPEFunctions *fpe_functions = (FPEFunctions *) 0; +#endif static int num_fpe_types = 0; @@ -92,7 +106,11 @@ static int size_slept_fpes = 0; static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0; +#ifdef XFONT2 +static xfont2_pattern_cache_ptr patternCache; +#else static FontPatternCachePtr patternCache; +#endif _X_EXPORT int FontToXError(err) @@ -114,6 +132,17 @@ int err; } } +#ifdef XFONT2 +void +GetGlyphs(FontPtr font, unsigned long count, unsigned char *chars, + FontEncoding fontEncoding, + unsigned long *glyphcount, /* RETURN */ + CharInfoPtr *glyphs) /* RETURN */ +{ + (*font->get_glyphs) (font, count, chars, fontEncoding, glyphcount, glyphs); +} +#endif + /* * adding RT_FONT prevents conflict with default cursor font */ @@ -202,7 +231,11 @@ FontWakeup(pointer data, int count, pointer LastSelectMask) /* wake up any fpe's that may be waiting for information */ for (i = 0; i < num_slept_fpes; i++) { fpe = slept_fpes[i]; +#ifdef XFONT2 + (void) (*fpe_functions[fpe->type]->wakeup_fpe) (fpe); +#else (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask); +#endif } } @@ -218,7 +251,11 @@ FreeFPE(FontPathElementPtr fpe) { fpe->refcount--; if (fpe->refcount == 0) { +#ifdef XFONT2 + (*fpe_functions[fpe->type]->free_fpe) (fpe); +#else (*fpe_functions[fpe->type].free_fpe) (fpe); +#endif free(fpe->name); free(fpe); } @@ -269,14 +306,22 @@ doOpenFont(ClientPtr client, OFclosurePtr c) if (client->clientGone) { if (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; +#ifdef XFONT2 + (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif } err = Successful; goto bail; } while (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; +#ifdef XFONT2 + err = (*fpe_functions[fpe->type]->open_font) +#else err = (*fpe_functions[fpe->type].open_font) +#endif ((pointer) client, fpe, c->flags, c->fontname, c->fnamelen, FontFormat, BitmapFormatMaskByte | @@ -345,8 +390,13 @@ doOpenFont(ClientPtr client, OFclosurePtr c) goto bail; } if (patternCache && pfont != c->non_cachable_font) +#ifdef XFONT2 + xfont2_cache_font_pattern(patternCache, c->origFontName, c->origFontNameLen, + pfont); +#else CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen, pfont); +#endif bail: if (err != Successful && c->client != serverClient) { SendErrorToClient(c->client, X_OpenFont, 0, @@ -403,7 +453,11 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, ** having to create another instance of a font that already exists. */ +#ifdef XFONT2 + cached = xfont2_find_cached_font_pattern(patternCache, pfontname, lenfname); +#else cached = FindCachedFontPattern(patternCache, pfontname, lenfname); +#endif if (cached && cached->info.cachable) { if (!AddResource(fid, RT_FONT, (pointer) cached)) return BadAlloc; @@ -470,7 +524,11 @@ CloseFont(pointer value, XID fid) return (Success); if (--pfont->refcnt == 0) { if (patternCache) +#ifdef XFONT2 + xfont2_remove_cached_font_pattern(patternCache, pfont); +#else RemoveCachedFontPattern(patternCache, pfont); +#endif /* * since the last reference is gone, ask each screen to free any * storage it may have allocated locally for it. @@ -486,7 +544,11 @@ CloseFont(pointer value, XID fid) XF86BigfontFreeFontShm(pfont); #endif fpe = pfont->fpe; +#ifdef XFONT2 + (*fpe_functions[fpe->type]->close_font) (fpe, pfont); +#else (*fpe_functions[fpe->type].close_font) (fpe, pfont); +#endif FreeFPE(fpe); } return (Success); @@ -596,7 +658,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; +#ifdef XFONT2 + (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif } // err = Successful; goto bail; @@ -609,10 +675,18 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; +#ifdef XFONT2 + if (!fpe_functions[fpe->type]->start_list_fonts_and_aliases) { +#else if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) { +#endif /* This FPE doesn't support/require list_fonts_and_aliases */ +#ifdef XFONT2 + err = (*fpe_functions[fpe->type]->list_fonts) +#else err = (*fpe_functions[fpe->type].list_fonts) +#endif ((pointer) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, c->names); @@ -640,7 +714,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) the FPEs. */ if (!c->current.list_started) { +#ifdef XFONT2 + err = (*fpe_functions[fpe->type]->start_list_fonts_and_aliases) +#else err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) +#endif ((pointer) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, &c->current.private); @@ -660,7 +738,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) char *tmpname; name = 0; +#ifdef XFONT2 + err = (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else err = (*fpe_functions[fpe->type].list_next_font_or_alias) +#endif ((pointer) c->client, fpe, &name, &namelen, &tmpname, &resolvedlen, c->current.private); if (err == Suspended) { @@ -684,11 +766,20 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (err == Successful) { if (c->haveSaved) { if (c->savedName) +#ifdef XFONT2 + (void) xfont2_add_font_names_name(c->names, c->savedName, + c->savedNameLen); +#else (void) AddFontNamesName(c->names, c->savedName, c->savedNameLen); +#endif } else +#ifdef XFONT2 + (void) xfont2_add_font_names_name(c->names, name, namelen); +#else (void) AddFontNamesName(c->names, name, namelen); +#endif } /* @@ -714,7 +805,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) int tmpnamelen; tmpname = 0; +#ifdef XFONT2 + (void) (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else (void) (*fpe_functions[fpe->type].list_next_font_or_alias) +#endif ((pointer) c->client, fpe, &tmpname, &tmpnamelen, &tmpname, &tmpnamelen, c->current.private); if (--aliascount <= 0) { @@ -822,7 +917,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) free(c->fpe_list); if (c->savedName) free(c->savedName); +#ifdef XFONT2 + xfont2_free_font_names(names); +#else FreeFontNames(names); +#endif free(c); if (resolved) free(resolved); @@ -854,7 +953,11 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, free(c); return BadAlloc; } +#ifdef XFONT2 + c->names = xfont2_make_font_names_record(max_names < 100 ? max_names : 100); +#else c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100); +#endif if (!c->names) { free(c->fpe_list); free(c); @@ -909,7 +1012,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; +#ifdef XFONT2 + (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif } err = Successful; goto bail; @@ -921,7 +1028,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; if (!c->current.list_started) { +#ifdef XFONT2 + err = (*fpe_functions[fpe->type]->start_list_fonts_with_info) +#else err = (*fpe_functions[fpe->type].start_list_fonts_with_info) +#endif (client, fpe, c->current.pattern, c->current.patlen, c->current.max_names, &c->current.private); if (err == Suspended) { @@ -938,7 +1049,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (err == Successful) { name = 0; pFontInfo = &fontInfo; +#ifdef XFONT2 + err = (*fpe_functions[fpe->type]->list_next_font_with_info) +#else err = (*fpe_functions[fpe->type].list_next_font_with_info) +#endif (client, fpe, &name, &namelen, &pFontInfo, &numFonts, c->current.private); if (err == Suspended) { @@ -972,7 +1087,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) tmpname = 0; tmpFontInfo = &fontInfo; +#ifdef XFONT2 + (void) (*fpe_functions[fpe->type]->list_next_font_with_info) +#else (void) (*fpe_functions[fpe->type].list_next_font_with_info) +#endif (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo, &numFonts, c->current.private); if (--aliascount <= 0) { @@ -1168,7 +1287,11 @@ doPolyText(ClientPtr client, register PTclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; +#ifdef XFONT2 + (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif if (c->slept) { /* Client has died, but we cannot bail out right now. We @@ -1195,7 +1318,11 @@ doPolyText(ClientPtr client, register PTclosurePtr c) the FPE code to clean up after client and avoid further rendering while we clean up after ourself. */ fpe = c->pGC->font->fpe; +#ifdef XFONT2 + (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif c->pDraw = (DrawablePtr) 0; } @@ -1441,7 +1568,11 @@ doImageText(ClientPtr client, register ITclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; +#ifdef XFONT2 + (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif err = Success; goto bail; } @@ -1456,7 +1587,11 @@ doImageText(ClientPtr client, register ITclosurePtr c) /* Our drawable has disappeared. Treat like client died... ask the FPE code to clean up after client. */ fpe = c->pGC->font->fpe; +#ifdef XFONT2 + (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif err = Success; goto bail; } @@ -1588,7 +1723,11 @@ DetermineFPEType(char *pathname) int i; for (i = 0; i < num_fpe_types; i++) { +#ifdef XFONT2 + if ((*fpe_functions[i]->name_check) (pathname)) +#else if ((*fpe_functions[i].name_check) (pathname)) +#endif return i; } return -1; @@ -1656,8 +1795,13 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) return BadAlloc; } for (i = 0; i < num_fpe_types; i++) { +#ifdef XFONT2 + if (fpe_functions[i]->set_path_hook) + (*fpe_functions[i]->set_path_hook) (); +#else if (fpe_functions[i].set_path_hook) (*fpe_functions[i].set_path_hook) (); +#endif } for (i = 0; i < npaths; i++) { len = (unsigned int) (*cp++); @@ -1676,7 +1820,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) */ fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); if (fpe) { +#ifdef XFONT2 + err = (*fpe_functions[fpe->type]->reset_fpe) (fpe); +#else err = (*fpe_functions[fpe->type].reset_fpe) (fpe); +#endif if (err == Successful) { UseFPE(fpe); /* since it'll be decref'd later when freed * from the old list */ @@ -1706,7 +1854,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) if (fpe->type == -1) err = BadValue; else +#ifdef XFONT2 + err = (*fpe_functions[fpe->type]->init_fpe) (fpe); +#else err = (*fpe_functions[fpe->type].init_fpe) (fpe); +#endif if (err != Successful) { if (persist) { ErrorF @@ -1731,7 +1883,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) FreeFontPath(font_path_elements, num_fpes, FALSE); font_path_elements = fplist; if (patternCache) +#ifdef XFONT2 + xfont2_empty_font_pattern_cache(patternCache); +#else EmptyFontPatternCache(patternCache); +#endif num_fpes = valid_paths; return Success; @@ -1832,8 +1988,13 @@ _X_EXPORT int LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data) { +#ifdef XFONT2 + if (fpe_functions[pfont->fpe->type]->load_glyphs) + return (*fpe_functions[pfont->fpe->type]->load_glyphs) +#else if (fpe_functions[pfont->fpe->type].load_glyphs) return (*fpe_functions[pfont->fpe->type].load_glyphs) +#endif (client, pfont, 0, nchars, item_size, data); else return Successful; @@ -1848,34 +2009,64 @@ DeleteClientFontStuff(ClientPtr client) for (i = 0; i < num_fpes; i++) { fpe = font_path_elements[i]; +#ifdef XFONT2 + if (fpe_functions[fpe->type]->client_died) + (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else if (fpe_functions[fpe->type].client_died) (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif } } +#ifdef XFONT2 +_X_EXPORT XFONT_LTO +Font +get_new_font_client_id() +{ + return FakeClientID(0); +} + +_X_EXPORT XFONT_LTO +int +store_font_Client_font(FontPtr pfont, Font id) +{ + return AddResource(id, RT_NONE, (pointer) pfont); +} + +_X_EXPORT XFONT_LTO void -InitFonts() +delete_font_client_id(Font id) { - patternCache = MakeFontPatternCache(); + FreeResource(id, RT_NONE); +} - { -#ifdef KDRIVESERVER - BuiltinRegisterFpeFunctions(); -#endif - FontFileRegisterFpeFunctions(); - } +_X_EXPORT XFONT_LTO +int +_client_auth_generation(ClientPtr client) +{ + return 0; } +#endif _X_EXPORT XFONT_LTO int +#ifdef XFONT2 +get_default_point_size() +#else GetDefaultPointSize() +#endif { return 120; } _X_EXPORT XFONT_LTO FontResolutionPtr +#ifdef XFONT2 +get_client_resolutions(int *num) +#else GetClientResolutions(int *num) +#endif { if (requestingClient && requestingClient->fontResFunc != NULL && !requestingClient->clientGone) { @@ -1907,6 +2098,7 @@ GetClientResolutions(int *num) } } +#ifndef XFONT2 /* * returns the type index of the new fpe * @@ -1958,12 +2150,16 @@ RegisterFPEFunctions(NameCheckFunc name_func, return num_fpe_types++; } - +#endif void FreeFonts() { if (patternCache) { +#ifdef XFONT2 + xfont2_free_font_pattern_cache(patternCache); +#else FreeFontPatternCache(patternCache); +#endif patternCache = 0; } FreeFontPath(font_path_elements, num_fpes, TRUE); @@ -1971,9 +2167,16 @@ FreeFonts() num_fpes = 0; free(fpe_functions); num_fpe_types = 0; - fpe_functions = (FPEFunctions *) 0; + fpe_functions = NULL; } +#ifdef XFONT2 +static uint32_t wrap_time_in_millis(void) +{ + return GetTimeInMillis(); +} +#endif + /* convenience functions for FS interface */ FontPtr @@ -1982,7 +2185,7 @@ find_old_font(XID id) return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, SecurityUnknownAccess); } - +#ifndef XFONT2 _X_EXPORT XFONT_LTO Font GetNewFontClientID() @@ -2010,14 +2213,27 @@ client_auth_generation(ClientPtr client) { return 0; } +#endif static int fs_handlers_installed = 0; static unsigned int last_server_gen; +#ifdef XFONT2 +static void +adjust_fs_wait_for_delay(void *wt, unsigned long newdelay) +{ + AdjustWaitForDelay(wt, newdelay); +} +#endif + _X_EXPORT XFONT_LTO int +#ifdef XFONT2 +_init_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler) +#else init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) +#endif { /* if server has reset, make sure the b&w handlers are reinstalled */ if (last_server_gen < serverGeneration) { @@ -2026,9 +2242,13 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) } if (fs_handlers_installed == 0) { - +#ifdef XFONT2 + if (!RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)block_handler, + FontWakeup, (pointer) 0)) +#else if (!RegisterBlockAndWakeupHandlers(block_handler, FontWakeup, (pointer) 0)) +#endif return AllocError; fs_handlers_installed++; } @@ -2038,18 +2258,120 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) _X_EXPORT XFONT_LTO void +#ifdef XFONT2 +_remove_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler, + Bool all) +#else remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) +#endif { if (all) { /* remove the handlers if no one else is using them */ if (--fs_handlers_installed == 0) { - +#ifdef XFONT2 + RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)block_handler, FontWakeup, + (pointer) 0); +#else RemoveBlockAndWakeupHandlers(block_handler, FontWakeup, (pointer) 0); +#endif } } RemoveFontWakeup(fpe); } +#ifdef XFONT2 +static int +register_fpe_funcs(const xfont2_fpe_funcs_rec *funcs) +{ + xfont2_fpe_funcs_rec const **new; + + /* grow the list */ + new = reallocarray(fpe_functions, num_fpe_types + 1, sizeof(xfont2_fpe_funcs_ptr)); + if (!new) + return -1; + fpe_functions = new; + + fpe_functions[num_fpe_types] = funcs; + + return num_fpe_types++; +} + +static unsigned long +get_server_generation(void) +{ + return serverGeneration; +} + +static void * +get_server_client(void) +{ + return serverClient; +} + +static int +add_fs_fd(int fd, FontFdHandlerProcPtr handler, void *data) +{ + return TRUE; +} + +static void +remove_fs_fd(int fd) +{ +} + +/* + * returns the type index of the new fpe + * + * should be called (only once!) by each type of fpe when initialized + */ + +xfont2_pattern_cache_ptr fontPatternCache; + +static const xfont2_client_funcs_rec xfont2_client_funcs = { + .version = XFONT2_CLIENT_FUNCS_VERSION, + .client_auth_generation = _client_auth_generation, + .client_signal = ClientSignal, + .delete_font_client_id = delete_font_client_id, + .verrorf = VErrorF, + .find_old_font = find_old_font, + .get_client_resolutions = get_client_resolutions, + .get_default_point_size = get_default_point_size, + .get_new_font_client_id = get_new_font_client_id, + .get_time_in_millis = wrap_time_in_millis, + .init_fs_handlers = _init_fs_handlers, + .register_fpe_funcs = register_fpe_funcs, + .remove_fs_handlers = _remove_fs_handlers, + .get_server_client = get_server_client, + .set_font_authorizations = set_font_authorizations, + .store_font_client_font = store_font_Client_font, + .make_atom = (Atom (*)(const char *, unsigned int, int))MakeAtom, + .valid_atom = ValidAtom, + .name_for_atom = (const char * (*)(Atom))NameForAtom, + .get_server_generation = get_server_generation, + .add_fs_fd = add_fs_fd, + .remove_fs_fd = remove_fs_fd, + .adjust_fs_wait_for_delay = adjust_fs_wait_for_delay, +}; +#endif + +void +InitFonts() +{ +#ifdef XFONT2 + if (fontPatternCache) + xfont2_free_font_pattern_cache(fontPatternCache); + fontPatternCache = xfont2_make_font_pattern_cache(); + xfont2_init(&xfont2_client_funcs); +#else + patternCache = MakeFontPatternCache(); +#endif + { +#ifdef KDRIVESERVER + BuiltinRegisterFpeFunctions(); +#endif + FontFileRegisterFpeFunctions(); + } +} diff --git a/dix/main.c b/dix/main.c index a2c3a25..4fa3bf8 100644 --- a/dix/main.c +++ b/dix/main.c @@ -292,7 +292,11 @@ main(int argc, char *argv[], char *envp[]) InitAtoms(); InitEvents(); +#ifdef XFONT2 + xfont2_init_glyph_caching(); +#else InitGlyphCaching(); +#endif ResetExtensionPrivates(); ResetClientPrivates(); ResetScreenPrivates(); @@ -300,7 +304,9 @@ main(int argc, char *argv[], char *envp[]) ResetGCPrivates(); ResetPixmapPrivates(); ResetColormapPrivates(); +#ifndef XFONT2 ResetFontPrivateIndex(); +#endif ResetDevicePrivateIndex(); InitCallbackManager(); InitVisualWrap(); diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 121977a..076c559 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -21,6 +21,9 @@ /* Support XDM-AUTH*-1 */ #undef HASXDMAUTH +/* Use libXfont2 */ +#undef XFONT2 + /* Define to 1 if you have the `getdtablesize' function. */ #undef HAS_GETDTABLESIZE diff --git a/include/dixfont.h b/include/dixfont.h index 2ce672f..501614c 100644 --- a/include/dixfont.h +++ b/include/dixfont.h @@ -28,12 +28,17 @@ SOFTWARE. #include #include "closure.h" #include +#ifdef XFONT2 +#include +#endif #define NullDIXFontProp ((DIXFontPropPtr)0) typedef struct _DIXFontProp *DIXFontPropPtr; +#ifndef XFONT2 extern FPEFunctions *fpe_functions; +#endif int FontToXError(int /*err*/); diff --git a/mi/miglblt.c b/mi/miglblt.c index e826162..29d9ff8 100644 --- a/mi/miglblt.c +++ b/mi/miglblt.c @@ -209,7 +209,11 @@ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) unsigned long oldFG; xRectangle backrect; +#ifdef XFONT2 + xfont2_query_glyph_extents(pGC->font, ppci, (unsigned long)nglyph, &info); +#else QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info); +#endif if (info.overallWidth >= 0) { diff --git a/miext/damage/damage.c b/miext/damage/damage.c index 16959aa..8661fbd 100644 --- a/miext/damage/damage.c +++ b/miext/damage/damage.c @@ -1289,7 +1289,11 @@ damageDamageChars(DrawablePtr pDrawable, BoxRec box; +#ifdef XFONT2 + xfont2_query_glyph_extents(font, charinfo, n, &extents); +#else QueryGlyphExtents(font, charinfo, n, &extents); +#endif if (imageblt) { if (extents.overallWidth > extents.overallRight) extents.overallRight = extents.overallWidth; diff --git a/os/utils.c b/os/utils.c index 657a3fa..213dc19 100644 --- a/os/utils.c +++ b/os/utils.c @@ -617,7 +617,11 @@ ProcessCommandLine(int argc, char *argv[]) #endif else if ( strcmp( argv[i], "-deferglyphs") == 0) { +#ifdef XFONT2 + if(++i >= argc || !xfont2_parse_glyph_caching_mode(argv[i])) +#else if(++i >= argc || !ParseGlyphCachingMode(argv[i])) +#endif UseMsg(); } else if ( strcmp( argv[i], "-f") == 0) From e2688ad8f11d9702177379013bcfcf712a947ceb Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Thu, 19 Dec 2024 19:00:57 +0200 Subject: [PATCH 2/6] mend --- Xext/xf86bigfont.c | 5 +- dix/dispatch.c | 5 +- dix/dixfonts.c | 257 ++++++++-------------------------------- dix/main.c | 4 - include/Makefile.am | 2 +- include/dixfont.h | 11 +- include/xfont2_compat.h | 41 +++++++ mi/miglblt.c | 7 +- miext/damage/damage.c | 5 +- os/utils.c | 5 +- 10 files changed, 105 insertions(+), 237 deletions(-) create mode 100644 include/xfont2_compat.h diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index 17286c3..5e68575 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -64,6 +64,7 @@ #include "gcstruct.h" #include "dixfontstr.h" #include "extnsionst.h" +#include "xfont2_compat.h" #define _XF86BIGFONT_SERVER_ #include @@ -179,11 +180,7 @@ XFree86BigfontExtensionInit() + (unsigned int) (65536.0 / (RAND_MAX + 1.0) * rand()); /* fprintf(stderr, "signature = 0x%08X\n", signature); */ -#ifdef XFONT2 - FontShmdescIndex = xfont2_allocate_font_private_index(); -#else FontShmdescIndex = AllocateFontPrivateIndex(); -#endif #if !defined(CSRG_BASED) && !defined(__CYGWIN__) pagesize = SHMLBA; diff --git a/dix/dispatch.c b/dix/dispatch.c index 13a0568..84cc626 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -94,6 +94,7 @@ Equipment Corporation. #include "dispatch.h" #include "swaprep.h" #include "swapreq.h" +#include "xfont2_compat.h" #define mskcnt ((MAXCLIENTS + 31) / 32) #define BITMASK(i) (1U << ((i) & 31)) @@ -1388,11 +1389,7 @@ ProcQueryTextExtents(register ClientPtr client) return (BadLength); length--; } -#ifdef XFONT2 - if (!xfont2_query_text_extents(pFont, length, (unsigned char *) &stuff[1], &info)) -#else if (!QueryTextExtents(pFont, length, (unsigned char *) &stuff[1], &info)) -#endif return (BadAlloc); reply.type = X_Reply; reply.length = 0; diff --git a/dix/dixfonts.c b/dix/dixfonts.c index efd3013..2ca04cb 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -55,12 +55,6 @@ Equipment Corporation. #include #include #include - -#ifdef XFONT2 -#include -#include -#endif - #include "scrnintstr.h" #include "resource.h" #include "dixstruct.h" @@ -69,6 +63,7 @@ Equipment Corporation. #include "opaque.h" #include "dixfontstr.h" #include "closestr.h" +#include "xfont2_compat.h" #ifdef XF86BIGFONT #define _XF86BIGFONT_SERVER_ @@ -78,11 +73,7 @@ Equipment Corporation. #define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics -#ifdef XFONT2 -extern void *fosNaturalParams; -#else extern pointer fosNaturalParams; -#endif extern FontPtr defaultFont; @@ -91,9 +82,10 @@ static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; static int num_fpes = 0; #ifdef XFONT2 -static xfont2_fpe_funcs_rec const **fpe_functions; +_X_EXPORT xfont2_fpe_funcs_rec const **fpe_functions = (xfont2_fpe_funcs_rec const **) 0; #else -_X_EXPORT FPEFunctions *fpe_functions = (FPEFunctions *) 0; +_X_EXPORT FPEFunctions *_fpe_functions = (FPEFunctions *) 0; +_X_EXPORT FPEFunctions **fpe_functions = &_fpe_functions; #endif static int num_fpe_types = 0; @@ -234,7 +226,7 @@ FontWakeup(pointer data, int count, pointer LastSelectMask) #ifdef XFONT2 (void) (*fpe_functions[fpe->type]->wakeup_fpe) (fpe); #else - (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask); + (void) (*fpe_functions[fpe->type]->wakeup_fpe) (fpe, LastSelectMask); #endif } } @@ -251,11 +243,7 @@ FreeFPE(FontPathElementPtr fpe) { fpe->refcount--; if (fpe->refcount == 0) { -#ifdef XFONT2 (*fpe_functions[fpe->type]->free_fpe) (fpe); -#else - (*fpe_functions[fpe->type].free_fpe) (fpe); -#endif free(fpe->name); free(fpe); } @@ -306,22 +294,14 @@ doOpenFont(ClientPtr client, OFclosurePtr c) if (client->clientGone) { if (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif } err = Successful; goto bail; } while (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->open_font) -#else - err = (*fpe_functions[fpe->type].open_font) -#endif ((pointer) client, fpe, c->flags, c->fontname, c->fnamelen, FontFormat, BitmapFormatMaskByte | @@ -390,13 +370,8 @@ doOpenFont(ClientPtr client, OFclosurePtr c) goto bail; } if (patternCache && pfont != c->non_cachable_font) -#ifdef XFONT2 - xfont2_cache_font_pattern(patternCache, c->origFontName, c->origFontNameLen, - pfont); -#else CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen, pfont); -#endif bail: if (err != Successful && c->client != serverClient) { SendErrorToClient(c->client, X_OpenFont, 0, @@ -453,11 +428,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, ** having to create another instance of a font that already exists. */ -#ifdef XFONT2 - cached = xfont2_find_cached_font_pattern(patternCache, pfontname, lenfname); -#else cached = FindCachedFontPattern(patternCache, pfontname, lenfname); -#endif if (cached && cached->info.cachable) { if (!AddResource(fid, RT_FONT, (pointer) cached)) return BadAlloc; @@ -524,11 +495,7 @@ CloseFont(pointer value, XID fid) return (Success); if (--pfont->refcnt == 0) { if (patternCache) -#ifdef XFONT2 - xfont2_remove_cached_font_pattern(patternCache, pfont); -#else RemoveCachedFontPattern(patternCache, pfont); -#endif /* * since the last reference is gone, ask each screen to free any * storage it may have allocated locally for it. @@ -544,11 +511,7 @@ CloseFont(pointer value, XID fid) XF86BigfontFreeFontShm(pfont); #endif fpe = pfont->fpe; -#ifdef XFONT2 (*fpe_functions[fpe->type]->close_font) (fpe, pfont); -#else - (*fpe_functions[fpe->type].close_font) (fpe, pfont); -#endif FreeFPE(fpe); } return (Success); @@ -658,11 +621,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif } // err = Successful; goto bail; @@ -675,18 +634,10 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; -#ifdef XFONT2 if (!fpe_functions[fpe->type]->start_list_fonts_and_aliases) { -#else - if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) { -#endif /* This FPE doesn't support/require list_fonts_and_aliases */ -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->list_fonts) -#else - err = (*fpe_functions[fpe->type].list_fonts) -#endif ((pointer) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, c->names); @@ -714,11 +665,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) the FPEs. */ if (!c->current.list_started) { -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->start_list_fonts_and_aliases) -#else - err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) -#endif ((pointer) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, &c->current.private); @@ -738,11 +685,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) char *tmpname; name = 0; -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->list_next_font_or_alias) -#else - err = (*fpe_functions[fpe->type].list_next_font_or_alias) -#endif ((pointer) c->client, fpe, &name, &namelen, &tmpname, &resolvedlen, c->current.private); if (err == Suspended) { @@ -766,20 +709,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (err == Successful) { if (c->haveSaved) { if (c->savedName) -#ifdef XFONT2 - (void) xfont2_add_font_names_name(c->names, c->savedName, - c->savedNameLen); -#else (void) AddFontNamesName(c->names, c->savedName, c->savedNameLen); -#endif } else -#ifdef XFONT2 - (void) xfont2_add_font_names_name(c->names, name, namelen); -#else (void) AddFontNamesName(c->names, name, namelen); -#endif } /* @@ -805,11 +739,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) int tmpnamelen; tmpname = 0; -#ifdef XFONT2 (void) (*fpe_functions[fpe->type]->list_next_font_or_alias) -#else - (void) (*fpe_functions[fpe->type].list_next_font_or_alias) -#endif ((pointer) c->client, fpe, &tmpname, &tmpnamelen, &tmpname, &tmpnamelen, c->current.private); if (--aliascount <= 0) { @@ -917,11 +847,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) free(c->fpe_list); if (c->savedName) free(c->savedName); -#ifdef XFONT2 - xfont2_free_font_names(names); -#else FreeFontNames(names); -#endif free(c); if (resolved) free(resolved); @@ -953,11 +879,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, free(c); return BadAlloc; } -#ifdef XFONT2 - c->names = xfont2_make_font_names_record(max_names < 100 ? max_names : 100); -#else c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100); -#endif if (!c->names) { free(c->fpe_list); free(c); @@ -1012,11 +934,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif } err = Successful; goto bail; @@ -1028,11 +946,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; if (!c->current.list_started) { -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->start_list_fonts_with_info) -#else - err = (*fpe_functions[fpe->type].start_list_fonts_with_info) -#endif (client, fpe, c->current.pattern, c->current.patlen, c->current.max_names, &c->current.private); if (err == Suspended) { @@ -1049,11 +963,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (err == Successful) { name = 0; pFontInfo = &fontInfo; -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->list_next_font_with_info) -#else - err = (*fpe_functions[fpe->type].list_next_font_with_info) -#endif (client, fpe, &name, &namelen, &pFontInfo, &numFonts, c->current.private); if (err == Suspended) { @@ -1087,11 +997,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) tmpname = 0; tmpFontInfo = &fontInfo; -#ifdef XFONT2 - (void) (*fpe_functions[fpe->type]->list_next_font_with_info) -#else - (void) (*fpe_functions[fpe->type].list_next_font_with_info) -#endif + (void) (*fpe_functions[fpe->type]->list_next_font_with_info) (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo, &numFonts, c->current.private); if (--aliascount <= 0) { @@ -1287,11 +1193,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif if (c->slept) { /* Client has died, but we cannot bail out right now. We @@ -1318,11 +1220,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) the FPE code to clean up after client and avoid further rendering while we clean up after ourself. */ fpe = c->pGC->font->fpe; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif c->pDraw = (DrawablePtr) 0; } @@ -1568,11 +1466,7 @@ doImageText(ClientPtr client, register ITclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif err = Success; goto bail; } @@ -1587,11 +1481,7 @@ doImageText(ClientPtr client, register ITclosurePtr c) /* Our drawable has disappeared. Treat like client died... ask the FPE code to clean up after client. */ fpe = c->pGC->font->fpe; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif err = Success; goto bail; } @@ -1723,11 +1613,7 @@ DetermineFPEType(char *pathname) int i; for (i = 0; i < num_fpe_types; i++) { -#ifdef XFONT2 if ((*fpe_functions[i]->name_check) (pathname)) -#else - if ((*fpe_functions[i].name_check) (pathname)) -#endif return i; } return -1; @@ -1795,13 +1681,8 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) return BadAlloc; } for (i = 0; i < num_fpe_types; i++) { -#ifdef XFONT2 if (fpe_functions[i]->set_path_hook) (*fpe_functions[i]->set_path_hook) (); -#else - if (fpe_functions[i].set_path_hook) - (*fpe_functions[i].set_path_hook) (); -#endif } for (i = 0; i < npaths; i++) { len = (unsigned int) (*cp++); @@ -1820,11 +1701,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) */ fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); if (fpe) { -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->reset_fpe) (fpe); -#else - err = (*fpe_functions[fpe->type].reset_fpe) (fpe); -#endif if (err == Successful) { UseFPE(fpe); /* since it'll be decref'd later when freed * from the old list */ @@ -1854,11 +1731,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) if (fpe->type == -1) err = BadValue; else -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->init_fpe) (fpe); -#else - err = (*fpe_functions[fpe->type].init_fpe) (fpe); -#endif if (err != Successful) { if (persist) { ErrorF @@ -1883,11 +1756,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) FreeFontPath(font_path_elements, num_fpes, FALSE); font_path_elements = fplist; if (patternCache) -#ifdef XFONT2 - xfont2_empty_font_pattern_cache(patternCache); -#else EmptyFontPatternCache(patternCache); -#endif num_fpes = valid_paths; return Success; @@ -1988,13 +1857,8 @@ _X_EXPORT int LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data) { -#ifdef XFONT2 if (fpe_functions[pfont->fpe->type]->load_glyphs) return (*fpe_functions[pfont->fpe->type]->load_glyphs) -#else - if (fpe_functions[pfont->fpe->type].load_glyphs) - return (*fpe_functions[pfont->fpe->type].load_glyphs) -#endif (client, pfont, 0, nchars, item_size, data); else return Successful; @@ -2009,15 +1873,25 @@ DeleteClientFontStuff(ClientPtr client) for (i = 0; i < num_fpes; i++) { fpe = font_path_elements[i]; -#ifdef XFONT2 if (fpe_functions[fpe->type]->client_died) (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - if (fpe_functions[fpe->type].client_died) - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + } +} + +#ifndef XFONT2 +void +InitFonts() +{ + patternCache = MakeFontPatternCache(); + + { +#ifdef KDRIVESERVER + BuiltinRegisterFpeFunctions(); #endif + FontFileRegisterFpeFunctions(); } } +#endif #ifdef XFONT2 _X_EXPORT XFONT_LTO @@ -2051,22 +1925,14 @@ _client_auth_generation(ClientPtr client) _X_EXPORT XFONT_LTO int -#ifdef XFONT2 -get_default_point_size() -#else GetDefaultPointSize() -#endif { return 120; } _X_EXPORT XFONT_LTO FontResolutionPtr -#ifdef XFONT2 -get_client_resolutions(int *num) -#else GetClientResolutions(int *num) -#endif { if (requestingClient && requestingClient->fontResFunc != NULL && !requestingClient->clientGone) { @@ -2099,6 +1965,7 @@ GetClientResolutions(int *num) } #ifndef XFONT2 + /* * returns the type index of the new fpe * @@ -2125,49 +1992,47 @@ RegisterFPEFunctions(NameCheckFunc name_func, FPEFunctions *new; /* grow the list */ - new = (FPEFunctions *) realloc(fpe_functions, + new = (FPEFunctions *) realloc(*fpe_functions, (num_fpe_types + 1) * sizeof(FPEFunctions)); if (!new) return -1; - fpe_functions = new; - - fpe_functions[num_fpe_types].name_check = name_func; - fpe_functions[num_fpe_types].open_font = open_func; - fpe_functions[num_fpe_types].close_font = close_func; - fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func; - fpe_functions[num_fpe_types].list_fonts = list_func; - fpe_functions[num_fpe_types].start_list_fonts_with_info = start_lfwi_func; - fpe_functions[num_fpe_types].list_next_font_with_info = next_lfwi_func; - fpe_functions[num_fpe_types].init_fpe = init_func; - fpe_functions[num_fpe_types].free_fpe = free_func; - fpe_functions[num_fpe_types].reset_fpe = reset_func; - fpe_functions[num_fpe_types].client_died = client_died; - fpe_functions[num_fpe_types].load_glyphs = load_glyphs; - fpe_functions[num_fpe_types].start_list_fonts_and_aliases = + *fpe_functions = new; + + fpe_functions[num_fpe_types]->name_check = name_func; + fpe_functions[num_fpe_types]->open_font = open_func; + fpe_functions[num_fpe_types]->close_font = close_func; + fpe_functions[num_fpe_types]->wakeup_fpe = wakeup_func; + fpe_functions[num_fpe_types]->list_fonts = list_func; + fpe_functions[num_fpe_types]->start_list_fonts_with_info = start_lfwi_func; + fpe_functions[num_fpe_types]->list_next_font_with_info = next_lfwi_func; + fpe_functions[num_fpe_types]->init_fpe = init_func; + fpe_functions[num_fpe_types]->free_fpe = free_func; + fpe_functions[num_fpe_types]->reset_fpe = reset_func; + fpe_functions[num_fpe_types]->client_died = client_died; + fpe_functions[num_fpe_types]->load_glyphs = load_glyphs; + fpe_functions[num_fpe_types]->start_list_fonts_and_aliases = start_list_alias_func; - fpe_functions[num_fpe_types].list_next_font_or_alias = next_list_alias_func; - fpe_functions[num_fpe_types].set_path_hook = set_path_func; + fpe_functions[num_fpe_types]->list_next_font_or_alias = next_list_alias_func; + fpe_functions[num_fpe_types]->set_path_hook = set_path_func; return num_fpe_types++; } + #endif + void FreeFonts() { if (patternCache) { -#ifdef XFONT2 - xfont2_free_font_pattern_cache(patternCache); -#else FreeFontPatternCache(patternCache); -#endif patternCache = 0; } FreeFontPath(font_path_elements, num_fpes, TRUE); font_path_elements = 0; num_fpes = 0; - free(fpe_functions); + free((pointer)*fpe_functions); num_fpe_types = 0; - fpe_functions = NULL; + *fpe_functions = (pointer) 0; } #ifdef XFONT2 @@ -2185,6 +2050,7 @@ find_old_font(XID id) return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, SecurityUnknownAccess); } + #ifndef XFONT2 _X_EXPORT XFONT_LTO Font @@ -2229,11 +2095,7 @@ adjust_fs_wait_for_delay(void *wt, unsigned long newdelay) _X_EXPORT XFONT_LTO int -#ifdef XFONT2 -_init_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler) -#else init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) -#endif { /* if server has reset, make sure the b&w handlers are reinstalled */ if (last_server_gen < serverGeneration) { @@ -2242,13 +2104,9 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) } if (fs_handlers_installed == 0) { -#ifdef XFONT2 + if (!RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)block_handler, FontWakeup, (pointer) 0)) -#else - if (!RegisterBlockAndWakeupHandlers(block_handler, - FontWakeup, (pointer) 0)) -#endif return AllocError; fs_handlers_installed++; } @@ -2258,25 +2116,16 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) _X_EXPORT XFONT_LTO void -#ifdef XFONT2 -_remove_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler, - Bool all) -#else remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) -#endif { if (all) { /* remove the handlers if no one else is using them */ if (--fs_handlers_installed == 0) { -#ifdef XFONT2 - RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)block_handler, FontWakeup, - (pointer) 0); -#else + RemoveBlockAndWakeupHandlers(block_handler, FontWakeup, (pointer) 0); -#endif } } RemoveFontWakeup(fpe); @@ -2337,13 +2186,13 @@ static const xfont2_client_funcs_rec xfont2_client_funcs = { .delete_font_client_id = delete_font_client_id, .verrorf = VErrorF, .find_old_font = find_old_font, - .get_client_resolutions = get_client_resolutions, - .get_default_point_size = get_default_point_size, + .get_client_resolutions = GetClientResolutions, + .get_default_point_size = GetDefaultPointSize, .get_new_font_client_id = get_new_font_client_id, .get_time_in_millis = wrap_time_in_millis, - .init_fs_handlers = _init_fs_handlers, + .init_fs_handlers = (int (*)(FontPathElementPtr, FontBlockHandlerProcPtr))init_fs_handlers, .register_fpe_funcs = register_fpe_funcs, - .remove_fs_handlers = _remove_fs_handlers, + .remove_fs_handlers = (void (*)(FontPathElementPtr, FontBlockHandlerProcPtr, Bool))remove_fs_handlers, .get_server_client = get_server_client, .set_font_authorizations = set_font_authorizations, .store_font_client_font = store_font_Client_font, @@ -2355,19 +2204,14 @@ static const xfont2_client_funcs_rec xfont2_client_funcs = { .remove_fs_fd = remove_fs_fd, .adjust_fs_wait_for_delay = adjust_fs_wait_for_delay, }; -#endif void InitFonts() { -#ifdef XFONT2 if (fontPatternCache) xfont2_free_font_pattern_cache(fontPatternCache); fontPatternCache = xfont2_make_font_pattern_cache(); xfont2_init(&xfont2_client_funcs); -#else - patternCache = MakeFontPatternCache(); -#endif { #ifdef KDRIVESERVER BuiltinRegisterFpeFunctions(); @@ -2375,3 +2219,4 @@ InitFonts() FontFileRegisterFpeFunctions(); } } +#endif diff --git a/dix/main.c b/dix/main.c index 4fa3bf8..1159061 100644 --- a/dix/main.c +++ b/dix/main.c @@ -292,11 +292,7 @@ main(int argc, char *argv[], char *envp[]) InitAtoms(); InitEvents(); -#ifdef XFONT2 - xfont2_init_glyph_caching(); -#else InitGlyphCaching(); -#endif ResetExtensionPrivates(); ResetClientPrivates(); ResetScreenPrivates(); diff --git a/include/Makefile.am b/include/Makefile.am index e010e5a..8f7beea 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -9,4 +9,4 @@ EXTRA_DIST = do-not-use-config.h dix-config.h \ misc.h miscstruct.h opaque.h os.h pixmap.h \ pixmapstr.h property.h propertyst.h region.h regionstr.h resource.h \ screenint.h scrnintstr.h selection.h servermd.h site.h \ - swaprep.h swapreq.h validate.h window.h windowstr.h + swaprep.h swapreq.h validate.h window.h windowstr.h xfont2_compat.h diff --git a/include/dixfont.h b/include/dixfont.h index 501614c..8bd2c55 100644 --- a/include/dixfont.h +++ b/include/dixfont.h @@ -28,18 +28,19 @@ SOFTWARE. #include #include "closure.h" #include -#ifdef XFONT2 -#include -#endif +#include "xfont2_compat.h" #define NullDIXFontProp ((DIXFontPropPtr)0) typedef struct _DIXFontProp *DIXFontPropPtr; -#ifndef XFONT2 -extern FPEFunctions *fpe_functions; +#ifdef XFONT2 +extern xfont2_fpe_funcs_rec const **fpe_functions; +#else +extern FPEFunctions **fpe_functions; #endif + int FontToXError(int /*err*/); Bool SetDefaultFont(char * /*defaultfontname*/); diff --git a/include/xfont2_compat.h b/include/xfont2_compat.h new file mode 100644 index 0000000..299389d --- /dev/null +++ b/include/xfont2_compat.h @@ -0,0 +1,41 @@ +#ifdef XFONT2 +#include +#include +#endif + +/* for Xext/xf86bigfont.c */ +#ifdef XFONT2 +#define AllocateFontPrivateIndex xfont2_allocate_font_private_index +#endif + +/* for dix/dispatch.c */ +#ifdef XFONT2 +#define QueryTextExtents xfont2_query_text_extents +#endif + +/* for dix/main.c */ +#ifdef XFONT2 +#define InitGlyphCaching xfont2_init_glyph_caching +#endif + +/* for mi/miglbt.c and miext/damage/damage.c */ +#ifdef XFONT2 +#define QueryGlyphExtents xfont2_query_glyph_extents +#endif + +/* for os/utils.c */ +#ifdef XFONT2 +#define ParseGlyphCachingMode xfont2_parse_glyph_caching_mode +#endif + +/* for dix/dixfonts.c */ +#ifdef XFONT2 +#define CacheFontPattern xfont2_cache_font_pattern +#define FindCachedFontPattern xfont2_find_cached_font_pattern +#define RemoveCachedFontPattern xfont2_remove_cached_font_pattern +#define AddFontNamesName xfont2_add_font_names_name +#define FreeFontNames xfont2_free_font_names +#define MakeFontNamesRecord xfont2_make_font_names_record +#define EmptyFontPatternCache xfont2_empty_font_pattern_cache +#define FreeFontPatternCache xfont2_free_font_pattern_cache +#endif diff --git a/mi/miglblt.c b/mi/miglblt.c index 29d9ff8..88b4537 100644 --- a/mi/miglblt.c +++ b/mi/miglblt.c @@ -61,7 +61,8 @@ SOFTWARE. #include "scrnintstr.h" #include "pixmap.h" #include "servermd.h" -#include "mi.h" +#include "mi.h" +#include "xfont2_compat.h" /* machine-independent glyph blt. @@ -209,11 +210,7 @@ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) unsigned long oldFG; xRectangle backrect; -#ifdef XFONT2 - xfont2_query_glyph_extents(pGC->font, ppci, (unsigned long)nglyph, &info); -#else QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info); -#endif if (info.overallWidth >= 0) { diff --git a/miext/damage/damage.c b/miext/damage/damage.c index 8661fbd..2452775 100644 --- a/miext/damage/damage.c +++ b/miext/damage/damage.c @@ -39,6 +39,7 @@ #include "gcstruct.h" #include "damage.h" #include "damagestr.h" +#include "xfont2_compat.h" #define wrap(priv, real, mem, func) {\ priv->mem = real->mem; \ @@ -1289,11 +1290,7 @@ damageDamageChars(DrawablePtr pDrawable, BoxRec box; -#ifdef XFONT2 - xfont2_query_glyph_extents(font, charinfo, n, &extents); -#else QueryGlyphExtents(font, charinfo, n, &extents); -#endif if (imageblt) { if (extents.overallWidth > extents.overallRight) extents.overallRight = extents.overallWidth; diff --git a/os/utils.c b/os/utils.c index 213dc19..c750949 100644 --- a/os/utils.c +++ b/os/utils.c @@ -101,6 +101,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #include "picture.h" +#include "xfont2_compat.h" _X_EXPORT Bool noTestExtensions; _X_EXPORT Bool noBigReqExtension = FALSE; @@ -617,11 +618,7 @@ ProcessCommandLine(int argc, char *argv[]) #endif else if ( strcmp( argv[i], "-deferglyphs") == 0) { -#ifdef XFONT2 - if(++i >= argc || !xfont2_parse_glyph_caching_mode(argv[i])) -#else if(++i >= argc || !ParseGlyphCachingMode(argv[i])) -#endif UseMsg(); } else if ( strcmp( argv[i], "-f") == 0) From 98d07534b6c1dfc9577b0b8779ac42f88f750324 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Thu, 19 Dec 2024 22:18:43 +0200 Subject: [PATCH 3/6] revert last commit --- Xext/xf86bigfont.c | 5 +- dix/dispatch.c | 5 +- dix/dixfonts.c | 257 ++++++++++++++++++++++++++++++++-------- dix/main.c | 4 + include/Makefile.am | 2 +- include/dixfont.h | 11 +- include/xfont2_compat.h | 41 ------- mi/miglblt.c | 7 +- miext/damage/damage.c | 5 +- os/utils.c | 5 +- 10 files changed, 237 insertions(+), 105 deletions(-) delete mode 100644 include/xfont2_compat.h diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index 5e68575..17286c3 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -64,7 +64,6 @@ #include "gcstruct.h" #include "dixfontstr.h" #include "extnsionst.h" -#include "xfont2_compat.h" #define _XF86BIGFONT_SERVER_ #include @@ -180,7 +179,11 @@ XFree86BigfontExtensionInit() + (unsigned int) (65536.0 / (RAND_MAX + 1.0) * rand()); /* fprintf(stderr, "signature = 0x%08X\n", signature); */ +#ifdef XFONT2 + FontShmdescIndex = xfont2_allocate_font_private_index(); +#else FontShmdescIndex = AllocateFontPrivateIndex(); +#endif #if !defined(CSRG_BASED) && !defined(__CYGWIN__) pagesize = SHMLBA; diff --git a/dix/dispatch.c b/dix/dispatch.c index 84cc626..13a0568 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -94,7 +94,6 @@ Equipment Corporation. #include "dispatch.h" #include "swaprep.h" #include "swapreq.h" -#include "xfont2_compat.h" #define mskcnt ((MAXCLIENTS + 31) / 32) #define BITMASK(i) (1U << ((i) & 31)) @@ -1389,7 +1388,11 @@ ProcQueryTextExtents(register ClientPtr client) return (BadLength); length--; } +#ifdef XFONT2 + if (!xfont2_query_text_extents(pFont, length, (unsigned char *) &stuff[1], &info)) +#else if (!QueryTextExtents(pFont, length, (unsigned char *) &stuff[1], &info)) +#endif return (BadAlloc); reply.type = X_Reply; reply.length = 0; diff --git a/dix/dixfonts.c b/dix/dixfonts.c index 2ca04cb..efd3013 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -55,6 +55,12 @@ Equipment Corporation. #include #include #include + +#ifdef XFONT2 +#include +#include +#endif + #include "scrnintstr.h" #include "resource.h" #include "dixstruct.h" @@ -63,7 +69,6 @@ Equipment Corporation. #include "opaque.h" #include "dixfontstr.h" #include "closestr.h" -#include "xfont2_compat.h" #ifdef XF86BIGFONT #define _XF86BIGFONT_SERVER_ @@ -73,7 +78,11 @@ Equipment Corporation. #define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics +#ifdef XFONT2 +extern void *fosNaturalParams; +#else extern pointer fosNaturalParams; +#endif extern FontPtr defaultFont; @@ -82,10 +91,9 @@ static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; static int num_fpes = 0; #ifdef XFONT2 -_X_EXPORT xfont2_fpe_funcs_rec const **fpe_functions = (xfont2_fpe_funcs_rec const **) 0; +static xfont2_fpe_funcs_rec const **fpe_functions; #else -_X_EXPORT FPEFunctions *_fpe_functions = (FPEFunctions *) 0; -_X_EXPORT FPEFunctions **fpe_functions = &_fpe_functions; +_X_EXPORT FPEFunctions *fpe_functions = (FPEFunctions *) 0; #endif static int num_fpe_types = 0; @@ -226,7 +234,7 @@ FontWakeup(pointer data, int count, pointer LastSelectMask) #ifdef XFONT2 (void) (*fpe_functions[fpe->type]->wakeup_fpe) (fpe); #else - (void) (*fpe_functions[fpe->type]->wakeup_fpe) (fpe, LastSelectMask); + (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask); #endif } } @@ -243,7 +251,11 @@ FreeFPE(FontPathElementPtr fpe) { fpe->refcount--; if (fpe->refcount == 0) { +#ifdef XFONT2 (*fpe_functions[fpe->type]->free_fpe) (fpe); +#else + (*fpe_functions[fpe->type].free_fpe) (fpe); +#endif free(fpe->name); free(fpe); } @@ -294,14 +306,22 @@ doOpenFont(ClientPtr client, OFclosurePtr c) if (client->clientGone) { if (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; +#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif } err = Successful; goto bail; } while (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; +#ifdef XFONT2 err = (*fpe_functions[fpe->type]->open_font) +#else + err = (*fpe_functions[fpe->type].open_font) +#endif ((pointer) client, fpe, c->flags, c->fontname, c->fnamelen, FontFormat, BitmapFormatMaskByte | @@ -370,8 +390,13 @@ doOpenFont(ClientPtr client, OFclosurePtr c) goto bail; } if (patternCache && pfont != c->non_cachable_font) +#ifdef XFONT2 + xfont2_cache_font_pattern(patternCache, c->origFontName, c->origFontNameLen, + pfont); +#else CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen, pfont); +#endif bail: if (err != Successful && c->client != serverClient) { SendErrorToClient(c->client, X_OpenFont, 0, @@ -428,7 +453,11 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, ** having to create another instance of a font that already exists. */ +#ifdef XFONT2 + cached = xfont2_find_cached_font_pattern(patternCache, pfontname, lenfname); +#else cached = FindCachedFontPattern(patternCache, pfontname, lenfname); +#endif if (cached && cached->info.cachable) { if (!AddResource(fid, RT_FONT, (pointer) cached)) return BadAlloc; @@ -495,7 +524,11 @@ CloseFont(pointer value, XID fid) return (Success); if (--pfont->refcnt == 0) { if (patternCache) +#ifdef XFONT2 + xfont2_remove_cached_font_pattern(patternCache, pfont); +#else RemoveCachedFontPattern(patternCache, pfont); +#endif /* * since the last reference is gone, ask each screen to free any * storage it may have allocated locally for it. @@ -511,7 +544,11 @@ CloseFont(pointer value, XID fid) XF86BigfontFreeFontShm(pfont); #endif fpe = pfont->fpe; +#ifdef XFONT2 (*fpe_functions[fpe->type]->close_font) (fpe, pfont); +#else + (*fpe_functions[fpe->type].close_font) (fpe, pfont); +#endif FreeFPE(fpe); } return (Success); @@ -621,7 +658,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; +#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif } // err = Successful; goto bail; @@ -634,10 +675,18 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; +#ifdef XFONT2 if (!fpe_functions[fpe->type]->start_list_fonts_and_aliases) { +#else + if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) { +#endif /* This FPE doesn't support/require list_fonts_and_aliases */ +#ifdef XFONT2 err = (*fpe_functions[fpe->type]->list_fonts) +#else + err = (*fpe_functions[fpe->type].list_fonts) +#endif ((pointer) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, c->names); @@ -665,7 +714,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) the FPEs. */ if (!c->current.list_started) { +#ifdef XFONT2 err = (*fpe_functions[fpe->type]->start_list_fonts_and_aliases) +#else + err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) +#endif ((pointer) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, &c->current.private); @@ -685,7 +738,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) char *tmpname; name = 0; +#ifdef XFONT2 err = (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else + err = (*fpe_functions[fpe->type].list_next_font_or_alias) +#endif ((pointer) c->client, fpe, &name, &namelen, &tmpname, &resolvedlen, c->current.private); if (err == Suspended) { @@ -709,11 +766,20 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (err == Successful) { if (c->haveSaved) { if (c->savedName) +#ifdef XFONT2 + (void) xfont2_add_font_names_name(c->names, c->savedName, + c->savedNameLen); +#else (void) AddFontNamesName(c->names, c->savedName, c->savedNameLen); +#endif } else +#ifdef XFONT2 + (void) xfont2_add_font_names_name(c->names, name, namelen); +#else (void) AddFontNamesName(c->names, name, namelen); +#endif } /* @@ -739,7 +805,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) int tmpnamelen; tmpname = 0; +#ifdef XFONT2 (void) (*fpe_functions[fpe->type]->list_next_font_or_alias) +#else + (void) (*fpe_functions[fpe->type].list_next_font_or_alias) +#endif ((pointer) c->client, fpe, &tmpname, &tmpnamelen, &tmpname, &tmpnamelen, c->current.private); if (--aliascount <= 0) { @@ -847,7 +917,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) free(c->fpe_list); if (c->savedName) free(c->savedName); +#ifdef XFONT2 + xfont2_free_font_names(names); +#else FreeFontNames(names); +#endif free(c); if (resolved) free(resolved); @@ -879,7 +953,11 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, free(c); return BadAlloc; } +#ifdef XFONT2 + c->names = xfont2_make_font_names_record(max_names < 100 ? max_names : 100); +#else c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100); +#endif if (!c->names) { free(c->fpe_list); free(c); @@ -934,7 +1012,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; +#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif } err = Successful; goto bail; @@ -946,7 +1028,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; if (!c->current.list_started) { +#ifdef XFONT2 err = (*fpe_functions[fpe->type]->start_list_fonts_with_info) +#else + err = (*fpe_functions[fpe->type].start_list_fonts_with_info) +#endif (client, fpe, c->current.pattern, c->current.patlen, c->current.max_names, &c->current.private); if (err == Suspended) { @@ -963,7 +1049,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (err == Successful) { name = 0; pFontInfo = &fontInfo; +#ifdef XFONT2 err = (*fpe_functions[fpe->type]->list_next_font_with_info) +#else + err = (*fpe_functions[fpe->type].list_next_font_with_info) +#endif (client, fpe, &name, &namelen, &pFontInfo, &numFonts, c->current.private); if (err == Suspended) { @@ -997,7 +1087,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) tmpname = 0; tmpFontInfo = &fontInfo; - (void) (*fpe_functions[fpe->type]->list_next_font_with_info) +#ifdef XFONT2 + (void) (*fpe_functions[fpe->type]->list_next_font_with_info) +#else + (void) (*fpe_functions[fpe->type].list_next_font_with_info) +#endif (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo, &numFonts, c->current.private); if (--aliascount <= 0) { @@ -1193,7 +1287,11 @@ doPolyText(ClientPtr client, register PTclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; +#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif if (c->slept) { /* Client has died, but we cannot bail out right now. We @@ -1220,7 +1318,11 @@ doPolyText(ClientPtr client, register PTclosurePtr c) the FPE code to clean up after client and avoid further rendering while we clean up after ourself. */ fpe = c->pGC->font->fpe; +#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif c->pDraw = (DrawablePtr) 0; } @@ -1466,7 +1568,11 @@ doImageText(ClientPtr client, register ITclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; +#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif err = Success; goto bail; } @@ -1481,7 +1587,11 @@ doImageText(ClientPtr client, register ITclosurePtr c) /* Our drawable has disappeared. Treat like client died... ask the FPE code to clean up after client. */ fpe = c->pGC->font->fpe; +#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); +#else + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); +#endif err = Success; goto bail; } @@ -1613,7 +1723,11 @@ DetermineFPEType(char *pathname) int i; for (i = 0; i < num_fpe_types; i++) { +#ifdef XFONT2 if ((*fpe_functions[i]->name_check) (pathname)) +#else + if ((*fpe_functions[i].name_check) (pathname)) +#endif return i; } return -1; @@ -1681,8 +1795,13 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) return BadAlloc; } for (i = 0; i < num_fpe_types; i++) { +#ifdef XFONT2 if (fpe_functions[i]->set_path_hook) (*fpe_functions[i]->set_path_hook) (); +#else + if (fpe_functions[i].set_path_hook) + (*fpe_functions[i].set_path_hook) (); +#endif } for (i = 0; i < npaths; i++) { len = (unsigned int) (*cp++); @@ -1701,7 +1820,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) */ fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); if (fpe) { +#ifdef XFONT2 err = (*fpe_functions[fpe->type]->reset_fpe) (fpe); +#else + err = (*fpe_functions[fpe->type].reset_fpe) (fpe); +#endif if (err == Successful) { UseFPE(fpe); /* since it'll be decref'd later when freed * from the old list */ @@ -1731,7 +1854,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) if (fpe->type == -1) err = BadValue; else +#ifdef XFONT2 err = (*fpe_functions[fpe->type]->init_fpe) (fpe); +#else + err = (*fpe_functions[fpe->type].init_fpe) (fpe); +#endif if (err != Successful) { if (persist) { ErrorF @@ -1756,7 +1883,11 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) FreeFontPath(font_path_elements, num_fpes, FALSE); font_path_elements = fplist; if (patternCache) +#ifdef XFONT2 + xfont2_empty_font_pattern_cache(patternCache); +#else EmptyFontPatternCache(patternCache); +#endif num_fpes = valid_paths; return Success; @@ -1857,8 +1988,13 @@ _X_EXPORT int LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data) { +#ifdef XFONT2 if (fpe_functions[pfont->fpe->type]->load_glyphs) return (*fpe_functions[pfont->fpe->type]->load_glyphs) +#else + if (fpe_functions[pfont->fpe->type].load_glyphs) + return (*fpe_functions[pfont->fpe->type].load_glyphs) +#endif (client, pfont, 0, nchars, item_size, data); else return Successful; @@ -1873,25 +2009,15 @@ DeleteClientFontStuff(ClientPtr client) for (i = 0; i < num_fpes; i++) { fpe = font_path_elements[i]; +#ifdef XFONT2 if (fpe_functions[fpe->type]->client_died) (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); - } -} - -#ifndef XFONT2 -void -InitFonts() -{ - patternCache = MakeFontPatternCache(); - - { -#ifdef KDRIVESERVER - BuiltinRegisterFpeFunctions(); +#else + if (fpe_functions[fpe->type].client_died) + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); #endif - FontFileRegisterFpeFunctions(); } } -#endif #ifdef XFONT2 _X_EXPORT XFONT_LTO @@ -1925,14 +2051,22 @@ _client_auth_generation(ClientPtr client) _X_EXPORT XFONT_LTO int +#ifdef XFONT2 +get_default_point_size() +#else GetDefaultPointSize() +#endif { return 120; } _X_EXPORT XFONT_LTO FontResolutionPtr +#ifdef XFONT2 +get_client_resolutions(int *num) +#else GetClientResolutions(int *num) +#endif { if (requestingClient && requestingClient->fontResFunc != NULL && !requestingClient->clientGone) { @@ -1965,7 +2099,6 @@ GetClientResolutions(int *num) } #ifndef XFONT2 - /* * returns the type index of the new fpe * @@ -1992,47 +2125,49 @@ RegisterFPEFunctions(NameCheckFunc name_func, FPEFunctions *new; /* grow the list */ - new = (FPEFunctions *) realloc(*fpe_functions, + new = (FPEFunctions *) realloc(fpe_functions, (num_fpe_types + 1) * sizeof(FPEFunctions)); if (!new) return -1; - *fpe_functions = new; - - fpe_functions[num_fpe_types]->name_check = name_func; - fpe_functions[num_fpe_types]->open_font = open_func; - fpe_functions[num_fpe_types]->close_font = close_func; - fpe_functions[num_fpe_types]->wakeup_fpe = wakeup_func; - fpe_functions[num_fpe_types]->list_fonts = list_func; - fpe_functions[num_fpe_types]->start_list_fonts_with_info = start_lfwi_func; - fpe_functions[num_fpe_types]->list_next_font_with_info = next_lfwi_func; - fpe_functions[num_fpe_types]->init_fpe = init_func; - fpe_functions[num_fpe_types]->free_fpe = free_func; - fpe_functions[num_fpe_types]->reset_fpe = reset_func; - fpe_functions[num_fpe_types]->client_died = client_died; - fpe_functions[num_fpe_types]->load_glyphs = load_glyphs; - fpe_functions[num_fpe_types]->start_list_fonts_and_aliases = + fpe_functions = new; + + fpe_functions[num_fpe_types].name_check = name_func; + fpe_functions[num_fpe_types].open_font = open_func; + fpe_functions[num_fpe_types].close_font = close_func; + fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func; + fpe_functions[num_fpe_types].list_fonts = list_func; + fpe_functions[num_fpe_types].start_list_fonts_with_info = start_lfwi_func; + fpe_functions[num_fpe_types].list_next_font_with_info = next_lfwi_func; + fpe_functions[num_fpe_types].init_fpe = init_func; + fpe_functions[num_fpe_types].free_fpe = free_func; + fpe_functions[num_fpe_types].reset_fpe = reset_func; + fpe_functions[num_fpe_types].client_died = client_died; + fpe_functions[num_fpe_types].load_glyphs = load_glyphs; + fpe_functions[num_fpe_types].start_list_fonts_and_aliases = start_list_alias_func; - fpe_functions[num_fpe_types]->list_next_font_or_alias = next_list_alias_func; - fpe_functions[num_fpe_types]->set_path_hook = set_path_func; + fpe_functions[num_fpe_types].list_next_font_or_alias = next_list_alias_func; + fpe_functions[num_fpe_types].set_path_hook = set_path_func; return num_fpe_types++; } - #endif - void FreeFonts() { if (patternCache) { +#ifdef XFONT2 + xfont2_free_font_pattern_cache(patternCache); +#else FreeFontPatternCache(patternCache); +#endif patternCache = 0; } FreeFontPath(font_path_elements, num_fpes, TRUE); font_path_elements = 0; num_fpes = 0; - free((pointer)*fpe_functions); + free(fpe_functions); num_fpe_types = 0; - *fpe_functions = (pointer) 0; + fpe_functions = NULL; } #ifdef XFONT2 @@ -2050,7 +2185,6 @@ find_old_font(XID id) return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, SecurityUnknownAccess); } - #ifndef XFONT2 _X_EXPORT XFONT_LTO Font @@ -2095,7 +2229,11 @@ adjust_fs_wait_for_delay(void *wt, unsigned long newdelay) _X_EXPORT XFONT_LTO int +#ifdef XFONT2 +_init_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler) +#else init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) +#endif { /* if server has reset, make sure the b&w handlers are reinstalled */ if (last_server_gen < serverGeneration) { @@ -2104,9 +2242,13 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) } if (fs_handlers_installed == 0) { - +#ifdef XFONT2 if (!RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)block_handler, FontWakeup, (pointer) 0)) +#else + if (!RegisterBlockAndWakeupHandlers(block_handler, + FontWakeup, (pointer) 0)) +#endif return AllocError; fs_handlers_installed++; } @@ -2116,16 +2258,25 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) _X_EXPORT XFONT_LTO void +#ifdef XFONT2 +_remove_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler, + Bool all) +#else remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) +#endif { if (all) { /* remove the handlers if no one else is using them */ if (--fs_handlers_installed == 0) { - +#ifdef XFONT2 + RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)block_handler, FontWakeup, + (pointer) 0); +#else RemoveBlockAndWakeupHandlers(block_handler, FontWakeup, (pointer) 0); +#endif } } RemoveFontWakeup(fpe); @@ -2186,13 +2337,13 @@ static const xfont2_client_funcs_rec xfont2_client_funcs = { .delete_font_client_id = delete_font_client_id, .verrorf = VErrorF, .find_old_font = find_old_font, - .get_client_resolutions = GetClientResolutions, - .get_default_point_size = GetDefaultPointSize, + .get_client_resolutions = get_client_resolutions, + .get_default_point_size = get_default_point_size, .get_new_font_client_id = get_new_font_client_id, .get_time_in_millis = wrap_time_in_millis, - .init_fs_handlers = (int (*)(FontPathElementPtr, FontBlockHandlerProcPtr))init_fs_handlers, + .init_fs_handlers = _init_fs_handlers, .register_fpe_funcs = register_fpe_funcs, - .remove_fs_handlers = (void (*)(FontPathElementPtr, FontBlockHandlerProcPtr, Bool))remove_fs_handlers, + .remove_fs_handlers = _remove_fs_handlers, .get_server_client = get_server_client, .set_font_authorizations = set_font_authorizations, .store_font_client_font = store_font_Client_font, @@ -2204,14 +2355,19 @@ static const xfont2_client_funcs_rec xfont2_client_funcs = { .remove_fs_fd = remove_fs_fd, .adjust_fs_wait_for_delay = adjust_fs_wait_for_delay, }; +#endif void InitFonts() { +#ifdef XFONT2 if (fontPatternCache) xfont2_free_font_pattern_cache(fontPatternCache); fontPatternCache = xfont2_make_font_pattern_cache(); xfont2_init(&xfont2_client_funcs); +#else + patternCache = MakeFontPatternCache(); +#endif { #ifdef KDRIVESERVER BuiltinRegisterFpeFunctions(); @@ -2219,4 +2375,3 @@ InitFonts() FontFileRegisterFpeFunctions(); } } -#endif diff --git a/dix/main.c b/dix/main.c index 1159061..4fa3bf8 100644 --- a/dix/main.c +++ b/dix/main.c @@ -292,7 +292,11 @@ main(int argc, char *argv[], char *envp[]) InitAtoms(); InitEvents(); +#ifdef XFONT2 + xfont2_init_glyph_caching(); +#else InitGlyphCaching(); +#endif ResetExtensionPrivates(); ResetClientPrivates(); ResetScreenPrivates(); diff --git a/include/Makefile.am b/include/Makefile.am index 8f7beea..e010e5a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -9,4 +9,4 @@ EXTRA_DIST = do-not-use-config.h dix-config.h \ misc.h miscstruct.h opaque.h os.h pixmap.h \ pixmapstr.h property.h propertyst.h region.h regionstr.h resource.h \ screenint.h scrnintstr.h selection.h servermd.h site.h \ - swaprep.h swapreq.h validate.h window.h windowstr.h xfont2_compat.h + swaprep.h swapreq.h validate.h window.h windowstr.h diff --git a/include/dixfont.h b/include/dixfont.h index 8bd2c55..501614c 100644 --- a/include/dixfont.h +++ b/include/dixfont.h @@ -28,19 +28,18 @@ SOFTWARE. #include #include "closure.h" #include -#include "xfont2_compat.h" +#ifdef XFONT2 +#include +#endif #define NullDIXFontProp ((DIXFontPropPtr)0) typedef struct _DIXFontProp *DIXFontPropPtr; -#ifdef XFONT2 -extern xfont2_fpe_funcs_rec const **fpe_functions; -#else -extern FPEFunctions **fpe_functions; +#ifndef XFONT2 +extern FPEFunctions *fpe_functions; #endif - int FontToXError(int /*err*/); Bool SetDefaultFont(char * /*defaultfontname*/); diff --git a/include/xfont2_compat.h b/include/xfont2_compat.h deleted file mode 100644 index 299389d..0000000 --- a/include/xfont2_compat.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifdef XFONT2 -#include -#include -#endif - -/* for Xext/xf86bigfont.c */ -#ifdef XFONT2 -#define AllocateFontPrivateIndex xfont2_allocate_font_private_index -#endif - -/* for dix/dispatch.c */ -#ifdef XFONT2 -#define QueryTextExtents xfont2_query_text_extents -#endif - -/* for dix/main.c */ -#ifdef XFONT2 -#define InitGlyphCaching xfont2_init_glyph_caching -#endif - -/* for mi/miglbt.c and miext/damage/damage.c */ -#ifdef XFONT2 -#define QueryGlyphExtents xfont2_query_glyph_extents -#endif - -/* for os/utils.c */ -#ifdef XFONT2 -#define ParseGlyphCachingMode xfont2_parse_glyph_caching_mode -#endif - -/* for dix/dixfonts.c */ -#ifdef XFONT2 -#define CacheFontPattern xfont2_cache_font_pattern -#define FindCachedFontPattern xfont2_find_cached_font_pattern -#define RemoveCachedFontPattern xfont2_remove_cached_font_pattern -#define AddFontNamesName xfont2_add_font_names_name -#define FreeFontNames xfont2_free_font_names -#define MakeFontNamesRecord xfont2_make_font_names_record -#define EmptyFontPatternCache xfont2_empty_font_pattern_cache -#define FreeFontPatternCache xfont2_free_font_pattern_cache -#endif diff --git a/mi/miglblt.c b/mi/miglblt.c index 88b4537..29d9ff8 100644 --- a/mi/miglblt.c +++ b/mi/miglblt.c @@ -61,8 +61,7 @@ SOFTWARE. #include "scrnintstr.h" #include "pixmap.h" #include "servermd.h" -#include "mi.h" -#include "xfont2_compat.h" +#include "mi.h" /* machine-independent glyph blt. @@ -210,7 +209,11 @@ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) unsigned long oldFG; xRectangle backrect; +#ifdef XFONT2 + xfont2_query_glyph_extents(pGC->font, ppci, (unsigned long)nglyph, &info); +#else QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info); +#endif if (info.overallWidth >= 0) { diff --git a/miext/damage/damage.c b/miext/damage/damage.c index 2452775..8661fbd 100644 --- a/miext/damage/damage.c +++ b/miext/damage/damage.c @@ -39,7 +39,6 @@ #include "gcstruct.h" #include "damage.h" #include "damagestr.h" -#include "xfont2_compat.h" #define wrap(priv, real, mem, func) {\ priv->mem = real->mem; \ @@ -1290,7 +1289,11 @@ damageDamageChars(DrawablePtr pDrawable, BoxRec box; +#ifdef XFONT2 + xfont2_query_glyph_extents(font, charinfo, n, &extents); +#else QueryGlyphExtents(font, charinfo, n, &extents); +#endif if (imageblt) { if (extents.overallWidth > extents.overallRight) extents.overallRight = extents.overallWidth; diff --git a/os/utils.c b/os/utils.c index c750949..213dc19 100644 --- a/os/utils.c +++ b/os/utils.c @@ -101,7 +101,6 @@ OR PERFORMANCE OF THIS SOFTWARE. #include "picture.h" -#include "xfont2_compat.h" _X_EXPORT Bool noTestExtensions; _X_EXPORT Bool noBigReqExtension = FALSE; @@ -618,7 +617,11 @@ ProcessCommandLine(int argc, char *argv[]) #endif else if ( strcmp( argv[i], "-deferglyphs") == 0) { +#ifdef XFONT2 + if(++i >= argc || !xfont2_parse_glyph_caching_mode(argv[i])) +#else if(++i >= argc || !ParseGlyphCachingMode(argv[i])) +#endif UseMsg(); } else if ( strcmp( argv[i], "-f") == 0) From 47c124fa78c77391e01c889606a9349d1969b0ff Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Thu, 19 Dec 2024 22:27:20 +0200 Subject: [PATCH 4/6] begin improving libXfont2 port --- dix/dixfonts.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/dix/dixfonts.c b/dix/dixfonts.c index efd3013..2d453a1 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -2225,15 +2225,19 @@ adjust_fs_wait_for_delay(void *wt, unsigned long newdelay) { AdjustWaitForDelay(wt, newdelay); } + +static void +fs_block_handler(void *blockData, OSTimePtr timeout, void *readmask) +{ + FontBlockHandlerProcPtr block_handler = blockData; + + (*block_handler)(timeout); +} #endif _X_EXPORT XFONT_LTO int -#ifdef XFONT2 -_init_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler) -#else init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) -#endif { /* if server has reset, make sure the b&w handlers are reinstalled */ if (last_server_gen < serverGeneration) { @@ -2243,8 +2247,8 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) if (fs_handlers_installed == 0) { #ifdef XFONT2 - if (!RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)block_handler, - FontWakeup, (pointer) 0)) + if (!RegisterBlockAndWakeupHandlers(fs_block_handler, + FontWakeup, (pointer) block_handler)) #else if (!RegisterBlockAndWakeupHandlers(block_handler, FontWakeup, (pointer) 0)) @@ -2258,21 +2262,16 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) _X_EXPORT XFONT_LTO void -#ifdef XFONT2 -_remove_fs_handlers(FontPathElementPtr fpe, FontBlockHandlerProcPtr block_handler, - Bool all) -#else remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) -#endif { if (all) { /* remove the handlers if no one else is using them */ if (--fs_handlers_installed == 0) { #ifdef XFONT2 - RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)block_handler, FontWakeup, - (pointer) 0); + RemoveBlockAndWakeupHandlers(fs_block_handler, FontWakeup, + (pointer) block_handler); #else RemoveBlockAndWakeupHandlers(block_handler, FontWakeup, (pointer) 0); @@ -2341,9 +2340,9 @@ static const xfont2_client_funcs_rec xfont2_client_funcs = { .get_default_point_size = get_default_point_size, .get_new_font_client_id = get_new_font_client_id, .get_time_in_millis = wrap_time_in_millis, - .init_fs_handlers = _init_fs_handlers, + .init_fs_handlers = (int (*)(FontPathElementPtr, FontBlockHandlerProcPtr))init_fs_handlers, .register_fpe_funcs = register_fpe_funcs, - .remove_fs_handlers = _remove_fs_handlers, + .remove_fs_handlers = (void (*)(FontPathElementPtr, FontBlockHandlerProcPtr, Bool))remove_fs_handlers, .get_server_client = get_server_client, .set_font_authorizations = set_font_authorizations, .store_font_client_font = store_font_Client_font, From 796e4107a49a06456a3d9ec9a8f9a554698750c6 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Thu, 19 Dec 2024 22:40:45 +0200 Subject: [PATCH 5/6] improve libXfont2 port --- Xext/xf86bigfont.c | 5 +---- dix/dispatch.c | 5 +---- dix/main.c | 5 +---- include/Makefile.am | 2 +- include/xfont2_compat.h | 41 +++++++++++++++++++++++++++++++++++++++++ mi/miglblt.c | 7 ++----- miext/damage/damage.c | 5 +---- os/utils.c | 5 +---- 8 files changed, 49 insertions(+), 26 deletions(-) create mode 100644 include/xfont2_compat.h diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index 17286c3..5e68575 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -64,6 +64,7 @@ #include "gcstruct.h" #include "dixfontstr.h" #include "extnsionst.h" +#include "xfont2_compat.h" #define _XF86BIGFONT_SERVER_ #include @@ -179,11 +180,7 @@ XFree86BigfontExtensionInit() + (unsigned int) (65536.0 / (RAND_MAX + 1.0) * rand()); /* fprintf(stderr, "signature = 0x%08X\n", signature); */ -#ifdef XFONT2 - FontShmdescIndex = xfont2_allocate_font_private_index(); -#else FontShmdescIndex = AllocateFontPrivateIndex(); -#endif #if !defined(CSRG_BASED) && !defined(__CYGWIN__) pagesize = SHMLBA; diff --git a/dix/dispatch.c b/dix/dispatch.c index 13a0568..84cc626 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -94,6 +94,7 @@ Equipment Corporation. #include "dispatch.h" #include "swaprep.h" #include "swapreq.h" +#include "xfont2_compat.h" #define mskcnt ((MAXCLIENTS + 31) / 32) #define BITMASK(i) (1U << ((i) & 31)) @@ -1388,11 +1389,7 @@ ProcQueryTextExtents(register ClientPtr client) return (BadLength); length--; } -#ifdef XFONT2 - if (!xfont2_query_text_extents(pFont, length, (unsigned char *) &stuff[1], &info)) -#else if (!QueryTextExtents(pFont, length, (unsigned char *) &stuff[1], &info)) -#endif return (BadAlloc); reply.type = X_Reply; reply.length = 0; diff --git a/dix/main.c b/dix/main.c index 4fa3bf8..03bb9a6 100644 --- a/dix/main.c +++ b/dix/main.c @@ -98,6 +98,7 @@ Equipment Corporation. #include "dixfont.h" #include "extnsionst.h" #include "dixevents.h" /* InitEvents() */ +#include "xfont2_compat.h" #ifdef DPMSExtension #define DPMS_SERVER @@ -292,11 +293,7 @@ main(int argc, char *argv[], char *envp[]) InitAtoms(); InitEvents(); -#ifdef XFONT2 - xfont2_init_glyph_caching(); -#else InitGlyphCaching(); -#endif ResetExtensionPrivates(); ResetClientPrivates(); ResetScreenPrivates(); diff --git a/include/Makefile.am b/include/Makefile.am index e010e5a..c01fdeb 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -9,4 +9,4 @@ EXTRA_DIST = do-not-use-config.h dix-config.h \ misc.h miscstruct.h opaque.h os.h pixmap.h \ pixmapstr.h property.h propertyst.h region.h regionstr.h resource.h \ screenint.h scrnintstr.h selection.h servermd.h site.h \ - swaprep.h swapreq.h validate.h window.h windowstr.h + swaprep.h swapreq.h validate.h window.h windowstr.h xfont2_compat diff --git a/include/xfont2_compat.h b/include/xfont2_compat.h new file mode 100644 index 0000000..299389d --- /dev/null +++ b/include/xfont2_compat.h @@ -0,0 +1,41 @@ +#ifdef XFONT2 +#include +#include +#endif + +/* for Xext/xf86bigfont.c */ +#ifdef XFONT2 +#define AllocateFontPrivateIndex xfont2_allocate_font_private_index +#endif + +/* for dix/dispatch.c */ +#ifdef XFONT2 +#define QueryTextExtents xfont2_query_text_extents +#endif + +/* for dix/main.c */ +#ifdef XFONT2 +#define InitGlyphCaching xfont2_init_glyph_caching +#endif + +/* for mi/miglbt.c and miext/damage/damage.c */ +#ifdef XFONT2 +#define QueryGlyphExtents xfont2_query_glyph_extents +#endif + +/* for os/utils.c */ +#ifdef XFONT2 +#define ParseGlyphCachingMode xfont2_parse_glyph_caching_mode +#endif + +/* for dix/dixfonts.c */ +#ifdef XFONT2 +#define CacheFontPattern xfont2_cache_font_pattern +#define FindCachedFontPattern xfont2_find_cached_font_pattern +#define RemoveCachedFontPattern xfont2_remove_cached_font_pattern +#define AddFontNamesName xfont2_add_font_names_name +#define FreeFontNames xfont2_free_font_names +#define MakeFontNamesRecord xfont2_make_font_names_record +#define EmptyFontPatternCache xfont2_empty_font_pattern_cache +#define FreeFontPatternCache xfont2_free_font_pattern_cache +#endif diff --git a/mi/miglblt.c b/mi/miglblt.c index 29d9ff8..88b4537 100644 --- a/mi/miglblt.c +++ b/mi/miglblt.c @@ -61,7 +61,8 @@ SOFTWARE. #include "scrnintstr.h" #include "pixmap.h" #include "servermd.h" -#include "mi.h" +#include "mi.h" +#include "xfont2_compat.h" /* machine-independent glyph blt. @@ -209,11 +210,7 @@ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) unsigned long oldFG; xRectangle backrect; -#ifdef XFONT2 - xfont2_query_glyph_extents(pGC->font, ppci, (unsigned long)nglyph, &info); -#else QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info); -#endif if (info.overallWidth >= 0) { diff --git a/miext/damage/damage.c b/miext/damage/damage.c index 8661fbd..2452775 100644 --- a/miext/damage/damage.c +++ b/miext/damage/damage.c @@ -39,6 +39,7 @@ #include "gcstruct.h" #include "damage.h" #include "damagestr.h" +#include "xfont2_compat.h" #define wrap(priv, real, mem, func) {\ priv->mem = real->mem; \ @@ -1289,11 +1290,7 @@ damageDamageChars(DrawablePtr pDrawable, BoxRec box; -#ifdef XFONT2 - xfont2_query_glyph_extents(font, charinfo, n, &extents); -#else QueryGlyphExtents(font, charinfo, n, &extents); -#endif if (imageblt) { if (extents.overallWidth > extents.overallRight) extents.overallRight = extents.overallWidth; diff --git a/os/utils.c b/os/utils.c index 213dc19..c750949 100644 --- a/os/utils.c +++ b/os/utils.c @@ -101,6 +101,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #include "picture.h" +#include "xfont2_compat.h" _X_EXPORT Bool noTestExtensions; _X_EXPORT Bool noBigReqExtension = FALSE; @@ -617,11 +618,7 @@ ProcessCommandLine(int argc, char *argv[]) #endif else if ( strcmp( argv[i], "-deferglyphs") == 0) { -#ifdef XFONT2 - if(++i >= argc || !xfont2_parse_glyph_caching_mode(argv[i])) -#else if(++i >= argc || !ParseGlyphCachingMode(argv[i])) -#endif UseMsg(); } else if ( strcmp( argv[i], "-f") == 0) From 8b9fec1b6577fa9af4b2e2b8969d117f6503e9f9 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Thu, 19 Dec 2024 23:04:45 +0200 Subject: [PATCH 6/6] add fixed code --- dix/dixfonts.c | 239 ++++++++++---------------------------------- dix/main.c | 1 - include/Makefile.am | 2 +- include/dixfont.h | 11 +- 4 files changed, 61 insertions(+), 192 deletions(-) diff --git a/dix/dixfonts.c b/dix/dixfonts.c index 2d453a1..2a8af69 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -55,12 +55,6 @@ Equipment Corporation. #include #include #include - -#ifdef XFONT2 -#include -#include -#endif - #include "scrnintstr.h" #include "resource.h" #include "dixstruct.h" @@ -69,6 +63,7 @@ Equipment Corporation. #include "opaque.h" #include "dixfontstr.h" #include "closestr.h" +#include "xfont2_compat.h" #ifdef XF86BIGFONT #define _XF86BIGFONT_SERVER_ @@ -78,11 +73,7 @@ Equipment Corporation. #define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics -#ifdef XFONT2 -extern void *fosNaturalParams; -#else extern pointer fosNaturalParams; -#endif extern FontPtr defaultFont; @@ -91,9 +82,10 @@ static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; static int num_fpes = 0; #ifdef XFONT2 -static xfont2_fpe_funcs_rec const **fpe_functions; +_X_EXPORT xfont2_fpe_funcs_rec const **fpe_functions = (xfont2_fpe_funcs_rec const **) 0; #else -_X_EXPORT FPEFunctions *fpe_functions = (FPEFunctions *) 0; +_X_EXPORT FPEFunctions *_fpe_functions = (FPEFunctions *) 0; +_X_EXPORT FPEFunctions **fpe_functions = &_fpe_functions; #endif static int num_fpe_types = 0; @@ -234,7 +226,7 @@ FontWakeup(pointer data, int count, pointer LastSelectMask) #ifdef XFONT2 (void) (*fpe_functions[fpe->type]->wakeup_fpe) (fpe); #else - (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask); + (void) (*fpe_functions[fpe->type]->wakeup_fpe) (fpe, LastSelectMask); #endif } } @@ -251,11 +243,7 @@ FreeFPE(FontPathElementPtr fpe) { fpe->refcount--; if (fpe->refcount == 0) { -#ifdef XFONT2 (*fpe_functions[fpe->type]->free_fpe) (fpe); -#else - (*fpe_functions[fpe->type].free_fpe) (fpe); -#endif free(fpe->name); free(fpe); } @@ -306,22 +294,14 @@ doOpenFont(ClientPtr client, OFclosurePtr c) if (client->clientGone) { if (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif } err = Successful; goto bail; } while (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->open_font) -#else - err = (*fpe_functions[fpe->type].open_font) -#endif ((pointer) client, fpe, c->flags, c->fontname, c->fnamelen, FontFormat, BitmapFormatMaskByte | @@ -390,13 +370,8 @@ doOpenFont(ClientPtr client, OFclosurePtr c) goto bail; } if (patternCache && pfont != c->non_cachable_font) -#ifdef XFONT2 - xfont2_cache_font_pattern(patternCache, c->origFontName, c->origFontNameLen, - pfont); -#else CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen, pfont); -#endif bail: if (err != Successful && c->client != serverClient) { SendErrorToClient(c->client, X_OpenFont, 0, @@ -453,11 +428,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, ** having to create another instance of a font that already exists. */ -#ifdef XFONT2 - cached = xfont2_find_cached_font_pattern(patternCache, pfontname, lenfname); -#else cached = FindCachedFontPattern(patternCache, pfontname, lenfname); -#endif if (cached && cached->info.cachable) { if (!AddResource(fid, RT_FONT, (pointer) cached)) return BadAlloc; @@ -524,11 +495,7 @@ CloseFont(pointer value, XID fid) return (Success); if (--pfont->refcnt == 0) { if (patternCache) -#ifdef XFONT2 - xfont2_remove_cached_font_pattern(patternCache, pfont); -#else RemoveCachedFontPattern(patternCache, pfont); -#endif /* * since the last reference is gone, ask each screen to free any * storage it may have allocated locally for it. @@ -544,11 +511,7 @@ CloseFont(pointer value, XID fid) XF86BigfontFreeFontShm(pfont); #endif fpe = pfont->fpe; -#ifdef XFONT2 (*fpe_functions[fpe->type]->close_font) (fpe, pfont); -#else - (*fpe_functions[fpe->type].close_font) (fpe, pfont); -#endif FreeFPE(fpe); } return (Success); @@ -658,11 +621,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif } // err = Successful; goto bail; @@ -675,18 +634,10 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; -#ifdef XFONT2 if (!fpe_functions[fpe->type]->start_list_fonts_and_aliases) { -#else - if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) { -#endif /* This FPE doesn't support/require list_fonts_and_aliases */ -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->list_fonts) -#else - err = (*fpe_functions[fpe->type].list_fonts) -#endif ((pointer) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, c->names); @@ -714,11 +665,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) the FPEs. */ if (!c->current.list_started) { -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->start_list_fonts_and_aliases) -#else - err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) -#endif ((pointer) c->client, fpe, c->current.pattern, c->current.patlen, c->current.max_names - c->names->nnames, &c->current.private); @@ -738,11 +685,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) char *tmpname; name = 0; -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->list_next_font_or_alias) -#else - err = (*fpe_functions[fpe->type].list_next_font_or_alias) -#endif ((pointer) c->client, fpe, &name, &namelen, &tmpname, &resolvedlen, c->current.private); if (err == Suspended) { @@ -766,20 +709,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) if (err == Successful) { if (c->haveSaved) { if (c->savedName) -#ifdef XFONT2 - (void) xfont2_add_font_names_name(c->names, c->savedName, - c->savedNameLen); -#else (void) AddFontNamesName(c->names, c->savedName, c->savedNameLen); -#endif } else -#ifdef XFONT2 - (void) xfont2_add_font_names_name(c->names, name, namelen); -#else (void) AddFontNamesName(c->names, name, namelen); -#endif } /* @@ -805,11 +739,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) int tmpnamelen; tmpname = 0; -#ifdef XFONT2 (void) (*fpe_functions[fpe->type]->list_next_font_or_alias) -#else - (void) (*fpe_functions[fpe->type].list_next_font_or_alias) -#endif ((pointer) c->client, fpe, &tmpname, &tmpnamelen, &tmpname, &tmpnamelen, c->current.private); if (--aliascount <= 0) { @@ -917,11 +847,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) free(c->fpe_list); if (c->savedName) free(c->savedName); -#ifdef XFONT2 - xfont2_free_font_names(names); -#else FreeFontNames(names); -#endif free(c); if (resolved) free(resolved); @@ -953,11 +879,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, free(c); return BadAlloc; } -#ifdef XFONT2 - c->names = xfont2_make_font_names_record(max_names < 100 ? max_names : 100); -#else c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100); -#endif if (!c->names) { free(c->fpe_list); free(c); @@ -1012,11 +934,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif } err = Successful; goto bail; @@ -1028,11 +946,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) fpe = c->fpe_list[c->current.current_fpe]; err = Successful; if (!c->current.list_started) { -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->start_list_fonts_with_info) -#else - err = (*fpe_functions[fpe->type].start_list_fonts_with_info) -#endif (client, fpe, c->current.pattern, c->current.patlen, c->current.max_names, &c->current.private); if (err == Suspended) { @@ -1049,11 +963,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) if (err == Successful) { name = 0; pFontInfo = &fontInfo; -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->list_next_font_with_info) -#else - err = (*fpe_functions[fpe->type].list_next_font_with_info) -#endif (client, fpe, &name, &namelen, &pFontInfo, &numFonts, c->current.private); if (err == Suspended) { @@ -1087,11 +997,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) tmpname = 0; tmpFontInfo = &fontInfo; -#ifdef XFONT2 - (void) (*fpe_functions[fpe->type]->list_next_font_with_info) -#else - (void) (*fpe_functions[fpe->type].list_next_font_with_info) -#endif + (void) (*fpe_functions[fpe->type]->list_next_font_with_info) (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo, &numFonts, c->current.private); if (--aliascount <= 0) { @@ -1287,11 +1193,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif if (c->slept) { /* Client has died, but we cannot bail out right now. We @@ -1318,11 +1220,7 @@ doPolyText(ClientPtr client, register PTclosurePtr c) the FPE code to clean up after client and avoid further rendering while we clean up after ourself. */ fpe = c->pGC->font->fpe; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif c->pDraw = (DrawablePtr) 0; } @@ -1568,11 +1466,7 @@ doImageText(ClientPtr client, register ITclosurePtr c) if (client->clientGone) { fpe = c->pGC->font->fpe; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif err = Success; goto bail; } @@ -1587,11 +1481,7 @@ doImageText(ClientPtr client, register ITclosurePtr c) /* Our drawable has disappeared. Treat like client died... ask the FPE code to clean up after client. */ fpe = c->pGC->font->fpe; -#ifdef XFONT2 (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); -#endif err = Success; goto bail; } @@ -1723,11 +1613,7 @@ DetermineFPEType(char *pathname) int i; for (i = 0; i < num_fpe_types; i++) { -#ifdef XFONT2 if ((*fpe_functions[i]->name_check) (pathname)) -#else - if ((*fpe_functions[i].name_check) (pathname)) -#endif return i; } return -1; @@ -1795,13 +1681,8 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) return BadAlloc; } for (i = 0; i < num_fpe_types; i++) { -#ifdef XFONT2 if (fpe_functions[i]->set_path_hook) (*fpe_functions[i]->set_path_hook) (); -#else - if (fpe_functions[i].set_path_hook) - (*fpe_functions[i].set_path_hook) (); -#endif } for (i = 0; i < npaths; i++) { len = (unsigned int) (*cp++); @@ -1820,11 +1701,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) */ fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); if (fpe) { -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->reset_fpe) (fpe); -#else - err = (*fpe_functions[fpe->type].reset_fpe) (fpe); -#endif if (err == Successful) { UseFPE(fpe); /* since it'll be decref'd later when freed * from the old list */ @@ -1854,11 +1731,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) if (fpe->type == -1) err = BadValue; else -#ifdef XFONT2 err = (*fpe_functions[fpe->type]->init_fpe) (fpe); -#else - err = (*fpe_functions[fpe->type].init_fpe) (fpe); -#endif if (err != Successful) { if (persist) { ErrorF @@ -1883,11 +1756,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) FreeFontPath(font_path_elements, num_fpes, FALSE); font_path_elements = fplist; if (patternCache) -#ifdef XFONT2 - xfont2_empty_font_pattern_cache(patternCache); -#else EmptyFontPatternCache(patternCache); -#endif num_fpes = valid_paths; return Success; @@ -1988,13 +1857,8 @@ _X_EXPORT int LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data) { -#ifdef XFONT2 if (fpe_functions[pfont->fpe->type]->load_glyphs) return (*fpe_functions[pfont->fpe->type]->load_glyphs) -#else - if (fpe_functions[pfont->fpe->type].load_glyphs) - return (*fpe_functions[pfont->fpe->type].load_glyphs) -#endif (client, pfont, 0, nchars, item_size, data); else return Successful; @@ -2009,15 +1873,25 @@ DeleteClientFontStuff(ClientPtr client) for (i = 0; i < num_fpes; i++) { fpe = font_path_elements[i]; -#ifdef XFONT2 if (fpe_functions[fpe->type]->client_died) (*fpe_functions[fpe->type]->client_died) ((pointer) client, fpe); -#else - if (fpe_functions[fpe->type].client_died) - (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + } +} + +#ifndef XFONT2 +void +InitFonts() +{ + patternCache = MakeFontPatternCache(); + + { +#ifdef KDRIVESERVER + BuiltinRegisterFpeFunctions(); #endif + FontFileRegisterFpeFunctions(); } } +#endif #ifdef XFONT2 _X_EXPORT XFONT_LTO @@ -2051,22 +1925,14 @@ _client_auth_generation(ClientPtr client) _X_EXPORT XFONT_LTO int -#ifdef XFONT2 -get_default_point_size() -#else GetDefaultPointSize() -#endif { return 120; } _X_EXPORT XFONT_LTO FontResolutionPtr -#ifdef XFONT2 -get_client_resolutions(int *num) -#else GetClientResolutions(int *num) -#endif { if (requestingClient && requestingClient->fontResFunc != NULL && !requestingClient->clientGone) { @@ -2099,6 +1965,7 @@ GetClientResolutions(int *num) } #ifndef XFONT2 + /* * returns the type index of the new fpe * @@ -2125,49 +1992,52 @@ RegisterFPEFunctions(NameCheckFunc name_func, FPEFunctions *new; /* grow the list */ - new = (FPEFunctions *) realloc(fpe_functions, + new = (FPEFunctions *) realloc(*fpe_functions, (num_fpe_types + 1) * sizeof(FPEFunctions)); if (!new) return -1; - fpe_functions = new; - - fpe_functions[num_fpe_types].name_check = name_func; - fpe_functions[num_fpe_types].open_font = open_func; - fpe_functions[num_fpe_types].close_font = close_func; - fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func; - fpe_functions[num_fpe_types].list_fonts = list_func; - fpe_functions[num_fpe_types].start_list_fonts_with_info = start_lfwi_func; - fpe_functions[num_fpe_types].list_next_font_with_info = next_lfwi_func; - fpe_functions[num_fpe_types].init_fpe = init_func; - fpe_functions[num_fpe_types].free_fpe = free_func; - fpe_functions[num_fpe_types].reset_fpe = reset_func; - fpe_functions[num_fpe_types].client_died = client_died; - fpe_functions[num_fpe_types].load_glyphs = load_glyphs; - fpe_functions[num_fpe_types].start_list_fonts_and_aliases = + *fpe_functions = new; + + fpe_functions[num_fpe_types]->name_check = name_func; + fpe_functions[num_fpe_types]->open_font = open_func; + fpe_functions[num_fpe_types]->close_font = close_func; + fpe_functions[num_fpe_types]->wakeup_fpe = wakeup_func; + fpe_functions[num_fpe_types]->list_fonts = list_func; + fpe_functions[num_fpe_types]->start_list_fonts_with_info = start_lfwi_func; + fpe_functions[num_fpe_types]->list_next_font_with_info = next_lfwi_func; + fpe_functions[num_fpe_types]->init_fpe = init_func; + fpe_functions[num_fpe_types]->free_fpe = free_func; + fpe_functions[num_fpe_types]->reset_fpe = reset_func; + fpe_functions[num_fpe_types]->client_died = client_died; + fpe_functions[num_fpe_types]->load_glyphs = load_glyphs; + fpe_functions[num_fpe_types]->start_list_fonts_and_aliases = start_list_alias_func; - fpe_functions[num_fpe_types].list_next_font_or_alias = next_list_alias_func; - fpe_functions[num_fpe_types].set_path_hook = set_path_func; + fpe_functions[num_fpe_types]->list_next_font_or_alias = next_list_alias_func; + fpe_functions[num_fpe_types]->set_path_hook = set_path_func; return num_fpe_types++; } + #endif + void FreeFonts() { if (patternCache) { -#ifdef XFONT2 - xfont2_free_font_pattern_cache(patternCache); -#else FreeFontPatternCache(patternCache); -#endif patternCache = 0; } FreeFontPath(font_path_elements, num_fpes, TRUE); font_path_elements = 0; num_fpes = 0; - free(fpe_functions); num_fpe_types = 0; - fpe_functions = NULL; +#ifdef XFONT2 + free((pointer)fpe_functions); + fpe_functions = (pointer) 0; +#else + free((pointer)*fpe_functions); + *fpe_functions = (pointer) 0; +#endif } #ifdef XFONT2 @@ -2185,6 +2055,7 @@ find_old_font(XID id) return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, SecurityUnknownAccess); } + #ifndef XFONT2 _X_EXPORT XFONT_LTO Font @@ -2310,12 +2181,14 @@ get_server_client(void) return serverClient; } +/* not implemented */ static int add_fs_fd(int fd, FontFdHandlerProcPtr handler, void *data) { return TRUE; } +/* not implemented */ static void remove_fs_fd(int fd) { @@ -2336,8 +2209,8 @@ static const xfont2_client_funcs_rec xfont2_client_funcs = { .delete_font_client_id = delete_font_client_id, .verrorf = VErrorF, .find_old_font = find_old_font, - .get_client_resolutions = get_client_resolutions, - .get_default_point_size = get_default_point_size, + .get_client_resolutions = GetClientResolutions, + .get_default_point_size = GetDefaultPointSize, .get_new_font_client_id = get_new_font_client_id, .get_time_in_millis = wrap_time_in_millis, .init_fs_handlers = (int (*)(FontPathElementPtr, FontBlockHandlerProcPtr))init_fs_handlers, @@ -2354,19 +2227,14 @@ static const xfont2_client_funcs_rec xfont2_client_funcs = { .remove_fs_fd = remove_fs_fd, .adjust_fs_wait_for_delay = adjust_fs_wait_for_delay, }; -#endif void InitFonts() { -#ifdef XFONT2 if (fontPatternCache) xfont2_free_font_pattern_cache(fontPatternCache); fontPatternCache = xfont2_make_font_pattern_cache(); xfont2_init(&xfont2_client_funcs); -#else - patternCache = MakeFontPatternCache(); -#endif { #ifdef KDRIVESERVER BuiltinRegisterFpeFunctions(); @@ -2374,3 +2242,4 @@ InitFonts() FontFileRegisterFpeFunctions(); } } +#endif diff --git a/dix/main.c b/dix/main.c index 03bb9a6..1159061 100644 --- a/dix/main.c +++ b/dix/main.c @@ -98,7 +98,6 @@ Equipment Corporation. #include "dixfont.h" #include "extnsionst.h" #include "dixevents.h" /* InitEvents() */ -#include "xfont2_compat.h" #ifdef DPMSExtension #define DPMS_SERVER diff --git a/include/Makefile.am b/include/Makefile.am index c01fdeb..8f7beea 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -9,4 +9,4 @@ EXTRA_DIST = do-not-use-config.h dix-config.h \ misc.h miscstruct.h opaque.h os.h pixmap.h \ pixmapstr.h property.h propertyst.h region.h regionstr.h resource.h \ screenint.h scrnintstr.h selection.h servermd.h site.h \ - swaprep.h swapreq.h validate.h window.h windowstr.h xfont2_compat + swaprep.h swapreq.h validate.h window.h windowstr.h xfont2_compat.h diff --git a/include/dixfont.h b/include/dixfont.h index 501614c..8bd2c55 100644 --- a/include/dixfont.h +++ b/include/dixfont.h @@ -28,18 +28,19 @@ SOFTWARE. #include #include "closure.h" #include -#ifdef XFONT2 -#include -#endif +#include "xfont2_compat.h" #define NullDIXFontProp ((DIXFontPropPtr)0) typedef struct _DIXFontProp *DIXFontPropPtr; -#ifndef XFONT2 -extern FPEFunctions *fpe_functions; +#ifdef XFONT2 +extern xfont2_fpe_funcs_rec const **fpe_functions; +#else +extern FPEFunctions **fpe_functions; #endif + int FontToXError(int /*err*/); Bool SetDefaultFont(char * /*defaultfontname*/);