Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[xsrc/trunk]: xsrc/external/mit/libXft/dist/src merge libXft 2.3.5.



details:   https://anonhg.NetBSD.org/xsrc/rev/afa12749767e
branches:  trunk
changeset: 7154:afa12749767e
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Sep 09 23:18:56 2022 +0000

description:
merge libXft 2.3.5.

diffstat:

 external/mit/libXft/dist/src/xftdpy.c    |   37 +-
 external/mit/libXft/dist/src/xftglyphs.c |  677 ++++++++++++++++++++++++++----
 2 files changed, 613 insertions(+), 101 deletions(-)

diffs (truncated from 1108 to 300 lines):

diff -r 2ff65591a487 -r afa12749767e external/mit/libXft/dist/src/xftdpy.c
--- a/external/mit/libXft/dist/src/xftdpy.c     Fri Sep 09 23:17:48 2022 +0000
+++ b/external/mit/libXft/dist/src/xftdpy.c     Fri Sep 09 23:18:56 2022 +0000
@@ -22,10 +22,12 @@
 
 #include "xftint.h"
 
+#define BtoS(b) ((b) ? "true" : "false")
+
 _X_HIDDEN XftDisplayInfo       *_XftDisplayInfo;
 
 static int
-_XftCloseDisplay (Display *dpy, XExtCodes *codes)
+_XftCloseDisplay (Display *dpy, XExtCodes *codes _X_UNUSED)
 {
     XftDisplayInfo  *info, **prev;
 
@@ -51,7 +53,8 @@
     for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
        if (info->display == dpy)
            break;
-    *prev = info->next;
+    if (info != NULL)
+       *prev = info->next;
 
     free (info);
     return 0;
@@ -85,7 +88,7 @@
     if (!createIfNecessary)
        return NULL;
 
-    info = (XftDisplayInfo *) malloc (sizeof (XftDisplayInfo));
+    info = malloc (sizeof (XftDisplayInfo));
     if (!info)
        goto bail0;
     info->codes = XAddExtension (dpy);
@@ -169,7 +172,7 @@
                                                   XFT_MAX_GLYPH_MEMORY, 0,
                                                   XFT_DPY_MAX_GLYPH_MEMORY);
     if (XftDebug () & XFT_DBG_CACHE)
-       printf ("global max cache memory %ld\n", info->max_glyph_memory);
+       printf ("global max cache memory %lu\n", info->max_glyph_memory);
 
 
     info->num_unref_fonts = 0;
@@ -177,7 +180,14 @@
                                                  XFT_MAX_UNREF_FONTS, 0,
                                                  XFT_DPY_MAX_UNREF_FONTS);
     if (XftDebug() & XFT_DBG_CACHE)
-       printf ("global max unref fonts %d\n", info->max_unref_fonts);
+       printf ("global max unref fonts  %d\n", info->max_unref_fonts);
+
+    info->track_mem_usage = FcFalse;
+    info->track_mem_usage = XftDefaultGetBool (dpy,
+                                              XFT_TRACK_MEM_USAGE, 0,
+                                              FcFalse);
+    if (XftDebug() & XFT_DBG_CACHE)
+       printf ("global track mem usage  %s\n", BtoS(info->track_mem_usage));
 
     memset (info->fontHash, '\0', sizeof (XftFont *) * XFT_NUM_FONT_HASH);
     return info;
@@ -210,7 +220,7 @@
        glyph_memory += font->glyph_memory;
     }
     if (glyph_memory != info->glyph_memory)
-       printf ("Display glyph cache incorrect has %ld bytes, should have %ld\n",
+       printf ("Display glyph cache incorrect has %lu bytes, should have %lu\n",
                info->glyph_memory, glyph_memory);
 }
 
@@ -227,7 +237,7 @@
     if (XftDebug () & XFT_DBG_CACHE)
     {
        if (info->glyph_memory > info->max_glyph_memory)
-           printf ("Reduce global memory from %ld to %ld\n",
+           printf ("Reduce global memory from %lu to %lu\n",
                    info->glyph_memory, info->max_glyph_memory);
        _XftDisplayValidateMemory (info);
     }
@@ -272,16 +282,29 @@
     if (info->defaults)
        FcPatternDestroy (info->defaults);
     info->defaults = defaults;
+
     if (!info->max_glyph_memory)
        info->max_glyph_memory = XFT_DPY_MAX_GLYPH_MEMORY;
     info->max_glyph_memory = (unsigned long)XftDefaultGetInteger (dpy,
                                                   XFT_MAX_GLYPH_MEMORY, 0,
                                                   (int)info->max_glyph_memory);
+    if (XftDebug () & XFT_DBG_CACHE)
+       printf ("update max cache memory %lu\n", info->max_glyph_memory);
+
     if (!info->max_unref_fonts)
        info->max_unref_fonts = XFT_DPY_MAX_UNREF_FONTS;
     info->max_unref_fonts = XftDefaultGetInteger (dpy,
                                                  XFT_MAX_UNREF_FONTS, 0,
                                                  info->max_unref_fonts);
+    if (XftDebug() & XFT_DBG_CACHE)
+       printf ("update max unref fonts  %d\n", info->max_unref_fonts);
+
+    info->track_mem_usage = XftDefaultGetBool (dpy,
+                                              XFT_TRACK_MEM_USAGE, 0,
+                                              info->track_mem_usage);
+    if (XftDebug() & XFT_DBG_CACHE)
+       printf ("update track mem usage  %s\n", BtoS(info->track_mem_usage));
+
     return True;
 }
 
diff -r 2ff65591a487 -r afa12749767e external/mit/libXft/dist/src/xftglyphs.c
--- a/external/mit/libXft/dist/src/xftglyphs.c  Fri Sep 09 23:17:48 2022 +0000
+++ b/external/mit/libXft/dist/src/xftglyphs.c  Fri Sep 09 23:18:56 2022 +0000
@@ -1,23 +1,24 @@
 /*
+ * Copyright © 2022 Thomas E. Dickey
  * Copyright © 2000 Keith Packard
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the above copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The above copyright holders make no
  * representations about the suitability of this software for any purpose.  It
  * is provided "as is" without express or implied warranty.
  *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
 #include "xftint.h"
@@ -26,12 +27,54 @@
 
 #include FT_SYNTHESIS_H
 
+#include FT_GLYPH_H
+
+typedef double m3x3[3][3];
+
+static void
+m3x3_uniform(m3x3 m)
+{
+    m[0][0] = m[1][1] = m[2][2] = 1.0;
+    m[0][1] = m[1][0] = m[0][2] = m[1][2] = m[2][0] = m[2][1] = 0;
+}
+
+static void
+m3x3_transform(FT_Vector *v, m3x3 m)
+{
+    double x, y;
+
+    x = (double)v->x;
+    y = (double)v->y;
+    v->x = (FT_Pos)(x * m[0][0] + y * m[0][1] + m[0][2] + 0.5);
+    v->y = (FT_Pos)(x * m[1][0] + y * m[1][1] + m[1][2] + 0.5);
+}
+
+static void
+m3x3_invert(m3x3 m, m3x3 mi)
+{
+    double det;
+
+    det  = m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]);
+    det -= m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]);
+    det += m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
+    det  = 1.0 / det;
+    mi[0][0] = det * (m[1][1] * m[2][2] - m[1][2] * m[2][1]);
+    mi[1][0] = det * (m[1][2] * m[2][0] - m[1][0] * m[2][2]);
+    mi[2][0] = det * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
+    mi[0][1] = det * (m[0][2] * m[2][1] - m[0][1] * m[2][2]);
+    mi[1][1] = det * (m[0][0] * m[2][2] - m[0][2] * m[2][0]);
+    mi[2][1] = det * (m[0][1] * m[2][0] - m[0][0] * m[2][1]);
+    mi[0][2] = det * (m[0][1] * m[1][2] - m[0][2] * m[1][1]);
+    mi[1][2] = det * (m[0][2] * m[1][0] - m[0][0] * m[1][2]);
+    mi[2][2] = det * (m[0][0] * m[1][1] - m[0][1] * m[1][0]);
+}
+
 /*
  * Validate the memory info for a font
  */
 
 static void
-_XftFontValidateMemory (Display *dpy, XftFont *public)
+_XftFontValidateMemory (Display *dpy _X_UNUSED, XftFont *public)
 {
     XftFontInt     *font = (XftFontInt *) public;
     unsigned long   glyph_memory;
@@ -48,10 +91,72 @@
        }
     }
     if (glyph_memory != font->glyph_memory)
-       printf ("Font glyph cache incorrect has %ld bytes, should have %ld\n",
+       printf ("Font glyph cache incorrect has %lu bytes, should have %lu\n",
                font->glyph_memory, glyph_memory);
 }
 
+/*
+ * Validate the glyph usage-links for a font.
+ */
+static void
+_XftValidateGlyphUsage(XftFontInt *font)
+{
+    if (font->newest != FT_UINT_MAX) {
+       FT_UInt forward;
+       FT_UInt reverse;
+       FT_UInt next;
+       XftGlyphUsage *x1st = (XftGlyphUsage *) font->glyphs[font->newest];
+       XftGlyphUsage *xuse = x1st;
+       for (forward = 1,
+            next = x1st->newer;
+            xuse != NULL &&
+            next != font->newest;
+            next = xuse->newer) {
+           if (next >= font->num_glyphs) {
+               printf("Xft: out of range; %d\n", next);
+               break;
+           }
+           if (++forward > font->total_inuse) {
+               printf("Xft: too many in-use glyphs (%d vs %d)\n",
+                      forward, font->total_inuse);
+               if (forward > font->total_inuse + 10)
+                   break;
+           }
+           xuse = (XftGlyphUsage *) font->glyphs[next];
+       }
+       if (forward < font->total_inuse) {
+           printf("Xft: too few in-use glyphs (%u vs %d)\n",
+                  forward, font->total_inuse);
+       }
+       for (reverse = 1,
+            next = x1st->older;
+            xuse != NULL &&
+            next != font->newest;
+            next = xuse->older) {
+           if (next >= font->num_glyphs) {
+               printf("Xft out of range; %d\n", next);
+               break;
+           }
+           if (++reverse > font->total_inuse) {
+               printf("Xft: too many in-use glyphs (%d vs %d)\n",
+                      reverse, font->total_inuse);
+               if (reverse > font->total_inuse + 10)
+                   break;
+           }
+           xuse = (XftGlyphUsage *) font->glyphs[next];
+       }
+       if (reverse < font->total_inuse) {
+           printf("Xft: too few in-use glyphs (%u vs %d)\n",
+                  reverse, font->total_inuse);
+       }
+       if (forward != reverse) {
+           printf("Xft: forward %d vs reverse %d\n",
+                  forward, reverse);
+           exit(1);
+       }
+    }
+}
+
 /* we sometimes need to convert the glyph bitmap in a FT_GlyphSlot
  * into a different format. For example, we want to convert a
  * FT_PIXEL_MODE_LCD or FT_PIXEL_MODE_LCD_V bitmap into a 32-bit
@@ -78,7 +183,9 @@
 static int
 _compute_xrender_bitmap_size( FT_Bitmap*       target,
                              FT_GlyphSlot      slot,
-                             FT_Render_Mode    mode )
+                             FT_Render_Mode    mode,
+                             FT_Matrix*        matrix,
+                             m3x3              m )
 {
     FT_Bitmap* ftbit;
     int                width, height, pitch;
@@ -91,6 +198,63 @@
 
     width = (int)ftbit->width;
     height = (int)ftbit->rows;
+
+    if ( matrix && mode == FT_RENDER_MODE_NORMAL )
+    {
+       FT_Matrix mirror, inverse;
+       FT_Vector vector;
+       int xc, yc;



Home | Main Index | Thread Index | Old Index