src/video/SDL_blit_N.c
changeset 12601 22056748671d
parent 12600 be2c1d4ee0d1
child 12602 75f13d4bfa9a
equal deleted inserted replaced
12600:be2c1d4ee0d1 12601:22056748671d
  2377             }
  2377             }
  2378             return;
  2378             return;
  2379         }
  2379         }
  2380     }
  2380     }
  2381 
  2381 
       
  2382     /* Any src/dst 8888, not CopyAlpha, no ARGB2101010 */
       
  2383     if (srcbpp == 4 && dstbpp == 4 &&
       
  2384         srcfmt->format != SDL_PIXELFORMAT_ARGB2101010 &&
       
  2385         dstfmt->format != SDL_PIXELFORMAT_ARGB2101010) {
       
  2386 
       
  2387         Uint32 *src32 = (Uint32*)src;
       
  2388         Uint32 *dst32 = (Uint32*)dst;
       
  2389         
       
  2390         if (dstfmt->Amask) {
       
  2391             /* Find the appropriate permutation */
       
  2392             int missing = 0, r, g, b, a;
       
  2393             int Pixel = 0x03020100;
       
  2394             RGB_FROM_PIXEL(Pixel, srcfmt, r, g, b);
       
  2395             PIXEL_FROM_RGBA(Pixel, dstfmt, r, g, b, 255);
       
  2396             r = Pixel & 0xFF;
       
  2397             g = (Pixel >> 8) & 0xFF;
       
  2398             b = (Pixel >> 16) & 0xFF;
       
  2399             a = (Pixel >> 24) & 0xFF;
       
  2400 
       
  2401             {
       
  2402                 int val;
       
  2403                 for (val = 0; val <= 3; val++) {
       
  2404                     if (r != val && g != val && b != val && a != val) {
       
  2405                         missing = val;
       
  2406                     }
       
  2407                 }
       
  2408             }
       
  2409 
       
  2410             if (r == 255) {
       
  2411                 r = missing;
       
  2412                 missing = 0;
       
  2413             } else if (g == 255) {
       
  2414                 g = missing;
       
  2415                 missing = 1;
       
  2416             } else if (b == 255) {
       
  2417                 b = missing;
       
  2418                 missing = 2;
       
  2419             } else if (a == 255) {
       
  2420                 a = missing;
       
  2421                 missing = 3;
       
  2422             }
       
  2423 
       
  2424             while (height--) {
       
  2425                 /* *INDENT-OFF* */
       
  2426                 DUFFS_LOOP(
       
  2427                 {
       
  2428                     if ((*src32 & rgbmask) != ckey) {
       
  2429                         Uint8 *s8 = (Uint8 *)src32;
       
  2430                         Uint8 *d8 = (Uint8 *)dst32;
       
  2431                         d8[0] = s8[r];
       
  2432                         d8[1] = s8[g];
       
  2433                         d8[2] = s8[b];
       
  2434                         d8[3] = s8[a];
       
  2435                         d8[missing] = alpha;
       
  2436                     }
       
  2437                     ++src32;
       
  2438                     ++dst32;
       
  2439                 }, width);
       
  2440                 /* *INDENT-ON* */
       
  2441                 src32 = (Uint32 *)((Uint8 *)src32 + srcskip);
       
  2442                 dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
       
  2443             }
       
  2444         
       
  2445             return;
       
  2446         } else {
       
  2447             /* Find the appropriate permutation */
       
  2448             int missing = 0, r, g, b, a;
       
  2449             int Pixel = 0x04030201; /* +1 */
       
  2450             RGBA_FROM_PIXEL(Pixel, srcfmt, r, g, b, a);
       
  2451             missing = a;
       
  2452             PIXEL_FROM_RGB(Pixel, dstfmt, r, g, b);
       
  2453             r = Pixel & 0xFF;
       
  2454             g = (Pixel >> 8) & 0xFF;
       
  2455             b = (Pixel >> 16) & 0xFF;
       
  2456             a = (Pixel >> 24) & 0xFF;
       
  2457 
       
  2458             if (r == 0) {
       
  2459                 r = missing;
       
  2460                 missing = 0;
       
  2461             } else if (g == 0) {
       
  2462                 g = missing;
       
  2463                 missing = 1;
       
  2464             } else if (b == 0) {
       
  2465                 b = missing;
       
  2466                 missing = 2;
       
  2467             } else if (a == 0) {
       
  2468                 a = missing;
       
  2469                 missing = 3;
       
  2470             }
       
  2471         
       
  2472             /* -1 */
       
  2473             r -= 1; g -= 1; b -= 1; a -= 1;
       
  2474 
       
  2475             while (height--) {
       
  2476                 /* *INDENT-OFF* */
       
  2477                 DUFFS_LOOP(
       
  2478                 {
       
  2479                     if ((*src32 & rgbmask) != ckey) {
       
  2480                         Uint8 *s8 = (Uint8 *)src32;
       
  2481                         Uint8 *d8 = (Uint8 *)dst32;
       
  2482                         d8[0] = s8[r];
       
  2483                         d8[1] = s8[g];
       
  2484                         d8[2] = s8[b];
       
  2485                         d8[3] = s8[a];
       
  2486                         d8[missing] = 0;
       
  2487                     }
       
  2488                     ++src32;
       
  2489                     ++dst32;
       
  2490                 }, width);
       
  2491                 /* *INDENT-ON* */
       
  2492                 src32 = (Uint32 *)((Uint8 *)src32 + srcskip);
       
  2493                 dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
       
  2494             }
       
  2495             return;
       
  2496         }
       
  2497     }
       
  2498 
  2382     /* BPP 3, same rgb triplet */
  2499     /* BPP 3, same rgb triplet */
  2383     if ((sfmt == SDL_PIXELFORMAT_RGB24 && dfmt == SDL_PIXELFORMAT_RGB24) ||
  2500     if ((sfmt == SDL_PIXELFORMAT_RGB24 && dfmt == SDL_PIXELFORMAT_RGB24) ||
  2384         (sfmt == SDL_PIXELFORMAT_BGR24 && dfmt == SDL_PIXELFORMAT_BGR24)) {
  2501         (sfmt == SDL_PIXELFORMAT_BGR24 && dfmt == SDL_PIXELFORMAT_BGR24)) {
  2385 
  2502 
  2386         Uint8 k0 = ckey & 0x000000FF;
  2503         Uint8 k0 = ckey & 0x000000FF;