libmemdraw/libmemlayer: get rid of drawdebug prints
This commit is contained in:
parent
3c894ece0c
commit
9a5e55782d
5 changed files with 11 additions and 207 deletions
|
@ -175,14 +175,6 @@ extern Memcmap *memdefcmap;
|
||||||
*/
|
*/
|
||||||
void memimagemove(void*, void*);
|
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
|
* doprint interface: numbconv bit strings
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <memdraw.h>
|
#include <memdraw.h>
|
||||||
#include <memlayer.h>
|
#include <memlayer.h>
|
||||||
|
|
||||||
extern int drawdebug;
|
|
||||||
void
|
void
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -40,26 +39,3 @@ main(int argc, char **argv)
|
||||||
t1 = nsec();
|
t1 = nsec();
|
||||||
print("%lld %lld\n", t1-t0-del, del);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <pool.h>
|
#include <pool.h>
|
||||||
|
|
||||||
extern Pool* imagmem;
|
extern Pool* imagmem;
|
||||||
int drawdebug;
|
|
||||||
|
|
||||||
/* perfect approximation to NTSC = .299r+.587g+.114b when 0 ≤ r,g,b < 256 */
|
/* 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)
|
#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 rgbatoimg(Memimage*, ulong);
|
||||||
static ulong pixelbits(Memimage*, Point);
|
static ulong pixelbits(Memimage*, Point);
|
||||||
|
|
||||||
#define DBG if(0)
|
|
||||||
void
|
void
|
||||||
memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1, int op)
|
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)
|
if(mask == nil)
|
||||||
mask = memopaque;
|
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(drawclip(dst, &r, src, &p0, mask, &p1, &par.sr, &par.mr) == 0){
|
|
||||||
// if(drawdebug)
|
|
||||||
// iprint("empty clipped rectangle\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if(op < Clear || op > SoverD){
|
if(op < Clear || op > SoverD)
|
||||||
// if(drawdebug)
|
|
||||||
// iprint("op out of range: %d\n", op);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
par.op = op;
|
par.op = op;
|
||||||
par.dst = dst;
|
par.dst = dst;
|
||||||
|
@ -137,21 +127,17 @@ DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->ch
|
||||||
par.state |= Simplesrc;
|
par.state |= Simplesrc;
|
||||||
par.srgba = imgtorgba(src, par.sval);
|
par.srgba = imgtorgba(src, par.sval);
|
||||||
par.sdval = rgbatoimg(dst, par.srgba);
|
par.sdval = rgbatoimg(dst, par.srgba);
|
||||||
if((par.srgba&0xFF) == 0 && (op&DoutS)){
|
if((par.srgba&0xFF) == 0 && (op&DoutS))
|
||||||
// if (drawdebug) iprint("fill with transparent source\n");
|
|
||||||
return; /* no-op successfully handled */
|
return; /* no-op successfully handled */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(mask->flags & Frepl){
|
if(mask->flags & Frepl){
|
||||||
par.state |= Replmask;
|
par.state |= Replmask;
|
||||||
if(Dx(mask->r)==1 && Dy(mask->r)==1){
|
if(Dx(mask->r)==1 && Dy(mask->r)==1){
|
||||||
par.mval = pixelbits(mask, mask->r.min);
|
par.mval = pixelbits(mask, mask->r.min);
|
||||||
if(par.mval == 0 && (op&DoutS)){
|
if(par.mval == 0 && (op&DoutS))
|
||||||
// if(drawdebug) iprint("fill with zero mask\n");
|
|
||||||
return; /* no-op successfully handled */
|
return; /* no-op successfully handled */
|
||||||
}
|
|
||||||
par.state |= Simplemask;
|
par.state |= Simplemask;
|
||||||
if(par.mval == ~0)
|
if(par.mval == ~0)
|
||||||
par.state |= Fullmask;
|
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
|
* 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
|
* 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.
|
* 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.
|
* 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(hwdraw(&par)){
|
|
||||||
//if(drawdebug) iprint("hw handled\n");
|
|
||||||
DBG print("hwdraw handled\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Optimizations using memmove and memset.
|
* Optimizations using memmove and memset.
|
||||||
*/
|
*/
|
||||||
DBG print("test memoptdraw\n");
|
if(memoptdraw(&par))
|
||||||
if(memoptdraw(&par)){
|
|
||||||
//if(drawdebug) iprint("memopt handled\n");
|
|
||||||
DBG print("memopt handled\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Character drawing.
|
* Character drawing.
|
||||||
* Solid source color being painted through a boolean mask onto a high res image.
|
* Solid source color being painted through a boolean mask onto a high res image.
|
||||||
*/
|
*/
|
||||||
DBG print("test chardraw\n");
|
if(chardraw(&par))
|
||||||
if(chardraw(&par)){
|
|
||||||
//if(drawdebug) iprint("chardraw handled\n");
|
|
||||||
DBG print("chardraw handled\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* General calculation-laden case that does alpha for each pixel.
|
* General calculation-laden case that does alpha for each pixel.
|
||||||
*/
|
*/
|
||||||
DBG print("do alphadraw\n");
|
|
||||||
alphadraw(&par);
|
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);
|
assert(0 <= *y && *y < dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
dumpbuf(char *s, Buffer b, int n)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
uchar *p;
|
|
||||||
|
|
||||||
print("%s", s);
|
|
||||||
for(i=0; i<n; i++){
|
|
||||||
print(" ");
|
|
||||||
if(p=b.grey){
|
|
||||||
print(" k%.2uX", *p);
|
|
||||||
b.grey += b.delta;
|
|
||||||
}else{
|
|
||||||
if(p=b.red){
|
|
||||||
print(" r%.2uX", *p);
|
|
||||||
b.red += b.delta;
|
|
||||||
}
|
|
||||||
if(p=b.grn){
|
|
||||||
print(" g%.2uX", *p);
|
|
||||||
b.grn += b.delta;
|
|
||||||
}
|
|
||||||
if(p=b.blu){
|
|
||||||
print(" b%.2uX", *p);
|
|
||||||
b.blu += b.delta;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if((p=b.alpha) != &ones){
|
|
||||||
print(" α%.2uX", *p);
|
|
||||||
b.alpha += b.delta;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For each scan line, we expand the pixels from source, mask, and destination
|
* For each scan line, we expand the pixels from source, mask, and destination
|
||||||
* into byte-aligned red, green, blue, alpha, and grey channels. If buffering is not
|
* into byte-aligned red, green, blue, alpha, and grey channels. If buffering is not
|
||||||
|
@ -629,7 +562,6 @@ dumpbuf(char *s, Buffer b, int n)
|
||||||
* the calculator, and that buffer is passed to a function to write it to the destination.
|
* the calculator, and that buffer is passed to a function to write it to the destination.
|
||||||
* If the buffer is already pointing at the destination, the writing function is a no-op.
|
* If the buffer is already pointing at the destination, the writing function is a no-op.
|
||||||
*/
|
*/
|
||||||
#define DBG if(0)
|
|
||||||
static int
|
static int
|
||||||
alphadraw(Memdrawparam *par)
|
alphadraw(Memdrawparam *par)
|
||||||
{
|
{
|
||||||
|
@ -693,9 +625,7 @@ alphadraw(Memdrawparam *par)
|
||||||
* but it avoids a fair amount of code duplication to make this a case here
|
* but it avoids a fair amount of code duplication to make this a case here
|
||||||
* rather than have a separate booldraw.
|
* rather than have a separate booldraw.
|
||||||
*/
|
*/
|
||||||
//if(drawdebug) iprint("flag %lud mchan %lux=?%x dd %d\n", src->flags&Falpha, mask->chan, GREY1, dst->depth);
|
|
||||||
if(!(src->flags&Falpha) && mask->chan == GREY1 && dst->depth >= 8 && op == SoverD){
|
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);
|
rdsrc = convfn(dst, &z->dpar, src, &z->spar, &ndrawbuf);
|
||||||
rddst = readptr;
|
rddst = readptr;
|
||||||
rdmask = readfn(mask);
|
rdmask = readfn(mask);
|
||||||
|
@ -795,13 +725,8 @@ alphadraw(Memdrawparam *par)
|
||||||
clipy(mask, &masky);
|
clipy(mask, &masky);
|
||||||
|
|
||||||
bsrc = rdsrc(&z->spar, z->spar.bufbase, srcy);
|
bsrc = rdsrc(&z->spar, z->spar.bufbase, srcy);
|
||||||
DBG print("[");
|
|
||||||
bmask = rdmask(&z->mpar, z->mpar.bufbase, masky);
|
bmask = rdmask(&z->mpar, z->mpar.bufbase, masky);
|
||||||
DBG print("]\n");
|
|
||||||
bdst = rddst(&z->dpar, z->dpar.bufbase, dsty);
|
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);
|
bdst = calc(bdst, bsrc, bmask, dx, isgrey, op);
|
||||||
wrdst(&z->dpar, z->dpar.bytermin+dsty*z->dpar.bwidth, bdst);
|
wrdst(&z->dpar, z->dpar.bytermin+dsty*z->dpar.bwidth, bdst);
|
||||||
}
|
}
|
||||||
|
@ -809,7 +734,6 @@ DBG dumpbuf("dst", bdst, dx);
|
||||||
z->inuse = 0;
|
z->inuse = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#undef DBG
|
|
||||||
|
|
||||||
static Buffer
|
static Buffer
|
||||||
alphacalc0(Buffer bdst, Buffer b1, Buffer b2, int dx, int grey, int op)
|
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;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DBG if(0)
|
|
||||||
static Buffer
|
static Buffer
|
||||||
readnbit(Param *p, uchar *buf, int y)
|
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;
|
n = p->img->r.max.x - x;
|
||||||
|
|
||||||
r = p->bytermin + y*p->bwidth;
|
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++;
|
bits = *r++;
|
||||||
nbits = 8;
|
nbits = 8;
|
||||||
if(i=x&(npack-1)){
|
if(i=x&(npack-1)){
|
||||||
DBG print("throwaway %d...", i);
|
|
||||||
bits <<= depth*i;
|
bits <<= depth*i;
|
||||||
nbits -= depth*i;
|
nbits -= depth*i;
|
||||||
}
|
}
|
||||||
for(i=0; i<n; i++){
|
for(i=0; i<n; i++){
|
||||||
if(nbits == 0){
|
if(nbits == 0){
|
||||||
DBG print("(%.2ux)...", *r);
|
|
||||||
bits = *r++;
|
bits = *r++;
|
||||||
nbits = 8;
|
nbits = 8;
|
||||||
}
|
}
|
||||||
*w++ = repl[bits>>sh];
|
*w++ = repl[bits>>sh];
|
||||||
DBG print("bit %x...", repl[bits>>sh]);
|
|
||||||
bits <<= depth;
|
bits <<= depth;
|
||||||
nbits -= depth;
|
nbits -= depth;
|
||||||
}
|
}
|
||||||
|
@ -1403,24 +1322,20 @@ DBG print("bit %x...", repl[bits>>sh]);
|
||||||
n = p->r.min.x - x;
|
n = p->r.min.x - x;
|
||||||
|
|
||||||
r = p->bytey0s + y*p->bwidth;
|
r = p->bytey0s + y*p->bwidth;
|
||||||
DBG print("x=%d r=%p...", x, r);
|
|
||||||
bits = *r++;
|
bits = *r++;
|
||||||
nbits = 8;
|
nbits = 8;
|
||||||
if(i=x&(npack-1)){
|
if(i=x&(npack-1)){
|
||||||
bits <<= depth*i;
|
bits <<= depth*i;
|
||||||
nbits -= depth*i;
|
nbits -= depth*i;
|
||||||
}
|
}
|
||||||
DBG print("nbits=%d...", nbits);
|
|
||||||
for(i=0; i<n; i++){
|
for(i=0; i<n; i++){
|
||||||
if(nbits == 0){
|
if(nbits == 0){
|
||||||
bits = *r++;
|
bits = *r++;
|
||||||
nbits = 8;
|
nbits = 8;
|
||||||
}
|
}
|
||||||
*w++ = repl[bits>>sh];
|
*w++ = repl[bits>>sh];
|
||||||
DBG print("bit %x...", repl[bits>>sh]);
|
|
||||||
bits <<= depth;
|
bits <<= depth;
|
||||||
nbits -= depth;
|
nbits -= depth;
|
||||||
DBG print("bits %x nbits %d...", bits, nbits);
|
|
||||||
}
|
}
|
||||||
dx -= n;
|
dx -= n;
|
||||||
if(dx == 0)
|
if(dx == 0)
|
||||||
|
@ -1434,9 +1349,7 @@ DBG print("bits %x nbits %d...", bits, nbits);
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
#undef DBG
|
|
||||||
|
|
||||||
#define DBG if(0)
|
|
||||||
static void
|
static void
|
||||||
writenbit(Param *p, uchar *w, Buffer src)
|
writenbit(Param *p, uchar *w, Buffer src)
|
||||||
{
|
{
|
||||||
|
@ -1459,7 +1372,6 @@ writenbit(Param *p, uchar *w, Buffer src)
|
||||||
|
|
||||||
for(; x<ex; x++){
|
for(; x<ex; x++){
|
||||||
bits <<= depth;
|
bits <<= depth;
|
||||||
DBG print(" %x", *r);
|
|
||||||
bits |= (*r++ >> sh);
|
bits |= (*r++ >> sh);
|
||||||
nbits += depth;
|
nbits += depth;
|
||||||
if(nbits == 8){
|
if(nbits == 8){
|
||||||
|
@ -1474,10 +1386,8 @@ DBG print(" %x", *r);
|
||||||
bits |= *w & ((1<<sh)-1);
|
bits |= *w & ((1<<sh)-1);
|
||||||
*w = bits;
|
*w = bits;
|
||||||
}
|
}
|
||||||
DBG print("\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#undef DBG
|
|
||||||
|
|
||||||
static Buffer
|
static Buffer
|
||||||
readcmap(Param *p, uchar *buf, int y)
|
readcmap(Param *p, uchar *buf, int y)
|
||||||
|
@ -1575,7 +1485,6 @@ writecmap(Param *p, uchar *w, Buffer src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DBG if(0)
|
|
||||||
static Buffer
|
static Buffer
|
||||||
readbyte(Param *p, uchar *buf, int y)
|
readbyte(Param *p, uchar *buf, int y)
|
||||||
{
|
{
|
||||||
|
@ -1600,7 +1509,6 @@ readbyte(Param *p, uchar *buf, int y)
|
||||||
alphaonly = p->alphaonly;
|
alphaonly = p->alphaonly;
|
||||||
copyalpha = (img->flags&Falpha) != 0;
|
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 we can, avoid processing everything */
|
||||||
if(!(img->flags&Frepl) && !convgrey && (img->flags&Fbytes)){
|
if(!(img->flags&Frepl) && !convgrey && (img->flags&Fbytes)){
|
||||||
memset(&b, 0, sizeof b);
|
memset(&b, 0, sizeof b);
|
||||||
|
@ -1625,7 +1533,6 @@ DBG print("copyalpha %d alphaonly %d convgrey %d isgrey %d\n", copyalpha, alphao
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG print("2\n");
|
|
||||||
rrepl = replbit[img->nbits[CRed]];
|
rrepl = replbit[img->nbits[CRed]];
|
||||||
grepl = replbit[img->nbits[CGreen]];
|
grepl = replbit[img->nbits[CGreen]];
|
||||||
brepl = replbit[img->nbits[CBlue]];
|
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);
|
u = r[0] | (r[1]<<8) | (r[2]<<16) | (r[3]<<24);
|
||||||
if(copyalpha) {
|
if(copyalpha) {
|
||||||
*w++ = arepl[(u>>img->shift[CAlpha]) & img->mask[CAlpha]];
|
*w++ = arepl[(u>>img->shift[CAlpha]) & img->mask[CAlpha]];
|
||||||
DBG print("a %x\n", w[-1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isgrey)
|
if(isgrey)
|
||||||
|
@ -1646,9 +1552,7 @@ DBG print("a %x\n", w[-1]);
|
||||||
ugrn = grepl[(u >> img->shift[CGreen]) & img->mask[CGreen]];
|
ugrn = grepl[(u >> img->shift[CGreen]) & img->mask[CGreen]];
|
||||||
ublu = brepl[(u >> img->shift[CBlue]) & img->mask[CBlue]];
|
ublu = brepl[(u >> img->shift[CBlue]) & img->mask[CBlue]];
|
||||||
if(convgrey){
|
if(convgrey){
|
||||||
DBG print("g %x %x %x\n", ured, ugrn, ublu);
|
|
||||||
*w++ = RGB2K(ured, ugrn, ublu);
|
*w++ = RGB2K(ured, ugrn, ublu);
|
||||||
DBG print("%x\n", w[-1]);
|
|
||||||
}else{
|
}else{
|
||||||
w[0] = ublu;
|
w[0] = ublu;
|
||||||
w[1] = ugrn;
|
w[1] = ugrn;
|
||||||
|
@ -1672,7 +1576,6 @@ DBG print("%x\n", w[-1]);
|
||||||
b.grey = buf+copyalpha;
|
b.grey = buf+copyalpha;
|
||||||
b.red = b.grn = b.blu = buf+copyalpha;
|
b.red = b.grn = b.blu = buf+copyalpha;
|
||||||
b.delta = copyalpha+1;
|
b.delta = copyalpha+1;
|
||||||
DBG print("alpha %x grey %x\n", *b.alpha, *b.grey);
|
|
||||||
}else{
|
}else{
|
||||||
b.blu = buf+copyalpha;
|
b.blu = buf+copyalpha;
|
||||||
b.grn = buf+copyalpha+1;
|
b.grn = buf+copyalpha+1;
|
||||||
|
@ -1682,9 +1585,7 @@ DBG print("alpha %x grey %x\n", *b.alpha, *b.grey);
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
#undef DBG
|
|
||||||
|
|
||||||
#define DBG if(0)
|
|
||||||
static void
|
static void
|
||||||
writebyte(Param *p, uchar *w, Buffer src)
|
writebyte(Param *p, uchar *w, Buffer src)
|
||||||
{
|
{
|
||||||
|
@ -1745,12 +1646,9 @@ writebyte(Param *p, uchar *w, Buffer src)
|
||||||
mask = (nb==4) ? 0 : ~((1<<img->depth)-1);
|
mask = (nb==4) ? 0 : ~((1<<img->depth)-1);
|
||||||
for(i=0; i<dx; i++){
|
for(i=0; i<dx; i++){
|
||||||
u = w[0] | (w[1]<<8) | (w[2]<<16) | (w[3]<<24);
|
u = w[0] | (w[1]<<8) | (w[2]<<16) | (w[3]<<24);
|
||||||
DBG print("u %.8lux...", u);
|
|
||||||
u &= mask;
|
u &= mask;
|
||||||
DBG print("&mask %.8lux...", u);
|
|
||||||
if(isgrey){
|
if(isgrey){
|
||||||
u |= ((*grey >> (8-img->nbits[CGrey])) & img->mask[CGrey]) << img->shift[CGrey];
|
u |= ((*grey >> (8-img->nbits[CGrey])) & img->mask[CGrey]) << img->shift[CGrey];
|
||||||
DBG print("|grey %.8lux...", u);
|
|
||||||
grey += delta;
|
grey += delta;
|
||||||
}else{
|
}else{
|
||||||
u |= ((*red >> (8-img->nbits[CRed])) & img->mask[CRed]) << img->shift[CRed];
|
u |= ((*red >> (8-img->nbits[CRed])) & img->mask[CRed]) << img->shift[CRed];
|
||||||
|
@ -1759,13 +1657,11 @@ DBG print("|grey %.8lux...", u);
|
||||||
red += delta;
|
red += delta;
|
||||||
grn += delta;
|
grn += delta;
|
||||||
blu += delta;
|
blu += delta;
|
||||||
DBG print("|rgb %.8lux...", u);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isalpha){
|
if(isalpha){
|
||||||
u |= ((*alpha >> (8-img->nbits[CAlpha])) & img->mask[CAlpha]) << img->shift[CAlpha];
|
u |= ((*alpha >> (8-img->nbits[CAlpha])) & img->mask[CAlpha]) << img->shift[CAlpha];
|
||||||
alpha += adelta;
|
alpha += adelta;
|
||||||
DBG print("|alpha %.8lux...", u);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w[0] = u;
|
w[0] = u;
|
||||||
|
@ -1775,7 +1671,6 @@ DBG print("|alpha %.8lux...", u);
|
||||||
w += nb;
|
w += nb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#undef DBG
|
|
||||||
|
|
||||||
static Readfn*
|
static Readfn*
|
||||||
readfn(Memimage *img)
|
readfn(Memimage *img)
|
||||||
|
@ -1951,14 +1846,11 @@ genconv(Param *p, uchar *buf, int y)
|
||||||
static Readfn*
|
static Readfn*
|
||||||
convfn(Memimage *dst, Param *dpar, Memimage *src, Param *spar, int *ndrawbuf)
|
convfn(Memimage *dst, Param *dpar, Memimage *src, Param *spar, int *ndrawbuf)
|
||||||
{
|
{
|
||||||
if(dst->chan == src->chan && !(src->flags&Frepl)){
|
if(dst->chan == src->chan && !(src->flags&Frepl))
|
||||||
//if(drawdebug) iprint("readptr...");
|
|
||||||
return readptr;
|
return readptr;
|
||||||
}
|
|
||||||
|
|
||||||
if(dst->chan==CMAP8 && (src->chan==GREY1||src->chan==GREY2||src->chan==GREY4)){
|
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. */
|
/* cheat because we know the replicated value is exactly the color map entry. */
|
||||||
//if(drawdebug) iprint("Readnbit...");
|
|
||||||
return readnbit;
|
return readnbit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1975,7 +1867,6 @@ convfn(Memimage *dst, Param *dpar, Memimage *src, Param *spar, int *ndrawbuf)
|
||||||
spar->dx = Dx(spar->img->r);
|
spar->dx = Dx(spar->img->r);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if(drawdebug) iprint("genconv...");
|
|
||||||
return genconv;
|
return genconv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2186,11 +2077,9 @@ rgbatoimg(Memimage *img, ulong rgba)
|
||||||
}
|
}
|
||||||
d += nb;
|
d += nb;
|
||||||
}
|
}
|
||||||
// print("rgba2img %.8lux = %.*lux\n", rgba, 2*d/8, v);
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DBG if(0)
|
|
||||||
static int
|
static int
|
||||||
memoptdraw(Memdrawparam *par)
|
memoptdraw(Memdrawparam *par)
|
||||||
{
|
{
|
||||||
|
@ -2205,7 +2094,6 @@ memoptdraw(Memdrawparam *par)
|
||||||
dst = par->dst;
|
dst = par->dst;
|
||||||
op = par->op;
|
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
|
* If we have an opaque mask and source is one opaque pixel we can convert to the
|
||||||
* destination format and just replicate with memset.
|
* 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;
|
int d, dwid, ppb, np, nb;
|
||||||
uchar *dp, lm, rm;
|
uchar *dp, lm, rm;
|
||||||
|
|
||||||
DBG print("memopt, dst %p, dst->data->bdata %p\n", dst, dst->data->bdata);
|
|
||||||
dwid = dst->width*sizeof(ulong);
|
dwid = dst->width*sizeof(ulong);
|
||||||
dp = byteaddr(dst, par->r.min);
|
dp = byteaddr(dst, par->r.min);
|
||||||
v = par->sdval;
|
v = par->sdval;
|
||||||
DBG print("sdval %lud, depth %d\n", v, dst->depth);
|
|
||||||
switch(dst->depth){
|
switch(dst->depth){
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -2233,16 +2119,13 @@ DBG print("sdval %lud, depth %d\n", v, dst->depth);
|
||||||
dx -= (ppb-np);
|
dx -= (ppb-np);
|
||||||
nb = 8 - np * dst->depth; /* no. bits used on right side of word */
|
nb = 8 - np * dst->depth; /* no. bits used on right side of word */
|
||||||
lm = (1<<nb)-1;
|
lm = (1<<nb)-1;
|
||||||
DBG print("np %d x %d nb %d lm %ux ppb %d m %ux\n", np, par->r.min.x, nb, lm, ppb, m);
|
|
||||||
|
|
||||||
/* right edge */
|
/* right edge */
|
||||||
np = par->r.max.x&m; /* no. pixels used on left side of word */
|
np = par->r.max.x&m; /* no. pixels used on left side of word */
|
||||||
dx -= np;
|
dx -= np;
|
||||||
nb = 8 - np * dst->depth; /* no. bits unused on right side of word */
|
nb = 8 - np * dst->depth; /* no. bits unused on right side of word */
|
||||||
rm = ~((1<<nb)-1);
|
rm = ~((1<<nb)-1);
|
||||||
DBG print("np %d x %d nb %d rm %ux ppb %d m %ux\n", np, par->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 */
|
/* lm, rm are masks that are 1 where we should touch the bits */
|
||||||
if(dx < 0){ /* just one byte */
|
if(dx < 0){ /* just one byte */
|
||||||
lm &= rm;
|
lm &= rm;
|
||||||
|
@ -2254,7 +2137,6 @@ DBG print("dx %d Dx %d\n", dx, Dx(par->r));
|
||||||
|
|
||||||
for(y=0; y<dy; y++, dp+=dwid){
|
for(y=0; y<dy; y++, dp+=dwid){
|
||||||
if(lm){
|
if(lm){
|
||||||
DBG print("dp %p v %lux lm %ux (v ^ *dp) & lm %lux\n", dp, v, lm, (v^*dp)&lm);
|
|
||||||
*dp ^= (v ^ *dp) & lm;
|
*dp ^= (v ^ *dp) & lm;
|
||||||
dp++;
|
dp++;
|
||||||
}
|
}
|
||||||
|
@ -2428,13 +2310,11 @@ DBG print("dp %p v %lux lm %ux (v ^ *dp) & lm %lux\n", dp, v, lm, (v^*dp)&lm);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#undef DBG
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Boolean character drawing.
|
* Boolean character drawing.
|
||||||
* Solid opaque color through a 1-bit greyscale mask.
|
* Solid opaque color through a 1-bit greyscale mask.
|
||||||
*/
|
*/
|
||||||
#define DBG if(0)
|
|
||||||
static int
|
static int
|
||||||
chardraw(Memdrawparam *par)
|
chardraw(Memdrawparam *par)
|
||||||
{
|
{
|
||||||
|
@ -2447,10 +2327,6 @@ chardraw(Memdrawparam *par)
|
||||||
Rectangle r, mr;
|
Rectangle r, mr;
|
||||||
Memimage *mask, *src, *dst;
|
Memimage *mask, *src, *dst;
|
||||||
|
|
||||||
if(0) if(drawdebug) iprint("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d ddat %p sdat %p\n",
|
|
||||||
par->mask->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;
|
mask = par->mask;
|
||||||
src = par->src;
|
src = par->src;
|
||||||
dst = par->dst;
|
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)
|
|| op != SoverD)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
//if(drawdebug) iprint("chardraw...");
|
|
||||||
|
|
||||||
depth = mask->depth;
|
depth = mask->depth;
|
||||||
maskwid = mask->width*sizeof(ulong);
|
maskwid = mask->width*sizeof(ulong);
|
||||||
rp = byteaddr(mask, mr.min);
|
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);
|
wp = byteaddr(dst, r.min);
|
||||||
dstwid = dst->width*sizeof(ulong);
|
dstwid = dst->width*sizeof(ulong);
|
||||||
DBG print("bsh %d\n", bsh);
|
|
||||||
dy = Dy(r);
|
dy = Dy(r);
|
||||||
dx = Dx(r);
|
dx = Dx(r);
|
||||||
|
|
||||||
|
@ -2499,20 +2372,17 @@ DBG print("bsh %d\n", bsh);
|
||||||
sp[2] = v>>16;
|
sp[2] = v>>16;
|
||||||
sp[3] = v>>24;
|
sp[3] = v>>24;
|
||||||
|
|
||||||
//print("sp %x %x %x %x\n", sp[0], sp[1], sp[2], sp[3]);
|
|
||||||
for(y=0; y<dy; y++, rp+=maskwid, wp+=dstwid){
|
for(y=0; y<dy; y++, rp+=maskwid, wp+=dstwid){
|
||||||
q = rp;
|
q = rp;
|
||||||
if(bsh)
|
if(bsh)
|
||||||
bits = *q++;
|
bits = *q++;
|
||||||
switch(ddepth){
|
switch(ddepth){
|
||||||
case 8:
|
case 8:
|
||||||
//if(drawdebug) iprint("8loop...");
|
|
||||||
wc = wp;
|
wc = wp;
|
||||||
for(x=bx; x>ex; x--, wc++){
|
for(x=bx; x>ex; x--, wc++){
|
||||||
i = x&7;
|
i = x&7;
|
||||||
if(i == 8-1)
|
if(i == 8-1)
|
||||||
bits = *q++;
|
bits = *q++;
|
||||||
DBG print("bits %lux sh %d...", bits, i);
|
|
||||||
if((bits>>i)&1)
|
if((bits>>i)&1)
|
||||||
*wc = v;
|
*wc = v;
|
||||||
}
|
}
|
||||||
|
@ -2524,7 +2394,6 @@ DBG print("bits %lux sh %d...", bits, i);
|
||||||
i = x&7;
|
i = x&7;
|
||||||
if(i == 8-1)
|
if(i == 8-1)
|
||||||
bits = *q++;
|
bits = *q++;
|
||||||
DBG print("bits %lux sh %d...", bits, i);
|
|
||||||
if((bits>>i)&1)
|
if((bits>>i)&1)
|
||||||
*ws = v;
|
*ws = v;
|
||||||
}
|
}
|
||||||
|
@ -2535,7 +2404,6 @@ DBG print("bits %lux sh %d...", bits, i);
|
||||||
i = x&7;
|
i = x&7;
|
||||||
if(i == 8-1)
|
if(i == 8-1)
|
||||||
bits = *q++;
|
bits = *q++;
|
||||||
DBG print("bits %lux sh %d...", bits, i);
|
|
||||||
if((bits>>i)&1){
|
if((bits>>i)&1){
|
||||||
wc[0] = sp[0];
|
wc[0] = sp[0];
|
||||||
wc[1] = sp[1];
|
wc[1] = sp[1];
|
||||||
|
@ -2550,18 +2418,14 @@ DBG print("bits %lux sh %d...", bits, i);
|
||||||
i = x&7;
|
i = x&7;
|
||||||
if(i == 8-1)
|
if(i == 8-1)
|
||||||
bits = *q++;
|
bits = *q++;
|
||||||
DBG iprint("bits %lux sh %d...", bits, i);
|
|
||||||
if((bits>>i)&1)
|
if((bits>>i)&1)
|
||||||
*wl = v;
|
*wl = v;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG print("\n");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#undef DBG
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -26,7 +26,6 @@ ulong rgbatopix(uchar, uchar, uchar, uchar);
|
||||||
char *dchan, *schan, *mchan;
|
char *dchan, *schan, *mchan;
|
||||||
int dbpp, sbpp, mbpp;
|
int dbpp, sbpp, mbpp;
|
||||||
|
|
||||||
int drawdebug=0;
|
|
||||||
int seed;
|
int seed;
|
||||||
int niters = 100;
|
int niters = 100;
|
||||||
int dbpp; /* bits per pixel in destination */
|
int dbpp; /* bits per pixel in destination */
|
||||||
|
@ -49,26 +48,6 @@ uchar *srcbits;
|
||||||
uchar *maskbits;
|
uchar *maskbits;
|
||||||
ulong *savedstbits;
|
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
|
void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,16 +57,11 @@ memdraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Poi
|
||||||
Rectangle srcr, tr, mr;
|
Rectangle srcr, tr, mr;
|
||||||
Memlayer *dl, *sl;
|
Memlayer *dl, *sl;
|
||||||
|
|
||||||
if(drawdebug)
|
|
||||||
iprint("memdraw %p %R %p %P %p %P\n", dst, r, src, p0, mask, p1);
|
|
||||||
|
|
||||||
if(mask == nil)
|
if(mask == nil)
|
||||||
mask = memopaque;
|
mask = memopaque;
|
||||||
|
|
||||||
if(mask->layer){
|
if(mask->layer)
|
||||||
if(drawdebug) iprint("mask->layer != nil\n");
|
|
||||||
return; /* too hard, at least for now */
|
return; /* too hard, at least for now */
|
||||||
}
|
|
||||||
|
|
||||||
Top:
|
Top:
|
||||||
if(dst->layer==nil && src->layer==nil){
|
if(dst->layer==nil && src->layer==nil){
|
||||||
|
@ -74,10 +69,8 @@ if(drawdebug) iprint("mask->layer != nil\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(drawclipnorepl(dst, &r, src, &p0, mask, &p1, &srcr, &mr) == 0){
|
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);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert to screen coordinates.
|
* Convert to screen coordinates.
|
||||||
|
|
Loading…
Reference in a new issue