| @@ -3,8 +3,6 @@ · 2 unmodified lines |
| 3 | 3 | #include <draw.h> |
| 4 | 4 | #include <memdraw.h> |
| 5 | 5 | |
| 6 | | −int drawdebug; |
| 7 | | − |
| 8 | 6 | /* perfect approximation to NTSC = .299r+.587g+.114b when 0 ≤ r,g,b < 256 */ |
| 9 | 7 | #define RGB2K(r,g,b) ((156763*(r)+307758*(g)+59769*(b))>>19) |
| 10 | 8 | |
| @@ -91,7 +89,6 @@ static ulong imgtorgba(Memimage*, ulong); · 80 unmodified lines |
| 91 | 89 | static ulong rgbatoimg(Memimage*, ulong); |
| 92 | 90 | static ulong pixelbits(Memimage*, Point); |
| 93 | 91 | |
| 94 | | −#define DBG if(0) |
| 95 | 92 | void |
| 96 | 93 | memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1, int op) |
| 97 | 94 | { |
| @@ -100,19 +97,11 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask · 2 unmodified lines |
| 100 | 97 | if(mask == nil) |
| 101 | 98 | mask = memopaque; |
| 102 | 99 | |
| 103 | | −DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->chan, r, dst->data->bdata, src, src->chan, p0, mask, mask->chan, p1); |
| 104 | | − |
| 105 | | − if(drawclip(dst, &r, src, &p0, mask, &p1, &par.sr, &par.mr) == 0){ |
| 106 | | −// if(drawdebug) |
| 107 | | −// iprint("empty clipped rectangle\n"); |
| 100 | + if(drawclip(dst, &r, src, &p0, mask, &p1, &par.sr, &par.mr) == 0) |
| 108 | 101 | return; |
| 109 | | − } |
| 110 | 102 | |
| 111 | | − if(op < Clear || op > SoverD){ |
| 112 | | −// if(drawdebug) |
| 113 | | −// iprint("op out of range: %d\n", op); |
| 103 | + if(op < Clear || op > SoverD) |
| 114 | 104 | return; |
| 115 | | − } |
| 116 | 105 | |
| 117 | 106 | par.op = op; |
| 118 | 107 | par.dst = dst; |
| @@ -130,10 +119,8 @@ DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->ch · 11 unmodified lines |
| 130 | 119 | par.state |= Simplesrc; |
| 131 | 120 | par.srgba = imgtorgba(src, par.sval); |
| 132 | 121 | par.sdval = rgbatoimg(dst, par.srgba); |
| 133 | | − if((par.srgba&0xFF) == 0 && (op&DoutS)){ |
| 134 | | −// if (drawdebug) iprint("fill with transparent source\n"); |
| 122 | + if((par.srgba&0xFF) == 0 && (op&DoutS)) |
| 135 | 123 | return; /* no-op successfully handled */ |
| 136 | | − } |
| 137 | 124 | } |
| 138 | 125 | } |
| 139 | 126 | |
| @@ -141,10 +128,8 @@ DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->ch · 1 unmodified line |
| 141 | 128 | par.state |= Replmask; |
| 142 | 129 | if(Dx(mask->r)==1 && Dy(mask->r)==1){ |
| 143 | 130 | par.mval = pixelbits(mask, mask->r.min); |
| 144 | | − if(par.mval == 0 && (op&DoutS)){ |
| 145 | | −// if(drawdebug) iprint("fill with zero mask\n"); |
| 131 | + if(par.mval == 0 && (op&DoutS)) |
| 146 | 132 | return; /* no-op successfully handled */ |
| 147 | | − } |
| 148 | 133 | par.state |= Simplemask; |
| 149 | 134 | if(par.mval == ~0) |
| 150 | 135 | par.state |= Fullmask; |
| @@ -152,10 +137,6 @@ DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->ch · 1 unmodified line |
| 152 | 137 | } |
| 153 | 138 | } |
| 154 | 139 | |
| 155 | | −// if(drawdebug) |
| 156 | | −// iprint("dr %R sr %R mr %R...", r, par.sr, par.mr); |
| 157 | | −DBG print("draw dr %R sr %R mr %R %lux\n", r, par.sr, par.mr, par.state); |
| 158 | | − |
| 159 | 140 | /* |
| 160 | 141 | * Now that we've clipped the parameters down to be consistent, we |
| 161 | 142 | * simply try sub-drawing routines in order until we find one that was able |
| @@ -168,42 +149,27 @@ DBG print("draw dr %R sr %R mr %R %lux\n", r, par.sr, par.mr, par.state); · 6 unmodified lines |
| 168 | 149 | * which checks to see if there is anything it can help with. |
| 169 | 150 | * There could be an if around this checking to see if dst is in video memory. |
| 170 | 151 | */ |
| 171 | | −DBG print("test hwdraw\n"); |
| 172 | | − if(hwdraw(&par)){ |
| 173 | | −//if(drawdebug) iprint("hw handled\n"); |
| 174 | | −DBG print("hwdraw handled\n"); |
| 152 | + if(hwdraw(&par)) |
| 175 | 153 | return; |
| 176 | | − } |
| 154 | + |
| 177 | 155 | /* |
| 178 | 156 | * Optimizations using memmove and memset. |
| 179 | 157 | */ |
| 180 | | −DBG print("test memoptdraw\n"); |
| 181 | | − if(memoptdraw(&par)){ |
| 182 | | −//if(drawdebug) iprint("memopt handled\n"); |
| 183 | | −DBG print("memopt handled\n"); |
| 158 | + if(memoptdraw(&par)) |
| 184 | 159 | return; |
| 185 | | − } |
| 186 | 160 | |
| 187 | 161 | /* |
| 188 | 162 | * Character drawing. |
| 189 | 163 | * Solid source color being painted through a boolean mask onto a high res image. |
| 190 | 164 | */ |
| 191 | | −DBG print("test chardraw\n"); |
| 192 | | − if(chardraw(&par)){ |
| 193 | | −//if(drawdebug) iprint("chardraw handled\n"); |
| 194 | | −DBG print("chardraw handled\n"); |
| 165 | + if(chardraw(&par)) |
| 195 | 166 | return; |
| 196 | | − } |
| 197 | 167 | |
| 198 | 168 | /* |
| 199 | 169 | * General calculation-laden case that does alpha for each pixel. |
| 200 | 170 | */ |
| 201 | | −DBG print("do alphadraw\n"); |
| 202 | 171 | alphadraw(&par); |
| 203 | | −//if(drawdebug) iprint("alphadraw handled\n"); |
| 204 | | −DBG print("alphadraw handled\n"); |
| 205 | 172 | } |
| 206 | | −#undef DBG |
| 207 | 173 | |
| 208 | 174 | |
| 209 | 175 | /* |
| @@ -573,40 +539,6 @@ clipy(Memimage *img, int *y) · 363 unmodified lines |
| 573 | 539 | assert(0 <= *y && *y < dy); |
| 574 | 540 | } |
| 575 | 541 | |
| 576 | | −static void |
| 577 | | −dumpbuf(char *s, Buffer b, int n) |
| 578 | | −{ |
| 579 | | − int i; |
| 580 | | − uchar *p; |
| 581 | | − |
| 582 | | − print("%s", s); |
| 583 | | − for(i=0; i<n; i++){ |
| 584 | | − print(" "); |
| 585 | | − if(p=b.grey){ |
| 586 | | − print(" k%.2uX", *p); |
| 587 | | − b.grey += b.delta; |
| 588 | | − }else{ |
| 589 | | − if(p=b.red){ |
| 590 | | − print(" r%.2uX", *p); |
| 591 | | − b.red += b.delta; |
| 592 | | − } |
| 593 | | − if(p=b.grn){ |
| 594 | | − print(" g%.2uX", *p); |
| 595 | | − b.grn += b.delta; |
| 596 | | − } |
| 597 | | − if(p=b.blu){ |
| 598 | | − print(" b%.2uX", *p); |
| 599 | | − b.blu += b.delta; |
| 600 | | − } |
| 601 | | − } |
| 602 | | − if((p=b.alpha) != &ones){ |
| 603 | | − print(" α%.2uX", *p); |
| 604 | | − b.alpha += b.delta; |
| 605 | | − } |
| 606 | | − } |
| 607 | | − print("\n"); |
| 608 | | −} |
| 609 | | − |
| 610 | 542 | /* |
| 611 | 543 | * For each scan line, we expand the pixels from source, mask, and destination |
| 612 | 544 | * into byte-aligned red, green, blue, alpha, and grey channels. If buffering is not |
| @@ -622,7 +554,6 @@ dumpbuf(char *s, Buffer b, int n) · 9 unmodified lines |
| 622 | 554 | * the calculator, and that buffer is passed to a function to write it to the destination. |
| 623 | 555 | * If the buffer is already pointing at the destination, the writing function is a no-op. |
| 624 | 556 | */ |
| 625 | | −#define DBG if(0) |
| 626 | 557 | static int |
| 627 | 558 | alphadraw(Memdrawparam *par) |
| 628 | 559 | { |
| @@ -686,9 +617,7 @@ alphadraw(Memdrawparam *par) · 57 unmodified lines |
| 686 | 617 | * but it avoids a fair amount of code duplication to make this a case here |
| 687 | 618 | * rather than have a separate booldraw. |
| 688 | 619 | */ |
| 689 | | −//if(drawdebug) iprint("flag %lud mchan %lux=?%x dd %d\n", src->flags&Falpha, mask->chan, GREY1, dst->depth); |
| 690 | 620 | if(!(src->flags&Falpha) && mask->chan == GREY1 && dst->depth >= 8 && op == SoverD){ |
| 691 | | −//if(drawdebug) iprint("boolcopy..."); |
| 692 | 621 | rdsrc = convfn(dst, &z->dpar, src, &z->spar, &ndrawbuf); |
| 693 | 622 | rddst = readptr; |
| 694 | 623 | rdmask = readfn(mask); |
| @@ -788,13 +717,8 @@ alphadraw(Memdrawparam *par) · 93 unmodified lines |
| 788 | 717 | clipy(mask, &masky); |
| 789 | 718 | |
| 790 | 719 | bsrc = rdsrc(&z->spar, z->spar.bufbase, srcy); |
| 791 | | −DBG print("["); |
| 792 | 720 | bmask = rdmask(&z->mpar, z->mpar.bufbase, masky); |
| 793 | | −DBG print("]\n"); |
| 794 | 721 | bdst = rddst(&z->dpar, z->dpar.bufbase, dsty); |
| 795 | | −DBG dumpbuf("src", bsrc, dx); |
| 796 | | −DBG dumpbuf("mask", bmask, dx); |
| 797 | | −DBG dumpbuf("dst", bdst, dx); |
| 798 | 722 | bdst = calc(bdst, bsrc, bmask, dx, isgrey, op); |
| 799 | 723 | wrdst(&z->dpar, z->dpar.bytermin+dsty*z->dpar.bwidth, bdst); |
| 800 | 724 | } |
| @@ -802,7 +726,6 @@ DBG dumpbuf("dst", bdst, dx); · 1 unmodified line |
| 802 | 726 | z->inuse = 0; |
| 803 | 727 | return 1; |
| 804 | 728 | } |
| 805 | | −#undef DBG |
| 806 | 729 | |
| 807 | 730 | static Buffer |
| 808 | 731 | alphacalc0(Buffer bdst, Buffer b1, Buffer b2, int dx, int grey, int op) |
| @@ -1329,7 +1252,6 @@ greymaskread(Param *p, uchar *buf, int y) · 520 unmodified lines |
| 1329 | 1252 | return b; |
| 1330 | 1253 | } |
| 1331 | 1254 | |
| 1332 | | −#define DBG if(0) |
| 1333 | 1255 | static Buffer |
| 1334 | 1256 | readnbit(Param *p, uchar *buf, int y) |
| 1335 | 1257 | { |
| @@ -1358,22 +1280,18 @@ readnbit(Param *p, uchar *buf, int y) · 22 unmodified lines |
| 1358 | 1280 | n = p->img->r.max.x - x; |
| 1359 | 1281 | |
| 1360 | 1282 | r = p->bytermin + y*p->bwidth; |
| 1361 | | −DBG print("readnbit dx %d %p=%p+%d*%d, *r=%d fetch %d ", dx, r, p->bytermin, y, p->bwidth, *r, n); |
| 1362 | 1283 | bits = *r++; |
| 1363 | 1284 | nbits = 8; |
| 1364 | 1285 | if(i=x&(npack-1)){ |
| 1365 | | −DBG print("throwaway %d...", i); |
| 1366 | 1286 | bits <<= depth*i; |
| 1367 | 1287 | nbits -= depth*i; |
| 1368 | 1288 | } |
| 1369 | 1289 | for(i=0; i<n; i++){ |
| 1370 | 1290 | if(nbits == 0){ |
| 1371 | | −DBG print("(%.2ux)...", *r); |
| 1372 | 1291 | bits = *r++; |
| 1373 | 1292 | nbits = 8; |
| 1374 | 1293 | } |
| 1375 | 1294 | *w++ = repl[bits>>sh]; |
| 1376 | | −DBG print("bit %x...", repl[bits>>sh]); |
| 1377 | 1295 | bits <<= depth; |
| 1378 | 1296 | nbits -= depth; |
| 1379 | 1297 | } |
| @@ -1390,24 +1308,20 @@ DBG print("bit %x...", repl[bits>>sh]); · 10 unmodified lines |
| 1390 | 1308 | n = p->r.min.x - x; |
| 1391 | 1309 | |
| 1392 | 1310 | r = p->bytey0s + y*p->bwidth; |
| 1393 | | −DBG print("x=%d r=%p...", x, r); |
| 1394 | 1311 | bits = *r++; |
| 1395 | 1312 | nbits = 8; |
| 1396 | 1313 | if(i=x&(npack-1)){ |
| 1397 | 1314 | bits <<= depth*i; |
| 1398 | 1315 | nbits -= depth*i; |
| 1399 | 1316 | } |
| 1400 | | −DBG print("nbits=%d...", nbits); |
| 1401 | 1317 | for(i=0; i<n; i++){ |
| 1402 | 1318 | if(nbits == 0){ |
| 1403 | 1319 | bits = *r++; |
| 1404 | 1320 | nbits = 8; |
| 1405 | 1321 | } |
| 1406 | 1322 | *w++ = repl[bits>>sh]; |
| 1407 | | −DBG print("bit %x...", repl[bits>>sh]); |
| 1408 | 1323 | bits <<= depth; |
| 1409 | 1324 | nbits -= depth; |
| 1410 | | −DBG print("bits %x nbits %d...", bits, nbits); |
| 1411 | 1325 | } |
| 1412 | 1326 | dx -= n; |
| 1413 | 1327 | if(dx == 0) |
| @@ -1421,9 +1335,7 @@ DBG print("bits %x nbits %d...", bits, nbits); · 7 unmodified lines |
| 1421 | 1335 | |
| 1422 | 1336 | return b; |
| 1423 | 1337 | } |
| 1424 | | −#undef DBG |
| 1425 | 1338 | |
| 1426 | | −#define DBG if(0) |
| 1427 | 1339 | static void |
| 1428 | 1340 | writenbit(Param *p, uchar *w, Buffer src) |
| 1429 | 1341 | { |
| @@ -1446,7 +1358,6 @@ writenbit(Param *p, uchar *w, Buffer src) · 16 unmodified lines |
| 1446 | 1358 | |
| 1447 | 1359 | for(; x<ex; x++){ |
| 1448 | 1360 | bits <<= depth; |
| 1449 | | −DBG print(" %x", *r); |
| 1450 | 1361 | bits |= (*r++ >> sh); |
| 1451 | 1362 | nbits += depth; |
| 1452 | 1363 | if(nbits == 8){ |
| @@ -1461,10 +1372,8 @@ DBG print(" %x", *r); · 8 unmodified lines |
| 1461 | 1372 | bits |= *w & ((1<<sh)-1); |
| 1462 | 1373 | *w = bits; |
| 1463 | 1374 | } |
| 1464 | | −DBG print("\n"); |
| 1465 | 1375 | return; |
| 1466 | 1376 | } |
| 1467 | | −#undef DBG |
| 1468 | 1377 | |
| 1469 | 1378 | static Buffer |
| 1470 | 1379 | readcmap(Param *p, uchar *buf, int y) |
| @@ -1562,7 +1471,6 @@ writecmap(Param *p, uchar *w, Buffer src) · 91 unmodified lines |
| 1562 | 1471 | } |
| 1563 | 1472 | } |
| 1564 | 1473 | |
| 1565 | | −#define DBG if(0) |
| 1566 | 1474 | static Buffer |
| 1567 | 1475 | readbyte(Param *p, uchar *buf, int y) |
| 1568 | 1476 | { |
| @@ -1587,7 +1495,6 @@ readbyte(Param *p, uchar *buf, int y) · 18 unmodified lines |
| 1587 | 1495 | alphaonly = p->alphaonly; |
| 1588 | 1496 | copyalpha = (img->flags&Falpha) != 0; |
| 1589 | 1497 | |
| 1590 | | −DBG print("copyalpha %d alphaonly %d convgrey %d isgrey %d\n", copyalpha, alphaonly, convgrey, isgrey); |
| 1591 | 1498 | /* if we can, avoid processing everything */ |
| 1592 | 1499 | if(!(img->flags&Frepl) && !convgrey && (img->flags&Fbytes)){ |
| 1593 | 1500 | memset(&b, 0, sizeof b); |
| @@ -1612,7 +1519,6 @@ DBG print("copyalpha %d alphaonly %d convgrey %d isgrey %d\n", copyalpha, alphao · 18 unmodified lines |
| 1612 | 1519 | return b; |
| 1613 | 1520 | } |
| 1614 | 1521 | |
| 1615 | | −DBG print("2\n"); |
| 1616 | 1522 | rrepl = replbit[img->nbits[CRed]]; |
| 1617 | 1523 | grepl = replbit[img->nbits[CGreen]]; |
| 1618 | 1524 | brepl = replbit[img->nbits[CBlue]]; |
| @@ -1623,7 +1529,6 @@ DBG print("2\n"); · 4 unmodified lines |
| 1623 | 1529 | u = r[0] | (r[1]<<8) | (r[2]<<16) | (r[3]<<24); |
| 1624 | 1530 | if(copyalpha) { |
| 1625 | 1531 | *w++ = arepl[(u>>img->shift[CAlpha]) & img->mask[CAlpha]]; |
| 1626 | | −DBG print("a %x\n", w[-1]); |
| 1627 | 1532 | } |
| 1628 | 1533 | |
| 1629 | 1534 | if(isgrey) |
| @@ -1633,9 +1538,7 @@ DBG print("a %x\n", w[-1]); · 3 unmodified lines |
| 1633 | 1538 | ugrn = grepl[(u >> img->shift[CGreen]) & img->mask[CGreen]]; |
| 1634 | 1539 | ublu = brepl[(u >> img->shift[CBlue]) & img->mask[CBlue]]; |
| 1635 | 1540 | if(convgrey){ |
| 1636 | | −DBG print("g %x %x %x\n", ured, ugrn, ublu); |
| 1637 | 1541 | *w++ = RGB2K(ured, ugrn, ublu); |
| 1638 | | −DBG print("%x\n", w[-1]); |
| 1639 | 1542 | }else{ |
| 1640 | 1543 | w[0] = ublu; |
| 1641 | 1544 | w[1] = ugrn; |
| @@ -1659,7 +1562,6 @@ DBG print("%x\n", w[-1]); · 17 unmodified lines |
| 1659 | 1562 | b.grey = buf+copyalpha; |
| 1660 | 1563 | b.red = b.grn = b.blu = buf+copyalpha; |
| 1661 | 1564 | b.delta = copyalpha+1; |
| 1662 | | −DBG print("alpha %x grey %x\n", *b.alpha, *b.grey); |
| 1663 | 1565 | }else{ |
| 1664 | 1566 | b.blu = buf+copyalpha; |
| 1665 | 1567 | b.grn = buf+copyalpha+1; |
| @@ -1669,9 +1571,7 @@ DBG print("alpha %x grey %x\n", *b.alpha, *b.grey); · 3 unmodified lines |
| 1669 | 1571 | } |
| 1670 | 1572 | return b; |
| 1671 | 1573 | } |
| 1672 | | −#undef DBG |
| 1673 | 1574 | |
| 1674 | | −#define DBG if(0) |
| 1675 | 1575 | static void |
| 1676 | 1576 | writebyte(Param *p, uchar *w, Buffer src) |
| 1677 | 1577 | { |
| @@ -1732,12 +1632,9 @@ writebyte(Param *p, uchar *w, Buffer src) · 54 unmodified lines |
| 1732 | 1632 | mask = (nb==4) ? 0 : ~((1<<img->depth)-1); |
| 1733 | 1633 | for(i=0; i<dx; i++){ |
| 1734 | 1634 | u = w[0] | (w[1]<<8) | (w[2]<<16) | (w[3]<<24); |
| 1735 | | −DBG print("u %.8lux...", u); |
| 1736 | 1635 | u &= mask; |
| 1737 | | −DBG print("&mask %.8lux...", u); |
| 1738 | 1636 | if(isgrey){ |
| 1739 | 1637 | u |= ((*grey >> (8-img->nbits[CGrey])) & img->mask[CGrey]) << img->shift[CGrey]; |
| 1740 | | −DBG print("|grey %.8lux...", u); |
| 1741 | 1638 | grey += delta; |
| 1742 | 1639 | }else{ |
| 1743 | 1640 | u |= ((*red >> (8-img->nbits[CRed])) & img->mask[CRed]) << img->shift[CRed]; |
| @@ -1746,13 +1643,11 @@ DBG print("|grey %.8lux...", u); · 2 unmodified lines |
| 1746 | 1643 | red += delta; |
| 1747 | 1644 | grn += delta; |
| 1748 | 1645 | blu += delta; |
| 1749 | | −DBG print("|rgb %.8lux...", u); |
| 1750 | 1646 | } |
| 1751 | 1647 | |
| 1752 | 1648 | if(isalpha){ |
| 1753 | 1649 | u |= ((*alpha >> (8-img->nbits[CAlpha])) & img->mask[CAlpha]) << img->shift[CAlpha]; |
| 1754 | 1650 | alpha += adelta; |
| 1755 | | −DBG print("|alpha %.8lux...", u); |
| 1756 | 1651 | } |
| 1757 | 1652 | |
| 1758 | 1653 | w[0] = u; |
| @@ -1762,7 +1657,6 @@ DBG print("|alpha %.8lux...", u); · 3 unmodified lines |
| 1762 | 1657 | w += nb; |
| 1763 | 1658 | } |
| 1764 | 1659 | } |
| 1765 | | −#undef DBG |
| 1766 | 1660 | |
| 1767 | 1661 | static Readfn* |
| 1768 | 1662 | readfn(Memimage *img) |
| @@ -1935,14 +1829,11 @@ genconv(Param *p, uchar *buf, int y) · 166 unmodified lines |
| 1935 | 1829 | static Readfn* |
| 1936 | 1830 | convfn(Memimage *dst, Param *dpar, Memimage *src, Param *spar, int *ndrawbuf) |
| 1937 | 1831 | { |
| 1938 | | − if(dst->chan == src->chan && !(src->flags&Frepl)){ |
| 1939 | | −//if(drawdebug) iprint("readptr..."); |
| 1832 | + if(dst->chan == src->chan && !(src->flags&Frepl)) |
| 1940 | 1833 | return readptr; |
| 1941 | | − } |
| 1942 | 1834 | |
| 1943 | 1835 | if(dst->chan==CMAP8 && (src->chan==GREY1||src->chan==GREY2||src->chan==GREY4)){ |
| 1944 | 1836 | /* cheat because we know the replicated value is exactly the color map entry. */ |
| 1945 | | −//if(drawdebug) iprint("Readnbit..."); |
| 1946 | 1837 | return readnbit; |
| 1947 | 1838 | } |
| 1948 | 1839 | |
| @@ -1959,7 +1850,6 @@ convfn(Memimage *dst, Param *dpar, Memimage *src, Param *spar, int *ndrawbuf) · 10 unmodified lines |
| 1959 | 1850 | spar->dx = Dx(spar->img->r); |
| 1960 | 1851 | } |
| 1961 | 1852 | |
| 1962 | | −//if(drawdebug) iprint("genconv..."); |
| 1963 | 1853 | return genconv; |
| 1964 | 1854 | } |
| 1965 | 1855 | |
| @@ -2170,11 +2060,9 @@ rgbatoimg(Memimage *img, ulong rgba) · 204 unmodified lines |
| 2170 | 2060 | } |
| 2171 | 2061 | d += nb; |
| 2172 | 2062 | } |
| 2173 | | −// print("rgba2img %.8lux = %.*lux\n", rgba, 2*d/8, v); |
| 2174 | 2063 | return v; |
| 2175 | 2064 | } |
| 2176 | 2065 | |
| 2177 | | −#define DBG if(0) |
| 2178 | 2066 | static int |
| 2179 | 2067 | memoptdraw(Memdrawparam *par) |
| 2180 | 2068 | { |
| @@ -2189,7 +2077,6 @@ memoptdraw(Memdrawparam *par) · 8 unmodified lines |
| 2189 | 2077 | dst = par->dst; |
| 2190 | 2078 | op = par->op; |
| 2191 | 2079 | |
| 2192 | | −DBG print("state %lux mval %lux dd %d\n", par->state, par->mval, dst->depth); |
| 2193 | 2080 | /* |
| 2194 | 2081 | * If we have an opaque mask and source is one opaque pixel we can convert to the |
| 2195 | 2082 | * destination format and just replicate with memset. |
| @@ -2199,11 +2086,9 @@ DBG print("state %lux mval %lux dd %d\n", par->state, par->mval, dst->depth); · 3 unmodified lines |
| 2199 | 2086 | int d, dwid, ppb, np, nb; |
| 2200 | 2087 | uchar *dp, lm, rm; |
| 2201 | 2088 | |
| 2202 | | −DBG print("memopt, dst %p, dst->data->bdata %p\n", dst, dst->data->bdata); |
| 2203 | 2089 | dwid = dst->width*sizeof(ulong); |
| 2204 | 2090 | dp = byteaddr(dst, par->r.min); |
| 2205 | 2091 | v = par->sdval; |
| 2206 | | −DBG print("sdval %lud, depth %d\n", v, dst->depth); |
| 2207 | 2092 | switch(dst->depth){ |
| 2208 | 2093 | case 1: |
| 2209 | 2094 | case 2: |
| @@ -2217,16 +2102,13 @@ DBG print("sdval %lud, depth %d\n", v, dst->depth); · 7 unmodified lines |
| 2217 | 2102 | dx -= (ppb-np); |
| 2218 | 2103 | nb = 8 - np * dst->depth; /* no. bits used on right side of word */ |
| 2219 | 2104 | lm = (1<<nb)-1; |
| 2220 | | −DBG print("np %d x %d nb %d lm %ux ppb %d m %ux\n", np, par->r.min.x, nb, lm, ppb, m); |
| 2221 | 2105 | |
| 2222 | 2106 | /* right edge */ |
| 2223 | 2107 | np = par->r.max.x&m; /* no. pixels used on left side of word */ |
| 2224 | 2108 | dx -= np; |
| 2225 | 2109 | nb = 8 - np * dst->depth; /* no. bits unused on right side of word */ |
| 2226 | 2110 | rm = ~((1<<nb)-1); |
| 2227 | | −DBG print("np %d x %d nb %d rm %ux ppb %d m %ux\n", np, par->r.max.x, nb, rm, ppb, m); |
| 2228 | 2111 | |
| 2229 | | −DBG print("dx %d Dx %d\n", dx, Dx(par->r)); |
| 2230 | 2112 | /* lm, rm are masks that are 1 where we should touch the bits */ |
| 2231 | 2113 | if(dx < 0){ /* just one byte */ |
| 2232 | 2114 | lm &= rm; |
| @@ -2238,7 +2120,6 @@ DBG print("dx %d Dx %d\n", dx, Dx(par->r)); · 5 unmodified lines |
| 2238 | 2120 | |
| 2239 | 2121 | for(y=0; y<dy; y++, dp+=dwid){ |
| 2240 | 2122 | if(lm){ |
| 2241 | | −DBG print("dp %p v %lux lm %ux (v ^ *dp) & lm %lux\n", dp, v, lm, (v^*dp)&lm); |
| 2242 | 2123 | *dp ^= (v ^ *dp) & lm; |
| 2243 | 2124 | dp++; |
| 2244 | 2125 | } |
| @@ -2412,13 +2293,11 @@ DBG print("dp %p v %lux lm %ux (v ^ *dp) & lm %lux\n", dp, v, lm, (v^*dp)&lm); · 167 unmodified lines |
| 2412 | 2293 | } |
| 2413 | 2294 | return 0; |
| 2414 | 2295 | } |
| 2415 | | −#undef DBG |
| 2416 | 2296 | |
| 2417 | 2297 | /* |
| 2418 | 2298 | * Boolean character drawing. |
| 2419 | 2299 | * Solid opaque color through a 1-bit greyscale mask. |
| 2420 | 2300 | */ |
| 2421 | | −#define DBG if(0) |
| 2422 | 2301 | static int |
| 2423 | 2302 | chardraw(Memdrawparam *par) |
| 2424 | 2303 | { |
| @@ -2431,10 +2310,6 @@ chardraw(Memdrawparam *par) · 6 unmodified lines |
| 2431 | 2310 | Rectangle r, mr; |
| 2432 | 2311 | Memimage *mask, *src, *dst; |
| 2433 | 2312 | |
| 2434 | | −if(0) if(drawdebug) iprint("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d ddat %p sdat %p\n", |
| 2435 | | − par->mask->flags, par->mask->depth, par->src->flags, |
| 2436 | | − Dx(par->src->r), Dy(par->src->r), par->dst->depth, par->dst->data, par->src->data); |
| 2437 | | − |
| 2438 | 2313 | mask = par->mask; |
| 2439 | 2314 | src = par->src; |
| 2440 | 2315 | dst = par->dst; |
| @@ -2447,8 +2322,6 @@ if(0) if(drawdebug) iprint("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d · 6 unmodified lines |
| 2447 | 2322 | || op != SoverD) |
| 2448 | 2323 | return 0; |
| 2449 | 2324 | |
| 2450 | | −//if(drawdebug) iprint("chardraw..."); |
| 2451 | | − |
| 2452 | 2325 | depth = mask->depth; |
| 2453 | 2326 | maskwid = mask->width*sizeof(ulong); |
| 2454 | 2327 | rp = byteaddr(mask, mr.min); |
| @@ -2457,7 +2330,6 @@ if(0) if(drawdebug) iprint("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d · 2 unmodified lines |
| 2457 | 2330 | |
| 2458 | 2331 | wp = byteaddr(dst, r.min); |
| 2459 | 2332 | dstwid = dst->width*sizeof(ulong); |
| 2460 | | −DBG print("bsh %d\n", bsh); |
| 2461 | 2333 | dy = Dy(r); |
| 2462 | 2334 | dx = Dx(r); |
| 2463 | 2335 | |
| @@ -2483,20 +2355,17 @@ DBG print("bsh %d\n", bsh); · 19 unmodified lines |
| 2483 | 2355 | sp[2] = v>>16; |
| 2484 | 2356 | sp[3] = v>>24; |
| 2485 | 2357 | |
| 2486 | | −//print("sp %x %x %x %x\n", sp[0], sp[1], sp[2], sp[3]); |
| 2487 | 2358 | for(y=0; y<dy; y++, rp+=maskwid, wp+=dstwid){ |
| 2488 | 2359 | q = rp; |
| 2489 | 2360 | if(bsh) |
| 2490 | 2361 | bits = *q++; |
| 2491 | 2362 | switch(ddepth){ |
| 2492 | 2363 | case 8: |
| 2493 | | −//if(drawdebug) iprint("8loop..."); |
| 2494 | 2364 | wc = wp; |
| 2495 | 2365 | for(x=bx; x>ex; x--, wc++){ |
| 2496 | 2366 | i = x&7; |
| 2497 | 2367 | if(i == 8-1) |
| 2498 | 2368 | bits = *q++; |
| 2499 | | −DBG print("bits %lux sh %d...", bits, i); |
| 2500 | 2369 | if((bits>>i)&1) |
| 2501 | 2370 | *wc = v; |
| 2502 | 2371 | } |
| @@ -2508,7 +2377,6 @@ DBG print("bits %lux sh %d...", bits, i); · 5 unmodified lines |
| 2508 | 2377 | i = x&7; |
| 2509 | 2378 | if(i == 8-1) |
| 2510 | 2379 | bits = *q++; |
| 2511 | | −DBG print("bits %lux sh %d...", bits, i); |
| 2512 | 2380 | if((bits>>i)&1) |
| 2513 | 2381 | *ws = v; |
| 2514 | 2382 | } |
| @@ -2519,7 +2387,6 @@ DBG print("bits %lux sh %d...", bits, i); · 4 unmodified lines |
| 2519 | 2387 | i = x&7; |
| 2520 | 2388 | if(i == 8-1) |
| 2521 | 2389 | bits = *q++; |
| 2522 | | −DBG print("bits %lux sh %d...", bits, i); |
| 2523 | 2390 | if((bits>>i)&1){ |
| 2524 | 2391 | wc[0] = sp[0]; |
| 2525 | 2392 | wc[1] = sp[1]; |
| @@ -2534,18 +2401,14 @@ DBG print("bits %lux sh %d...", bits, i); · 8 unmodified lines |
| 2534 | 2401 | i = x&7; |
| 2535 | 2402 | if(i == 8-1) |
| 2536 | 2403 | bits = *q++; |
| 2537 | | −DBG iprint("bits %lux sh %d...", bits, i); |
| 2538 | 2404 | if((bits>>i)&1) |
| 2539 | 2405 | *wl = v; |
| 2540 | 2406 | } |
| 2541 | 2407 | break; |
| 2542 | 2408 | } |
| 2543 | 2409 | } |
| 2544 | | − |
| 2545 | | −DBG print("\n"); |
| 2546 | 2410 | return 1; |
| 2547 | 2411 | } |
| 2548 | | −#undef DBG |
| 2549 | 2412 | |
| 2550 | 2413 | |
| 2551 | 2414 | void |