src/video/SDL_blit_1.c
changeset 12201 8bdc4d340419
parent 11811 5d94cb6b24d3
child 12503 806492103856
equal deleted inserted replaced
12200:c0b17b32b95e 12201:8bdc4d340419
    47     map = info->table;
    47     map = info->table;
    48 
    48 
    49     while (height--) {
    49     while (height--) {
    50 #ifdef USE_DUFFS_LOOP
    50 #ifdef USE_DUFFS_LOOP
    51         /* *INDENT-OFF* */
    51         /* *INDENT-OFF* */
    52 		DUFFS_LOOP(
    52         DUFFS_LOOP(
    53 			{
    53             {
    54 			  *dst = map[*src];
    54               *dst = map[*src];
    55 			}
    55             }
    56 			dst++;
    56             dst++;
    57 			src++;
    57             src++;
    58 		, width);
    58         , width);
    59         /* *INDENT-ON* */
    59         /* *INDENT-ON* */
    60 #else
    60 #else
    61         for (c = width; c; --c) {
    61         for (c = width; c; --c) {
    62             *dst = map[*src];
    62             *dst = map[*src];
    63             dst++;
    63             dst++;
    70 }
    70 }
    71 
    71 
    72 /* This is now endian dependent */
    72 /* This is now endian dependent */
    73 #ifndef USE_DUFFS_LOOP
    73 #ifndef USE_DUFFS_LOOP
    74 # if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
    74 # if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
    75 #  define HI	1
    75 #  define HI    1
    76 #  define LO	0
    76 #  define LO    0
    77 # else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
    77 # else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
    78 #  define HI	0
    78 #  define HI    0
    79 #  define LO	1
    79 #  define LO    1
    80 # endif
    80 # endif
    81 #endif
    81 #endif
    82 static void
    82 static void
    83 Blit1to2(SDL_BlitInfo * info)
    83 Blit1to2(SDL_BlitInfo * info)
    84 {
    84 {
    99     dstskip = info->dst_skip;
    99     dstskip = info->dst_skip;
   100     map = (Uint16 *) info->table;
   100     map = (Uint16 *) info->table;
   101 
   101 
   102 #ifdef USE_DUFFS_LOOP
   102 #ifdef USE_DUFFS_LOOP
   103     while (height--) {
   103     while (height--) {
   104 		/* *INDENT-OFF* */
   104         /* *INDENT-OFF* */
   105 		DUFFS_LOOP(
   105         DUFFS_LOOP(
   106 		{
   106         {
   107 			*(Uint16 *)dst = map[*src++];
   107             *(Uint16 *)dst = map[*src++];
   108 			dst += 2;
   108             dst += 2;
   109 		},
   109         },
   110 		width);
   110         width);
   111 		/* *INDENT-ON* */
   111         /* *INDENT-ON* */
   112         src += srcskip;
   112         src += srcskip;
   113         dst += dstskip;
   113         dst += dstskip;
   114     }
   114     }
   115 #else
   115 #else
   116     /* Memory align at 4-byte boundary, if necessary */
   116     /* Memory align at 4-byte boundary, if necessary */
   206     dstskip = info->dst_skip;
   206     dstskip = info->dst_skip;
   207     map = info->table;
   207     map = info->table;
   208 
   208 
   209     while (height--) {
   209     while (height--) {
   210 #ifdef USE_DUFFS_LOOP
   210 #ifdef USE_DUFFS_LOOP
   211 		/* *INDENT-OFF* */
   211         /* *INDENT-OFF* */
   212 		DUFFS_LOOP(
   212         DUFFS_LOOP(
   213 			{
   213             {
   214 				o = *src * 4;
   214                 o = *src * 4;
   215 				dst[0] = map[o++];
   215                 dst[0] = map[o++];
   216 				dst[1] = map[o++];
   216                 dst[1] = map[o++];
   217 				dst[2] = map[o++];
   217                 dst[2] = map[o++];
   218 			}
   218             }
   219 			src++;
   219             src++;
   220 			dst += 3;
   220             dst += 3;
   221 		, width);
   221         , width);
   222 		/* *INDENT-ON* */
   222         /* *INDENT-ON* */
   223 #else
   223 #else
   224         for (c = width; c; --c) {
   224         for (c = width; c; --c) {
   225             o = *src * 4;
   225             o = *src * 4;
   226             dst[0] = map[o++];
   226             dst[0] = map[o++];
   227             dst[1] = map[o++];
   227             dst[1] = map[o++];
   255     dstskip = info->dst_skip / 4;
   255     dstskip = info->dst_skip / 4;
   256     map = (Uint32 *) info->table;
   256     map = (Uint32 *) info->table;
   257 
   257 
   258     while (height--) {
   258     while (height--) {
   259 #ifdef USE_DUFFS_LOOP
   259 #ifdef USE_DUFFS_LOOP
   260 		/* *INDENT-OFF* */
   260         /* *INDENT-OFF* */
   261 		DUFFS_LOOP(
   261         DUFFS_LOOP(
   262 			*dst++ = map[*src++];
   262             *dst++ = map[*src++];
   263 		, width);
   263         , width);
   264 		/* *INDENT-ON* */
   264         /* *INDENT-ON* */
   265 #else
   265 #else
   266         for (c = width / 4; c; --c) {
   266         for (c = width / 4; c; --c) {
   267             *dst++ = map[*src++];
   267             *dst++ = map[*src++];
   268             *dst++ = map[*src++];
   268             *dst++ = map[*src++];
   269             *dst++ = map[*src++];
   269             *dst++ = map[*src++];
   295     Uint8 *palmap = info->table;
   295     Uint8 *palmap = info->table;
   296     Uint32 ckey = info->colorkey;
   296     Uint32 ckey = info->colorkey;
   297 
   297 
   298     if (palmap) {
   298     if (palmap) {
   299         while (height--) {
   299         while (height--) {
   300 			/* *INDENT-OFF* */
   300             /* *INDENT-OFF* */
   301 			DUFFS_LOOP(
   301             DUFFS_LOOP(
   302 			{
   302             {
   303 				if ( *src != ckey ) {
   303                 if ( *src != ckey ) {
   304 				  *dst = palmap[*src];
   304                   *dst = palmap[*src];
   305 				}
   305                 }
   306 				dst++;
   306                 dst++;
   307 				src++;
   307                 src++;
   308 			},
   308             },
   309 			width);
   309             width);
   310 			/* *INDENT-ON* */
   310             /* *INDENT-ON* */
   311             src += srcskip;
   311             src += srcskip;
   312             dst += dstskip;
   312             dst += dstskip;
   313         }
   313         }
   314     } else {
   314     } else {
   315         while (height--) {
   315         while (height--) {
   316 			/* *INDENT-OFF* */
   316             /* *INDENT-OFF* */
   317 			DUFFS_LOOP(
   317             DUFFS_LOOP(
   318 			{
   318             {
   319 				if ( *src != ckey ) {
   319                 if ( *src != ckey ) {
   320 				  *dst = *src;
   320                   *dst = *src;
   321 				}
   321                 }
   322 				dst++;
   322                 dst++;
   323 				src++;
   323                 src++;
   324 			},
   324             },
   325 			width);
   325             width);
   326 			/* *INDENT-ON* */
   326             /* *INDENT-ON* */
   327             src += srcskip;
   327             src += srcskip;
   328             dst += dstskip;
   328             dst += dstskip;
   329         }
   329         }
   330     }
   330     }
   331 }
   331 }
   344 
   344 
   345     /* Set up some basic variables */
   345     /* Set up some basic variables */
   346     dstskip /= 2;
   346     dstskip /= 2;
   347 
   347 
   348     while (height--) {
   348     while (height--) {
   349 		/* *INDENT-OFF* */
   349         /* *INDENT-OFF* */
   350 		DUFFS_LOOP(
   350         DUFFS_LOOP(
   351 		{
   351         {
   352 			if ( *src != ckey ) {
   352             if ( *src != ckey ) {
   353 				*dstp=palmap[*src];
   353                 *dstp=palmap[*src];
   354 			}
   354             }
   355 			src++;
   355             src++;
   356 			dstp++;
   356             dstp++;
   357 		},
   357         },
   358 		width);
   358         width);
   359 		/* *INDENT-ON* */
   359         /* *INDENT-ON* */
   360         src += srcskip;
   360         src += srcskip;
   361         dstp += dstskip;
   361         dstp += dstskip;
   362     }
   362     }
   363 }
   363 }
   364 
   364 
   374     Uint8 *palmap = info->table;
   374     Uint8 *palmap = info->table;
   375     Uint32 ckey = info->colorkey;
   375     Uint32 ckey = info->colorkey;
   376     int o;
   376     int o;
   377 
   377 
   378     while (height--) {
   378     while (height--) {
   379 		/* *INDENT-OFF* */
   379         /* *INDENT-OFF* */
   380 		DUFFS_LOOP(
   380         DUFFS_LOOP(
   381 		{
   381         {
   382 			if ( *src != ckey ) {
   382             if ( *src != ckey ) {
   383 				o = *src * 4;
   383                 o = *src * 4;
   384 				dst[0] = palmap[o++];
   384                 dst[0] = palmap[o++];
   385 				dst[1] = palmap[o++];
   385                 dst[1] = palmap[o++];
   386 				dst[2] = palmap[o++];
   386                 dst[2] = palmap[o++];
   387 			}
   387             }
   388 			src++;
   388             src++;
   389 			dst += 3;
   389             dst += 3;
   390 		},
   390         },
   391 		width);
   391         width);
   392 		/* *INDENT-ON* */
   392         /* *INDENT-ON* */
   393         src += srcskip;
   393         src += srcskip;
   394         dst += dstskip;
   394         dst += dstskip;
   395     }
   395     }
   396 }
   396 }
   397 
   397 
   409 
   409 
   410     /* Set up some basic variables */
   410     /* Set up some basic variables */
   411     dstskip /= 4;
   411     dstskip /= 4;
   412 
   412 
   413     while (height--) {
   413     while (height--) {
   414 		/* *INDENT-OFF* */
   414         /* *INDENT-OFF* */
   415 		DUFFS_LOOP(
   415         DUFFS_LOOP(
   416 		{
   416         {
   417 			if ( *src != ckey ) {
   417             if ( *src != ckey ) {
   418 				*dstp = palmap[*src];
   418                 *dstp = palmap[*src];
   419 			}
   419             }
   420 			src++;
   420             src++;
   421 			dstp++;
   421             dstp++;
   422 		},
   422         },
   423 		width);
   423         width);
   424 		/* *INDENT-ON* */
   424         /* *INDENT-ON* */
   425         src += srcskip;
   425         src += srcskip;
   426         dstp += dstskip;
   426         dstp += dstskip;
   427     }
   427     }
   428 }
   428 }
   429 
   429 
   487 
   487 
   488     /* Set up some basic variables */
   488     /* Set up some basic variables */
   489     dstbpp = dstfmt->BytesPerPixel;
   489     dstbpp = dstfmt->BytesPerPixel;
   490 
   490 
   491     while (height--) {
   491     while (height--) {
   492 		/* *INDENT-OFF* */
   492         /* *INDENT-OFF* */
   493 		DUFFS_LOOP(
   493         DUFFS_LOOP(
   494 		{
   494         {
   495 			if ( *src != ckey ) {
   495             if ( *src != ckey ) {
   496 				sR = srcpal[*src].r;
   496                 sR = srcpal[*src].r;
   497 				sG = srcpal[*src].g;
   497                 sG = srcpal[*src].g;
   498 				sB = srcpal[*src].b;
   498                 sB = srcpal[*src].b;
   499 				DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
   499                 DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
   500 				ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
   500                 ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
   501 			  	ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
   501                   ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
   502 			}
   502             }
   503 			src++;
   503             src++;
   504 			dst += dstbpp;
   504             dst += dstbpp;
   505 		},
   505         },
   506 		width);
   506         width);
   507 		/* *INDENT-ON* */
   507         /* *INDENT-ON* */
   508         src += srcskip;
   508         src += srcskip;
   509         dst += dstskip;
   509         dst += dstskip;
   510     }
   510     }
   511 }
   511 }
   512 
   512