/* * Set up a blit between two surfaces -- split into three parts: * The upper part, SDL_UpperBlit(), performs clipping and rectangle * verification. The lower part is a pointer to a low level * accelerated blitting function. * * These parts are separated out and each used internally by this * library in the optimimum places. They are exported so that if * you know exactly what you are doing, you can optimize your code * by calling the one(s) you need. */ int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { SDL_blit do_blit; SDL_Rect hw_srcrect; SDL_Rect hw_dstrect; /* Check to make sure the blit mapping is valid */ if ( (src->map->dst != dst) || (src->map->dst->format_version != src->map->format_version) ) { if ( SDL_MapSurface(src, dst) < 0 ) { return(-1); } } /* Figure out which blitter to use */ if ( (src->flags & SDL_HWACCEL) == SDL_HWACCEL ) { if ( src == SDL_VideoSurface ) { hw_srcrect = *srcrect; hw_srcrect.x += current_video->offset_x; hw_srcrect.y += current_video->offset_y; srcrect = &hw_srcrect; } if ( dst == SDL_VideoSurface ) { hw_dstrect = *dstrect; hw_dstrect.x += current_video->offset_x; hw_dstrect.y += current_video->offset_y; dstrect = &hw_dstrect; } do_blit = src->map->hw_blit; } else { do_blit = src->map->sw_blit; } return(do_blit(src, srcrect, dst, dstrect)); }
/* * Set up a blit between two surfaces -- split into three parts: * The upper part, SDL_UpperBlit(), performs clipping and rectangle * verification. The lower part is a pointer to a low level * accelerated blitting function. * * These parts are separated out and each used internally by this * library in the optimimum places. They are exported so that if * you know exactly what you are doing, you can optimize your code * by calling the one(s) you need. */ int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { /* Check to make sure the blit mapping is valid */ if ( (src->map->dst != dst) || (src->map->dst->format_version != src->map->format_version) ) { if ( SDL_MapSurface(src, dst) < 0 ) { return(-1); } } return(src->map->sw_blit(src, srcrect, dst, dstrect)); }
PUBLIC SDL_Surface * surface_from_dib (void *lp) { SDL_Surface *retval; retval = SDL_LoadCF_DIB (lp); if (retval) { int first_bpp; first_bpp = SDL_bpp (retval); if (first_bpp < 8) { /* TODO: convert < 8bpp to 8bpp */ } else if (first_bpp > 8) { /* convert > 8bpp to our particular 32bpp */ SDL_Surface *new_surface; int pixels_per_line; int n_lines; enum { A = 0x00000000, R = 0x0000FF00, G = 0x00FF0000, B = 0xFF000000 }; pixels_per_line = SDL_pixels_per_line (retval); n_lines = SDL_n_lines (retval); new_surface = SDL_AllocSurface (SDL_SWSURFACE, pixels_per_line, n_lines, 32, R, G, B, A); if (!new_surface || #if SDL_MAJOR_VERSION == 0 && SDL_MINOR_VERSION < 9 SDL_MapSurface (retval, new_surface->format) != 0 || #endif SDL_BlitSurface (retval, NULL, new_surface, NULL) != 0) { if (new_surface) { SDL_FreeSurface (new_surface); new_surface = NULL; } } SDL_FreeSurface (retval); retval = new_surface; } } return retval; }
/* * Set up a blit between two surfaces -- split into three parts: * The upper part, SDL_UpperBlit(), performs clipping and rectangle * verification. The lower part is a pointer to a low level * accelerated blitting function. * * These parts are separated out and each used internally by this * library in the optimimum places. They are exported so that if * you know exactly what you are doing, you can optimize your code * by calling the one(s) you need. */ int SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) { /* Check to make sure the blit mapping is valid */ if ((src->map->dst != dst) || (dst->format->palette && src->map->dst_palette_version != dst->format->palette->version) || (src->format->palette && src->map->src_palette_version != src->format->palette->version)) { if (SDL_MapSurface(src, dst) < 0) { return (-1); } /* just here for debugging */ /* printf */ /* ("src = 0x%08X src->flags = %08X src->map->info.flags = %08x\ndst = 0x%08X dst->flags = %08X dst->map->info.flags = %08X\nsrc->map->blit = 0x%08x\n", */ /* src, dst->flags, src->map->info.flags, dst, dst->flags, */ /* dst->map->info.flags, src->map->blit); */ } return (src->map->blit(src, srcrect, dst, dstrect)); }
/* * Set up a blit between two surfaces -- split into three parts: * The upper part, SDL_UpperBlit(), performs clipping and rectangle * verification. The lower part is a pointer to a low level * accelerated blitting function. * * These parts are separated out and each used internally by this * library in the optimimum places. They are exported so that if * you know exactly what you are doing, you can optimize your code * by calling the one(s) you need. */ int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { SDL_blit do_blit; /* Check to make sure the blit mapping is valid */ if ( (src->map->dst != dst) || (src->map->dst->format_version != src->map->format_version) ) { if ( SDL_MapSurface(src, dst) < 0 ) { return(-1); } } /* Figure out which blitter to use */ if ( (src->flags & SDL_HWACCEL) == SDL_HWACCEL ) { do_blit = src->map->hw_blit; } else { do_blit = src->map->sw_blit; } return(do_blit(src, srcrect, dst, dstrect)); }