comparison src/video/SDL_blit.c @ 2267:c785543d1843

Okay, still some bugs, but everything builds again...
author Sam Lantinga <slouken@libsdl.org>
date Sat, 18 Aug 2007 05:39:09 +0000
parents e61ad15a205f
children 91e601d9df8b
comparison
equal deleted inserted replaced
2266:e61ad15a205f 2267:c785543d1843
69 info->src = (Uint8 *) src->pixels + 69 info->src = (Uint8 *) src->pixels +
70 (Uint16) srcrect->y * src->pitch + 70 (Uint16) srcrect->y * src->pitch +
71 (Uint16) srcrect->x * info->src_fmt->BytesPerPixel; 71 (Uint16) srcrect->x * info->src_fmt->BytesPerPixel;
72 info->src_w = srcrect->w; 72 info->src_w = srcrect->w;
73 info->src_h = srcrect->h; 73 info->src_h = srcrect->h;
74 info->dst = (Uint8 *) dst->pixels + 74 info->src_skip =
75 (Uint16) dstrect->y * dst->pitch + 75 info->src_pitch - info->src_w * info->src_fmt->BytesPerPixel;
76 info->dst =
77 (Uint8 *) dst->pixels + (Uint16) dstrect->y * dst->pitch +
76 (Uint16) dstrect->x * info->dst_fmt->BytesPerPixel; 78 (Uint16) dstrect->x * info->dst_fmt->BytesPerPixel;
77 info->dst_w = dstrect->w; 79 info->dst_w = dstrect->w;
78 info->dst_h = dstrect->h; 80 info->dst_h = dstrect->h;
81 info->dst_skip =
82 info->dst_pitch - info->dst_w * info->dst_fmt->BytesPerPixel;
79 RunBlit = (SDL_BlitFunc) src->map->data; 83 RunBlit = (SDL_BlitFunc) src->map->data;
80 84
81 /* Run the actual software blit */ 85 /* Run the actual software blit */
82 RunBlit(info); 86 RunBlit(info);
83 } 87 }
117 return SDL_TRUE; 121 return SDL_TRUE;
118 } 122 }
119 #endif /* __MACOSX__ */ 123 #endif /* __MACOSX__ */
120 124
121 static SDL_BlitFunc 125 static SDL_BlitFunc
122 SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries) 126 SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
127 SDL_BlitFuncEntry * entries)
123 { 128 {
124 int i, flagcheck; 129 int i, flagcheck;
125 static Uint32 features = 0xffffffff; 130 static Uint32 features = 0xffffffff;
126 131
127 /* Get the available CPU features */ 132 /* Get the available CPU features */
164 if (dst_format != entries[i].dst_format) { 169 if (dst_format != entries[i].dst_format) {
165 continue; 170 continue;
166 } 171 }
167 172
168 /* Check modulation flags */ 173 /* Check modulation flags */
169 flagcheck = (flags & (SDL_COPY_MODULATE_COLOR|SDL_COPY_MODULATE_COLOR)); 174 flagcheck =
175 (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_COLOR));
170 if ((flagcheck & entries[i].flags) != flagcheck) { 176 if ((flagcheck & entries[i].flags) != flagcheck) {
171 continue; 177 continue;
172 } 178 }
173 179
174 /* Check blend flags */ 180 /* Check blend flags */
175 flagcheck = (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)); 181 flagcheck =
182 (flags &
183 (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD));
176 if ((flagcheck & entries[i].flags) != flagcheck) { 184 if ((flagcheck & entries[i].flags) != flagcheck) {
177 continue; 185 continue;
178 } 186 }
179 187
180 /* Check colorkey flag */ 188 /* Check colorkey flag */
206 SDL_CalculateBlit(SDL_Surface * surface) 214 SDL_CalculateBlit(SDL_Surface * surface)
207 { 215 {
208 SDL_BlitFunc blit = NULL; 216 SDL_BlitFunc blit = NULL;
209 SDL_BlitMap *map = surface->map; 217 SDL_BlitMap *map = surface->map;
210 SDL_Surface *dst = map->dst; 218 SDL_Surface *dst = map->dst;
211 Uint32 src_format;
212 Uint32 dst_format;
213 219
214 /* Clean everything out to start */ 220 /* Clean everything out to start */
215 if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { 221 if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
216 SDL_UnRLESurface(surface, 1); 222 SDL_UnRLESurface(surface, 1);
217 } 223 }
220 map->info.src_pitch = surface->pitch; 226 map->info.src_pitch = surface->pitch;
221 map->info.dst_fmt = dst->format; 227 map->info.dst_fmt = dst->format;
222 map->info.dst_pitch = dst->pitch; 228 map->info.dst_pitch = dst->pitch;
223 229
224 /* See if we can do RLE acceleration */ 230 /* See if we can do RLE acceleration */
225 if (surface->flags & SDL_RLEACCELOK) { 231 if (surface->map->info.flags & SDL_COPY_RLE_DESIRED) {
226 if (SDL_RLESurface(surface) == 0) { 232 if (SDL_RLESurface(surface) == 0) {
227 return 0; 233 return 0;
228 } 234 }
229 } 235 }
230 236
231 /* Choose a standard blit function */ 237 /* Choose a standard blit function */
232 src_format = SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask);
233 dst_format = SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask);
234
235 if (map->identity && !map->info.flags) { 238 if (map->identity && !map->info.flags) {
236 /* Handle overlapping blits on the same surface */ 239 /* Handle overlapping blits on the same surface */
237 if (surface == dst) { 240 if (surface == dst) {
238 blit = SDL_BlitCopyOverlap; 241 blit = SDL_BlitCopyOverlap;
239 } else { 242 } else {
240 blit = SDL_BlitCopy; 243 blit = SDL_BlitCopy;
241 } 244 }
242 } else if (surface->format->BitsPerPixel < 8) { 245 } else if (surface->format->BitsPerPixel < 8) {
243 blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTable0); 246 blit = SDL_CalculateBlit0(surface);
244 } else if (surface->format->BytesPerPixel == 1) { 247 } else if (surface->format->BytesPerPixel == 1) {
245 blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTable1); 248 blit = SDL_CalculateBlit1(surface);
249 } else if (map->info.flags & SDL_COPY_BLEND) {
250 blit = SDL_CalculateBlitA(surface);
246 } else { 251 } else {
247 blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTableN); 252 blit = SDL_CalculateBlitN(surface);
248 } 253 }
249 if (blit == NULL) { 254 if (blit == NULL) {
250 blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_GeneratedBlitFuncTable); 255 Uint32 src_format =
251 } 256 SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel,
257 surface->format->Rmask,
258 surface->format->Gmask,
259 surface->format->Bmask,
260 surface->format->Amask);
261 Uint32 dst_format =
262 SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel,
263 dst->format->Rmask, dst->format->Gmask,
264 dst->format->Bmask,
265 dst->format->Amask);
266
267 blit =
268 SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags,
269 SDL_GeneratedBlitFuncTable);
270 }
271 map->data = blit;
252 272
253 /* Make sure we have a blit function */ 273 /* Make sure we have a blit function */
254 if (blit == NULL) { 274 if (blit == NULL) {
255 SDL_InvalidateMap(map); 275 SDL_InvalidateMap(map);
256 SDL_SetError("Blit combination not supported"); 276 SDL_SetError("Blit combination not supported");