amd64 fixes

This commit is contained in:
Russ Cox
2006-05-21 16:32:29 +00:00
parent af11a9e129
commit 5797fdc0c0
28 changed files with 116 additions and 66 deletions

View File

@ -867,12 +867,17 @@ drawpoint(Point *p, uchar *a)
p->y = BGLONG(a+1*4);
}
#define isvgascreen(dst) 1
Point
drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int index, int op)
drawchar(Memimage *dst, Memimage *rdst, Point p,
Memimage *src, Point *sp, DImage *font, int index, int op)
{
FChar *fc;
Rectangle r;
Point sp1;
static Memimage *tmp;
fc = &font->fchar[index];
r.min.x = p.x+fc->left;
@ -881,7 +886,31 @@ drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int ind
r.max.y = r.min.y+(fc->maxy-fc->miny);
sp1.x = sp->x+fc->left;
sp1.y = sp->y+fc->miny;
memdraw(dst, r, src, sp1, font->image, Pt(fc->minx, fc->miny), op);
/*
* If we're drawing greyscale fonts onto a VGA screen,
* it's very costly to read the screen memory to do the
* alpha blending inside memdraw. If this is really a stringbg,
* then rdst is the bg image (in main memory) which we can
* refer to for the underlying dst pixels instead of reading dst
* directly.
*/
if(1 || (isvgascreen(dst) && !isvgascreen(rdst) /*&& font->image->depth > 1*/)){
if(tmp == nil || tmp->chan != dst->chan || Dx(tmp->r) < Dx(r) || Dy(tmp->r) < Dy(r)){
if(tmp)
freememimage(tmp);
tmp = allocmemimage(Rect(0,0,Dx(r),Dy(r)), dst->chan);
if(tmp == nil)
goto fallback;
}
memdraw(tmp, Rect(0,0,Dx(r),Dy(r)), rdst, r.min, memopaque, ZP, S);
memdraw(tmp, Rect(0,0,Dx(r),Dy(r)), src, sp1, font->image, Pt(fc->minx, fc->miny), op);
memdraw(dst, r, tmp, ZP, memopaque, ZP, S);
}else{
fallback:
memdraw(dst, r, src, sp1, font->image, Pt(fc->minx, fc->miny), op);
}
p.x += fc->width;
sp->x += fc->width;
return p;
@ -1873,6 +1902,7 @@ drawmesg(Client *client, void *av, int n)
clipr = dst->clipr;
dst->clipr = r;
op = drawclientop(client);
l = dst;
if(*a == 'x'){
/* paint background */
l = drawimage(client, a+47);
@ -1901,7 +1931,7 @@ drawmesg(Client *client, void *av, int n)
dst->clipr = clipr;
error(Eindex);
}
q = drawchar(dst, q, src, &sp, font, ci, op);
q = drawchar(dst, l, q, src, &sp, font, ci, op);
u += 2;
}
dst->clipr = clipr;