diff --git a/reactos/subsys/win32k/dib/dib.h b/reactos/subsys/win32k/dib/dib.h index 72bdff1373b..cdc032351b2 100644 --- a/reactos/subsys/win32k/dib/dib.h +++ b/reactos/subsys/win32k/dib/dib.h @@ -1,11 +1,21 @@ static unsigned char notmask[2] = { 0x0f, 0xf0 }; static unsigned char altnotmask[2] = { 0xf0, 0x0f }; +static unsigned char mask1Bpp[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; typedef VOID (*PFN_DIB_PutPixel)(PSURFOBJ, LONG, LONG, ULONG); typedef ULONG (*PFN_DIB_GetPixel)(PSURFOBJ, LONG, LONG); typedef VOID (*PFN_DIB_HLine) (PSURFOBJ, LONG, LONG, LONG, ULONG); typedef VOID (*PFN_DIB_VLine) (PSURFOBJ, LONG, LONG, LONG, ULONG); +PFN_DIB_PutPixel DIB_1BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c); +PFN_DIB_GetPixel DIB_1BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y); +PFN_DIB_HLine DIB_1BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c); +PFN_DIB_VLine DIB_1BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c); +BOOLEAN DIB_To_1BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, + SURFGDI *DestGDI, SURFGDI *SourceGDI, + PRECTL DestRect, POINTL *SourcePoint, + ULONG Delta, XLATEOBJ *ColorTranslation); + PFN_DIB_PutPixel DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c); PFN_DIB_GetPixel DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y); PFN_DIB_HLine DIB_4BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c); diff --git a/reactos/subsys/win32k/dib/dib1bpp.c b/reactos/subsys/win32k/dib/dib1bpp.c new file mode 100644 index 00000000000..eafc4e5347b --- /dev/null +++ b/reactos/subsys/win32k/dib/dib1bpp.c @@ -0,0 +1,122 @@ +#undef WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include +#include +#include "../eng/objects.h" +#include "dib.h" + +PFN_DIB_PutPixel DIB_1BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c) +{ + unsigned char *vp; + unsigned char mask; + PBYTE addr = SurfObj->pvBits; + + addr += y * SurfObj->lDelta + (x >> 3); + + if(c == 1) + { + *addr = (*addr | mask1Bpp[mod(x, 8)]); + } + else + { + *addr = (*addr ^ mask1Bpp[mod(x, 8)]); + } +} + +PFN_DIB_GetPixel DIB_1BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y) +{ + PBYTE addr = SurfObj->pvBits + y * SurfObj->lDelta + (x >> 3); + + if(*addr & mask1Bpp[mod(x, 8)]) return (PFN_DIB_GetPixel)(1); + return (PFN_DIB_GetPixel)(0); +} + +PFN_DIB_HLine DIB_1BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c) +{ + LONG cx = x1; + + while(cx <= x2) { + DIB_1BPP_PutPixel(SurfObj, cx, y, c); + } +} + +PFN_DIB_VLine DIB_1BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c) +{ + while(y1++ <= y2) { + DIB_1BPP_PutPixel(SurfObj, x, y1, c); + } +} + +BOOLEAN DIB_To_1BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, + SURFGDI *DestGDI, SURFGDI *SourceGDI, + PRECTL DestRect, POINTL *SourcePoint, + ULONG Delta, XLATEOBJ *ColorTranslation) +{ + ULONG i, j, sx, sy = SourcePoint->y; + + switch(SourceGDI->BitsPerPixel) + { + case 1: + for (j=DestRect->top; jbottom; j++) + { + sx = SourcePoint->x; + for (i=DestRect->left; iright; i++) + { + if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0) + { + DIB_1BPP_PutPixel(DestSurf, i, j, 0); + } else { + DIB_1BPP_PutPixel(DestSurf, i, j, 1); + } + sx++; + } + sy++; + } + break; + + case 4: + for (j=DestRect->top; jbottom; j++) + { + sx = SourcePoint->x; + for (i=DestRect->left; iright; i++) + { + if(XLATEOBJ_iXlate(ColorTranslation, DIB_4BPP_GetPixel(SourceSurf, sx, sy)) == 0) + { + DIB_1BPP_PutPixel(DestSurf, i, j, 0); + } else { + DIB_1BPP_PutPixel(DestSurf, i, j, 1); + } + sx++; + } + sy++; + } + break; + + case 24: + for (j=DestRect->top; jbottom; j++) + { + sx = SourcePoint->x; + for (i=DestRect->left; iright; i++) + { + if(XLATEOBJ_iXlate(ColorTranslation, DIB_24BPP_GetPixel(SourceSurf, sx, sy)) == 0) + { + DIB_1BPP_PutPixel(DestSurf, i, j, 0); + } else { + DIB_1BPP_PutPixel(DestSurf, i, j, 1); + } + sx++; + } + sy++; + } + break; + + default: + DbgPrint("DIB_1BPP_Bitblt: Unhandled Source BPP: %u\n", SourceGDI->BitsPerPixel); + return FALSE; + } + + return TRUE; +} diff --git a/reactos/subsys/win32k/dib/dib24bpp.c b/reactos/subsys/win32k/dib/dib24bpp.c index e4f6ec1163a..f5bab13bbbb 100644 --- a/reactos/subsys/win32k/dib/dib24bpp.c +++ b/reactos/subsys/win32k/dib/dib24bpp.c @@ -88,7 +88,7 @@ BOOLEAN DIB_To_24BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, PRECTL DestRect, POINTL *SourcePoint, ULONG Delta, XLATEOBJ *ColorTranslation) { - ULONG i, j, sx, xColor, f1; + ULONG i, j, sx, sy, xColor, f1; PBYTE DestBits, SourceBits_24BPP, DestLine, SourceLine_24BPP; PRGBTRIPLE SPDestBits, SPSourceBits_24BPP, SPDestLine, SPSourceLine_24BPP; // specially for 24-to-24 blit PBYTE SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP; @@ -99,6 +99,27 @@ BOOLEAN DIB_To_24BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, switch(SourceGDI->BitsPerPixel) { + case 1: + sx = SourcePoint->x; + sy = SourcePoint->y; + + for (j=DestRect->top; jbottom; j++) + { + sx = SourcePoint->x; + for (i=DestRect->left; iright; i++) + { + if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0) + { + DIB_24BPP_PutPixel(DestSurf, i, j, XLATEOBJ_iXlate(ColorTranslation, 0)); + } else { + DIB_24BPP_PutPixel(DestSurf, i, j, XLATEOBJ_iXlate(ColorTranslation, 1)); + } + sx++; + } + sy++; + } + break; + case 4: SourceBits_4BPP = SourceSurf->pvBits + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x; diff --git a/reactos/subsys/win32k/dib/dib4bpp.c b/reactos/subsys/win32k/dib/dib4bpp.c index 7b5f707e8a3..dc38a2f74d2 100644 --- a/reactos/subsys/win32k/dib/dib4bpp.c +++ b/reactos/subsys/win32k/dib/dib4bpp.c @@ -55,7 +55,7 @@ BOOLEAN DIB_To_4BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, PRECTL DestRect, POINTL *SourcePoint, ULONG Delta, XLATEOBJ *ColorTranslation) { - ULONG i, j, sx, f1, f2, xColor; + ULONG i, j, sx, sy, f1, f2, xColor; PBYTE SourceBits_24BPP, SourceLine_24BPP; PBYTE DestBits, DestLine, SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP; PWORD SourceBits_16BPP, SourceLine_16BPP; @@ -65,6 +65,27 @@ BOOLEAN DIB_To_4BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf, switch(SourceGDI->BitsPerPixel) { + case 1: + sx = SourcePoint->x; + sy = SourcePoint->y; + + for (j=DestRect->top; jbottom; j++) + { + sx = SourcePoint->x; + for (i=DestRect->left; iright; i++) + { + if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0) + { + DIB_4BPP_PutPixel(DestSurf, i, j, XLATEOBJ_iXlate(ColorTranslation, 0)); + } else { + DIB_4BPP_PutPixel(DestSurf, i, j, XLATEOBJ_iXlate(ColorTranslation, 1)); + } + sx++; + } + sy++; + } + break; + case 4: SourceBits_4BPP = SourceSurf->pvBits + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x; diff --git a/reactos/subsys/win32k/makefile b/reactos/subsys/win32k/makefile index 58f319873ed..ad4fa09584c 100644 --- a/reactos/subsys/win32k/makefile +++ b/reactos/subsys/win32k/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.51 2002/09/08 10:23:48 chorns Exp $ +# $Id: makefile,v 1.52 2002/09/13 20:36:05 jfilby Exp $ PATH_TO_TOP = ../.. @@ -40,7 +40,7 @@ OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \ objects/region.o objects/text.o objects/wingl.o \ objects/bezier.o objects/objconv.o objects/dib.o \ objects/palette.o objects/rect.o -DIB_OBJECTS = dib/dib4bpp.o dib/dib24bpp.o +DIB_OBJECTS = dib/dib1bpp.o dib/dib4bpp.o dib/dib24bpp.o FREETYPE_OBJECTS = freetype/ctype.o freetype/grfont.o \ freetype/src/base/ftsystem.o freetype/src/base/ftdebug.o \ freetype/src/base/ftinit.o freetype/src/base/ftbase.o \ diff --git a/reactos/subsys/win32k/misc/math.c b/reactos/subsys/win32k/misc/math.c index e5e6f0b015f..ca4c6595c43 100644 --- a/reactos/subsys/win32k/misc/math.c +++ b/reactos/subsys/win32k/misc/math.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include +#include double atan (double __x); double atan2 (double __y, double __x); @@ -33,7 +34,8 @@ double pow (double __x, double __y); double sin (double __x); double sqrt (double __x); double tan (double __x); - +div_t div(int num, int denom); +int mod(int num, int denom); double atan (double __x) { @@ -209,6 +211,32 @@ double tan (double __x) return __value; } +div_t div(int num, int denom) +{ + div_t r; + if (num > 0 && denom < 0) { + num = -num; + denom = -denom; + } + r.quot = num / denom; + r.rem = num % denom; + if (num < 0 && denom > 0) + { + if (r.rem > 0) + { + r.quot++; + r.rem -= denom; + } + } + return r; +} + +int mod(int num, int denom) +{ + div_t dvt = div(num, denom); + return dvt.rem; +} + //FIXME! Is there a better algorithm. like FT_MulDiv INT STDCALL EngMulDiv( INT nMultiplicand,