2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #undef WIN32_LEAN_AND_MEAN
23 #include <win32k/bitmaps.h>
24 #include <win32k/debug.h>
26 #include <ddk/winddi.h>
27 #include "../eng/objects.h"
31 DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
33 PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
34 PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
40 DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
42 PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
43 PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
45 return *(PULONG)(addr) & 0x00ffffff;
49 DIB_24BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
51 PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
52 PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x1;
63 DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
65 PBYTE byteaddr = SurfObj->pvScan0 + y1 * SurfObj->lDelta;
66 PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
67 LONG lDelta = SurfObj->lDelta;
69 byteaddr = (PBYTE)addr;
74 addr = (PRGBTRIPLE)byteaddr;
79 DIB_24BPP_BitBltSrcCopy( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
80 SURFGDI *DestGDI, SURFGDI *SourceGDI,
81 PRECTL DestRect, POINTL *SourcePoint,
82 XLATEOBJ *ColorTranslation)
84 LONG i, j, sx, sy, xColor, f1;
85 PBYTE SourceBits, DestBits, SourceLine, DestLine;
86 PBYTE SourceBits_4BPP, SourceLine_4BPP;
87 PWORD SourceBits_16BPP, SourceLine_16BPP;
89 DestBits = DestSurf->pvScan0 + (DestRect->top * DestSurf->lDelta) + DestRect->left * 3;
91 switch(SourceGDI->BitsPerPixel)
97 for (j=DestRect->top; j<DestRect->bottom; j++)
100 for (i=DestRect->left; i<DestRect->right; i++)
102 if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
104 DIB_24BPP_PutPixel(DestSurf, i, j, XLATEOBJ_iXlate(ColorTranslation, 0));
106 DIB_24BPP_PutPixel(DestSurf, i, j, XLATEOBJ_iXlate(ColorTranslation, 1));
115 SourceBits_4BPP = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + (SourcePoint->x >> 1);
117 for (j=DestRect->top; j<DestRect->bottom; j++)
119 SourceLine_4BPP = SourceBits_4BPP;
124 for (i=DestRect->left; i<DestRect->right; i++)
126 xColor = XLATEOBJ_iXlate(ColorTranslation,
127 (*SourceLine_4BPP & altnotmask[sx&1]) >> (4 * (1-(sx & 1))));
128 *DestLine++ = xColor & 0xff;
129 *(PWORD)DestLine = xColor >> 8;
131 if(f1 == 1) { SourceLine_4BPP++; f1 = 0; } else { f1 = 1; }
135 SourceBits_4BPP += SourceSurf->lDelta;
136 DestBits += DestSurf->lDelta;
141 SourceLine = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x;
144 for (j = DestRect->top; j < DestRect->bottom; j++)
146 SourceBits = SourceLine;
149 for (i = DestRect->left; i < DestRect->right; i++)
151 xColor = XLATEOBJ_iXlate(ColorTranslation, *SourceBits);
152 *DestBits = xColor & 0xff;
153 *(PWORD)(DestBits + 1) = xColor >> 8;
158 SourceLine += SourceSurf->lDelta;
159 DestLine += DestSurf->lDelta;
164 SourceBits_16BPP = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 2 * SourcePoint->x;
166 for (j=DestRect->top; j<DestRect->bottom; j++)
168 SourceLine_16BPP = SourceBits_16BPP;
171 for (i=DestRect->left; i<DestRect->right; i++)
173 xColor = XLATEOBJ_iXlate(ColorTranslation, *SourceLine_16BPP);
174 *DestLine++ = xColor & 0xff;
175 *(PWORD)DestLine = xColor >> 8;
180 SourceBits_16BPP = (PWORD)((PBYTE)SourceBits_16BPP + SourceSurf->lDelta);
181 DestBits += DestSurf->lDelta;
186 if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
188 if (DestRect->top < SourcePoint->y)
190 SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 3 * SourcePoint->x;
191 for (j = DestRect->top; j < DestRect->bottom; j++)
193 RtlMoveMemory(DestBits, SourceBits, 3 * (DestRect->right - DestRect->left));
194 SourceBits += SourceSurf->lDelta;
195 DestBits += DestSurf->lDelta;
200 SourceBits = SourceSurf->pvScan0 + ((SourcePoint->y + DestRect->bottom - DestRect->top - 1) * SourceSurf->lDelta) + 3 * SourcePoint->x;
201 DestBits = DestSurf->pvScan0 + ((DestRect->bottom - 1) * DestSurf->lDelta) + 3 * DestRect->left;
202 for (j = DestRect->bottom - 1; DestRect->top <= j; j--)
204 RtlMoveMemory(DestBits, SourceBits, 3 * (DestRect->right - DestRect->left));
205 SourceBits -= SourceSurf->lDelta;
206 DestBits -= DestSurf->lDelta;
213 DPRINT1("DIB_24BPP_Bitblt: Unhandled ColorTranslation for 16 -> 16 copy");
219 SourceLine = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 4 * SourcePoint->x;
222 for (j = DestRect->top; j < DestRect->bottom; j++)
224 SourceBits = SourceLine;
227 for (i = DestRect->left; i < DestRect->right; i++)
229 xColor = XLATEOBJ_iXlate(ColorTranslation, *((PDWORD) SourceBits));
230 *DestBits = xColor & 0xff;
231 *(PWORD)(DestBits + 1) = xColor >> 8;
236 SourceLine += SourceSurf->lDelta;
237 DestLine += DestSurf->lDelta;
242 DbgPrint("DIB_24BPP_Bitblt: Unhandled Source BPP: %u\n", SourceGDI->BitsPerPixel);
250 DIB_24BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
251 SURFGDI *DestGDI, SURFGDI *SourceGDI,
252 PRECTL DestRect, POINTL *SourcePoint,
253 PBRUSHOBJ Brush, PPOINTL BrushOrigin,
254 XLATEOBJ *ColorTranslation, ULONG Rop4)
256 LONG i, j, k, sx, sy;
257 ULONG Dest, Source, Pattern;
259 BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
260 BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);
264 return(DIB_24BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
270 for (j = DestRect->top; j < DestRect->bottom; j++)
273 DestBits = (PULONG)(DestSurf->pvScan0 + 3 * DestRect->left + j * DestSurf->lDelta);
274 for (i=DestRect->left; i<DestRect->right; i++, DestBits++)
276 Dest = *DestBits & 0x00ffffff;
279 Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) & 0x00ffffff;
283 /* FIXME: No support for pattern brushes. */
284 Pattern = Brush->iSolidColor;
286 Dest = DIB_DoRop(Rop4, Dest, Source, Pattern);
287 *(PBYTE)DestBits = Dest & 0xff;
288 *(PWORD)(DestBits + 1) = Dest >> 8;