ReactOS  0.4.14-dev-317-g96040ec
dib24bppc.c
Go to the documentation of this file.
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
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 }
LONG lDelta
Definition: winddi.h:1213
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:109
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
uint32_t ULONG_PTR
Definition: typedefs.h:63
long LONG
Definition: pedump.c:60
const GLubyte * c
Definition: glext.h:8905
GLenum const GLvoid * addr
Definition: glext.h:9621
unsigned int * PULONG
Definition: retypes.h:1
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1
BYTE * PBYTE
Definition: pedump.c:66
VOID DIB_24BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
Definition: dib24bppc.c:16
unsigned short * PUSHORT
Definition: retypes.h:2
PVOID pvScan0
Definition: winddi.h:1212