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.
21 #undef WIN32_LEAN_AND_MEAN
24 #include <win32k/bitmaps.h>
25 #include <win32k/debug.h>
27 #include <ddk/winddi.h>
28 #include "../eng/objects.h"
32 DIB_1BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
34 PBYTE addr = SurfObj->pvScan0;
36 addr += y * SurfObj->lDelta + (x >> 3);
40 *addr = (*addr ^ mask1Bpp[x % 8]);
44 *addr = (*addr | mask1Bpp[x % 8]);
49 DIB_1BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
51 PBYTE addr = SurfObj->pvScan0 + y * SurfObj->lDelta + (x >> 3);
53 return (*addr & mask1Bpp[x % 8] ? 1 : 0);
57 DIB_1BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
60 DIB_1BPP_PutPixel(SurfObj, x1, y, c);
66 DIB_1BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
69 DIB_1BPP_PutPixel(SurfObj, x, y1, c);
75 DIB_1BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
76 SURFGDI *DestGDI, SURFGDI *SourceGDI,
77 PRECTL DestRect, POINTL *SourcePoint,
78 XLATEOBJ *ColorTranslation)
80 LONG i, j, sx, sy = SourcePoint->y;
82 switch(SourceGDI->BitsPerPixel)
85 if (DestRect->top < SourcePoint->y)
87 for (j = DestRect->top; j < DestRect->bottom; j++)
89 if (DestRect->left < SourcePoint->x)
92 for (i=DestRect->left; i<DestRect->right; i++)
94 if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
96 DIB_1BPP_PutPixel(DestSurf, i, j, 0);
100 DIB_1BPP_PutPixel(DestSurf, i, j, 1);
107 sx = SourcePoint->x + DestRect->right - DestRect->left - 1;
108 for (i = DestRect->right - 1; DestRect->left <= i; i--)
110 if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
112 DIB_1BPP_PutPixel(DestSurf, i, j, 0);
116 DIB_1BPP_PutPixel(DestSurf, i, j, 1);
126 sy = SourcePoint->y + DestRect->bottom - DestRect->top - 1;
127 for (j = DestRect->bottom - 1; DestRect->top <= j; j--)
129 if (DestRect->left < SourcePoint->x)
132 for (i=DestRect->left; i<DestRect->right; i++)
134 if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
136 DIB_1BPP_PutPixel(DestSurf, i, j, 0);
140 DIB_1BPP_PutPixel(DestSurf, i, j, 1);
147 sx = SourcePoint->x + DestRect->right - DestRect->left - 1;
148 for (i = DestRect->right - 1; DestRect->left <= i; i--)
150 if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
152 DIB_1BPP_PutPixel(DestSurf, i, j, 0);
156 DIB_1BPP_PutPixel(DestSurf, i, j, 1);
167 for (j=DestRect->top; j<DestRect->bottom; j++)
170 for (i=DestRect->left; i<DestRect->right; i++)
172 if(XLATEOBJ_iXlate(ColorTranslation, DIB_4BPP_GetPixel(SourceSurf, sx, sy)) == 0)
174 DIB_1BPP_PutPixel(DestSurf, i, j, 0);
176 DIB_1BPP_PutPixel(DestSurf, i, j, 1);
185 for (j=DestRect->top; j<DestRect->bottom; j++)
188 for (i=DestRect->left; i<DestRect->right; i++)
190 if(XLATEOBJ_iXlate(ColorTranslation, DIB_8BPP_GetPixel(SourceSurf, sx, sy)) == 0)
192 DIB_1BPP_PutPixel(DestSurf, i, j, 0);
194 DIB_1BPP_PutPixel(DestSurf, i, j, 1);
203 for (j=DestRect->top; j<DestRect->bottom; j++)
206 for (i=DestRect->left; i<DestRect->right; i++)
208 if(XLATEOBJ_iXlate(ColorTranslation, DIB_16BPP_GetPixel(SourceSurf, sx, sy)) == 0)
210 DIB_1BPP_PutPixel(DestSurf, i, j, 0);
212 DIB_1BPP_PutPixel(DestSurf, i, j, 1);
221 for (j=DestRect->top; j<DestRect->bottom; j++)
224 for (i=DestRect->left; i<DestRect->right; i++)
226 if(XLATEOBJ_iXlate(ColorTranslation, DIB_24BPP_GetPixel(SourceSurf, sx, sy)) == 0)
228 DIB_1BPP_PutPixel(DestSurf, i, j, 0);
230 DIB_1BPP_PutPixel(DestSurf, i, j, 1);
239 for (j=DestRect->top; j<DestRect->bottom; j++)
242 for (i=DestRect->left; i<DestRect->right; i++)
244 if(XLATEOBJ_iXlate(ColorTranslation, DIB_32BPP_GetPixel(SourceSurf, sx, sy)) == 0)
246 DIB_1BPP_PutPixel(DestSurf, i, j, 0);
248 DIB_1BPP_PutPixel(DestSurf, i, j, 1);
257 DbgPrint("DIB_1BPP_Bitblt: Unhandled Source BPP: %u\n", SourceGDI->BitsPerPixel);
265 DIB_1BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
266 SURFGDI *DestGDI, SURFGDI *SourceGDI,
267 PRECTL DestRect, POINTL *SourcePoint,
268 PBRUSHOBJ Brush, PPOINTL BrushOrigin,
269 XLATEOBJ *ColorTranslation, ULONG Rop4)
271 LONG i, j, k, sx, sy;
272 ULONG Dest, Source, Pattern;
274 BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
275 BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);
276 LONG RoundedRight = DestRect->right - (DestRect->right & 0x7);
280 return(DIB_1BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
286 for (j=DestRect->top; j<DestRect->bottom; j++)
289 DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left>>3) + j * DestSurf->lDelta);
290 for (i=DestRect->left; i<RoundedRight; i+=32, DestBits++)
296 for (k = 0; k < 32; k++)
298 Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << k);
303 /* FIXME: No support for pattern brushes. */
304 Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
306 *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);
308 if (i < DestRect->right)
311 for (; i < DestRect->right; i++)
315 Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation);
319 /* FIXME: No support for pattern brushes. */
320 Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
322 DIB_1BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);