1 2 #ifdef _MSC_VER 3 #pragma warning(disable:4711) 4 #endif 5 6 #define FASTCALL __fastcall 7 8 #include <stdarg.h> 9 #include <windef.h> 10 #include <wingdi.h> 11 #include <winddi.h> 12 13 #ifdef _OPTIMIZE_DIBLIB 14 #ifdef _MSC_VER 15 #pragma optimize("g", on) 16 #else 17 #pragma GCC optimize("O3") 18 #endif 19 #endif 20 21 typedef 22 ULONG 23 (FASTCALL *PFN_XLATE)(XLATEOBJ* pxlo, ULONG ulColor); 24 25 extern const BYTE ajShift4[2]; 26 27 #include "DibLib_interface.h" 28 29 #define _DibXlate(pBltData, ulColor) (pBltData->pfnXlate(pBltData->pxlo, ulColor)) 30 31 #define __PASTE_(s1,s2) s1##s2 32 #define __PASTE(s1,s2) __PASTE_(s1,s2) 33 34 #define __DIB_FUNCTION_NAME_SRCDST2(name, src_bpp, dst_bpp) Dib_ ## name ## _S ## src_bpp ## _D ## dst_bpp 35 #define __DIB_FUNCTION_NAME_SRCDST(name, src_bpp, dst_bpp) __DIB_FUNCTION_NAME_SRCDST2(name, src_bpp, dst_bpp) 36 37 #define __DIB_FUNCTION_NAME_DST2(name, dst_bpp) Dib_ ## name ## _D ## dst_bpp 38 #define __DIB_FUNCTION_NAME_DST(name, src_bpp, dst_bpp) __DIB_FUNCTION_NAME_DST2(name, dst_bpp) 39 #define __DIB_FUNCTION_NAME_SRCDSTEQ(name, src_bpp, dst_bpp) __PASTE(__DIB_FUNCTION_NAME_SRCDST2(name, src_bpp, dst_bpp), _EqSurf) 40 #define __DIB_FUNCTION_NAME_SRCDSTEQL2R(name, src_bpp, dst_bpp) __PASTE(__DIB_FUNCTION_NAME_SRCDST2(name, src_bpp, dst_bpp), _EqSurfL2R) 41 #define __DIB_FUNCTION_NAME_SRCDSTEQR2L(name, src_bpp, dst_bpp) __PASTE(__DIB_FUNCTION_NAME_SRCDST2(name, src_bpp, dst_bpp), _EqSurfR2L) 42 43 #define _ReadPixel_1(pjSource, jShift) (((*(pjSource)) >> (jShift)) & 1) 44 #define _WritePixel_1(pjDest, jShift, ulColor) (void)(*(pjDest) = (UCHAR)((*(pjDest) & ~(1<<(jShift))) | ((ulColor)<<(jShift)))) 45 #define _NextPixel_1(ppj, pjShift) (void)(((*(pjShift))--), (*(pjShift) &= 7), (*(ppj) += (*(pjShift) == 7))) 46 #define _NextPixelR2L_1(ppj, pjShift) (void)(((*(pjShift))++), (*(pjShift) &= 7), (*(ppj) -= (*(pjShift) == 0))) 47 #define _SHIFT_1(x) x 48 #define _CALCSHIFT_1(pShift, x) (void)(*(pShift) = (7 - ((x) & 7))) 49 50 #define _ReadPixel_4(pjSource, jShift) (((*(pjSource)) >> (jShift)) & 15) 51 #define _WritePixel_4(pjDest, jShift, ulColor) (void)(*(pjDest) = (UCHAR)((*(pjDest) & ~(15<<(jShift))) | ((ulColor)<<(jShift)))) 52 #define _NextPixel_4(ppj, pjShift) (void)((*(ppj) += (*(pjShift) & 1)), (*(pjShift)) -= 4, *(pjShift) &= 7) 53 #define _NextPixelR2L_4(ppj, pjShift) (void)((*(pjShift)) -= 4, *(pjShift) &= 7, (*(ppj) -= (*(pjShift) & 1))) 54 #define _SHIFT_4(x) x 55 #define _CALCSHIFT_4(pShift, x) (void)(*(pShift) = ajShift4[(x) & 1]) 56 57 #define _ReadPixel_8(pjSource, x) (*(UCHAR*)(pjSource)) 58 #define _WritePixel_8(pjDest, x, ulColor) (void)(*(UCHAR*)(pjDest) = (UCHAR)(ulColor)) 59 #define _NextPixel_8(ppj, pjShift) (void)(*(ppj) += 1) 60 #define _NextPixelR2L_8(ppj, pjShift) (void)(*(ppj) -= 1) 61 #define _SHIFT_8(x) 62 #define _CALCSHIFT_8(pShift, x) 63 64 #define _ReadPixel_16(pjSource, x) (*(USHORT*)(pjSource)) 65 #define _WritePixel_16(pjDest, x, ulColor) (void)(*(USHORT*)(pjDest) = (USHORT)(ulColor)) 66 #define _NextPixel_16(ppj, pjShift) (void)(*(ppj) += 2) 67 #define _NextPixelR2L_16(ppj, pjShift) (void)(*(ppj) -= 2) 68 #define _SHIFT_16(x) 69 #define _CALCSHIFT_16(pShift, x) 70 71 #define _ReadPixel_24(pjSource, x) ((pjSource)[0] | ((pjSource)[1] << 8) | ((pjSource)[2] << 16)) 72 #define _WritePixel_24(pjDest, x, ulColor) (void)(((pjDest)[0] = ((ulColor)&0xFF)),((pjDest)[1] = (((ulColor)>>8)&0xFF)),((pjDest)[2] = (((ulColor)>>16)&0xFF))) 73 #define _NextPixel_24(ppj, pjShift) (void)(*(ppj) += 3) 74 #define _NextPixelR2L_24(ppj, pjShift) (void)(*(ppj) -= 3) 75 #define _SHIFT_24(x) 76 #define _CALCSHIFT_24(pShift, x) 77 78 #define _ReadPixel_32(pjSource, x) (*(ULONG*)(pjSource)) 79 #define _WritePixel_32(pjDest, x, ulColor) (void)(*(ULONG*)(pjDest) = (ulColor)) 80 #define _NextPixel_32(ppj, pjShift) (void)(*(ppj) += 4) 81 #define _NextPixelR2L_32(ppj, pjShift) (void)(*(ppj) -= 4) 82 #define _SHIFT_32(x) 83 #define _CALCSHIFT_32(pShift, x) 84 85