Mercurial > hg > dmlib
comparison dmscaledblit.h @ 85:c257d73cf790
Rename some macros.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Oct 2012 10:23:42 +0300 |
parents | d9251dd496ce |
children | baf72a99d5ee |
comparison
equal
deleted
inserted
replaced
84:35db15881923 | 85:c257d73cf790 |
---|---|
3 * -- Sprite / surface blitting function template | 3 * -- Sprite / surface blitting function template |
4 * Programmed and designed by Matti 'ccr' Hamalainen | 4 * Programmed and designed by Matti 'ccr' Hamalainen |
5 * (C) Copyright 2011-2012 Tecnic Software productions (TNSP) | 5 * (C) Copyright 2011-2012 Tecnic Software productions (TNSP) |
6 */ | 6 */ |
7 | 7 |
8 int DM_SCALED_NAME (SDL_Surface *src, | 8 int DM_BLITFUNC_NAME (SDL_Surface *src, |
9 const int x0, const int y0, | 9 const int x0, const int y0, |
10 const int dwidth, const int dheight, | 10 const int dwidth, const int dheight, |
11 SDL_Surface *dst | 11 SDL_Surface *dst |
12 #ifdef DM_SCALED_ARGS | 12 #ifdef DM_BLITFUNC_ARGS |
13 DM_SCALED_ARGS | 13 DM_BLITFUNC_ARGS |
14 #endif | 14 #endif |
15 ) | 15 ) |
16 { | 16 { |
17 int yc; | 17 int yc; |
18 DMFixedPoint32 xv, yv, dx, dy; | 18 DMFixedPoint32 xv, yv, dx, dy; |
19 DMQValue xr, yr; | 19 DMQValue xr, yr; |
20 | 20 |
21 #ifdef DM_SCALED_VARS | 21 #ifdef DM_BLITFUNC_VARS |
22 DM_SCALED_VARS | 22 DM_BLITFUNC_VARS |
23 #endif | 23 #endif |
24 | 24 |
25 // Clip coordinates | 25 // Clip coordinates |
26 if (dmClipCoord(&xr, x0, src->w, dwidth, | 26 if (dmClipCoord(&xr, x0, src->w, dwidth, |
27 dst->clip_rect.x, dst->clip_rect.x + dst->clip_rect.w) | 27 dst->clip_rect.x, dst->clip_rect.x + dst->clip_rect.w) |
28 || | 28 || |
29 dmClipCoord(&yr, y0, src->h, dheight, | 29 dmClipCoord(&yr, y0, src->h, dheight, |
30 dst->clip_rect.y, dst->clip_rect.y + dst->clip_rect.h)) | 30 dst->clip_rect.y, dst->clip_rect.y + dst->clip_rect.h)) |
31 return -1; | 31 return -1; |
32 | 32 |
33 #ifdef DM_SCALED_INIT | 33 #ifdef DM_BLITFUNC_INIT |
34 DM_SCALED_INIT | 34 DM_BLITFUNC_INIT |
35 #endif | 35 #endif |
36 | 36 |
37 // Calculate "final" initial source bitmap offsets | 37 // Calculate "final" initial source bitmap offsets |
38 FP_CONV(dy, yr.voffs); | 38 FP_CONV(dy, yr.voffs); |
39 FP_MUL_R(yv, dy, yr.vdelta); | 39 FP_MUL_R(yv, dy, yr.vdelta); |
40 | 40 |
41 FP_CONV(dx, xr.voffs); | 41 FP_CONV(dx, xr.voffs); |
42 FP_MUL_R(dx, dx, xr.vdelta); | 42 FP_MUL_R(dx, dx, xr.vdelta); |
43 | 43 |
44 // Take pitch into account | 44 // Take pitch into account |
45 const int xadd = xr.vadd - dst->clip_rect.w + dst->clip_rect.x + (dst->pitch / DM_SCALED_DST_BYTES); | 45 const int xadd = xr.vadd - dst->clip_rect.w + dst->clip_rect.x + (dst->pitch / DM_BLITFUNC_DST_BYTES); |
46 | 46 |
47 // Blit scaled | 47 // Blit scaled |
48 DM_SCALED_DST_TYPE * dp = ((DM_SCALED_DST_TYPE *) dst->pixels) + (yr.v0 * dst->pitch) / DM_SCALED_DST_BYTES + xr.v0; | 48 DM_BLITFUNC_DST_TYPE * dp = ((DM_BLITFUNC_DST_TYPE *) dst->pixels) + (yr.v0 * dst->pitch) / DM_BLITFUNC_DST_BYTES + xr.v0; |
49 for (yc = yr.v0; yc < yr.v1; yc++) | 49 for (yc = yr.v0; yc < yr.v1; yc++) |
50 { | 50 { |
51 const DM_SCALED_SRC_TYPE * sp = ((DM_SCALED_SRC_TYPE *) src->pixels) + (FP_GETH(yv) * src->pitch) / DM_SCALED_SRC_BYTES; | 51 const DM_BLITFUNC_SRC_TYPE * sp = ((DM_BLITFUNC_SRC_TYPE *) src->pixels) + (FP_GETH(yv) * src->pitch) / DM_BLITFUNC_SRC_BYTES; |
52 int xc; | 52 int xc; |
53 | 53 |
54 #ifdef DM_SCALED_INNER_INIT | 54 #ifdef DM_BLITFUNC_INNER_INIT |
55 DM_SCALED_INNER_INIT | 55 DM_BLITFUNC_INNER_INIT |
56 #endif | 56 #endif |
57 | 57 |
58 for (xv.dw = dx.dw, xc = xr.v0; xc < xr.v1; xc++) | 58 for (xv.dw = dx.dw, xc = xr.v0; xc < xr.v1; xc++) |
59 { | 59 { |
60 DM_SCALED_INNER | 60 DM_BLITFUNC_INNER |
61 FP_ADD(xv, xr.vdelta); | 61 FP_ADD(xv, xr.vdelta); |
62 } | 62 } |
63 FP_ADD(yv, yr.vdelta); | 63 FP_ADD(yv, yr.vdelta); |
64 dp += xadd; | 64 dp += xadd; |
65 } | 65 } |
66 | 66 |
67 #ifdef DM_SCALED_FINISH | 67 #ifdef DM_BLITFUNC_FINISH |
68 DM_SCALED_FINISH | 68 DM_BLITFUNC_FINISH |
69 #endif | 69 #endif |
70 | 70 |
71 return 0; | 71 return 0; |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 #undef DM_SCALED_NAME | 75 #undef DM_BLITFUNC_NAME |
76 #undef DM_SCALED_ARGS | 76 #undef DM_BLITFUNC_ARGS |
77 #undef DM_SCALED_SRC_BYTES | 77 #undef DM_BLITFUNC_SRC_BYTES |
78 #undef DM_SCALED_DST_BYTES | 78 #undef DM_BLITFUNC_DST_BYTES |
79 #undef DM_SCALED_SRC_TYPE | 79 #undef DM_BLITFUNC_SRC_TYPE |
80 #undef DM_SCALED_DST_TYPE | 80 #undef DM_BLITFUNC_DST_TYPE |
81 #undef DM_SCALED_VARS | 81 #undef DM_BLITFUNC_VARS |
82 #undef DM_SCALED_INIT | 82 #undef DM_BLITFUNC_INIT |
83 #undef DM_SCALED_INNER_INIT | 83 #undef DM_BLITFUNC_INNER_INIT |
84 #undef DM_SCALED_INNER | 84 #undef DM_BLITFUNC_INNER |
85 #undef DM_SCALED_FINISH | 85 #undef DM_BLITFUNC_FINISH |