# HG changeset patch # User Matti Hamalainen # Date 1349162622 -10800 # Node ID c257d73cf79069ec230e48b70e77182b4b197783 # Parent 35db1588192395006c6436fe9f11696dcdf451f7 Rename some macros. diff -r 35db15881923 -r c257d73cf790 dmblitfunc.h --- a/dmblitfunc.h Tue Oct 02 10:23:29 2012 +0300 +++ b/dmblitfunc.h Tue Oct 02 10:23:42 2012 +0300 @@ -9,42 +9,42 @@ // DMD_NONE // ======================================================================= -#define DM_SCALED_NAME dmScaledBlitSurface8to8 -#define DM_SCALED_SRC_BYTES 1 -#define DM_SCALED_DST_BYTES 1 -#define DM_SCALED_SRC_TYPE Uint8 -#define DM_SCALED_DST_TYPE Uint8 +#define DM_BLITFUNC_NAME dmScaledBlitSurface8to8 +#define DM_BLITFUNC_SRC_BYTES 1 +#define DM_BLITFUNC_DST_BYTES 1 +#define DM_BLITFUNC_SRC_TYPE Uint8 +#define DM_BLITFUNC_DST_TYPE Uint8 -#define DM_SCALED_INNER *dp++ = sp[FP_GETH(xv)]; +#define DM_BLITFUNC_INNER *dp++ = sp[FP_GETH(xv)]; #include "dmscaledblit.h" // ----------------------------------------------------------------------- -#define DM_SCALED_NAME dmScaledBlitSurface8to32 -#define DM_SCALED_SRC_BYTES 1 -#define DM_SCALED_DST_BYTES 4 -#define DM_SCALED_SRC_TYPE Uint8 -#define DM_SCALED_DST_TYPE Uint32 +#define DM_BLITFUNC_NAME dmScaledBlitSurface8to32 +#define DM_BLITFUNC_SRC_BYTES 1 +#define DM_BLITFUNC_DST_BYTES 4 +#define DM_BLITFUNC_SRC_TYPE Uint8 +#define DM_BLITFUNC_DST_TYPE Uint32 -#define DM_SCALED_VARS const Uint32 *pal; -#define DM_SCALED_INIT \ +#define DM_BLITFUNC_VARS const Uint32 *pal; +#define DM_BLITFUNC_INIT \ if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ pal = (Uint32 *) src->format->palette->colors; -#define DM_SCALED_INNER *dp++ = pal[sp[FP_GETH(xv)]]; +#define DM_BLITFUNC_INNER *dp++ = pal[sp[FP_GETH(xv)]]; #include "dmscaledblit.h" // ----------------------------------------------------------------------- -#define DM_SCALED_NAME dmScaledBlitSurface32to32 -#define DM_SCALED_SRC_BYTES 4 -#define DM_SCALED_DST_BYTES 4 -#define DM_SCALED_SRC_TYPE Uint32 -#define DM_SCALED_DST_TYPE Uint32 -#define DM_SCALED_INIT -#define DM_SCALED_INNER *dp++ = sp[FP_GETH(xv)]; +#define DM_BLITFUNC_NAME dmScaledBlitSurface32to32 +#define DM_BLITFUNC_SRC_BYTES 4 +#define DM_BLITFUNC_DST_BYTES 4 +#define DM_BLITFUNC_SRC_TYPE Uint32 +#define DM_BLITFUNC_DST_TYPE Uint32 +#define DM_BLITFUNC_INIT +#define DM_BLITFUNC_INNER *dp++ = sp[FP_GETH(xv)]; #include "dmscaledblit.h" @@ -53,30 +53,30 @@ // DMD_TRANSPARENT // ======================================================================= -#define DM_SCALED_NAME dmScaledBlitSurface8to8Transparent -#define DM_SCALED_SRC_BYTES 1 -#define DM_SCALED_DST_BYTES 1 -#define DM_SCALED_SRC_TYPE Uint8 -#define DM_SCALED_DST_TYPE Uint8 +#define DM_BLITFUNC_NAME dmScaledBlitSurface8to8Transparent +#define DM_BLITFUNC_SRC_BYTES 1 +#define DM_BLITFUNC_DST_BYTES 1 +#define DM_BLITFUNC_SRC_TYPE Uint8 +#define DM_BLITFUNC_DST_TYPE Uint8 -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_INNER \ *dp = sp[FP_GETH(xv)] ? sp[FP_GETH(xv)] : *dp; dp++; #include "dmscaledblit.h" // ----------------------------------------------------------------------- -#define DM_SCALED_NAME dmScaledBlitSurface8to32Transparent -#define DM_SCALED_SRC_BYTES 1 -#define DM_SCALED_DST_BYTES 4 -#define DM_SCALED_SRC_TYPE Uint8 -#define DM_SCALED_DST_TYPE DMRGBA32 -#define DM_SCALED_VARS const DMRGBA32 *pal; -#define DM_SCALED_INIT \ +#define DM_BLITFUNC_NAME dmScaledBlitSurface8to32Transparent +#define DM_BLITFUNC_SRC_BYTES 1 +#define DM_BLITFUNC_DST_BYTES 4 +#define DM_BLITFUNC_SRC_TYPE Uint8 +#define DM_BLITFUNC_DST_TYPE DMRGBA32 +#define DM_BLITFUNC_VARS const DMRGBA32 *pal; +#define DM_BLITFUNC_INIT \ if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ pal = (DMRGBA32 *) src->format->palette->colors; -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_INNER \ const DMRGBA32 q = pal[sp[FP_GETH(xv)]]; \ dp->r += ((q.r - dp->r) * q.a) >> 8; \ dp->g += ((q.g - dp->g) * q.a) >> 8; \ @@ -89,18 +89,18 @@ // ----------------------------------------------------------------------- -#define DM_SCALED_NAME dmScaledBlitSurface32to32Transparent -#define DM_SCALED_SRC_BYTES 4 -#define DM_SCALED_DST_BYTES 4 +#define DM_BLITFUNC_NAME dmScaledBlitSurface32to32Transparent +#define DM_BLITFUNC_SRC_BYTES 4 +#define DM_BLITFUNC_DST_BYTES 4 #ifdef DM_USE_SIMD -#define DM_SCALED_VARS \ +#define DM_BLITFUNC_VARS \ const Uint32 qpdmask = 0xff000000; \ const Uint64 qpdrm = 0xff00ff00ff00ffULL; -#define DM_SCALED_SRC_TYPE Uint32 -#define DM_SCALED_DST_TYPE Uint32 -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_SRC_TYPE Uint32 +#define DM_BLITFUNC_DST_TYPE Uint32 +#define DM_BLITFUNC_INNER \ asm( \ "movd %2, %%mm1\n" \ \ @@ -127,13 +127,13 @@ : "m" (*dp), "m" (sp[FP_GETH(xv)]), "m" (qpdmask), "m" (qpdrm) \ : "memory", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5" ); dp++; -#define DM_SCALED_FINISH asm("emms\n"); +#define DM_BLITFUNC_FINISH asm("emms\n"); #else -#define DM_SCALED_SRC_TYPE DMRGBA32 -#define DM_SCALED_DST_TYPE DMRGBA32 -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_SRC_TYPE DMRGBA32 +#define DM_BLITFUNC_DST_TYPE DMRGBA32 +#define DM_BLITFUNC_INNER \ const DMRGBA32 q = sp[FP_GETH(xv)]; \ dp->r += ((q.r - dp->r) * q.a) >> 8; \ dp->g += ((q.g - dp->g) * q.a) >> 8; \ @@ -146,14 +146,14 @@ // ----------------------------------------------------------------------- -#define DM_SCALED_NAME dmScaledBlitSurface32to32TransparentX -#define DM_SCALED_SRC_BYTES 4 -#define DM_SCALED_DST_BYTES 4 -#define DM_SCALED_SRC_TYPE DMRGBA32 -#define DM_SCALED_DST_TYPE DMRGBA32 -#define DM_SCALED_INIT +#define DM_BLITFUNC_NAME dmScaledBlitSurface32to32TransparentX +#define DM_BLITFUNC_SRC_BYTES 4 +#define DM_BLITFUNC_DST_BYTES 4 +#define DM_BLITFUNC_SRC_TYPE DMRGBA32 +#define DM_BLITFUNC_DST_TYPE DMRGBA32 +#define DM_BLITFUNC_INIT -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_INNER \ const DMRGBA32 q = sp[FP_GETH(xv)]; \ dp->r = (q.r * q.a + dp->r * dp->a) >> 8; \ dp->g = (q.g * q.a + dp->g * dp->a) >> 8; \ @@ -166,18 +166,18 @@ // ----------------------------------------------------------------------- -#define DM_SCALED_NAME dmScaledBlitSurface32to32TransparentGA -#define DM_SCALED_SRC_BYTES 4 -#define DM_SCALED_DST_BYTES 4 -#define DM_SCALED_ARGS , Uint32 alpha +#define DM_BLITFUNC_NAME dmScaledBlitSurface32to32TransparentGA +#define DM_BLITFUNC_SRC_BYTES 4 +#define DM_BLITFUNC_DST_BYTES 4 +#define DM_BLITFUNC_ARGS , Uint32 alpha #ifdef DM_USE_SIMD -#define DM_SCALED_VARS \ +#define DM_BLITFUNC_VARS \ const Uint64 qpdrm = 0xff00ff00ff00ffULL; -#define DM_SCALED_SRC_TYPE Uint32 -#define DM_SCALED_DST_TYPE Uint32 -#define DM_SCALED_INNER_INIT \ +#define DM_BLITFUNC_SRC_TYPE Uint32 +#define DM_BLITFUNC_DST_TYPE Uint32 +#define DM_BLITFUNC_INNER_INIT \ asm( \ "movd %0, %%mm4\n" \ "punpcklwd %%mm4, %%mm4\n" \ @@ -186,7 +186,7 @@ : "m" (alpha) \ : "%mm4" ); -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_INNER \ asm( \ "movd %2, %%mm1\n" \ "pxor %%mm2, %%mm2\n" \ @@ -205,13 +205,13 @@ : "m" (*dp), "m" (sp[FP_GETH(xv)]), "m" (qpdrm) \ : "memory", "%mm1", "%mm2", "%mm3", "%mm4" ); dp++; -#define DM_SCALED_FINISH asm("emms\n"); +#define DM_BLITFUNC_FINISH asm("emms\n"); #else -#define DM_SCALED_SRC_TYPE DMRGBA32 -#define DM_SCALED_DST_TYPE DMRGBA32 -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_SRC_TYPE DMRGBA32 +#define DM_BLITFUNC_DST_TYPE DMRGBA32 +#define DM_BLITFUNC_INNER \ const DMRGBA32 q = sp[FP_GETH(xv)]; \ dp->r += ((q.r - dp->r) * alpha) >> 8; \ dp->g += ((q.g - dp->g) * alpha) >> 8; \ @@ -226,12 +226,12 @@ // DMD_SATURATE // ======================================================================= -#define DM_SCALED_NAME dmScaledBlitSurface8to8Saturate -#define DM_SCALED_SRC_BYTES 1 -#define DM_SCALED_DST_BYTES 1 -#define DM_SCALED_SRC_TYPE Uint8 -#define DM_SCALED_DST_TYPE Uint8 -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_NAME dmScaledBlitSurface8to8Saturate +#define DM_BLITFUNC_SRC_BYTES 1 +#define DM_BLITFUNC_DST_BYTES 1 +#define DM_BLITFUNC_SRC_TYPE Uint8 +#define DM_BLITFUNC_DST_TYPE Uint8 +#define DM_BLITFUNC_INNER \ const Uint8 q = sp[FP_GETH(xv)] + *dp; \ *(dp++) = q < 256 ? q : 255; @@ -239,18 +239,18 @@ // ----------------------------------------------------------------------- -#define DM_SCALED_NAME dmScaledBlitSurface8to32Saturate -#define DM_SCALED_SRC_BYTES 1 -#define DM_SCALED_DST_BYTES 4 -#define DM_SCALED_SRC_TYPE Uint8 -#define DM_SCALED_DST_TYPE DMRGBA32 -#define DM_SCALED_VARS const DMRGBA32 *pal; -#define DM_SCALED_INIT \ +#define DM_BLITFUNC_NAME dmScaledBlitSurface8to32Saturate +#define DM_BLITFUNC_SRC_BYTES 1 +#define DM_BLITFUNC_DST_BYTES 4 +#define DM_BLITFUNC_SRC_TYPE Uint8 +#define DM_BLITFUNC_DST_TYPE DMRGBA32 +#define DM_BLITFUNC_VARS const DMRGBA32 *pal; +#define DM_BLITFUNC_INIT \ if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ pal = (DMRGBA32 *) src->format->palette->colors; #ifdef DM_USE_SIMD -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_INNER \ asm("movd %2, %%mm1\n" \ "movd %1, %%mm2\n" \ "paddusb %%mm2, %%mm1\n" \ @@ -259,9 +259,9 @@ : "m" (*dp), "m" (pal[sp[FP_GETH(xv)]]) \ : "memory", "%mm1", "%mm2" ); dp++; -#define DM_SCALED_FINISH asm("emms\n"); +#define DM_BLITFUNC_FINISH asm("emms\n"); #else -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_INNER \ const DMRGBA32 q = pal[sp[FP_GETH(xv)]]; \ const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \ dp->r = qr < 256 ? qr : 255; \ @@ -275,15 +275,15 @@ // ----------------------------------------------------------------------- -#define DM_SCALED_NAME dmScaledBlitSurface32to32Saturate -#define DM_SCALED_SRC_BYTES 4 -#define DM_SCALED_DST_BYTES 4 -#define DM_SCALED_INIT +#define DM_BLITFUNC_NAME dmScaledBlitSurface32to32Saturate +#define DM_BLITFUNC_SRC_BYTES 4 +#define DM_BLITFUNC_DST_BYTES 4 +#define DM_BLITFUNC_INIT #ifdef DM_USE_SIMD -#define DM_SCALED_SRC_TYPE Uint32 -#define DM_SCALED_DST_TYPE Uint32 -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_SRC_TYPE Uint32 +#define DM_BLITFUNC_DST_TYPE Uint32 +#define DM_BLITFUNC_INNER \ asm("movd %2, %%mm1\n" \ "movd %1, %%mm2\n" \ "paddusb %%mm2, %%mm1\n" \ @@ -292,11 +292,11 @@ : "m" (*dp), "m" (sp[FP_GETH(xv)]) \ : "memory", "%mm1", "%mm2" ); dp++; -#define DM_SCALED_FINISH asm("emms\n"); +#define DM_BLITFUNC_FINISH asm("emms\n"); #else -#define DM_SCALED_SRC_TYPE DMRGBA32 -#define DM_SCALED_DST_TYPE DMRGBA32 -#define DM_SCALED_INNER \ +#define DM_BLITFUNC_SRC_TYPE DMRGBA32 +#define DM_BLITFUNC_DST_TYPE DMRGBA32 +#define DM_BLITFUNC_INNER \ const DMRGBA32 q = sp[FP_GETH(xv)]; \ const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \ dp->r = qr < 256 ? qr : 255; \ diff -r 35db15881923 -r c257d73cf790 dmscaledblit.h --- a/dmscaledblit.h Tue Oct 02 10:23:29 2012 +0300 +++ b/dmscaledblit.h Tue Oct 02 10:23:42 2012 +0300 @@ -5,12 +5,12 @@ * (C) Copyright 2011-2012 Tecnic Software productions (TNSP) */ -int DM_SCALED_NAME (SDL_Surface *src, +int DM_BLITFUNC_NAME (SDL_Surface *src, const int x0, const int y0, const int dwidth, const int dheight, SDL_Surface *dst -#ifdef DM_SCALED_ARGS - DM_SCALED_ARGS +#ifdef DM_BLITFUNC_ARGS + DM_BLITFUNC_ARGS #endif ) { @@ -18,8 +18,8 @@ DMFixedPoint32 xv, yv, dx, dy; DMQValue xr, yr; -#ifdef DM_SCALED_VARS - DM_SCALED_VARS +#ifdef DM_BLITFUNC_VARS + DM_BLITFUNC_VARS #endif // Clip coordinates @@ -30,8 +30,8 @@ dst->clip_rect.y, dst->clip_rect.y + dst->clip_rect.h)) return -1; -#ifdef DM_SCALED_INIT - DM_SCALED_INIT +#ifdef DM_BLITFUNC_INIT + DM_BLITFUNC_INIT #endif // Calculate "final" initial source bitmap offsets @@ -42,44 +42,44 @@ FP_MUL_R(dx, dx, xr.vdelta); // Take pitch into account - const int xadd = xr.vadd - dst->clip_rect.w + dst->clip_rect.x + (dst->pitch / DM_SCALED_DST_BYTES); + const int xadd = xr.vadd - dst->clip_rect.w + dst->clip_rect.x + (dst->pitch / DM_BLITFUNC_DST_BYTES); // Blit scaled - DM_SCALED_DST_TYPE * dp = ((DM_SCALED_DST_TYPE *) dst->pixels) + (yr.v0 * dst->pitch) / DM_SCALED_DST_BYTES + xr.v0; + DM_BLITFUNC_DST_TYPE * dp = ((DM_BLITFUNC_DST_TYPE *) dst->pixels) + (yr.v0 * dst->pitch) / DM_BLITFUNC_DST_BYTES + xr.v0; for (yc = yr.v0; yc < yr.v1; yc++) { - const DM_SCALED_SRC_TYPE * sp = ((DM_SCALED_SRC_TYPE *) src->pixels) + (FP_GETH(yv) * src->pitch) / DM_SCALED_SRC_BYTES; + const DM_BLITFUNC_SRC_TYPE * sp = ((DM_BLITFUNC_SRC_TYPE *) src->pixels) + (FP_GETH(yv) * src->pitch) / DM_BLITFUNC_SRC_BYTES; int xc; -#ifdef DM_SCALED_INNER_INIT - DM_SCALED_INNER_INIT +#ifdef DM_BLITFUNC_INNER_INIT + DM_BLITFUNC_INNER_INIT #endif for (xv.dw = dx.dw, xc = xr.v0; xc < xr.v1; xc++) { - DM_SCALED_INNER + DM_BLITFUNC_INNER FP_ADD(xv, xr.vdelta); } FP_ADD(yv, yr.vdelta); dp += xadd; } -#ifdef DM_SCALED_FINISH - DM_SCALED_FINISH +#ifdef DM_BLITFUNC_FINISH + DM_BLITFUNC_FINISH #endif return 0; } -#undef DM_SCALED_NAME -#undef DM_SCALED_ARGS -#undef DM_SCALED_SRC_BYTES -#undef DM_SCALED_DST_BYTES -#undef DM_SCALED_SRC_TYPE -#undef DM_SCALED_DST_TYPE -#undef DM_SCALED_VARS -#undef DM_SCALED_INIT -#undef DM_SCALED_INNER_INIT -#undef DM_SCALED_INNER -#undef DM_SCALED_FINISH +#undef DM_BLITFUNC_NAME +#undef DM_BLITFUNC_ARGS +#undef DM_BLITFUNC_SRC_BYTES +#undef DM_BLITFUNC_DST_BYTES +#undef DM_BLITFUNC_SRC_TYPE +#undef DM_BLITFUNC_DST_TYPE +#undef DM_BLITFUNC_VARS +#undef DM_BLITFUNC_INIT +#undef DM_BLITFUNC_INNER_INIT +#undef DM_BLITFUNC_INNER +#undef DM_BLITFUNC_FINISH