comparison src/video/SDL_pixels.c @ 1965:a788656ca29a

SDL constants are all uppercase.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 05 Aug 2006 17:09:42 +0000
parents 8a162bfdc838
children 0975e24a3670
comparison
equal deleted inserted replaced
1964:071b6598d48f 1965:a788656ca29a
44 } else { 44 } else {
45 *bpp = SDL_BITSPERPIXEL(format); 45 *bpp = SDL_BITSPERPIXEL(format);
46 } 46 }
47 *Rmask = *Gmask = *Bmask = *Amask = 0; 47 *Rmask = *Gmask = *Bmask = *Amask = 0;
48 48
49 if (SDL_PIXELTYPE(format) != SDL_PixelType_Packed8 && 49 if (SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED8 &&
50 SDL_PIXELTYPE(format) != SDL_PixelType_Packed16 && 50 SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED16 &&
51 SDL_PIXELTYPE(format) != SDL_PixelType_Packed32) { 51 SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED32) {
52 /* Not a format that uses masks */ 52 /* Not a format that uses masks */
53 return SDL_TRUE; 53 return SDL_TRUE;
54 } 54 }
55 55
56 switch (SDL_PIXELLAYOUT(format)) { 56 switch (SDL_PIXELLAYOUT(format)) {
57 case SDL_PackedLayout_332: 57 case SDL_PACKEDLAYOUT_332:
58 masks[0] = 0x00000000; 58 masks[0] = 0x00000000;
59 masks[1] = 0x000000E0; 59 masks[1] = 0x000000E0;
60 masks[2] = 0x0000001C; 60 masks[2] = 0x0000001C;
61 masks[3] = 0x00000003; 61 masks[3] = 0x00000003;
62 break; 62 break;
63 case SDL_PackedLayout_4444: 63 case SDL_PACKEDLAYOUT_4444:
64 masks[0] = 0x0000F000; 64 masks[0] = 0x0000F000;
65 masks[1] = 0x00000F00; 65 masks[1] = 0x00000F00;
66 masks[2] = 0x000000F0; 66 masks[2] = 0x000000F0;
67 masks[3] = 0x0000000F; 67 masks[3] = 0x0000000F;
68 break; 68 break;
69 case SDL_PackedLayout_1555: 69 case SDL_PACKEDLAYOUT_1555:
70 masks[0] = 0x00008000; 70 masks[0] = 0x00008000;
71 masks[1] = 0x00007C00; 71 masks[1] = 0x00007C00;
72 masks[2] = 0x000003E0; 72 masks[2] = 0x000003E0;
73 masks[3] = 0x0000001F; 73 masks[3] = 0x0000001F;
74 break; 74 break;
75 case SDL_PackedLayout_565: 75 case SDL_PACKEDLAYOUT_565:
76 masks[0] = 0x00000000; 76 masks[0] = 0x00000000;
77 masks[1] = 0x0000F800; 77 masks[1] = 0x0000F800;
78 masks[2] = 0x000007E0; 78 masks[2] = 0x000007E0;
79 masks[3] = 0x0000001F; 79 masks[3] = 0x0000001F;
80 break; 80 break;
81 case SDL_PackedLayout_8888: 81 case SDL_PACKEDLAYOUT_8888:
82 masks[0] = 0xFF000000; 82 masks[0] = 0xFF000000;
83 masks[1] = 0x00FF0000; 83 masks[1] = 0x00FF0000;
84 masks[2] = 0x0000FF00; 84 masks[2] = 0x0000FF00;
85 masks[3] = 0x000000FF; 85 masks[3] = 0x000000FF;
86 break; 86 break;
87 case SDL_PackedLayout_2101010: 87 case SDL_PACKEDLAYOUT_2101010:
88 masks[0] = 0xC0000000; 88 masks[0] = 0xC0000000;
89 masks[1] = 0x3FF00000; 89 masks[1] = 0x3FF00000;
90 masks[2] = 0x000FFC00; 90 masks[2] = 0x000FFC00;
91 masks[3] = 0x000003FF; 91 masks[3] = 0x000003FF;
92 break; 92 break;
94 /* Unknown layout */ 94 /* Unknown layout */
95 return SDL_FALSE; 95 return SDL_FALSE;
96 } 96 }
97 97
98 switch (SDL_PIXELORDER(format)) { 98 switch (SDL_PIXELORDER(format)) {
99 case SDL_PackedOrder_XRGB: 99 case SDL_PACKEDORDER_XRGB:
100 *Rmask = masks[1]; 100 *Rmask = masks[1];
101 *Gmask = masks[2]; 101 *Gmask = masks[2];
102 *Bmask = masks[3]; 102 *Bmask = masks[3];
103 break; 103 break;
104 case SDL_PackedOrder_RGBX: 104 case SDL_PACKEDORDER_RGBX:
105 *Rmask = masks[0]; 105 *Rmask = masks[0];
106 *Gmask = masks[1]; 106 *Gmask = masks[1];
107 *Bmask = masks[2]; 107 *Bmask = masks[2];
108 break; 108 break;
109 case SDL_PackedOrder_ARGB: 109 case SDL_PACKEDORDER_ARGB:
110 *Amask = masks[0]; 110 *Amask = masks[0];
111 *Rmask = masks[1]; 111 *Rmask = masks[1];
112 *Gmask = masks[2]; 112 *Gmask = masks[2];
113 *Bmask = masks[3]; 113 *Bmask = masks[3];
114 break; 114 break;
115 case SDL_PackedOrder_RGBA: 115 case SDL_PACKEDORDER_RGBA:
116 *Rmask = masks[0]; 116 *Rmask = masks[0];
117 *Gmask = masks[1]; 117 *Gmask = masks[1];
118 *Bmask = masks[2]; 118 *Bmask = masks[2];
119 *Amask = masks[3]; 119 *Amask = masks[3];
120 break; 120 break;
121 case SDL_PackedOrder_XBGR: 121 case SDL_PACKEDORDER_XBGR:
122 *Bmask = masks[1]; 122 *Bmask = masks[1];
123 *Gmask = masks[2]; 123 *Gmask = masks[2];
124 *Rmask = masks[3]; 124 *Rmask = masks[3];
125 break; 125 break;
126 case SDL_PackedOrder_BGRX: 126 case SDL_PACKEDORDER_BGRX:
127 *Bmask = masks[0]; 127 *Bmask = masks[0];
128 *Gmask = masks[1]; 128 *Gmask = masks[1];
129 *Rmask = masks[2]; 129 *Rmask = masks[2];
130 break; 130 break;
131 case SDL_PackedOrder_BGRA: 131 case SDL_PACKEDORDER_BGRA:
132 *Bmask = masks[0]; 132 *Bmask = masks[0];
133 *Gmask = masks[1]; 133 *Gmask = masks[1];
134 *Rmask = masks[2]; 134 *Rmask = masks[2];
135 *Amask = masks[3]; 135 *Amask = masks[3];
136 break; 136 break;
137 case SDL_PackedOrder_ABGR: 137 case SDL_PACKEDORDER_ABGR:
138 *Amask = masks[0]; 138 *Amask = masks[0];
139 *Bmask = masks[1]; 139 *Bmask = masks[1];
140 *Gmask = masks[2]; 140 *Gmask = masks[2];
141 *Rmask = masks[3]; 141 *Rmask = masks[3];
142 break; 142 break;
153 { 153 {
154 switch (bpp) { 154 switch (bpp) {
155 case 8: 155 case 8:
156 switch (Rmask) { 156 switch (Rmask) {
157 case 0: 157 case 0:
158 return SDL_PixelFormat_Index8; 158 return SDL_PIXELFORMAT_INDEX8;
159 case 0xE0: 159 case 0xE0:
160 return SDL_PixelFormat_RGB332; 160 return SDL_PIXELFORMAT_RGB332;
161 } 161 }
162 break; 162 break;
163 case 12: 163 case 12:
164 switch (Rmask) { 164 switch (Rmask) {
165 case 0x0F00: 165 case 0x0F00:
166 return SDL_PixelFormat_RGB444; 166 return SDL_PIXELFORMAT_RGB444;
167 } 167 }
168 break; 168 break;
169 case 15: 169 case 15:
170 switch (Rmask) { 170 switch (Rmask) {
171 case 0x7C00: 171 case 0x7C00:
172 return SDL_PixelFormat_RGB555; 172 return SDL_PIXELFORMAT_RGB555;
173 } 173 }
174 break; 174 break;
175 case 16: 175 case 16:
176 switch (Rmask) { 176 switch (Rmask) {
177 case 0x0F00: 177 case 0x0F00:
178 return SDL_PixelFormat_ARGB4444; 178 return SDL_PIXELFORMAT_ARGB4444;
179 case 0x7C00: 179 case 0x7C00:
180 return SDL_PixelFormat_ARGB1555; 180 return SDL_PIXELFORMAT_ARGB1555;
181 case 0xF800: 181 case 0xF800:
182 return SDL_PixelFormat_RGB565; 182 return SDL_PIXELFORMAT_RGB565;
183 } 183 }
184 break; 184 break;
185 case 32: 185 case 32:
186 switch (Rmask) { 186 switch (Rmask) {
187 case 0xFF000000: 187 case 0xFF000000:
188 if (Amask == 0x000000FF) { 188 if (Amask == 0x000000FF) {
189 return SDL_PixelFormat_RGBA8888; 189 return SDL_PIXELFORMAT_RGBA8888;
190 } 190 }
191 break; 191 break;
192 case 0x00FF0000: 192 case 0x00FF0000:
193 if (Amask == 0xFF000000) { 193 if (Amask == 0xFF000000) {
194 return SDL_PixelFormat_ARGB8888; 194 return SDL_PIXELFORMAT_ARGB8888;
195 } else { 195 } else {
196 return SDL_PixelFormat_RGB888; 196 return SDL_PIXELFORMAT_RGB888;
197 } 197 }
198 break; 198 break;
199 case 0x0000FF00: 199 case 0x0000FF00:
200 if (Amask == 0x000000FF) { 200 if (Amask == 0x000000FF) {
201 return SDL_PixelFormat_BGRA8888; 201 return SDL_PIXELFORMAT_BGRA8888;
202 } 202 }
203 break; 203 break;
204 case 0x000000FF: 204 case 0x000000FF:
205 if (Amask == 0xFF000000) { 205 if (Amask == 0xFF000000) {
206 return SDL_PixelFormat_ABGR8888; 206 return SDL_PIXELFORMAT_ABGR8888;
207 } else { 207 } else {
208 return SDL_PixelFormat_BGR888; 208 return SDL_PIXELFORMAT_BGR888;
209 } 209 }
210 break; 210 break;
211 case 0x3FF00000: 211 case 0x3FF00000:
212 return SDL_PixelFormat_ARGB2101010; 212 return SDL_PIXELFORMAT_ARGB2101010;
213 } 213 }
214 } 214 }
215 return SDL_PixelFormat_Unknown; 215 return SDL_PIXELFORMAT_UNKNOWN;
216 } 216 }
217 217
218 218
219 SDL_Palette * 219 SDL_Palette *
220 SDL_AllocPalette(int ncolors) 220 SDL_AllocPalette(int ncolors)