src/video/SDL_blit_N.c
changeset 12610 587922004ea0
parent 12609 48e26b5d4f56
child 12613 c8f998f83225
equal deleted inserted replaced
12609:48e26b5d4f56 12610:587922004ea0
  2936     int dstbpp = dstfmt->BytesPerPixel;
  2936     int dstbpp = dstfmt->BytesPerPixel;
  2937 
  2937 
  2938     if (dstfmt->Amask) {
  2938     if (dstfmt->Amask) {
  2939         /* SET_ALPHA */
  2939         /* SET_ALPHA */
  2940         Uint32 mask = info->a << dstfmt->Ashift;
  2940         Uint32 mask = info->a << dstfmt->Ashift;
       
  2941         int last_line = 0;
       
  2942         if (srcbpp == 3 && height) {
       
  2943             height -= 1;
       
  2944             last_line = 1;
       
  2945         }
       
  2946 
  2941         while (height--) {
  2947         while (height--) {
  2942             /* *INDENT-OFF* */
  2948             /* *INDENT-OFF* */
  2943             DUFFS_LOOP(
  2949             DUFFS_LOOP(
  2944             {
  2950             {
  2945                 Uint32  *dst32 = (Uint32*)dst;
  2951                 Uint32  *dst32 = (Uint32*)dst;
       
  2952                 Uint32  *src32 = (Uint32*)src;
       
  2953                 *dst32 = *src32 | mask;
       
  2954                 dst += 4;
       
  2955                 src += srcbpp;
       
  2956             }, width);
       
  2957             /* *INDENT-ON* */
       
  2958             src += srcskip;
       
  2959             dst += dstskip;
       
  2960         }
       
  2961 
       
  2962         if (last_line) {
       
  2963             while (width--) {
       
  2964                 Uint32  *dst32 = (Uint32*)dst;
  2946                 Uint8 s0 = src[0];
  2965                 Uint8 s0 = src[0];
  2947                 Uint8 s1 = src[1];
  2966                 Uint8 s1 = src[1];
  2948                 Uint8 s2 = src[2];
  2967                 Uint8 s2 = src[2];
  2949                 *dst32 = (s0) | (s1 << 8) | (s2 << 16) | mask;
  2968                 *dst32 = (s0) | (s1 << 8) | (s2 << 16) | mask;
       
  2969                 dst += 4;
       
  2970                 src += srcbpp;
       
  2971             }
       
  2972         }
       
  2973     } else {
       
  2974         /* NO_ALPHA */
       
  2975         int mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
       
  2976         int last_line = 0;
       
  2977         if ((dstbpp == 3 || srcbpp == 3) && height) {
       
  2978             height -= 1;
       
  2979             last_line = 1;
       
  2980         }
       
  2981 
       
  2982         while (height--) {
       
  2983             /* *INDENT-OFF* */
       
  2984             DUFFS_LOOP(
       
  2985             {
       
  2986                 Uint32  *dst32 = (Uint32*)dst;
       
  2987                 Uint32  *src32 = (Uint32*)src;
       
  2988                 *dst32 = *src32 & mask;
  2950                 dst += dstbpp;
  2989                 dst += dstbpp;
  2951                 src += srcbpp;
  2990                 src += srcbpp;
  2952             }, width);
  2991             }, width);
  2953             /* *INDENT-ON* */
  2992             /* *INDENT-ON* */
  2954             src += srcskip;
  2993             src += srcskip;
  2955             dst += dstskip;
  2994             dst += dstskip;
  2956         }
  2995         }
  2957     } else {
  2996 
  2958         /* NO_ALPHA */
  2997         if (last_line) {
  2959         while (height--) {
  2998             while (width--) {
  2960             /* *INDENT-OFF* */
       
  2961             DUFFS_LOOP(
       
  2962             {
       
  2963                 Uint32  *dst32 = (Uint32*)dst;
       
  2964                 Uint8 s0 = src[0];
  2999                 Uint8 s0 = src[0];
  2965                 Uint8 s1 = src[1];
  3000                 Uint8 s1 = src[1];
  2966                 Uint8 s2 = src[2];
  3001                 Uint8 s2 = src[2];
  2967                 *dst32 = (s0) | (s1 << 8) | (s2 << 16);
  3002                 dst[0] = s0;
       
  3003                 dst[1] = s1;
       
  3004                 dst[2] = s2;
  2968                 dst += dstbpp;
  3005                 dst += dstbpp;
  2969                 src += srcbpp;
  3006                 src += srcbpp;
  2970             }, width);
  3007             }
  2971             /* *INDENT-ON* */
       
  2972             src += srcskip;
       
  2973             dst += dstskip;
       
  2974         }
  3008         }
  2975     }
  3009     }
  2976     return;
  3010     return;
  2977 }
  3011 }
  2978 
  3012 
  3034                 dst += dstskip;
  3068                 dst += dstskip;
  3035             }
  3069             }
  3036         }
  3070         }
  3037     } else {
  3071     } else {
  3038         /* NO_ALPHA */
  3072         /* NO_ALPHA */
       
  3073         int last_line = 0;
       
  3074         if (dstbpp == 3 && height) {
       
  3075             height -= 1;
       
  3076             last_line = 1;
       
  3077         }
       
  3078 
  3039         while (height--) {
  3079         while (height--) {
  3040             /* *INDENT-OFF* */
  3080             /* *INDENT-OFF* */
  3041             DUFFS_LOOP(
  3081             DUFFS_LOOP(
  3042             {
  3082             {
  3043                 Uint32 *dst32 = (Uint32*)dst;
  3083                 Uint32 *dst32 = (Uint32*)dst;
  3050                 src += srcbpp;
  3090                 src += srcbpp;
  3051             }, width);
  3091             }, width);
  3052             /* *INDENT-ON* */
  3092             /* *INDENT-ON* */
  3053             src += srcskip;
  3093             src += srcskip;
  3054             dst += dstskip;
  3094             dst += dstskip;
       
  3095         }
       
  3096 
       
  3097         if (last_line) {
       
  3098             while (width--) {
       
  3099                 Uint8 s0 = src[0];
       
  3100                 Uint8 s1 = src[1];
       
  3101                 Uint8 s2 = src[2];
       
  3102                 /* inversed, compared to Blit_3or4_to_3or4__same_rgb */
       
  3103                 dst[0] = s2;
       
  3104                 dst[1] = s1;
       
  3105                 dst[2] = s0;
       
  3106                 dst += dstbpp;
       
  3107                 src += srcbpp;
       
  3108             }
  3055         }
  3109         }
  3056     }
  3110     }
  3057     return;
  3111     return;
  3058 }
  3112 }
  3059 
  3113