9d82b5ef8a1ed0790d0a4f35fe3c64ac822aeac4 kent Thu Feb 7 16:20:46 2013 -0800 Making horizontal line setter work with transparent mode. Doing a microoptimization in transparent put dot. diff --git src/lib/memgfx.c src/lib/memgfx.c index 62e2e6b..13099fa 100644 --- src/lib/memgfx.c +++ src/lib/memgfx.c @@ -35,32 +35,32 @@ } #ifndef min3 #define min3(x,y,z) (min(x,min(y,z))) /* Return min of x,y, and z. */ #endif #ifndef max3 #define max3(x,y,z) (max(x,max(y,z))) /* Return max of x,y, and z. */ #endif void _mgPutDotMultiply(struct memGfx *mg, int x, int y,Color color) { -Color src = *_mgPixAdr(mg,x,y); -*_mgPixAdr(mg,x,y) = multiply(src, color); +Color *pt = _mgPixAdr(mg,x,y); +*pt = multiply(*pt, color); } static void mgSetDefaultColorMap(struct memGfx *mg) /* Set up default color map for a memGfx. */ { #ifdef COLOR32 return; #else /* Note dependency in order here and in MG_WHITE, MG_BLACK, etc. */ int i; for (i=0; i<ArraySize(mgFixedColors); ++i) { struct rgbColor *c = &mgFixedColors[i]; @@ -559,35 +559,46 @@ void mgLineH(struct memGfx *mg, int y, int x1, int x2, Color color) /* Draw horizizontal line width pixels long starting at x/y in color */ { if (y >= mg->clipMinY && y < mg->clipMaxY) { int w; if (x1 < mg->clipMinX) x1 = mg->clipMinX; if (x2 > mg->clipMaxX) x2 = mg->clipMaxX; w = x2 - x1; if (w > 0) { Color *pt = _mgPixAdr(mg,x1,y); + if (mg->writeMode == MG_WRITE_MODE_MULTIPLY) + { + while (--w >= 0) + { + *pt = multiply(*pt, color); + pt += 1; + } + } + else + { while (--w >= 0) *pt++ = color; } } } +} boolean mgClipForBlit(int *w, int *h, int *sx, int *sy, struct memGfx *dest, int *dx, int *dy) { /* Make sure we don't overwrite destination. */ int over; if ((over = dest->clipMinX - *dx) > 0) { *w -= over; *sx += over; *dx = dest->clipMinX; } if ((over = dest->clipMinY - *dy) > 0)