--- fbportrait_left.c 2001-06-21 08:32:41.000000000 +0200 +++ fbportrait_left.c.new 2006-10-27 10:13:38.000000000 +0200 @@ -1,8 +1,8 @@ /* - * Copyright (c) 2000, 2001 Greg Haerr - * - * Portrait mode subdriver for Microwindows - */ +* Copyright (c) 2000, 2001 Greg Haerr +* +* Portrait mode subdriver for Microwindows +*/ #include #include #include @@ -22,7 +22,8 @@ } static void -fbportrait_drawhorzline(PSD psd,MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c) +fbportrait_drawhorzline(PSD psd,MWCOORD x1, MWCOORD x2, MWCOORD y, +MWPIXELVAL c) { psd->orgsubdriver->DrawVertLine(psd, y, psd->xvirtres-x2-1, psd->xvirtres-x1-1, c); @@ -36,7 +37,8 @@ } static void -fbportrait_drawvertline(PSD psd,MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c) +fbportrait_drawvertline(PSD psd,MWCOORD x, MWCOORD y1, MWCOORD y2, +MWPIXELVAL c) { psd->orgsubdriver->DrawHorzLine(psd, y1, y2, psd->xvirtres-x-1, c); @@ -51,10 +53,62 @@ fbportrait_fillrect(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2, MWPIXELVAL c) { +#ifdef MWPF_TRUECOLOR565 + MWCOORD x; + register ADDR16 addr, addr0; + short len; + + x1 = psd->xvirtres-x1-1; + x2 = psd->xvirtres-x2-1; + + assert (x2 >= 0 && x2 < psd->yres); + assert (x1 >= 0 && x1 < psd->yres); + assert (x1 >= x2); + assert (y1 >= 0 && y1 < psd->xres); + assert (y2 >= 0 && y2 < psd->xres); + assert (y2 >= y1); + assert (c < psd->ncolors); + DRAWON; + if(gr_mode == MWMODE_COPY) + { + // bytes per RECT-line + len = (y2-y1+1)<<1; + // first line + addr = psd->addr; + addr += x2*psd->linelen+y1; + addr0 = addr; + while(y1++<=y2) + *addr++ = c; + + // copy first line to all other lines... + addr = addr0; + while(++x2<=x1) + { + addr += psd->linelen; + memcpy(addr,addr0,len); + } + } + else + { + while(x2 <= x1) // alle Zeilen + { + addr = psd->addr; + addr += y1 + (x2++) * psd->linelen; + x = y1; + while(x++ <= y2) + { + applyOp(gr_mode, c, addr, ADDR16); + ++addr; + } + } + } + DRAWOFF; +#else x1 = psd->xvirtres-x1-1; x2 = psd->xvirtres-x2-1; while(x2 <= x1) - psd->orgsubdriver->DrawHorzLine(psd, y1, y2, x2++, c); + psd->orgsubdriver->DrawHorzLine(psd, y1, y2, x2++, c); +#endif } static void @@ -70,9 +124,74 @@ MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy, MWCOORD srcw, MWCOORD srch, long op) { - //dstpsd->orgsubdriver->StretchBlit(dstpsd, desty, dstpsd->xvirtres-destx-dstw, - //dsth, dstw, srcpsd, srcy, srcpsd->xvirtres-srcx-srcw, - //srch, srcw, op); + dstpsd->orgsubdriver->StretchBlit(dstpsd, desty, dstpsd->xvirtres-destx-dstw, + dsth, dstw, srcpsd, srcy, srcpsd->xvirtres-srcx-srcw, + srch, srcw, op); +} + +static void +fbportrait_drawarea_alphacol(PSD dstpsd, driver_gc_t * gc) +{ + driver_gc_t l_gc; + ADDR8 alpha_in, alpha_out; + int in_x, in_y; + int in_w, in_h; + int out_x, out_y; + int out_w, out_h; + + l_gc = *gc; + l_gc.dstx = gc->dsty; + l_gc.dsty = dstpsd->xvirtres - gc->dstx - gc->dstw; + l_gc.dstw = gc->dsth; + l_gc.dsth = gc->dstw; + + l_gc.srcx = 0; + l_gc.srcy = 0; + l_gc.src_linelen = l_gc.dstw; + if (!(l_gc.misc = malloc(l_gc.dstw * l_gc.dsth))) { + return; + } + + alpha_in = ((ADDR8) gc->misc) + gc->src_linelen * gc->srcy + gc->srcx; + in_w = gc->dstw; + in_h = gc->dsth; + + alpha_out = l_gc.misc; + out_w = l_gc.dstw; + out_h = l_gc.dsth; + + for (in_y = 0; in_y < in_h; in_y++) { + for (in_x = 0; in_x < in_w; in_x++) { + out_y = ((out_h - 1) - in_x); + out_x = in_y; + + alpha_out[((out_y * out_w) + out_x)] = alpha_in[((in_y * in_w) + in_x)]; + } + } + + dstpsd->orgsubdriver->DrawArea(dstpsd, &l_gc, PSDOP_ALPHACOL); + + free((void *)l_gc.misc); +} + +static void +fbportrait_drawarea(PSD dstpsd, driver_gc_t * gc, int op) +{ + if (!dstpsd->orgsubdriver->DrawArea) { + return; + } + + switch(op) { +#if MW_FEATURE_PSDOP_ALPHACOL + case PSDOP_ALPHACOL: + fbportrait_drawarea_alphacol(dstpsd, gc); + break; +#endif /* MW_FEATURE_PSDOP_ALPHACOL */ + + default: + break; + } + } SUBDRIVER fbportrait_left = { @@ -81,8 +200,9 @@ fbportrait_readpixel, fbportrait_drawhorzline, fbportrait_drawvertline, - gen_fillrect, + fbportrait_fillrect, // gen_fillrect, fbportrait_blit, - NULL, + fbportrait_drawarea, fbportrait_stretchblit }; +