comparison src/video/SDL_blit.c @ 1670:eef792d31de8 SDL-1.3

Work in progress. :)
author Sam Lantinga <slouken@libsdl.org>
date Wed, 07 Jun 2006 16:10:28 +0000
parents 4da1ee79c9af
children
comparison
equal deleted inserted replaced
1669:9857d21967bb 1670:eef792d31de8
215 215
216 /* Figure out which of many blit routines to set up on a surface */ 216 /* Figure out which of many blit routines to set up on a surface */
217 int 217 int
218 SDL_CalculateBlit(SDL_Surface * surface) 218 SDL_CalculateBlit(SDL_Surface * surface)
219 { 219 {
220 SDL_VideoDevice *_this = SDL_GetVideoDevice();
221 const SDL_VideoInfo *info = SDL_GetVideoInfo();
222 int blit_index; 220 int blit_index;
223 221
224 /* Clean everything out to start */ 222 /* Clean everything out to start */
225 if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { 223 if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
226 SDL_UnRLESurface(surface, 1); 224 SDL_UnRLESurface(surface, 1);
227 } 225 }
228 surface->map->sw_blit = NULL; 226 surface->map->sw_blit = NULL;
229
230 /* Figure out if an accelerated hardware blit is possible */
231 surface->flags &= ~SDL_HWACCEL;
232 if (surface->map->identity) {
233 int hw_blit_ok;
234
235 if ((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
236 /* We only support accelerated blitting to hardware */
237 if (surface->map->dst->flags & SDL_HWSURFACE) {
238 hw_blit_ok = info->blit_hw;
239 } else {
240 hw_blit_ok = 0;
241 }
242 if (hw_blit_ok && (surface->flags & SDL_SRCCOLORKEY)) {
243 hw_blit_ok = info->blit_hw_CC;
244 }
245 if (hw_blit_ok && (surface->flags & SDL_SRCALPHA)) {
246 hw_blit_ok = info->blit_hw_A;
247 }
248 } else {
249 /* We only support accelerated blitting to hardware */
250 if (surface->map->dst->flags & SDL_HWSURFACE) {
251 hw_blit_ok = info->blit_sw;
252 } else {
253 hw_blit_ok = 0;
254 }
255 if (hw_blit_ok && (surface->flags & SDL_SRCCOLORKEY)) {
256 hw_blit_ok = info->blit_sw_CC;
257 }
258 if (hw_blit_ok && (surface->flags & SDL_SRCALPHA)) {
259 hw_blit_ok = info->blit_sw_A;
260 }
261 }
262 if (hw_blit_ok) {
263 _this->CheckHWBlit(_this, surface, surface->map->dst);
264 }
265 }
266
267 /* if an alpha pixel format is specified, we can accelerate alpha blits */
268 if (((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE)
269 && (_this->displayformatalphapixel)) {
270 if ((surface->flags & SDL_SRCALPHA))
271 if (info->blit_hw_A) {
272 _this->CheckHWBlit(_this, surface, surface->map->dst);
273 }
274 }
275 227
276 /* Get the blit function index, based on surface mode */ 228 /* Get the blit function index, based on surface mode */
277 /* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */ 229 /* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */
278 blit_index = 0; 230 blit_index = 0;
279 blit_index |= (!!(surface->flags & SDL_SRCCOLORKEY)) << 0; 231 blit_index |= (!!(surface->flags & SDL_SRCCOLORKEY)) << 0;
319 SDL_SetError("Blit combination not supported"); 271 SDL_SetError("Blit combination not supported");
320 return (-1); 272 return (-1);
321 } 273 }
322 274
323 /* Choose software blitting function */ 275 /* Choose software blitting function */
324 if (surface->flags & SDL_RLEACCELOK 276 if (surface->flags & SDL_RLEACCELOK) {
325 && (surface->flags & SDL_HWACCEL) != SDL_HWACCEL) {
326
327 if (surface->map->identity 277 if (surface->map->identity
328 && (blit_index == 1 278 && (blit_index == 1
329 || (blit_index == 3 && !surface->format->Amask))) { 279 || (blit_index == 3 && !surface->format->Amask))) {
330 if (SDL_RLESurface(surface) == 0) 280 if (SDL_RLESurface(surface) == 0)
331 surface->map->sw_blit = SDL_RLEBlit; 281 surface->map->sw_blit = SDL_RLEBlit;