annotate src/dmscaledblit.h @ 2298:b5abfff07ca9

Add new DMGrowBuf helper functions dmGrowBufCopyOffsSize() and dmGrowBufConstCopyOffsSize().
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 04 Jul 2019 10:54:16 +0300
parents e06abfde6c39
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * DMLib
87
baf72a99d5ee Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
3 * -- Scaled sprite / surface blitting function template
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * Programmed and designed by Matti 'ccr' Hamalainen
863
27949209238b Update copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
5 * (C) Copyright 2011-2015 Tecnic Software productions (TNSP)
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 */
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
8
85
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
9 int DM_BLITFUNC_NAME (SDL_Surface *src,
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 const int x0, const int y0,
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 const int dwidth, const int dheight,
16
d9251dd496ce Add new scaled blit template parameters in order to implement global alpha.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
12 SDL_Surface *dst
85
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
13 #ifdef DM_BLITFUNC_ARGS
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
14 DM_BLITFUNC_ARGS
16
d9251dd496ce Add new scaled blit template parameters in order to implement global alpha.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
15 #endif
d9251dd496ce Add new scaled blit template parameters in order to implement global alpha.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
16 )
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
17 #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
18 ;
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
19 #else
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 {
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 int yc;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 DMFixedPoint32 xv, yv, dx, dy;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 DMQValue xr, yr;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
85
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
25 #ifdef DM_BLITFUNC_VARS
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
26 DM_BLITFUNC_VARS
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 #endif
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
28
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 // Clip coordinates
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
30 if (dmScaledClipCoord(&xr, x0, src->w, dwidth,
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 dst->clip_rect.x, dst->clip_rect.x + dst->clip_rect.w)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 ||
95
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
33 dmScaledClipCoord(&yr, y0, src->h, dheight,
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 dst->clip_rect.y, dst->clip_rect.y + dst->clip_rect.h))
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 return -1;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
85
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
37 #ifdef DM_BLITFUNC_INIT
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
38 DM_BLITFUNC_INIT
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 #endif
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 // Calculate "final" initial source bitmap offsets
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 FP_CONV(dy, yr.voffs);
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 FP_MUL_R(yv, dy, yr.vdelta);
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 FP_CONV(dx, xr.voffs);
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 FP_MUL_R(dx, dx, xr.vdelta);
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 // Take pitch into account
95
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
49 const int dstadd = xr.vadd - dst->clip_rect.w + dst->clip_rect.x + (dst->pitch / DM_BLITFUNC_DST_BYTES);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 // Blit scaled
85
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
52 DM_BLITFUNC_DST_TYPE * dp = ((DM_BLITFUNC_DST_TYPE *) dst->pixels) + (yr.v0 * dst->pitch) / DM_BLITFUNC_DST_BYTES + xr.v0;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 for (yc = yr.v0; yc < yr.v1; yc++)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 {
809
eba3b87f3f84 Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
55 const DM_BLITFUNC_SRC_TYPE * sp = ((DM_BLITFUNC_SRC_TYPE *) src->pixels) + (FP_GETH16(yv) * src->pitch) / DM_BLITFUNC_SRC_BYTES;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 int xc;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
85
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
58 #ifdef DM_BLITFUNC_INNER_INIT
87
baf72a99d5ee Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
59 DM_BLITFUNC_INNER_INIT
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 #endif
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 for (xv.dw = dx.dw, xc = xr.v0; xc < xr.v1; xc++)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 {
85
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
64 DM_BLITFUNC_INNER
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 FP_ADD(xv, xr.vdelta);
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 }
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 FP_ADD(yv, yr.vdelta);
95
0430f484641b Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
68 dp += dstadd;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 }
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70
85
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
71 #ifdef DM_BLITFUNC_FINISH
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
72 DM_BLITFUNC_FINISH
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 #endif
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 return 0;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 }
232
79dac918c81e Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
77 #endif
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78
85
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
79 #undef DM_BLITFUNC_NAME
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
80 #undef DM_BLITFUNC_ARGS
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
81 #undef DM_BLITFUNC_SRC_BYTES
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
82 #undef DM_BLITFUNC_DST_BYTES
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
83 #undef DM_BLITFUNC_SRC_TYPE
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
84 #undef DM_BLITFUNC_DST_TYPE
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
85 #undef DM_BLITFUNC_VARS
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
86 #undef DM_BLITFUNC_INIT
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
87 #undef DM_BLITFUNC_INNER_INIT
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
88 #undef DM_BLITFUNC_INNER
c257d73cf790 Rename some macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
89 #undef DM_BLITFUNC_FINISH