Mercurial > hg > dmlib
view dmscaledblit.h @ 11:eb0072860fb0
Improve benchmarking.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 28 Sep 2012 09:32:45 +0300 |
parents | 32250b436bca |
children | d9251dd496ce |
line wrap: on
line source
/* * DMLib * -- Sprite / surface blitting function template * Programmed and designed by Matti 'ccr' Hamalainen * (C) Copyright 2011-2012 Tecnic Software productions (TNSP) */ int DM_SCALED_NAME (SDL_Surface *src, const int x0, const int y0, const int dwidth, const int dheight, SDL_Surface *dst) { int yc; DMFixedPoint32 xv, yv, dx, dy; DMQValue xr, yr; #ifdef DM_SCALED_VARS DM_SCALED_VARS #endif // Clip coordinates if (dmClipCoord(&xr, x0, src->w, dwidth, dst->clip_rect.x, dst->clip_rect.x + dst->clip_rect.w) || dmClipCoord(&yr, y0, src->h, dheight, dst->clip_rect.y, dst->clip_rect.y + dst->clip_rect.h)) return -1; #ifdef DM_SCALED_INIT DM_SCALED_INIT #endif // Calculate "final" initial source bitmap offsets FP_CONV(dy, yr.voffs); FP_MUL_R(yv, dy, yr.vdelta); FP_CONV(dx, xr.voffs); 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); // Blit scaled DM_SCALED_DST_TYPE * dp = ((DM_SCALED_DST_TYPE *) dst->pixels) + (yr.v0 * dst->pitch) / DM_SCALED_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; int xc; #ifdef DM_SCALED_INNER_INIT DM_SCALED_INNER_INIT #endif for (xv.dw = dx.dw, xc = xr.v0; xc < xr.v1; xc++) { DM_SCALED_INNER FP_ADD(xv, xr.vdelta); } FP_ADD(yv, yr.vdelta); dp += xadd; } #ifdef DM_SCALED_FINISH DM_SCALED_FINISH #endif return 0; } #undef DM_SCALED_NAME #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