From 9a5e55782d2e25619e645109d3d1a018a13fa7c6 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 29 Apr 2017 21:10:28 +0200 Subject: [PATCH] libmemdraw/libmemlayer: get rid of drawdebug prints --- sys/include/memdraw.h | 8 -- sys/src/libmemdraw/arctest.c | 24 ------ sys/src/libmemdraw/draw.c | 154 ++-------------------------------- sys/src/libmemdraw/drawtest.c | 21 ----- sys/src/libmemlayer/draw.c | 11 +-- 5 files changed, 11 insertions(+), 207 deletions(-) diff --git a/sys/include/memdraw.h b/sys/include/memdraw.h index ccbc2abae..f1bb41e3f 100644 --- a/sys/include/memdraw.h +++ b/sys/include/memdraw.h @@ -175,14 +175,6 @@ extern Memcmap *memdefcmap; */ void memimagemove(void*, void*); -/* - * Kernel cruft - */ -extern void rdb(void); -extern int iprint(char*, ...); -#pragma varargck argpos iprint 1 -extern int drawdebug; - /* * doprint interface: numbconv bit strings */ diff --git a/sys/src/libmemdraw/arctest.c b/sys/src/libmemdraw/arctest.c index 6ea739e8e..cb10024ff 100644 --- a/sys/src/libmemdraw/arctest.c +++ b/sys/src/libmemdraw/arctest.c @@ -4,7 +4,6 @@ #include #include -extern int drawdebug; void main(int argc, char **argv) { @@ -40,26 +39,3 @@ main(int argc, char **argv) t1 = nsec(); print("%lld %lld\n", t1-t0-del, del); } - -int drawdebug = 0; - -void -rdb(void) -{ -} - -int -iprint(char *fmt, ...) -{ - int n; - va_list va; - char buf[1024]; - - va_start(va, fmt); - n = vseprint(buf, buf+sizeof buf, fmt, va) - buf; - va_end(va); - - write(1,buf,n); - return 1; -} - diff --git a/sys/src/libmemdraw/draw.c b/sys/src/libmemdraw/draw.c index 3cb93157d..d72715aad 100644 --- a/sys/src/libmemdraw/draw.c +++ b/sys/src/libmemdraw/draw.c @@ -5,7 +5,6 @@ #include extern Pool* imagmem; -int drawdebug; /* perfect approximation to NTSC = .299r+.587g+.114b when 0 ≤ r,g,b < 256 */ #define RGB2K(r,g,b) ((156763*(r)+307758*(g)+59769*(b))>>19) @@ -98,7 +97,6 @@ static ulong imgtorgba(Memimage*, ulong); static ulong rgbatoimg(Memimage*, ulong); static ulong pixelbits(Memimage*, Point); -#define DBG if(0) void memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1, int op) { @@ -107,19 +105,11 @@ memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask if(mask == nil) mask = memopaque; -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); - - if(drawclip(dst, &r, src, &p0, mask, &p1, &par.sr, &par.mr) == 0){ -// if(drawdebug) -// iprint("empty clipped rectangle\n"); + if(drawclip(dst, &r, src, &p0, mask, &p1, &par.sr, &par.mr) == 0) return; - } - if(op < Clear || op > SoverD){ -// if(drawdebug) -// iprint("op out of range: %d\n", op); + if(op < Clear || op > SoverD) return; - } par.op = op; par.dst = dst; @@ -137,10 +127,8 @@ DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->ch par.state |= Simplesrc; par.srgba = imgtorgba(src, par.sval); par.sdval = rgbatoimg(dst, par.srgba); - if((par.srgba&0xFF) == 0 && (op&DoutS)){ -// if (drawdebug) iprint("fill with transparent source\n"); + if((par.srgba&0xFF) == 0 && (op&DoutS)) return; /* no-op successfully handled */ - } } } @@ -148,10 +136,8 @@ DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->ch par.state |= Replmask; if(Dx(mask->r)==1 && Dy(mask->r)==1){ par.mval = pixelbits(mask, mask->r.min); - if(par.mval == 0 && (op&DoutS)){ -// if(drawdebug) iprint("fill with zero mask\n"); + if(par.mval == 0 && (op&DoutS)) return; /* no-op successfully handled */ - } par.state |= Simplemask; if(par.mval == ~0) par.state |= Fullmask; @@ -159,10 +145,6 @@ DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->ch } } -// if(drawdebug) -// iprint("dr %R sr %R mr %R...", r, par.sr, par.mr); -DBG print("draw dr %R sr %R mr %R %lux\n", r, par.sr, par.mr, par.state); - /* * Now that we've clipped the parameters down to be consistent, we * simply try sub-drawing routines in order until we find one that was able @@ -175,42 +157,27 @@ DBG print("draw dr %R sr %R mr %R %lux\n", r, par.sr, par.mr, par.state); * which checks to see if there is anything it can help with. * There could be an if around this checking to see if dst is in video memory. */ -DBG print("test hwdraw\n"); - if(hwdraw(&par)){ -//if(drawdebug) iprint("hw handled\n"); -DBG print("hwdraw handled\n"); + if(hwdraw(&par)) return; - } + /* * Optimizations using memmove and memset. */ -DBG print("test memoptdraw\n"); - if(memoptdraw(&par)){ -//if(drawdebug) iprint("memopt handled\n"); -DBG print("memopt handled\n"); + if(memoptdraw(&par)) return; - } /* * Character drawing. * Solid source color being painted through a boolean mask onto a high res image. */ -DBG print("test chardraw\n"); - if(chardraw(&par)){ -//if(drawdebug) iprint("chardraw handled\n"); -DBG print("chardraw handled\n"); + if(chardraw(&par)) return; - } /* * General calculation-laden case that does alpha for each pixel. */ -DBG print("do alphadraw\n"); alphadraw(&par); -//if(drawdebug) iprint("alphadraw handled\n"); -DBG print("alphadraw handled\n"); } -#undef DBG /* @@ -580,40 +547,6 @@ clipy(Memimage *img, int *y) assert(0 <= *y && *y < dy); } -static void -dumpbuf(char *s, Buffer b, int n) -{ - int i; - uchar *p; - - print("%s", s); - for(i=0; iflags&Falpha, mask->chan, GREY1, dst->depth); if(!(src->flags&Falpha) && mask->chan == GREY1 && dst->depth >= 8 && op == SoverD){ -//if(drawdebug) iprint("boolcopy..."); rdsrc = convfn(dst, &z->dpar, src, &z->spar, &ndrawbuf); rddst = readptr; rdmask = readfn(mask); @@ -795,13 +725,8 @@ alphadraw(Memdrawparam *par) clipy(mask, &masky); bsrc = rdsrc(&z->spar, z->spar.bufbase, srcy); -DBG print("["); bmask = rdmask(&z->mpar, z->mpar.bufbase, masky); -DBG print("]\n"); bdst = rddst(&z->dpar, z->dpar.bufbase, dsty); -DBG dumpbuf("src", bsrc, dx); -DBG dumpbuf("mask", bmask, dx); -DBG dumpbuf("dst", bdst, dx); bdst = calc(bdst, bsrc, bmask, dx, isgrey, op); wrdst(&z->dpar, z->dpar.bytermin+dsty*z->dpar.bwidth, bdst); } @@ -809,7 +734,6 @@ DBG dumpbuf("dst", bdst, dx); z->inuse = 0; return 1; } -#undef DBG static Buffer alphacalc0(Buffer bdst, Buffer b1, Buffer b2, int dx, int grey, int op) @@ -1342,7 +1266,6 @@ greymaskread(Param *p, uchar *buf, int y) return b; } -#define DBG if(0) static Buffer readnbit(Param *p, uchar *buf, int y) { @@ -1371,22 +1294,18 @@ readnbit(Param *p, uchar *buf, int y) n = p->img->r.max.x - x; r = p->bytermin + y*p->bwidth; -DBG print("readnbit dx %d %p=%p+%d*%d, *r=%d fetch %d ", dx, r, p->bytermin, y, p->bwidth, *r, n); bits = *r++; nbits = 8; if(i=x&(npack-1)){ -DBG print("throwaway %d...", i); bits <<= depth*i; nbits -= depth*i; } for(i=0; i>sh]; -DBG print("bit %x...", repl[bits>>sh]); bits <<= depth; nbits -= depth; } @@ -1403,24 +1322,20 @@ DBG print("bit %x...", repl[bits>>sh]); n = p->r.min.x - x; r = p->bytey0s + y*p->bwidth; -DBG print("x=%d r=%p...", x, r); bits = *r++; nbits = 8; if(i=x&(npack-1)){ bits <<= depth*i; nbits -= depth*i; } -DBG print("nbits=%d...", nbits); for(i=0; i>sh]; -DBG print("bit %x...", repl[bits>>sh]); bits <<= depth; nbits -= depth; -DBG print("bits %x nbits %d...", bits, nbits); } dx -= n; if(dx == 0) @@ -1434,9 +1349,7 @@ DBG print("bits %x nbits %d...", bits, nbits); return b; } -#undef DBG -#define DBG if(0) static void writenbit(Param *p, uchar *w, Buffer src) { @@ -1459,7 +1372,6 @@ writenbit(Param *p, uchar *w, Buffer src) for(; x> sh); nbits += depth; if(nbits == 8){ @@ -1474,10 +1386,8 @@ DBG print(" %x", *r); bits |= *w & ((1<alphaonly; copyalpha = (img->flags&Falpha) != 0; -DBG print("copyalpha %d alphaonly %d convgrey %d isgrey %d\n", copyalpha, alphaonly, convgrey, isgrey); /* if we can, avoid processing everything */ if(!(img->flags&Frepl) && !convgrey && (img->flags&Fbytes)){ memset(&b, 0, sizeof b); @@ -1625,7 +1533,6 @@ DBG print("copyalpha %d alphaonly %d convgrey %d isgrey %d\n", copyalpha, alphao return b; } -DBG print("2\n"); rrepl = replbit[img->nbits[CRed]]; grepl = replbit[img->nbits[CGreen]]; brepl = replbit[img->nbits[CBlue]]; @@ -1636,7 +1543,6 @@ DBG print("2\n"); u = r[0] | (r[1]<<8) | (r[2]<<16) | (r[3]<<24); if(copyalpha) { *w++ = arepl[(u>>img->shift[CAlpha]) & img->mask[CAlpha]]; -DBG print("a %x\n", w[-1]); } if(isgrey) @@ -1646,9 +1552,7 @@ DBG print("a %x\n", w[-1]); ugrn = grepl[(u >> img->shift[CGreen]) & img->mask[CGreen]]; ublu = brepl[(u >> img->shift[CBlue]) & img->mask[CBlue]]; if(convgrey){ -DBG print("g %x %x %x\n", ured, ugrn, ublu); *w++ = RGB2K(ured, ugrn, ublu); -DBG print("%x\n", w[-1]); }else{ w[0] = ublu; w[1] = ugrn; @@ -1672,7 +1576,6 @@ DBG print("%x\n", w[-1]); b.grey = buf+copyalpha; b.red = b.grn = b.blu = buf+copyalpha; b.delta = copyalpha+1; -DBG print("alpha %x grey %x\n", *b.alpha, *b.grey); }else{ b.blu = buf+copyalpha; b.grn = buf+copyalpha+1; @@ -1682,9 +1585,7 @@ DBG print("alpha %x grey %x\n", *b.alpha, *b.grey); } return b; } -#undef DBG -#define DBG if(0) static void writebyte(Param *p, uchar *w, Buffer src) { @@ -1745,12 +1646,9 @@ writebyte(Param *p, uchar *w, Buffer src) mask = (nb==4) ? 0 : ~((1<depth)-1); for(i=0; i> (8-img->nbits[CGrey])) & img->mask[CGrey]) << img->shift[CGrey]; -DBG print("|grey %.8lux...", u); grey += delta; }else{ u |= ((*red >> (8-img->nbits[CRed])) & img->mask[CRed]) << img->shift[CRed]; @@ -1759,13 +1657,11 @@ DBG print("|grey %.8lux...", u); red += delta; grn += delta; blu += delta; -DBG print("|rgb %.8lux...", u); } if(isalpha){ u |= ((*alpha >> (8-img->nbits[CAlpha])) & img->mask[CAlpha]) << img->shift[CAlpha]; alpha += adelta; -DBG print("|alpha %.8lux...", u); } w[0] = u; @@ -1775,7 +1671,6 @@ DBG print("|alpha %.8lux...", u); w += nb; } } -#undef DBG static Readfn* readfn(Memimage *img) @@ -1951,14 +1846,11 @@ genconv(Param *p, uchar *buf, int y) static Readfn* convfn(Memimage *dst, Param *dpar, Memimage *src, Param *spar, int *ndrawbuf) { - if(dst->chan == src->chan && !(src->flags&Frepl)){ -//if(drawdebug) iprint("readptr..."); + if(dst->chan == src->chan && !(src->flags&Frepl)) return readptr; - } if(dst->chan==CMAP8 && (src->chan==GREY1||src->chan==GREY2||src->chan==GREY4)){ /* cheat because we know the replicated value is exactly the color map entry. */ -//if(drawdebug) iprint("Readnbit..."); return readnbit; } @@ -1975,7 +1867,6 @@ convfn(Memimage *dst, Param *dpar, Memimage *src, Param *spar, int *ndrawbuf) spar->dx = Dx(spar->img->r); } -//if(drawdebug) iprint("genconv..."); return genconv; } @@ -2186,11 +2077,9 @@ rgbatoimg(Memimage *img, ulong rgba) } d += nb; } -// print("rgba2img %.8lux = %.*lux\n", rgba, 2*d/8, v); return v; } -#define DBG if(0) static int memoptdraw(Memdrawparam *par) { @@ -2205,7 +2094,6 @@ memoptdraw(Memdrawparam *par) dst = par->dst; op = par->op; -DBG print("state %lux mval %lux dd %d\n", par->state, par->mval, dst->depth); /* * If we have an opaque mask and source is one opaque pixel we can convert to the * destination format and just replicate with memset. @@ -2215,11 +2103,9 @@ DBG print("state %lux mval %lux dd %d\n", par->state, par->mval, dst->depth); int d, dwid, ppb, np, nb; uchar *dp, lm, rm; -DBG print("memopt, dst %p, dst->data->bdata %p\n", dst, dst->data->bdata); dwid = dst->width*sizeof(ulong); dp = byteaddr(dst, par->r.min); v = par->sdval; -DBG print("sdval %lud, depth %d\n", v, dst->depth); switch(dst->depth){ case 1: case 2: @@ -2233,16 +2119,13 @@ DBG print("sdval %lud, depth %d\n", v, dst->depth); dx -= (ppb-np); nb = 8 - np * dst->depth; /* no. bits used on right side of word */ lm = (1<r.min.x, nb, lm, ppb, m); /* right edge */ np = par->r.max.x&m; /* no. pixels used on left side of word */ dx -= np; nb = 8 - np * dst->depth; /* no. bits unused on right side of word */ rm = ~((1<r.max.x, nb, rm, ppb, m); -DBG print("dx %d Dx %d\n", dx, Dx(par->r)); /* lm, rm are masks that are 1 where we should touch the bits */ if(dx < 0){ /* just one byte */ lm &= rm; @@ -2254,7 +2137,6 @@ DBG print("dx %d Dx %d\n", dx, Dx(par->r)); for(y=0; ymask->flags, par->mask->depth, par->src->flags, - Dx(par->src->r), Dy(par->src->r), par->dst->depth, par->dst->data, par->src->data); - mask = par->mask; src = par->src; dst = par->dst; @@ -2463,8 +2339,6 @@ if(0) if(drawdebug) iprint("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d || op != SoverD) return 0; -//if(drawdebug) iprint("chardraw..."); - depth = mask->depth; maskwid = mask->width*sizeof(ulong); rp = byteaddr(mask, mr.min); @@ -2473,7 +2347,6 @@ if(0) if(drawdebug) iprint("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d wp = byteaddr(dst, r.min); dstwid = dst->width*sizeof(ulong); -DBG print("bsh %d\n", bsh); dy = Dy(r); dx = Dx(r); @@ -2499,20 +2372,17 @@ DBG print("bsh %d\n", bsh); sp[2] = v>>16; sp[3] = v>>24; -//print("sp %x %x %x %x\n", sp[0], sp[1], sp[2], sp[3]); for(y=0; yex; x--, wc++){ i = x&7; if(i == 8-1) bits = *q++; -DBG print("bits %lux sh %d...", bits, i); if((bits>>i)&1) *wc = v; } @@ -2524,7 +2394,6 @@ DBG print("bits %lux sh %d...", bits, i); i = x&7; if(i == 8-1) bits = *q++; -DBG print("bits %lux sh %d...", bits, i); if((bits>>i)&1) *ws = v; } @@ -2535,7 +2404,6 @@ DBG print("bits %lux sh %d...", bits, i); i = x&7; if(i == 8-1) bits = *q++; -DBG print("bits %lux sh %d...", bits, i); if((bits>>i)&1){ wc[0] = sp[0]; wc[1] = sp[1]; @@ -2550,18 +2418,14 @@ DBG print("bits %lux sh %d...", bits, i); i = x&7; if(i == 8-1) bits = *q++; -DBG iprint("bits %lux sh %d...", bits, i); if((bits>>i)&1) *wl = v; } break; } } - -DBG print("\n"); return 1; } -#undef DBG void diff --git a/sys/src/libmemdraw/drawtest.c b/sys/src/libmemdraw/drawtest.c index 7f71a37cb..08e068e44 100644 --- a/sys/src/libmemdraw/drawtest.c +++ b/sys/src/libmemdraw/drawtest.c @@ -26,7 +26,6 @@ ulong rgbatopix(uchar, uchar, uchar, uchar); char *dchan, *schan, *mchan; int dbpp, sbpp, mbpp; -int drawdebug=0; int seed; int niters = 100; int dbpp; /* bits per pixel in destination */ @@ -49,26 +48,6 @@ uchar *srcbits; uchar *maskbits; ulong *savedstbits; -void -rdb(void) -{ -} - -int -iprint(char *fmt, ...) -{ - int n; - va_list va; - char buf[1024]; - - va_start(va, fmt); - n = vseprint(buf, buf+sizeof buf, fmt, va) - buf; - va_end(va); - - write(1,buf,n); - return 1; -} - void main(int argc, char *argv[]) { diff --git a/sys/src/libmemlayer/draw.c b/sys/src/libmemlayer/draw.c index a9c546bd9..8b3ec6c85 100644 --- a/sys/src/libmemlayer/draw.c +++ b/sys/src/libmemlayer/draw.c @@ -57,16 +57,11 @@ memdraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Poi Rectangle srcr, tr, mr; Memlayer *dl, *sl; - if(drawdebug) - iprint("memdraw %p %R %p %P %p %P\n", dst, r, src, p0, mask, p1); - if(mask == nil) mask = memopaque; - if(mask->layer){ -if(drawdebug) iprint("mask->layer != nil\n"); + if(mask->layer) return; /* too hard, at least for now */ - } Top: if(dst->layer==nil && src->layer==nil){ @@ -74,10 +69,8 @@ if(drawdebug) iprint("mask->layer != nil\n"); return; } - if(drawclipnorepl(dst, &r, src, &p0, mask, &p1, &srcr, &mr) == 0){ -if(drawdebug) iprint("drawclip dstcr %R srccr %R maskcr %R\n", dst->clipr, src->clipr, mask->clipr); + if(drawclipnorepl(dst, &r, src, &p0, mask, &p1, &srcr, &mr) == 0) return; - } /* * Convert to screen coordinates.