src/video/SDL_blit_N.c
branchSDL-1.2
changeset 11973 94f71f4d90e9
parent 6411 ec7ccf5ee3dd
child 13065 5df049ec4620
equal deleted inserted replaced
11972:0b5ac2b90ab1 11973:94f71f4d90e9
  2037 			dst = (Uint32*)((Uint8*)dst + dstskip);
  2037 			dst = (Uint32*)((Uint8*)dst + dstskip);
  2038 		}
  2038 		}
  2039 	}
  2039 	}
  2040 }
  2040 }
  2041 
  2041 
       
  2042 /* blits 32 bit RGBA<->RGBA with both surfaces having the same R,G,B,A fields */
       
  2043 static void Blit4to4CopyAlpha(SDL_BlitInfo *info)
       
  2044 {
       
  2045 	int width = info->d_width;
       
  2046 	int height = info->d_height;
       
  2047 	Uint32 *src = (Uint32 *)info->s_pixels;
       
  2048 	int srcskip = info->s_skip;
       
  2049 	Uint32 *dst = (Uint32 *)info->d_pixels;
       
  2050 	int dstskip = info->d_skip;
       
  2051 
       
  2052 	/* RGBA->RGBA, COPY_ALPHA */
       
  2053 	while ( height-- ) {
       
  2054 		DUFFS_LOOP(
       
  2055 		{
       
  2056 			*dst = *src;
       
  2057 			++dst;
       
  2058 			++src;
       
  2059 		},
       
  2060 		width);
       
  2061 		src = (Uint32*)((Uint8*)src + srcskip);
       
  2062 		dst = (Uint32*)((Uint8*)dst + dstskip);
       
  2063 	}
       
  2064 }
       
  2065 
  2042 static void BlitNtoN(SDL_BlitInfo *info)
  2066 static void BlitNtoN(SDL_BlitInfo *info)
  2043 {
  2067 {
  2044 	int width = info->d_width;
  2068 	int width = info->d_width;
  2045 	int height = info->d_height;
  2069 	int height = info->d_height;
  2046 	Uint8 *src = info->s_pixels;
  2070 	Uint8 *src = info->s_pixels;
  2467 		}
  2491 		}
  2468 		sdata->aux_data = table[which].aux_data;
  2492 		sdata->aux_data = table[which].aux_data;
  2469 		blitfun = table[which].blitfunc;
  2493 		blitfun = table[which].blitfunc;
  2470 
  2494 
  2471 		if(blitfun == BlitNtoN) {  /* default C fallback catch-all. Slow! */
  2495 		if(blitfun == BlitNtoN) {  /* default C fallback catch-all. Slow! */
  2472 			/* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
       
  2473 			if ( srcfmt->BytesPerPixel == 4 && dstfmt->BytesPerPixel == 4 &&
  2496 			if ( srcfmt->BytesPerPixel == 4 && dstfmt->BytesPerPixel == 4 &&
  2474 			     srcfmt->Rmask == dstfmt->Rmask &&
  2497 			     srcfmt->Rmask == dstfmt->Rmask &&
  2475 			     srcfmt->Gmask == dstfmt->Gmask &&
  2498 			     srcfmt->Gmask == dstfmt->Gmask &&
  2476 			     srcfmt->Bmask == dstfmt->Bmask ) {
  2499 			     srcfmt->Bmask == dstfmt->Bmask ) {
  2477 				blitfun = Blit4to4MaskAlpha;
  2500 				if( a_need == COPY_ALPHA ) {
       
  2501 				    if( srcfmt->Amask == dstfmt->Amask ) {
       
  2502 				    /* Fastpath C fallback: 32bit RGBA<->RGBA blit with matching RGBA */
       
  2503 					blitfun = Blit4to4CopyAlpha;
       
  2504 				    } else {
       
  2505 					blitfun = BlitNtoNCopyAlpha;
       
  2506 				    }
       
  2507 				} else {
       
  2508 				    /* Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB */
       
  2509 				    blitfun = Blit4to4MaskAlpha;
       
  2510 				}
  2478 			} else if ( a_need == COPY_ALPHA ) {
  2511 			} else if ( a_need == COPY_ALPHA ) {
  2479 			    blitfun = BlitNtoNCopyAlpha;
  2512 			    blitfun = BlitNtoNCopyAlpha;
  2480 			}
  2513 			}
  2481 		}
  2514 		}
  2482 	}
  2515 	}