1 /* 2 * PROJECT: Win32 subsystem 3 * LICENSE: See COPYING in the top level directory 4 * FILE: win32ss/gdi/dib/dib24bppc.c 5 * PURPOSE: C language equivalents of asm optimised 24bpp functions 6 * PROGRAMMERS: Jason Filby 7 * Magnus Olsen 8 */ 9 10 #include <win32k.h> 11 12 #define NDEBUG 13 #include <debug.h> 14 15 VOID 16 DIB_24BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c) 17 { 18 PBYTE addr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta + (x1 << 1) + x1; 19 ULONG Count = x2 - x1; 20 21 if (Count < 8) 22 { 23 /* For small fills, don't bother doing anything fancy */ 24 while (Count--) 25 { 26 *(PUSHORT)(addr) = c; 27 addr += 2; 28 *(addr) = c >> 16; 29 addr += 1; 30 } 31 } 32 else 33 { 34 ULONG Fill[3]; 35 ULONG MultiCount; 36 37 /* Align to 4-byte address */ 38 while (0 != ((ULONG_PTR) addr & 0x3)) 39 { 40 *(PUSHORT)(addr) = c; 41 addr += 2; 42 *(addr) = c >> 16; 43 addr += 1; 44 Count--; 45 } 46 /* If the color we need to fill with is 0ABC, then the final mem pattern 47 * (note little-endianness) would be: 48 * 49 * |C.B.A|C.B.A|C.B.A|C.B.A| <- pixel borders 50 * |C.B.A.C|B.A.C.B|A.C.B.A| <- ULONG borders 51 * 52 * So, taking endianness into account again, we need to fill with these 53 * ULONGs: CABC BCAB ABCA */ 54 55 c = c & 0xffffff; /* 0ABC */ 56 Fill[0] = c | (c << 24); /* CABC */ 57 Fill[1] = (c >> 8) | (c << 16); /* BCAB */ 58 Fill[2] = (c << 8) | (c >> 16); /* ABCA */ 59 MultiCount = Count / 4; 60 do 61 { 62 *(PULONG)addr = Fill[0]; 63 addr += 4; 64 *(PULONG)addr = Fill[1]; 65 addr += 4; 66 *(PULONG)addr = Fill[2]; 67 addr += 4; 68 } 69 while (0 != --MultiCount); 70 71 Count = Count & 0x03; 72 while (0 != Count--) 73 { 74 *(PUSHORT)(addr) = c; 75 addr += 2; 76 *(addr) = c >> 16; 77 addr += 1; 78 } 79 } 80 } 81