fix ups some toehr stuff...

SVN revision: 437
This commit is contained in:
Carsten Haitzler 1999-09-28 18:51:07 +00:00
parent ee71d8d845
commit d791522024
5 changed files with 101 additions and 29 deletions

20
api.c
View File

@ -716,6 +716,15 @@ imlib_create_cropped_scaled_image(Imlib_Image image, char antialias,
return (Imlib_Image)im;
}
Imlib_Updates
imlib_updates_clone(Imlib_Updates updates)
{
ImlibUpdate *u;
u = (ImlibUpdate *)updates;
return (Imlib_Updates)__imlib_DupUpdates(u);
}
Imlib_Updates
imlib_update_append_rect(Imlib_Updates updates, int x, int y, int w, int h)
{
@ -731,7 +740,16 @@ imlib_updates_merge(Imlib_Updates updates, int w, int h)
ImlibUpdate *u;
u = (ImlibUpdate *)updates;
return (Imlib_Updates)__imlib_MergeUpdate(u, w, h);
return (Imlib_Updates)__imlib_MergeUpdate(u, w, h, 0);
}
Imlib_Updates
imlib_updates_merge_for_rendering(Imlib_Updates updates, int w, int h)
{
ImlibUpdate *u;
u = (ImlibUpdate *)updates;
return (Imlib_Updates)__imlib_MergeUpdate(u, w, h, 3);
}
void

3
api.h
View File

@ -220,12 +220,15 @@ Imlib_Image imlib_create_cropped_scaled_image(Imlib_Image image,
int source_height,
int destination_width,
int destination_height);
Imlib_Updates imlib_updates_clone(Imlib_Updates updates);
Imlib_Updates imlib_updates_init(void);
Imlib_Updates imlib_updates_append_updates(Imlib_Updates updates,
Imlib_Updates appended_updates);
Imlib_Updates imlib_update_append_rect(Imlib_Updates updates,
int x, int y, int w, int h);
Imlib_Updates imlib_updates_merge(Imlib_Updates updates, int w, int h);
Imlib_Updates imlib_updates_merge_for_rendering(Imlib_Updates updates, int w,
int h);
void imlib_updates_free(Imlib_Updates updates);
Imlib_Updates imlib_updates_get_next(Imlib_Updates updates);
void imlib_updates_get_coordinates(Imlib_Updates updates,

26
font.c
View File

@ -446,19 +446,6 @@ __imlib_render_str(ImlibImage *im, ImlibFont *fn, int drx, int dry, char *text,
switch(dir)
{
case 0:
if (retw)
*retw = w;
if (reth)
*reth = h;
if (*nexty)
*nexty = fn->ascent + fn->descent;
if (*nextx)
{
j = text[strlen(text) - 1];
TT_Get_Glyph_Metrics(fn->glyphs[j], &metrics);
*nextx = w - (x_offset / 64) + metrics.advance - metrics.bbox.xMax;
}
break;
case 1:
if (retw)
*retw = w;
@ -474,19 +461,6 @@ __imlib_render_str(ImlibImage *im, ImlibFont *fn, int drx, int dry, char *text,
}
break;
case 2:
if (retw)
*retw = h;
if (reth)
*reth = w;
if (*nextx)
*nextx = fn->ascent + fn->descent;
if (*nexty)
{
j = text[strlen(text) - 1];
TT_Get_Glyph_Metrics(fn->glyphs[j], &metrics);
*nexty = w - (x_offset / 64) + metrics.advance - metrics.bbox.xMax;
}
break;
case 3:
if (retw)
*retw = h;

View File

@ -27,11 +27,12 @@ if ((y + h) > hh) {h = hh - y;}
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
ImlibUpdate *
__imlib_MergeUpdate(ImlibUpdate *u, int w, int h)
__imlib_MergeUpdate(ImlibUpdate *u, int w, int h, int hgapmax)
{
ImlibUpdate *nu = NULL, *uu;
struct _tile *t;
int tw, th, x, y, i;
int *gaps = NULL;
/* if theres no rects to process.. return NULL */
if (!u)
@ -62,6 +63,58 @@ __imlib_MergeUpdate(ImlibUpdate *u, int w, int h)
T(x, y).used = T_USED;
}
}
/* scan each line - if > hgapmax gaps between tiles, then fill smallest */
gaps = malloc(tw *sizeof(int));
for (y = 0; y < th; y++)
{
int hgaps = 0, start = -1, min;
char have = 1, gap = 0;
for (x = 0; x < tw; x++)
gaps[x] = 0;
for (x = 0; x < tw; x++)
{
if ((have) && (T(x, y).used == T_UNUSED))
{
start = x;
gap = 1;
have = 0;
}
else if ((!have) && (gap) && (T(x, y).used & T_USED))
{
gap = 0;
hgaps++;
have = 1;
gaps[start] = x - start;
}
else if (T(x, y).used & T_USED)
have = 1;
}
while (hgaps > hgapmax)
{
start = -1;
min = tw;
for (x = 0; x < tw; x++)
{
if ((gaps[x] > 0) && (gaps[x] < min))
{
start = x;
min = gaps[x];
}
}
if (start >= 0)
{
gaps[start] = 0;
for (x = start;
T(x, y).used == T_UNUSED;
T(x++, y).used = T_USED);
hgaps--;
}
}
}
free(gaps);
/* coalesce tiles into larger blocks and make new rect list */
for (y = 0; y < th; y++)
{
for (x = 0; x < tw; x++)
@ -132,3 +185,26 @@ __imlib_FreeUpdates(ImlibUpdate *u)
}
}
ImlibUpdate *
__imlib_DupUpdates(ImlibUpdate *u)
{
ImlibUpdate *uu, *cu, *pu, *ru;
if (!u)
return NULL;
uu = malloc(sizeof(ImlibUpdate));
memcpy(uu, u, sizeof(ImlibUpdate));
cu = u->next;
pu = u;
ru = uu;
while (cu)
{
uu = malloc(sizeof(ImlibUpdate));
memcpy(uu, u, sizeof(ImlibUpdate));
pu->next = uu;
pu = cu;
cu = cu->next;
}
return ru;
}

View File

@ -9,7 +9,8 @@ struct _imlibupdate
};
ImlibUpdate *__imlib_AddUpdate(ImlibUpdate *u, int x, int y, int w, int h);
ImlibUpdate *__imlib_MergeUpdate(ImlibUpdate *u, int w, int h);
ImlibUpdate *__imlib_MergeUpdate(ImlibUpdate *u, int w, int h, int hgapmax);
void __imlib_FreeUpdates(ImlibUpdate *u);
ImlibUpdate *__imlib_DupUpdates(ImlibUpdate *u);
#endif