Mercurial > sdl-ios-xcode
annotate src/video/SDL_fill.c @ 2305:fbe8ff44c519
First pass of new SDL scancode concept for X11.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 07 Feb 2008 15:31:09 +0000 |
parents | 6d99edd791bf |
children | af3dd02cf043 |
rev | line source |
---|---|
2253
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "SDL_video.h" |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include "SDL_blit.h" |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #ifdef __SSE__ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 /* *INDENT-OFF* */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #ifdef _MSC_VER |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #define SSE_BEGIN \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 __m128 c128; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 c128.m128_u32[0] = color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 c128.m128_u32[1] = color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 c128.m128_u32[2] = color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 c128.m128_u32[3] = color; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #else |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #define SSE_BEGIN \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 DECLARE_ALIGNED(Uint32, cccc[4], 16); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 cccc[0] = color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 cccc[1] = color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 cccc[2] = color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 cccc[3] = color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 __m128 c128 = *(__m128 *)cccc; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 #endif |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 #define SSE_WORK \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 for (i = n / 64; i--;) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 _mm_stream_ps((float *)(p+0), c128); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 _mm_stream_ps((float *)(p+16), c128); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 _mm_stream_ps((float *)(p+32), c128); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 _mm_stream_ps((float *)(p+48), c128); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 p += 64; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 #define SSE_END |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 #define DEFINE_SSE_FILLRECT(bpp, type) \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 static void \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 SSE_BEGIN; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 while (h--) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 int i, n = w * bpp; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 Uint8 *p = pixels; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 if (n > 15) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 int adjust = 16 - ((uintptr_t)p & 15); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 if (adjust < 16) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 n -= adjust; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 adjust /= bpp; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 while(adjust--) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 *((type *)p) = (type)color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 p += bpp; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 SSE_WORK; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 if (n & 63) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 int remainder = (n & 63); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 remainder /= bpp; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 while(remainder--) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 *((type *)p) = (type)color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 p += bpp; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 pixels += pitch; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 SSE_END; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 DEFINE_SSE_FILLRECT(1, Uint8) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 DEFINE_SSE_FILLRECT(2, Uint16) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 DEFINE_SSE_FILLRECT(4, Uint32) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 /* *INDENT-ON* */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 #endif /* __SSE__ */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 #ifdef __MMX__ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 /* *INDENT-OFF* */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 #define MMX_BEGIN \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 __m64 c64 = _mm_set_pi32(color, color) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 #define MMX_WORK \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 for (i = n / 64; i--;) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 _mm_stream_pi((__m64 *)(p+0), c64); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 _mm_stream_pi((__m64 *)(p+8), c64); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 _mm_stream_pi((__m64 *)(p+16), c64); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 _mm_stream_pi((__m64 *)(p+24), c64); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 _mm_stream_pi((__m64 *)(p+32), c64); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 _mm_stream_pi((__m64 *)(p+40), c64); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 _mm_stream_pi((__m64 *)(p+48), c64); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 _mm_stream_pi((__m64 *)(p+56), c64); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 p += 64; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 #define MMX_END \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 _mm_empty() |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 #define DEFINE_MMX_FILLRECT(bpp, type) \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 static void \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 MMX_BEGIN; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 while (h--) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 int i, n = w * bpp; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 Uint8 *p = pixels; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 if (n > 7) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 int adjust = 8 - ((uintptr_t)p & 7); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 if (adjust < 8) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 n -= adjust; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 adjust /= bpp; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 while(adjust--) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 *((type *)p) = (type)color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 p += bpp; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 MMX_WORK; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 if (n & 63) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 int remainder = (n & 63); \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 remainder /= bpp; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 while(remainder--) { \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 *((type *)p) = (type)color; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 p += bpp; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 pixels += pitch; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 } \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 MMX_END; \ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 DEFINE_MMX_FILLRECT(1, Uint8) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 DEFINE_MMX_FILLRECT(2, Uint16) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 DEFINE_MMX_FILLRECT(4, Uint32) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 /* *INDENT-ON* */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 #endif /* __MMX__ */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 static void |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 while (h--) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 int n = w; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 Uint8 *p = pixels; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 if (n > 3) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 switch ((uintptr_t) p & 3) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 case 1: |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 *p++ = (Uint8) color; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 --n; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 case 2: |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 *p++ = (Uint8) color; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 --n; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 case 3: |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 *p++ = (Uint8) color; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 --n; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 SDL_memset4(p, color, (n >> 2)); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 if (n & 3) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 p += (n & ~3); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 switch (n & 3) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 case 3: |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 *p++ = (Uint8) color; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 case 2: |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 *p++ = (Uint8) color; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 case 1: |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 *p++ = (Uint8) color; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 pixels += pitch; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 static void |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 while (h--) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 int n = w; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 Uint16 *p = (Uint16 *) pixels; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 if (n > 1) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 if ((uintptr_t) p & 2) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 *p++ = (Uint16) color; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 --n; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 SDL_memset4(p, color, (n >> 1)); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 if (n & 1) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 p[n - 1] = (Uint16) color; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 pixels += pitch; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 static void |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 Uint8 r = (Uint8) ((color >> 16) & 0xFF); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 Uint8 g = (Uint8) ((color >> 8) & 0xFF); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 Uint8 b = (Uint8) (color & 0xFF); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 while (h--) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 int n = w; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 Uint8 *p = pixels; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 while (n--) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 *p++ = r; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 *p++ = g; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 *p++ = b; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 pixels += pitch; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 static void |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 SDL_FillRect4(Uint8 * pixels, int pitch, Uint32 color, int w, int h) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 while (h--) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 SDL_memset4(pixels, color, w); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 pixels += pitch; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 /* |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 * This function performs a fast fill of the given rectangle with 'color' |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 int |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 SDL_FillRect(SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 Uint8 *pixels; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 /* This function doesn't work on surfaces < 8 bpp */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 if (dst->format->BitsPerPixel < 8) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 SDL_SetError("SDL_FillRect(): Unsupported surface format"); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 return (-1); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 /* If 'dstrect' == NULL, then fill the whole surface */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 if (dstrect) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 /* Perform clipping */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 if (!SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect)) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 return (0); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 } else { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 dstrect = &dst->clip_rect; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 /* Perform software fill */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 if (!dst->pixels) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 SDL_SetError("SDL_FillRect(): You must lock the surface"); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 return (-1); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 pixels = |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 (Uint8 *) dst->pixels + dstrect->y * dst->pitch + |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 dstrect->x * dst->format->BytesPerPixel; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 switch (dst->format->BytesPerPixel) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 case 1: |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 color |= (color << 8); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 color |= (color << 16); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 #ifdef __SSE__ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 if (SDL_HasSSE()) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 SDL_FillRect1SSE(pixels, dst->pitch, color, dstrect->w, |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 dstrect->h); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 break; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 #endif |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 #ifdef __MMX__ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 if (SDL_HasMMX()) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 SDL_FillRect1MMX(pixels, dst->pitch, color, dstrect->w, |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 dstrect->h); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 break; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 #endif |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 SDL_FillRect1(pixels, dst->pitch, color, dstrect->w, dstrect->h); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 break; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 case 2: |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 color |= (color << 16); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 #ifdef __SSE__ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 if (SDL_HasSSE()) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 SDL_FillRect2SSE(pixels, dst->pitch, color, dstrect->w, |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 dstrect->h); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 break; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 #endif |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 #ifdef __MMX__ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 if (SDL_HasMMX()) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 SDL_FillRect2MMX(pixels, dst->pitch, color, dstrect->w, |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 dstrect->h); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 break; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 #endif |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 SDL_FillRect2(pixels, dst->pitch, color, dstrect->w, dstrect->h); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 break; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 case 3: |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 /* 24-bit RGB is a slow path, at least for now. */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 SDL_FillRect3(pixels, dst->pitch, color, dstrect->w, dstrect->h); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 break; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 case 4: |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 #ifdef __SSE__ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 if (SDL_HasSSE()) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 SDL_FillRect4SSE(pixels, dst->pitch, color, dstrect->w, |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 dstrect->h); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 break; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 #endif |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 #ifdef __MMX__ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 if (SDL_HasMMX()) { |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 SDL_FillRect4MMX(pixels, dst->pitch, color, dstrect->w, |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 dstrect->h); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 break; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 #endif |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 SDL_FillRect4(pixels, dst->pitch, color, dstrect->w, dstrect->h); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 break; |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 SDL_UnlockSurface(dst); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 /* We're done! */ |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 return (0); |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 } |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 |
6d99edd791bf
Added notes on the next steps for SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 /* vi: set ts=4 sw=4 expandtab: */ |