nanogui: it seems a bug
Subject:
Re: it seems a bug
From:
"zjujoe" ####@####.####
Date:
13 Nov 2000 08:02:57 -0000
Message-Id: <007501c04d48$be27b030$4ac809c0@step5>
hi,here is my version of drawhline and drawvline:
/* Draw horizontal line from x1,y to x2,y including final point*/
static void
mempl4_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
{
ADDR8 addr = psd->addr;
int cc;
assert (addr != 0);
assert (x1 >= 0 && x1 < psd->xres);
assert (x2 >= 0 && x2 < psd->xres);
assert (x2 >= x1);
assert (y >= 0 && y < psd->yres);
assert (c < psd->ncolors);
addr += (x1>>1) + y * psd->linelen;
cc = c | (c << 4);
if(gr_mode == MWMODE_XOR) {
if (x1 & 1) {
*addr = (*addr & notmask[1]) | (c ^ (*addr & notmask[0]));
*addr++;
x1 ++;
}
while (x1 < x2) {
*addr++ ^= cc ;
x1 += 2;
}
if (x1 == x2)
*addr = (*addr & notmask[0]) | ((c << 4)^(*addr & notmask[1]));
} else {
if (x1 & 1) {
*addr = (*addr & notmask[1]) | c;
*addr++;
x1 ++;
}
while (x1 < x2) {
*addr++ = cc ;
x1 += 2;
}
if (x1 == x2)
*addr = (*addr & notmask[0]) | (c << 4);
}
}
}
/* Draw a vertical line from x,y1 to x,y2 including final point*/
static void
mempl4_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
{
ADDR8 addr = psd->addr;
int linelen = psd->linelen;
assert (addr != 0);
assert (x >= 0 && x < psd->xres);
assert (y1 >= 0 && y1 < psd->yres);
assert (y2 >= 0 && y2 < psd->yres);
assert (y2 >= y1);
assert (c < psd->ncolors);
addr += (x>>1) + y1 * linelen;
if(gr_mode == MWMODE_XOR)
while(y1++ <= y2) {
*addr ^= (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2) ^ (*addr¬mask[1 - x&1]));
addr += linelen;
}
else
while(y1++ <= y2) {
*addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2));
addr += linelen;
}
}
----- Original Message -----
From: Greg Haerr ####@####.####
To: zjujoe ####@####.#### ####@####.####
Sent: Monday, November 13, 2000 1:37 AM
Subject: Re: it seems a bug
> : in microwin/src/drivers/fblin4.c: line 93. it seems we should only do xor to
> the right part.
> : such as :
> : *addr = (*addr & notmask[x1&1]) | ((c << ((1-(x1&1))<<2)) ^ (*addr &
> notmask[1-x1&1]) );
> : is it right...
>
>
> Hmm.. It looks like you're correct. This bug is normally
> not noticed except when lines are drawn with an odd length.
> Also, fblin2.c and fblin1.c have the same problem.
>
>
> :
> : and
> :
> : we can do some optimization:
> : newc = c |( c << 4);
> : then we can do most operation ( XOR , SET) byte by byte, only need
> : do half bytes operation at the beginning or end.
>
> That's a great idea. I don't have a 4bpp machine here,
> can you fix it and provide an optimized version as well?
>
> Regards,
>
> Greg
>
>
>