Mercurial > hg > dmlib
comparison dmunscaledblit.h @ 95:0430f484641b
Add unscaled blitting functions.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Oct 2012 18:51:16 +0300 |
parents | |
children | 79dac918c81e |
comparison
equal
deleted
inserted
replaced
94:4bbfc0274b29 | 95:0430f484641b |
---|---|
1 /* | |
2 * DMLib | |
3 * -- Unscaled sprite / surface blitting function template | |
4 * Programmed and designed by Matti 'ccr' Hamalainen | |
5 * (C) Copyright 2012 Tecnic Software productions (TNSP) | |
6 */ | |
7 | |
8 int DM_BLITFUNC_NAME (SDL_Surface *src, | |
9 const int x0, const int y0, | |
10 SDL_Surface *dst | |
11 #ifdef DM_BLITFUNC_ARGS | |
12 DM_BLITFUNC_ARGS | |
13 #endif | |
14 ) | |
15 { | |
16 int yc; | |
17 DMQValue xr, yr; | |
18 #ifdef DM_BLITFUNC_VARS | |
19 DM_BLITFUNC_VARS | |
20 #endif | |
21 | |
22 // Clip coordinates | |
23 if (dmUnscaledClipCoord(&xr, x0, src->w, | |
24 dst->clip_rect.x, dst->clip_rect.x + dst->clip_rect.w) | |
25 || | |
26 dmUnscaledClipCoord(&yr, y0, src->h, | |
27 dst->clip_rect.y, dst->clip_rect.y + dst->clip_rect.h)) | |
28 return -1; | |
29 | |
30 #ifdef DM_BLITFUNC_INIT | |
31 DM_BLITFUNC_INIT | |
32 #endif | |
33 const int srcadd = src->pitch / DM_BLITFUNC_SRC_BYTES; | |
34 const int dstadd = xr.vadd - dst->clip_rect.w + dst->clip_rect.x + (dst->pitch / DM_BLITFUNC_DST_BYTES); | |
35 | |
36 DM_BLITFUNC_SRC_TYPE * sp = ((DM_BLITFUNC_SRC_TYPE *) src->pixels) + (yr.voffs * src->pitch) / DM_BLITFUNC_SRC_BYTES; | |
37 DM_BLITFUNC_DST_TYPE * dp = ((DM_BLITFUNC_DST_TYPE *) dst->pixels) + (yr.v0 * dst->pitch) / DM_BLITFUNC_DST_BYTES + xr.v0; | |
38 | |
39 for (yc = yr.v0; yc < yr.v1; yc++) | |
40 { | |
41 int xv, xc; | |
42 | |
43 #ifdef DM_BLITFUNC_INNER_INIT | |
44 DM_BLITFUNC_INNER_INIT | |
45 #endif | |
46 | |
47 for (xv = xr.voffs, xc = xr.v0; xc < xr.v1; xc++, xv++) | |
48 { | |
49 DM_BLITFUNC_INNER | |
50 } | |
51 sp += srcadd; | |
52 dp += dstadd; | |
53 } | |
54 | |
55 #ifdef DM_BLITFUNC_FINISH | |
56 DM_BLITFUNC_FINISH | |
57 #endif | |
58 return 0; | |
59 } | |
60 | |
61 | |
62 #undef DM_BLITFUNC_NAME | |
63 #undef DM_BLITFUNC_ARGS | |
64 #undef DM_BLITFUNC_SRC_BYTES | |
65 #undef DM_BLITFUNC_DST_BYTES | |
66 #undef DM_BLITFUNC_SRC_TYPE | |
67 #undef DM_BLITFUNC_DST_TYPE | |
68 #undef DM_BLITFUNC_VARS | |
69 #undef DM_BLITFUNC_INIT | |
70 #undef DM_BLITFUNC_INNER_INIT | |
71 #undef DM_BLITFUNC_INNER | |
72 #undef DM_BLITFUNC_FINISH |