Mercurial > hg > dmlib
annotate src/dmunscaledblit.h @ 2294:7f6ba3b32f54
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 03 Jul 2019 10:28:43 +0300 |
parents | e06abfde6c39 |
children |
rev | line source |
---|---|
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * DMLib |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * -- Unscaled sprite / surface blitting function template |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * Programmed and designed by Matti 'ccr' Hamalainen |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * (C) Copyright 2012 Tecnic Software productions (TNSP) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 */ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 int DM_BLITFUNC_NAME (SDL_Surface *src, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 const int x0, const int y0, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 SDL_Surface *dst |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 #ifdef DM_BLITFUNC_ARGS |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 DM_BLITFUNC_ARGS |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 #endif |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 ) |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
15 #ifdef DM_HEADER |
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
16 ; |
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
17 #else |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 int yc; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 DMQValue xr, yr; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 #ifdef DM_BLITFUNC_VARS |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 DM_BLITFUNC_VARS |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 #endif |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
24 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 // Clip coordinates |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 if (dmUnscaledClipCoord(&xr, x0, src->w, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 dst->clip_rect.x, dst->clip_rect.x + dst->clip_rect.w) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 || |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 dmUnscaledClipCoord(&yr, y0, src->h, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 dst->clip_rect.y, dst->clip_rect.y + dst->clip_rect.h)) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 return -1; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 #ifdef DM_BLITFUNC_INIT |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 DM_BLITFUNC_INIT |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 #endif |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 const int srcadd = src->pitch / DM_BLITFUNC_SRC_BYTES; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 const int dstadd = xr.vadd - dst->clip_rect.w + dst->clip_rect.x + (dst->pitch / DM_BLITFUNC_DST_BYTES); |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 DM_BLITFUNC_SRC_TYPE * sp = ((DM_BLITFUNC_SRC_TYPE *) src->pixels) + (yr.voffs * src->pitch) / DM_BLITFUNC_SRC_BYTES; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 DM_BLITFUNC_DST_TYPE * dp = ((DM_BLITFUNC_DST_TYPE *) dst->pixels) + (yr.v0 * dst->pitch) / DM_BLITFUNC_DST_BYTES + xr.v0; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 for (yc = yr.v0; yc < yr.v1; yc++) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 int xv, xc; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 #ifdef DM_BLITFUNC_INNER_INIT |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 DM_BLITFUNC_INNER_INIT |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 #endif |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 for (xv = xr.voffs, xc = xr.v0; xc < xr.v1; xc++, xv++) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 DM_BLITFUNC_INNER |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 } |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 sp += srcadd; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 dp += dstadd; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 } |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 #ifdef DM_BLITFUNC_FINISH |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 DM_BLITFUNC_FINISH |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 #endif |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 return 0; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 } |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
63 #endif |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 #undef DM_BLITFUNC_NAME |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 #undef DM_BLITFUNC_ARGS |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 #undef DM_BLITFUNC_SRC_BYTES |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 #undef DM_BLITFUNC_DST_BYTES |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 #undef DM_BLITFUNC_SRC_TYPE |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 #undef DM_BLITFUNC_DST_TYPE |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 #undef DM_BLITFUNC_VARS |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 #undef DM_BLITFUNC_INIT |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 #undef DM_BLITFUNC_INNER_INIT |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 #undef DM_BLITFUNC_INNER |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 #undef DM_BLITFUNC_FINISH |