src/blitter/32bpp_base.hpp
changeset 11163 7034daa18792
parent 11083 19aff1f3244e
equal deleted inserted replaced
11162:37d01497c935 11163:7034daa18792
    52 		uint cg = GB(current, 8,  8);
    52 		uint cg = GB(current, 8,  8);
    53 		uint cb = GB(current, 0,  8);
    53 		uint cb = GB(current, 0,  8);
    54 
    54 
    55 		/* The 256 is wrong, it should be 255, but 256 is much faster... */
    55 		/* The 256 is wrong, it should be 255, but 256 is much faster... */
    56 		return ComposeColour(0xFF,
    56 		return ComposeColour(0xFF,
    57 							(r * a + cr * (256 - a)) / 256,
    57 							((int)(r - cr) * a) / 256 + cr,
    58 							(g * a + cg * (256 - a)) / 256,
    58 							((int)(g - cg) * a) / 256 + cg,
    59 							(b * a + cb * (256 - a)) / 256);
    59 							((int)(b - cb) * a) / 256 + cb);
    60 	}
    60 	}
    61 
    61 
    62 	/**
    62 	/**
    63 	 * Compose a colour based on RGBA values and the current pixel value.
    63 	 * Compose a colour based on RGBA values and the current pixel value.
    64 	 * Handles fully transparent and solid pixels in a special (faster) way.
    64 	 * Handles fully transparent and solid pixels in a special (faster) way.
    77 	static inline uint32 ComposeColourPANoCheck(uint32 colour, uint a, uint32 current)
    77 	static inline uint32 ComposeColourPANoCheck(uint32 colour, uint a, uint32 current)
    78 	{
    78 	{
    79 		uint r  = GB(colour,  16, 8);
    79 		uint r  = GB(colour,  16, 8);
    80 		uint g  = GB(colour,  8,  8);
    80 		uint g  = GB(colour,  8,  8);
    81 		uint b  = GB(colour,  0,  8);
    81 		uint b  = GB(colour,  0,  8);
    82 		uint cr = GB(current, 16, 8);
       
    83 		uint cg = GB(current, 8,  8);
       
    84 		uint cb = GB(current, 0,  8);
       
    85 
    82 
    86 		/* The 256 is wrong, it should be 255, but 256 is much faster... */
    83 		return ComposeColourRGBANoCheck(r, g, b, a, current);
    87 		return ComposeColour(0xFF,
       
    88 							(r * a + cr * (256 - a)) / 256,
       
    89 							(g * a + cg * (256 - a)) / 256,
       
    90 							(b * a + cb * (256 - a)) / 256);
       
    91 	}
    84 	}
    92 
    85 
    93 	/**
    86 	/**
    94 	 * Compose a colour based on Pixel value, alpha value, and the current pixel value.
    87 	 * Compose a colour based on Pixel value, alpha value, and the current pixel value.
    95 	 * Handles fully transparent and solid pixels in a special (faster) way.
    88 	 * Handles fully transparent and solid pixels in a special (faster) way.