[stsf-commit] stsf/STClientLibrary/src STGlyphVector.c, 1.5,
1.6 STLine.c, 1.4, 1.5 libtest.c, 1.4, 1.5 serverconnection.c,
1.9, 1.10
Alexander Gelfenbain
stsf-commit at pdx.freedesktop.org
Fri Jun 4 22:23:06 PDT 2004
- Previous message: [stsf-commit] stsf ChangeLog, 1.21, 1.22 configure, 1.10,
1.11 configure.ac, 1.10, 1.11 st.mk, 1.6, 1.7
- Next message: [stsf-commit] stsf/STFontServer/dropins/freetype2 ft2_glue.c, 1.2,
1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: adg
Index: STGlyphVector.c
===================================================================
RCS file: /cvs/stsf/stsf/STClientLibrary/src/STGlyphVector.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/STGlyphVector.c 26 May 2004 02:58:50 -0000 1.5
+++ b/STGlyphVector.c 5 Jun 2004 05:23:03 -0000 1.6
@@ -237,7 +237,7 @@
_inline unsigned StyleManagerCountStyles(StyleManager *s)
{
- DebugStr(7, "StyleManagerCountStyles [this: %s] -> %d", s, s->cur);
+ DebugStr(7, "StyleManagerCountStyles [this: %08X] -> %d", s, s->cur);
return s->cur;
}
@@ -443,6 +443,8 @@
p->styleHandle = -1;
p->pos = src->pos;
+ } else {
+ ErrorStr("%s: returning NULL", __func__);
}
return p;
}
@@ -488,7 +490,7 @@
(long) (*StyleManagerGetStyle(p->styles, g->styleHandle))->p);
}
if (g->rprops != NULL) {
- DebugStr(7, "2: StyleManagerGetStyle(handle: %d) -> %08X\n",
+ DebugStr(7, "2: StyleManagerGetStyle(handle: %d) -> %08X",
g->styleHandle, (long) (*StyleManagerGetStyle(p->styles, g->styleHandle))->p);
DataManagerRemove(p->rpropsManager,
@@ -501,6 +503,7 @@
/* de-reference glyphs from the glyph manager and free the memory */
_inline void FreeGlyphs(GlyphVectorRep *p, STPosition startFrom, STCount glyphCount) /*FOLD00*/
{
+ DebugStr(7, "%s: startFrom: %d, glyphCount: %d", __func__, startFrom, glyphCount);
if (glyphCount > 0) {
STPosition i = startFrom;
for (i = 0; i < glyphCount; i++) {
@@ -512,7 +515,7 @@
}
if (p->glyphs[i]->rprops != NULL) {
- DebugStr(7, "3: StyleManagerGetStyle(glyph: %d, handle: %d) -> %08X\n",
+ DebugStr(7, "3: StyleManagerGetStyle(glyph: %d, handle: %d) -> %08X",
i, p->glyphs[i]->styleHandle, (long) (*StyleManagerGetStyle(p->styles, p->glyphs[i]->styleHandle))->p);
@@ -531,6 +534,7 @@
/* Tells the glyph manager that we are removing an instance of fgm */
_inline void DecRefGlyphs(GlyphVectorRep *p, STPosition startFrom, STCount glyphCount) /*FOLD00*/
{
+ DebugStr(7, "%s: startFrom: %d, glyphCount: %d", __func__, startFrom, glyphCount);
if (glyphCount > 0) {
STPosition i = startFrom;
for (i = 0; i < glyphCount; i++) {
@@ -543,7 +547,7 @@
}
if (p->glyphs[i]->rprops != NULL) {
- DebugStr(7, "1: StyleManagerGetStyle(glyph: %d, handle: %d) -> %08X\n",
+ DebugStr(7, "1: StyleManagerGetStyle(glyph: %d, handle: %d) -> %08X",
i, p->glyphs[i]->styleHandle, (long) (*StyleManagerGetStyle(p->styles, p->glyphs[i]->styleHandle))->p);
DataManagerRemove(p->glyphManager,
@@ -585,6 +589,8 @@
void GlyphVectorRepDispose(GlyphVectorRep *p) /*FOLD00*/
{
+ D1;
+
if (p != NULL) {
if (p->glyphs != NULL) {
FreeGlyphs(p, 0, p->glyphCount);
@@ -607,6 +613,8 @@
FreeRenderPropsManager();
#endif
}
+ D2;
+
} /*fold00*/
GlyphVectorRep *GlyphVectorRepNew(STTypeEnv env, STStyledGlyph *src, STCount count) /*FOLD00*/
@@ -787,85 +795,71 @@
{
unsigned i;
int delta = arraySize - count;
+ STStyledGlyphInternal **q;
+ D1;
-#if 0
- if (delta == 0) {
- /*
- * Optimization would be to not do the free in this case, just substitute one styled glyph
- * structure for another and de-reference glyphs from the glyph manager.
- */
- DecRefGlyphs(p, start, count); /* refCnt--; and zero the fgm pointer */
-
- for (i = 0; i < count; i++) {
- memcpy(p->glyphs[start+i], glyphArray+i, sizeof(STStyledGlyph));
-
- p->glyphs[start+i] = STStyledGlyphInternalNew(glyphArray+i)
-
-
+#ifdef STSF_DEBUG
+ STBoolean GlyphVectorRepSerialize(GlyphVectorRep *p, FILE *xml);
+ if (DebugLevel > 7) {
+ int j;
+ DebugStr(8, "%s: start: %d, count: %d, arraySize: %d", __func__, start, count, arraySize); /* To initialize the files */
+ GlyphVectorRepSerialize(p, DebugFile);
+ for (j=0; j<arraySize; j++) {
+ DebugStr(-1, " %5d: id: %4d, style: %08X, style->p: %08X\n",
+ j, glyphArray[j].id, *glyphArray[j].style, (*glyphArray[j].style)->p);
}
- } else {
+ }
+ DataManagerDump(p->rpropsManager, 1);
#endif
- STStyledGlyphInternal **q;
-
- q = calloc(p->glyphCount + delta, sizeof(STStyledGlyphInternal *));
- if (q == NULL) return NULL;
-#if 0 /* XXX pre-styleHandle code */
- if (start > 0) {
- memcpy(q, p->glyphs, start * sizeof(STStyledGlyphInternal *));
- }
-#endif
- /* As we copy the glyphs, we need to replace style handles with actual styles
- * so that we can update indices when we insert new glyphs
- */
+ q = calloc(p->glyphCount + delta, sizeof(STStyledGlyphInternal *));
+ if (q == NULL) return NULL;
- for (i=0; i<start; i++) {
- q[i] = p->glyphs[i];
- q[i]->styleHandle = (uintptr_t) *(StyleManagerGetStyle(p->styles, q[i]->styleHandle));
- }
+ /* As we copy the glyphs, we need to replace style handles with actual styles
+ * so that we can update indices when we insert new glyphs
+ */
+ for (i=0; i<start; i++) {
+ q[i] = p->glyphs[i];
+ q[i]->styleHandle = (uintptr_t) *(StyleManagerGetStyle(p->styles, q[i]->styleHandle));
+ }
- for (i = 0; i < arraySize; i++) {
- if ((q[start+i] = STStyledGlyphInternalNew(glyphArray+i)) == NULL) {
- int j;
- for (j = 0; j < i; j++) {
- STStyledGlyphInternalDispose(p, q[start+j]);
- }
- free(q);
- return NULL;
+ for (i = 0; i < arraySize; i++) {
+ if ((q[start+i] = STStyledGlyphInternalNew(glyphArray+i)) == NULL) {
+ int j;
+ for (j = 0; j < i; j++) {
+ STStyledGlyphInternalDispose(p, q[start+j]);
}
- /* First Pass: Insert style objects into the old style manager */
- StyleManagerInsert(p->styles, *(glyphArray[i].style));
- q[start+i]->styleHandle = (uintptr_t) *(glyphArray[i].style);
+ free(q);
+ return NULL;
}
+ /* First Pass: Insert style objects into the old style manager */
+ StyleManagerInsert(p->styles, *(glyphArray[i].style));
+ q[start+i]->styleHandle = (uintptr_t) *(glyphArray[i].style);
+ }
-#if 0 /* XXX pre-styleHandle code */
- if (p->glyphCount - count - start > 0) {
- memcpy(q + start + arraySize, p->glyphs + start + count, (p->glyphCount - count - start) * sizeof(STStyledGlyphInternal *));
- }
-#endif
- for (i=0; i<p->glyphCount - count - start; i++) {
- q[start+arraySize+i] = p->glyphs[start+count+i];
- q[start+arraySize+i]->styleHandle = (uintptr_t) *(StyleManagerGetStyle(p->styles, q[start+arraySize+i]->styleHandle));
- }
+ for (i=0; i<p->glyphCount - count - start; i++) {
+ q[start+arraySize+i] = p->glyphs[start+count+i];
+ q[start+arraySize+i]->styleHandle = (uintptr_t) *(StyleManagerGetStyle(p->styles, q[start+arraySize+i]->styleHandle));
+ }
- /* Second Pass: re-link all style handles */
- for (i=0; i<p->glyphCount+delta; i++) {
- q[i]->styleHandle = StyleManagerGetIndex(p->styles, (STStyle) q[i]->styleHandle);
- }
+ /* Second Pass: re-link all style handles */
+ for (i=0; i<p->glyphCount+delta; i++) {
+ q[i]->styleHandle = StyleManagerGetIndex(p->styles, (STStyle) q[i]->styleHandle);
+ }
- FreeGlyphs(p, start, count);
- free(p->glyphs);
- p->glyphs = q;
- p->glyphCount += delta;
+ FreeGlyphs(p, start, count);
+ free(p->glyphs);
+ p->glyphs = q;
+ p->glyphCount += delta;
-#if 0
- }
-#endif
p->metricsCacheDirty = TRUE;
+
+ D2;
+
return p;
-} /*fold00*/
+}
void GlyphVectorRepAdjustPositions(GlyphVectorRep *p, STPosition start, STCount count, STPoint delta) /*FOLD00*/
{
@@ -936,7 +930,7 @@
}
for (i=0; i<n; i++) {
- fprintf(xml, "\t<Style Handle=\"%d\" Self=\"%d\" p=\"%d\"/>\n",
+ fprintf(xml, "\t<Style Handle=\"%d\" Self=\"%08X\" p=\"%08X\"/>\n",
i,
(int) StyleManagerGetStyle(p->styles, i),
(int) (*StyleManagerGetStyle(p->styles, i))->p
@@ -1102,6 +1096,9 @@
if ((res = STStyleGetScaler(s, &smask, &scaler, &hints, &sbits)) != ST_OK) {
return res;
}
+
+ DebugStr(7, "%s: style: %08X (p: %08X) => scaler: %d", __func__, s, s->p, scaler);
+
if ((res = STStyleGetEffects(s, &smask, &effects, NULL, NULL)) != ST_OK) {
return res;
}
@@ -1146,6 +1143,20 @@
return res;
}
+ /* XXX In order to minimize roundtrips, could we add the scalerID (NOT tag) to STIntNewFontInstance? */
+ if (smask & ST_SM_SCALER) {
+ STTag tag;
+
+ DebugStr(7, "%s: ST_SM_SCALER is set, changing scalerID to: %d", __func__, scaler);
+
+ if ((res=STScalerGetInfo(p->env, scaler, &tag, NULL, NULL, NULL, NULL, NULL, NULL)) != ST_OK) {
+ return res;
+ }
+ if ((res = STIntSetScalerForInstanceByTag(p->env, tag, instance)) != ST_OK) {
+ return res;
+ }
+ }
+
DebugStr(7, "STIntNewFontInstnce() -> %d", instance);
@@ -1153,6 +1164,9 @@
rp->env = p->env;
STIntGetFontRenderingParams(p->env, instance, &rp->scalerID, &rp->rparams.mode, &rp->rparams.bitsPerPixel, &rp->rparams.clut);
+ DebugStr(7, "%s: STIntGetFontRenderingParams: => scaler: %d", __func__, rp->scalerID);
+
+
/* To avoid race conditions in a MT environment */
DataManagerLock(p->rpropsManager);
@@ -1266,6 +1280,8 @@
STGlyphKey *gk;
#endif
+ DebugStr(7, "%s: start: %d, count: %d", __func__, start, count);
+
#if 0 /* the buffer is in shared cache now */
#if !defined(STSF_DEBUG)
static byte *buffer = NULL;
@@ -1324,7 +1340,7 @@
/* XXX will combining this loop with the next speed things up? */
for (i = 0; i < q->glyphCount; i++) {
if (q->glyphs[i]->rprops != NULL) {
- DebugStr(7, "4: StyleManagerGetStyle(glyph: %d, handle: %d) -> %08X\n",
+ DebugStr(7, "4: StyleManagerGetStyle(glyph: %d, handle: %d) -> %08X",
i, q->glyphs[i]->styleHandle, (long) (*StyleManagerGetStyle(q->styles, q->glyphs[i]->styleHandle))->p);
DataManagerRemove(q->rpropsManager, (long) (*StyleManagerGetStyle(q->styles, q->glyphs[i]->styleHandle))->p, (long) q->graphics);
@@ -1337,13 +1353,18 @@
gk = calloc(count, sizeof(STGlyphKey));
// gk = alloca(sizeof(STGlyphKey) * count);
+ /* DebugStr(-1, "%s: glyphs [", __func__); */
+
for (i=0; i<count; i++) {
STStyledGlyphInternal *glyph = q->glyphs[start+i];
if (glyph->rprops == NULL) {
+ /* DebugStr(-1, "*"); */
if ((ret = GetRenderProps(q, *StyleManagerGetStyle(q->styles, glyph->styleHandle), q->graphics, &glyph->rprops)) != ST_OK) {
if (gk != NULL) free(gk);
return ret;
}
+ } else {
+ /* DebugStr(-1, "!"); */
}
if (gk != NULL) {
STStyledGlyphInternal *glyph = q->glyphs[start+i];
@@ -1352,16 +1373,23 @@
gk[i].instanceID = glyph->rprops->fontInstance;
gk[i].glyphID = glyph->id;
gk[i].fracdelta = DOUBLE_XY_TO_FRACDELTA(glyph->pos.x, glyph->pos.y);
+ /* DebugStr(-1, "(%d %d %d) ", gk[i].scalerID, gk[i].instanceID, gk[i].glyphID); */
}
}
+ /* DebugStr(-1, "]\n"); */
if (gk != NULL) {
+ /* DebugStr(-1, "%s: scalers [", __func__); */
if (STIntPrefetchGlyphs(q->env, count, gk) == ST_OK) {
for (i=0; i<count; i++) { /* update the scalers */
if (gk[i].instanceID != 0) { /* glyph was indeed prefetched */
q->glyphs[start+i]->rprops->scalerID = gk[i].scalerID;
+ /* DebugStr(-1, "%d ", gk[i].scalerID); */
+ } else {
+ /* DebugStr(-1, "- "); */
}
}
}
+ /* DebugStr(-1, "]\n"); */
}
if (gk != NULL) free(gk);
#endif
@@ -1384,7 +1412,6 @@
sScalerID = glyph->rprops->scalerID;
#endif
-
ret = STIntRenderGlyph(q->env,
&glyph->rprops->scalerID,
glyph->rprops->fontInstance,
@@ -1404,12 +1431,6 @@
}
#endif
-#if 0 /* XXX not with the shared cache */
- if (ret == ST_BUFSIZE) { /* Do not increase the size of the buffer to prevent DOS attacks */
- return ST_MEMORY;
- }
-#endif
-
if ( bbdata.rparams.mode != glyph->rprops->rparams.mode )
memcpy(&bbdata.rparams, &glyph->rprops->rparams, sizeof(STRenderingParams));
@@ -1431,12 +1452,12 @@
DebugStr(4, "STGlyphVectorRender: Glyph %d - x,y = (%d, %d) - w,h = (%d, %d) - left,top = (%d, %d)",
glyph->id, bbdata.x, bbdata.y, bbdata.w, bbdata.h,
F16DOT16_TO_INT(metrics.leftH), F16DOT16_TO_INT(metrics.topH));
+
- if (bbdata.w == 0 || bbdata.h == 0) {
- DebugStr(4, "STGlyphVectorRender: Glyph size 0, skipping");
- } else {
- rdev->bitblt(rdev, &bbdata, buffer);
- }
+ /* ALWAYS call the callback, even on empty glyphs so that XST could
+ perform its shared cache optimization */
+
+ rdev->bitblt(rdev, &bbdata, buffer);
/* BitBlt is done - can release the buffer */
STIntReleaseGlyphBuffer(q->env, s, buffer);
Index: STLine.c
===================================================================
RCS file: /cvs/stsf/stsf/STClientLibrary/src/STLine.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/STLine.c 1 Jun 2004 16:38:16 -0000 1.4
+++ b/STLine.c 5 Jun 2004 05:23:03 -0000 1.5
@@ -718,6 +718,9 @@
if (styleMask & ST_SM_SCALER) {
STTag scalerTag;
+
+ DebugStr(1, "%s: ST_SM_SCALER is set, changing scalerID to: %d", __func__, scaler);
+ scalerID = scaler;
result = STScalerGetInfo(p->env, scaler, &scalerTag,
NULL, NULL, NULL, NULL, NULL, NULL);
@@ -1813,7 +1816,6 @@
TextChunkFindByPos(p->highlights, glyphs->glyphs[0].position);
for (i = 0, j = 1; i <= glyphs->count ; i++, j++) {
STTrapezoid trap;
- uint32_t scalerID; /* XXX ignored but needed due to stfsproto.c's inability to handle NULL pointers */
if (j < glyphs->count) {
highlight = TextChunkFindByPos ( p->highlights, glyphs->glyphs[j].position );
@@ -1837,7 +1839,7 @@
if ( !bbdata_filled ) {
result = STIntGetFontRenderingParams(p->env,
glyphs->glyphs[jj].fontID,
- &scalerID,
+ NULL,
&bbdata.rparams.mode,
&bbdata.rparams.bitsPerPixel,
&bbdata.rparams.clut);
@@ -1959,7 +1961,6 @@
// Do Nothing
} else if ( ((i==0) && lastStart_style) ||
(!lastStart_style && style) ) {
- uint32_t scalerID; /* XXX ignored but needed due to stfsproto.c's inability to handle NULL pointers */
jj = j;
if (i == 0)
@@ -1967,7 +1968,7 @@
if ( !bbdata_filled ) {
result = STIntGetFontRenderingParams(p->env, glyphs->glyphs[jj].fontID,
- &scalerID,
+ NULL,
&bbdata.rparams.mode,
&bbdata.rparams.bitsPerPixel,
&bbdata.rparams.clut);
@@ -2130,7 +2131,6 @@
// Do Nothing
} else if ( ((i==0) && lastStart_style) ||
(!lastStart_style && style) ) {
- uint32_t scalerID; /* XXX ignored but needed due to stfsproto.c's inability to handle NULL pointers */
jj = j;
if (i == 0)
@@ -2138,7 +2138,7 @@
if ( !bbdata_filled ) {
result = STIntGetFontRenderingParams(p->env, glyphs->glyphs[jj].fontID,
- &scalerID,
+ NULL,
&bbdata.rparams.mode,
&bbdata.rparams.bitsPerPixel,
&bbdata.rparams.clut);
Index: libtest.c
===================================================================
RCS file: /cvs/stsf/stsf/STClientLibrary/src/libtest.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/libtest.c 30 May 2004 23:07:17 -0000 1.4
+++ b/libtest.c 5 Jun 2004 05:23:03 -0000 1.5
@@ -57,6 +57,9 @@
#include "stmath.h"
#define TEST_FONT "/usr/j2se/jre/lib/fonts/LucidaTypewriterRegular.ttf"
+#define TEST_FONT2 "test_font"
+
+void FontInfoTest(void);
// Always BE
utf16 *CStringToUTF16(const char *str)
@@ -409,7 +412,7 @@
void GlyphTest1(STFont fontID)
{
STTypeEnv e;
- const unsigned char *fname = (unsigned char *) "Times New Roman";
+ const unsigned char *fname = (unsigned char *) "Arial";
STFont f;
STStatus s;
utf16 Ch;
@@ -435,7 +438,7 @@
matrix.xx = 14; matrix.xy = 0; matrix.tx = 0;
matrix.yx = 0; matrix.yy = 14; matrix.ty = 0;
- if ((s = STIntNewFontInstance(e, f, matrix, 72, 72, FS_RF_HINTS | FS_RF_GRAYSCALE, &instanceID)) != ST_OK) {
+ if ((s = STIntNewFontInstance(e, f, matrix, 72, 72, FS_RF_HINTS | FS_RF_BLACKANDWHITE, &instanceID)) != ST_OK) {
printf("STIntNewFontInstance: %s.\n", ErrorCodeName(s));
goto done;
}
@@ -443,7 +446,7 @@
STIntSetScalerForInstanceByTag(e, ST_SCALER_FREETYPE2, instanceID);
- for (Ch = 0; Ch < 255; Ch++) {
+ for (Ch = 32; Ch < 128; Ch++) {
if ((s = STIntMapChar(e, f, Ch, &glyph)) != ST_OK) {
printf("STIntMapChar: %s\n", ErrorCodeName(s));
continue;
@@ -456,7 +459,7 @@
continue;
}
- printglyph(buffer, metrics.width, metrics.height, metrics.bytesPerRow, 8, 256);
+ printglyph(buffer, metrics.width, metrics.height, metrics.bytesPerRow, 1, 1);
STIntReleaseGlyphBuffer(e, buffersize, buffer);
@@ -1260,11 +1263,11 @@
void CreateFontsTest(STTypeEnv e)
{
STStatus ret;
- char *filename = TEST_FONT;
+ char *filename = TEST_FONT2;
STCount count;
STFont *fontarray = NULL;
int i;
- FileImage *fi = LoadFile(filename, 0, 300000);
+ FileImage *fi = LoadFile(filename, 0, 30000000);
size_t l;
byte *p;
@@ -1302,6 +1305,8 @@
}
}
+ FontInfoTest();
+
if ((ret = STTypeEnvDestroyFonts(e, count, fontarray)) != ST_OK) {
printf("STTypeEnvDestroryFonts: %s.\n", ErrorCodeName(ret));
}
@@ -1429,6 +1434,9 @@
printf("fontenumerator.amounttochecksum: %d\n", tmp);
+ GlyphTest1(0);
+ return 1;
+
FontInfoTest();
FindFontTest(ac, av);
Index: serverconnection.c
===================================================================
RCS file: /cvs/stsf/stsf/STClientLibrary/src/serverconnection.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- a/serverconnection.c 30 May 2004 23:07:17 -0000 1.9
+++ b/serverconnection.c 5 Jun 2004 05:23:03 -0000 1.10
@@ -931,6 +931,8 @@
if (s == NULL) return ST_INTERNAL_ERROR;
+ DebugStr(3, "+%s: *scalerID: %d", __func__, *scalerID);
+
hdr = (SharedMemoryHeader *) s->shmaddr;
cache = (byte *) s->shmaddr + hdr->sc_offset;
@@ -939,6 +941,7 @@
memcpy(metrics, p, sizeof(ScaledGlyphData));
*buffersize = nbytes - sizeof(ScaledGlyphData) - s->psize;
*buffer = p + sizeof(ScaledGlyphData) + s->psize;
+ DebugStr(3, "-%s: *scalerID: %d", __func__, *scalerID);
return ST_OK;
}
@@ -958,6 +961,7 @@
memcpy(metrics, p, sizeof(ScaledGlyphData));
*buffersize = nbytes - sizeof(ScaledGlyphData) - s->psize;
*buffer = p + sizeof(ScaledGlyphData) + s->psize;
+ DebugStr(3, "-%s: *scalerID: %d", __func__, *scalerID);
return ST_OK;
}
- Previous message: [stsf-commit] stsf ChangeLog, 1.21, 1.22 configure, 1.10,
1.11 configure.ac, 1.10, 1.11 st.mk, 1.6, 1.7
- Next message: [stsf-commit] stsf/STFontServer/dropins/freetype2 ft2_glue.c, 1.2,
1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the stsf-commit
mailing list