32 |
|
|
33 |
|
static void FB_FUNC_NAME(uint8 * dest, const uint8 * source, uint32 length) |
34 |
|
{ |
35 |
+ |
union { |
36 |
+ |
uint8 * bp; |
37 |
+ |
uint16 * wp; |
38 |
+ |
uint32 * lp; |
39 |
+ |
} s, d; |
40 |
+ |
|
41 |
+ |
s.bp = (uint8 *)source; |
42 |
+ |
d.bp = dest; |
43 |
+ |
|
44 |
|
#if FB_DEPTH <= 8 |
45 |
|
// Align source and dest to 16-bit word boundaries |
46 |
|
if (FB_DEPTH <= 8 && ((unsigned long) source) & 1) { |
47 |
< |
*dest++ = *source++; |
47 |
> |
*d.bp++ = *s.bp++; |
48 |
|
length -= 1; |
49 |
|
} |
50 |
|
#endif |
51 |
|
|
43 |
– |
// source and dest are mutually aligned |
44 |
– |
uint16 * swp = ((uint16 *)source); |
45 |
– |
uint16 * dwp = ((uint16 *) dest ); |
46 |
– |
|
52 |
|
#if FB_DEPTH <= 8 |
53 |
|
if (length >= 2) { |
54 |
|
#endif |
56 |
|
#if FB_DEPTH <= 16 |
57 |
|
// Align source and dest to 32-bit word boundaries |
58 |
|
if (((unsigned long) source) & 2) { |
59 |
< |
const uint16 val = *swp++; |
60 |
< |
FB_BLIT_1(*dwp++, val); |
59 |
> |
const uint16 val = *s.wp++; |
60 |
> |
FB_BLIT_1(*d.wp++, val); |
61 |
|
length -= 2; |
62 |
|
} |
63 |
|
#endif |
65 |
|
// Blit 4-byte words |
66 |
|
if (length >= 4) { |
67 |
|
const int remainder = (length / 4) % 8; |
68 |
< |
uint32 * slp = (uint32 *)swp + remainder; |
69 |
< |
uint32 * dlp = (uint32 *)dwp + remainder; |
68 |
> |
s.lp += remainder; |
69 |
> |
d.lp += remainder; |
70 |
|
|
71 |
|
int n = ((length / 4) + 7) / 8; |
72 |
|
switch (remainder) { |
73 |
|
case 0: do { |
74 |
< |
slp += 8; dlp += 8; |
75 |
< |
FB_BLIT_2(dlp[-8], slp[-8]); |
76 |
< |
case 7: FB_BLIT_2(dlp[-7], slp[-7]); |
77 |
< |
case 6: FB_BLIT_2(dlp[-6], slp[-6]); |
78 |
< |
case 5: FB_BLIT_2(dlp[-5], slp[-5]); |
79 |
< |
case 4: FB_BLIT_2(dlp[-4], slp[-4]); |
80 |
< |
case 3: FB_BLIT_2(dlp[-3], slp[-3]); |
81 |
< |
case 2: FB_BLIT_2(dlp[-2], slp[-2]); |
82 |
< |
case 1: FB_BLIT_2(dlp[-1], slp[-1]); |
74 |
> |
s.lp += 8; d.lp += 8; |
75 |
> |
FB_BLIT_2(d.lp[-8], s.lp[-8]); |
76 |
> |
case 7: FB_BLIT_2(d.lp[-7], s.lp[-7]); |
77 |
> |
case 6: FB_BLIT_2(d.lp[-6], s.lp[-6]); |
78 |
> |
case 5: FB_BLIT_2(d.lp[-5], s.lp[-5]); |
79 |
> |
case 4: FB_BLIT_2(d.lp[-4], s.lp[-4]); |
80 |
> |
case 3: FB_BLIT_2(d.lp[-3], s.lp[-3]); |
81 |
> |
case 2: FB_BLIT_2(d.lp[-2], s.lp[-2]); |
82 |
> |
case 1: FB_BLIT_2(d.lp[-1], s.lp[-1]); |
83 |
|
} while (--n > 0); |
84 |
|
} |
85 |
|
} |
86 |
|
|
87 |
|
#if FB_DEPTH <= 16 |
88 |
< |
// There might remain one word to blit |
88 |
> |
// There might remain at least one word to blit |
89 |
|
if (length & 2) { |
90 |
< |
uint16 * const s = (uint16 *)(((uint8 *)swp) + length - 2); |
91 |
< |
uint16 * const d = (uint16 *)(((uint8 *)dwp) + length - 2); |
92 |
< |
FB_BLIT_1(*d, *s); |
90 |
> |
FB_BLIT_1(*d.wp, *s.wp); |
91 |
> |
#if FB_DEPTH <= 8 |
92 |
> |
d.wp++; |
93 |
> |
s.wp++; |
94 |
> |
#endif |
95 |
|
} |
96 |
|
#endif |
97 |
|
|
98 |
|
#if FB_DEPTH <= 8 |
99 |
|
} |
100 |
+ |
|
101 |
+ |
// There might remain one byte to blit |
102 |
+ |
if (length & 1) |
103 |
+ |
*d.bp = *s.bp; |
104 |
|
#endif |
105 |
|
} |
106 |
|
|