src/video/SDL_blit_N.c
changeset 12608 b3a02787a4dd
parent 12607 4fb583571d7c
child 12609 48e26b5d4f56
equal deleted inserted replaced
12607:4fb583571d7c 12608:b3a02787a4dd
  2217     int srcbpp = srcfmt->BytesPerPixel;
  2217     int srcbpp = srcfmt->BytesPerPixel;
  2218     SDL_PixelFormat *dstfmt = info->dst_fmt;
  2218     SDL_PixelFormat *dstfmt = info->dst_fmt;
  2219     int dstbpp = dstfmt->BytesPerPixel;
  2219     int dstbpp = dstfmt->BytesPerPixel;
  2220     unsigned alpha = dstfmt->Amask ? info->a : 0;
  2220     unsigned alpha = dstfmt->Amask ? info->a : 0;
  2221 
  2221 
  2222     /* Any src/dst 8888, not CopyAlpha, no ARGB2101010 */
  2222     /* Blit with permutation: 4->4 */
  2223     if (srcbpp == 4 && dstbpp == 4 &&
  2223     if (srcbpp == 4 && dstbpp == 4 &&
  2224         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
  2224         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
  2225         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
  2225         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
  2226 
  2226 
  2227         Uint32 *src32 = (Uint32*)src;
  2227         Uint32 *src32 = (Uint32*)src;
  2250             dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
  2250             dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
  2251         }
  2251         }
  2252         return;
  2252         return;
  2253     }
  2253     }
  2254 
  2254 
       
  2255     /* Blit with permutation: 4->3 */
       
  2256     if (srcbpp == 4 && dstbpp == 3 &&
       
  2257         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
       
  2258 
       
  2259         Uint32 *src32 = (Uint32*)src;
       
  2260 
       
  2261         /* Find the appropriate permutation */
       
  2262         int r, g, b, a;
       
  2263         get_permutation(srcfmt, dstfmt, &r, &g, &b, &a, NULL);
       
  2264 
       
  2265         while (height--) {
       
  2266             /* *INDENT-OFF* */
       
  2267             DUFFS_LOOP(
       
  2268             {
       
  2269                 Uint8 *s8 = (Uint8 *)src32;
       
  2270                 dst[0] = s8[r];
       
  2271                 dst[1] = s8[g];
       
  2272                 dst[2] = s8[b];
       
  2273                 ++src32;
       
  2274                 dst += 3;
       
  2275             }, width);
       
  2276             /* *INDENT-ON* */
       
  2277             src32 = (Uint32 *)((Uint8 *)src32 + srcskip);
       
  2278             dst += dstskip;
       
  2279         }
       
  2280         return;
       
  2281     }
       
  2282 
       
  2283     /* Blit with permutation: 3->4 */
       
  2284     if (srcbpp == 3 && dstbpp == 4 &&
       
  2285         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
       
  2286 
       
  2287         Uint32 *dst32 = (Uint32*)dst;
       
  2288 
       
  2289         /* Find the appropriate permutation */
       
  2290         int missing = 0, r, g, b, a;
       
  2291         get_permutation(srcfmt, dstfmt, &r, &g, &b, &a, &missing);
       
  2292 
       
  2293         while (height--) {
       
  2294             /* *INDENT-OFF* */
       
  2295             DUFFS_LOOP(
       
  2296             {
       
  2297                 Uint8 *d8 = (Uint8 *)dst32;
       
  2298                 d8[0] = src[r];
       
  2299                 d8[1] = src[g];
       
  2300                 d8[2] = src[b];
       
  2301                 d8[3] = src[a];
       
  2302                 d8[missing] = alpha;
       
  2303                 src += 3;
       
  2304                 ++dst32;
       
  2305             }, width);
       
  2306             /* *INDENT-ON* */
       
  2307             src += srcskip;
       
  2308             dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
       
  2309         }
       
  2310         return;
       
  2311     }
       
  2312 
  2255     while (height--) {
  2313     while (height--) {
  2256         /* *INDENT-OFF* */
  2314         /* *INDENT-OFF* */
  2257         DUFFS_LOOP(
  2315         DUFFS_LOOP(
  2258         {
  2316         {
  2259             Uint32 Pixel;
  2317             Uint32 Pixel;
  2285     int srcbpp = srcfmt->BytesPerPixel;
  2343     int srcbpp = srcfmt->BytesPerPixel;
  2286     SDL_PixelFormat *dstfmt = info->dst_fmt;
  2344     SDL_PixelFormat *dstfmt = info->dst_fmt;
  2287     int dstbpp = dstfmt->BytesPerPixel;
  2345     int dstbpp = dstfmt->BytesPerPixel;
  2288     int c;
  2346     int c;
  2289 
  2347 
  2290     /* Any src/dst 8888 for CopyAlpha, no ARGB2101010 */
  2348     /* Blit with permutation: 4->4 */
  2291     if (srcbpp == 4 && dstbpp == 4 &&
  2349     if (srcbpp == 4 && dstbpp == 4 &&
  2292         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
  2350         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
  2293         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
  2351         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
  2294 
  2352 
  2295         Uint32 *src32 = (Uint32*)src;
  2353         Uint32 *src32 = (Uint32*)src;
  2497             }
  2555             }
  2498             return;
  2556             return;
  2499         }
  2557         }
  2500     }
  2558     }
  2501 
  2559 
  2502     /* Any src/dst 8888, not CopyAlpha, no ARGB2101010 */
  2560     /* Blit with permutation: 4->4 */
  2503     if (srcbpp == 4 && dstbpp == 4 &&
  2561     if (srcbpp == 4 && dstbpp == 4 &&
  2504         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
  2562         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
  2505         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
  2563         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
  2506 
  2564 
  2507         Uint32 *src32 = (Uint32*)src;
  2565         Uint32 *src32 = (Uint32*)src;
  2596             dst += dstskip;
  2654             dst += dstskip;
  2597         }
  2655         }
  2598         return;
  2656         return;
  2599     }
  2657     }
  2600 
  2658 
       
  2659     /* Blit with permutation: 4->3 */
       
  2660     if (srcbpp == 4 && dstbpp == 3 &&
       
  2661         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
       
  2662 
       
  2663         Uint32 *src32 = (Uint32*)src;
       
  2664 
       
  2665         /* Find the appropriate permutation */
       
  2666         int r, g, b, a;
       
  2667         get_permutation(srcfmt, dstfmt, &r, &g, &b, &a, NULL);
       
  2668 
       
  2669         while (height--) {
       
  2670             /* *INDENT-OFF* */
       
  2671             DUFFS_LOOP(
       
  2672             {
       
  2673                 if ((*src32 & rgbmask) != ckey) {
       
  2674                     Uint8 *s8 = (Uint8 *)src32;
       
  2675                     dst[0] = s8[r];
       
  2676                     dst[1] = s8[g];
       
  2677                     dst[2] = s8[b];
       
  2678                 }
       
  2679                 ++src32;
       
  2680                 dst += 3;
       
  2681             }, width);
       
  2682             /* *INDENT-ON* */
       
  2683             src32 = (Uint32 *)((Uint8 *)src32 + srcskip);
       
  2684             dst += dstskip;
       
  2685         }
       
  2686         return;
       
  2687     }
       
  2688 
       
  2689     /* Blit with permutation: 3->4 */
       
  2690     if (srcbpp == 3 && dstbpp == 4 &&
       
  2691         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
       
  2692 
       
  2693         Uint32 *dst32 = (Uint32*)dst;
       
  2694 
       
  2695         Uint8 k0 = ckey & 0xFF;
       
  2696         Uint8 k1 = (ckey >> 8)  & 0xFF;
       
  2697         Uint8 k2 = (ckey >> 16) & 0xFF;
       
  2698 
       
  2699         /* Find the appropriate permutation */
       
  2700         int missing = 0, r, g, b, a;
       
  2701         get_permutation(srcfmt, dstfmt, &r, &g, &b, &a, &missing);
       
  2702 
       
  2703         while (height--) {
       
  2704             /* *INDENT-OFF* */
       
  2705             DUFFS_LOOP(
       
  2706             {
       
  2707                 Uint8 s0 = src[0];
       
  2708                 Uint8 s1 = src[1];
       
  2709                 Uint8 s2 = src[2];
       
  2710 
       
  2711                 if (k0 != s0 || k1 != s1 || k2 != s2) {
       
  2712                     Uint8 *d8 = (Uint8 *)dst32;
       
  2713                     d8[0] = src[r];
       
  2714                     d8[1] = src[g];
       
  2715                     d8[2] = src[b];
       
  2716                     d8[3] = src[a];
       
  2717                     d8[missing] = alpha;
       
  2718                 }
       
  2719                 src += 3;
       
  2720                 ++dst32;
       
  2721             }, width);
       
  2722             /* *INDENT-ON* */
       
  2723             src += srcskip;
       
  2724             dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
       
  2725 
       
  2726         }
       
  2727         return;
       
  2728     }
       
  2729 
  2601     while (height--) {
  2730     while (height--) {
  2602         /* *INDENT-OFF* */
  2731         /* *INDENT-OFF* */
  2603         DUFFS_LOOP(
  2732         DUFFS_LOOP(
  2604         {
  2733         {
  2605             Uint32 Pixel;
  2734             Uint32 Pixel;
  2672             }
  2801             }
  2673         }
  2802         }
  2674         return;
  2803         return;
  2675     }
  2804     }
  2676 
  2805 
  2677     /* Any src/dst 8888 for CopyAlpha, no ARGB2101010 */
  2806     /* Blit with permutation: 4->4 */
  2678     if (srcbpp == 4 && dstbpp == 4 &&
  2807     if (srcbpp == 4 && dstbpp == 4 &&
  2679         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
  2808         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
  2680         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
  2809         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
  2681 
  2810 
  2682         Uint32 *src32 = (Uint32*)src;
  2811         Uint32 *src32 = (Uint32*)src;