diff --git a/reactos/include/win32k/brush.h b/reactos/include/win32k/brush.h index 5e419e507e2..f7500dc389b 100644 --- a/reactos/include/win32k/brush.h +++ b/reactos/include/win32k/brush.h @@ -3,90 +3,136 @@ #include -/* Internal interface */ +/* Internal interface */ #define NB_HATCH_STYLES 6 -#define BRUSHOBJ_AllocBrush() \ - ((HBRUSH) GDIOBJ_AllocObj (sizeof (BRUSHOBJ), GDI_OBJECT_TYPE_BRUSH, NULL)) -#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH, GDIOBJFLAG_DEFAULT) -#define BRUSHOBJ_LockBrush(hBrush) ((PBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)) +/* + * The layout of this structure is taken from "Windows Graphics Programming" + * book written by Feng Yuan. + * + * DON'T MODIFY THIS STRUCTURE UNLESS REALLY NEEDED AND EVEN THEN ASK ON + * A MAILING LIST FIRST. + */ + +typedef struct +{ + ULONG AttrFlags; + COLORREF lbColor; +} BRUSHATTR, *PBRUSHATTR; + +typedef struct +{ + ULONG ulStyle; + HBITMAP hbmPattern; + HANDLE hbmClient; + ULONG flAttrs; + + ULONG ulBrushUnique; + BRUSHATTR *pBrushAttr; + BRUSHATTR BrushAttr; + ULONG Unknown30; + ULONG bCacheGrabbed; + COLORREF crBack; + COLORREF crFore; + ULONG ulPalTime; +#if 0 + ULONG ulSurfTime; + PVOID ulRealization; + ULONG Unknown4C[3]; +#else + BRUSHOBJ BrushObject; + ULONG Unknown50[2]; +#endif + POINT ptPenWidth; + ULONG ulPenStyle; + DWORD *pStyle; + ULONG dwStyleCount; + ULONG Unknown6C; +} GDIBRUSHOBJ, *PGDIBRUSHOBJ; + +/* GDI Brush Attributes */ + +#define GDIBRUSH_NEED_BK_CLR 0x0002 /* Background color is needed */ +#define GDIBRUSH_DITHER_OK 0x0004 /* Allow color dithering */ +#define GDIBRUSH_IS_SOLID 0x0010 /* Solid brush */ +#define GDIBRUSH_IS_HATCH 0x0020 /* Hatch brush */ +#define GDIBRUSH_IS_BITMAP 0x0040 /* DDB pattern brush */ +#define GDIBRUSH_IS_DIB 0x0080 /* DIB pattern brush */ +#define GDIBRUSH_IS_NULL 0x0100 /* Null/hollow brush */ +#define GDIBRUSH_IS_GLOBAL 0x0200 /* Stock objects */ +#define GDIBRUSH_IS_PEN 0x0400 /* Pen */ +#define GDIBRUSH_IS_OLDSTYLEPEN 0x0800 /* Geometric pen */ +#define GDIBRUSH_IS_MASKING 0x8000 /* Pattern bitmap is used as transparent mask (?) */ +#define GDIBRUSH_CACHED_IS_SOLID 0x80000000 + +#define BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (sizeof(GDIBRUSHOBJ), GDI_OBJECT_TYPE_BRUSH, NULL)) +#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH, GDIOBJFLAG_DEFAULT) +#define BRUSHOBJ_LockBrush(hBrush) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)) #define BRUSHOBJ_UnlockBrush(hBrush) GDIOBJ_UnlockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH) -HBRUSH -STDCALL -NtGdiCreateBrushIndirect ( - CONST LOGBRUSH * lb - ); -HBRUSH -STDCALL -NtGdiCreateDIBPatternBrush ( - HGLOBAL hDIBPacked, - UINT ColorSpec - ); -HBRUSH -STDCALL -NtGdiCreateDIBPatternBrushPt ( - CONST VOID * PackedDIB, - UINT Usage - ); -HBRUSH -STDCALL -NtGdiCreateHatchBrush ( - INT Style, - COLORREF Color - ); -HBRUSH -STDCALL -NtGdiCreatePatternBrush ( - HBITMAP hBitmap - ); -HBRUSH -STDCALL -NtGdiCreateSolidBrush ( - COLORREF Color - ); -BOOL -STDCALL -NtGdiFixBrushOrgEx ( - VOID - ); -BOOL -STDCALL -NtGdiPatBlt ( - HDC hDC, - INT XLeft, - INT YLeft, - INT Width, - INT Height, - DWORD ROP - ); -BOOL -STDCALL -NtGdiPolyPatBlt( - HDC hDC, - DWORD dwRop, - PPATRECT pRects, - int cRects, - ULONG Reserved - ); -BOOL -STDCALL -NtGdiPatBlt ( - HDC hDC, - INT XLeft, - INT YLeft, - INT Width, - INT Height, - DWORD ROP - ); -BOOL -STDCALL -NtGdiSetBrushOrgEx ( - HDC hDC, - INT XOrg, - INT YOrg, - LPPOINT Point - ); -#endif +HBRUSH STDCALL +NtGdiCreateBrushIndirect( + CONST LOGBRUSH *LogBrush); +HBRUSH STDCALL +NtGdiCreateDIBPatternBrush( + HGLOBAL hDIBPacked, + UINT ColorSpec); + +HBRUSH STDCALL +NtGdiCreateDIBPatternBrushPt( + CONST VOID *PackedDIB, + UINT Usage); + +HBRUSH STDCALL +NtGdiCreateHatchBrush( + INT Style, + COLORREF Color); + +HBRUSH STDCALL +NtGdiCreatePatternBrush( + HBITMAP hBitmap); + +HBRUSH STDCALL +NtGdiCreateSolidBrush( + COLORREF Color); + +BOOL STDCALL +NtGdiFixBrushOrgEx( + VOID); + +BOOL STDCALL +NtGdiPatBlt( + HDC hDC, + INT XLeft, + INT YLeft, + INT Width, + INT Height, + DWORD ROP); + +BOOL STDCALL +NtGdiPolyPatBlt( + HDC hDC, + DWORD dwRop, + PPATRECT pRects, + INT cRects, + ULONG Reserved); + +BOOL STDCALL +NtGdiPatBlt( + HDC hDC, + INT XLeft, + INT YLeft, + INT Width, + INT Height, + DWORD ROP); + +BOOL STDCALL +NtGdiSetBrushOrgEx( + HDC hDC, + INT XOrg, + INT YOrg, + LPPOINT Point); + +#endif diff --git a/reactos/include/win32k/pen.h b/reactos/include/win32k/pen.h index f7842eca2e2..b934be08b0d 100644 --- a/reactos/include/win32k/pen.h +++ b/reactos/include/win32k/pen.h @@ -1,35 +1,32 @@ - #ifndef __WIN32K_PEN_H #define __WIN32K_PEN_H #include +#include -/* GDI logical pen object */ -typedef struct -{ - LOGPEN logpen; - ULONG iSolidColor; -} PENOBJ, *PPENOBJ; +/* Internal interface */ -/* Internal interface */ +#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(sizeof(GDIBRUSHOBJ), GDI_OBJECT_TYPE_PEN, NULL)) +#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN, GDIOBJFLAG_DEFAULT) +#define PENOBJ_LockPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)) +#define PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN) -#define PENOBJ_AllocPen() \ - ((HPEN) GDIOBJ_AllocObj (sizeof (PENOBJ), GDI_OBJECT_TYPE_PEN, NULL)) -#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN, GDIOBJFLAG_DEFAULT) -#define PENOBJ_LockPen(hBMObj) ((PPENOBJ)GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)) -#define PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN) +HPEN STDCALL +NtGdiCreatePen( + INT PenStyle, + INT Width, + COLORREF Color); -HPEN STDCALL NtGdiCreatePen(INT PenStyle, - INT Width, - COLORREF Color); +HPEN STDCALL +NtGdiCreatePenIndirect( + CONST PLOGPEN LogBrush); -HPEN STDCALL NtGdiCreatePenIndirect(CONST PLOGPEN lgpn); - -HPEN STDCALL NtGdiExtCreatePen(DWORD PenStyle, - DWORD Width, - CONST PLOGBRUSH lb, - DWORD StyleCount, - CONST PDWORD Style); +HPEN STDCALL +NtGdiExtCreatePen( + DWORD PenStyle, + DWORD Width, + CONST PLOGBRUSH LogBrush, + DWORD StyleCount, + CONST PDWORD Style); #endif - diff --git a/reactos/lib/user32/windows/defwnd.c b/reactos/lib/user32/windows/defwnd.c index 53b6fafb6e8..7dfd7928cbc 100644 --- a/reactos/lib/user32/windows/defwnd.c +++ b/reactos/lib/user32/windows/defwnd.c @@ -1,4 +1,4 @@ -/* $Id: defwnd.c,v 1.128 2004/04/02 19:00:56 weiden Exp $ +/* $Id: defwnd.c,v 1.129 2004/04/05 21:26:24 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -902,7 +902,6 @@ DefWndHandleWindowPosChanged(HWND hWnd, WINDOWPOS* Pos) HBRUSH DefWndControlColor(HDC hDC, UINT ctlType) { -#if 0 /* FIXME: Re-enable when pattern brushes are implemented */ if (CTLCOLOR_SCROLLBAR == ctlType) { HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR); @@ -933,7 +932,6 @@ DefWndControlColor(HDC hDC, UINT ctlType) UnrealizeObject(hb); return hb; } -#endif SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); diff --git a/reactos/subsys/win32k/dib/dib16bpp.c b/reactos/subsys/win32k/dib/dib16bpp.c index 94e79c817b1..8ae97a6b89d 100644 --- a/reactos/subsys/win32k/dib/dib16bpp.c +++ b/reactos/subsys/win32k/dib/dib16bpp.c @@ -16,15 +16,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib16bpp.c,v 1.21 2004/03/28 23:25:48 navaraf Exp $ */ +/* $Id: dib16bpp.c,v 1.22 2004/04/05 21:26:24 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include #include -#include -#include #include #include +#include +#include +#include +#include #include "../eng/objects.h" #include "dib.h" @@ -279,64 +281,128 @@ DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, PBRUSHOBJ Brush, PPOINTL BrushOrigin, XLATEOBJ *ColorTranslation, ULONG Rop4) { - LONG i, j, sx, sy; - ULONG Dest, Source, Pattern; - PULONG DestBits; - BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); - BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); - LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x1); + ULONG X, Y; + ULONG SourceX, SourceY; + ULONG Dest, Source, Pattern = 0; + PULONG DestBits; + BOOL UsesSource; + BOOL UsesPattern; + LONG RoundedRight; + /* Pattern brushes */ + PGDIBRUSHOBJ GdiBrush; + HBITMAP PatternSurface = NULL; + PSURFOBJ PatternObj; + ULONG PatternWidth, PatternHeight; - if (Rop4 == SRCCOPY) - { - return(DIB_16BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); - } - else - { - sy = SourcePoint->y; + if (Rop4 == SRCCOPY) + { + return DIB_16BPP_BitBltSrcCopy( + DestSurf, + SourceSurf, + DestGDI, + SourceGDI, + DestRect, + SourcePoint, + ColorTranslation); + } - for (j=DestRect->top; jbottom; j++) + UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); + UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); + + if (UsesPattern) + { + if (Brush == NULL) { - sx = SourcePoint->x; - DestBits = (PULONG)(DestSurf->pvScan0 + 2 * DestRect->left + j * DestSurf->lDelta); - for (i=DestRect->left; ileft), sy, ColorTranslation); - Source |= DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + 1, sy, ColorTranslation) << 16; - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = (Brush->iSolidColor & 0xFFFF) | - ((Brush->iSolidColor & 0xFFFF) << 16); - } - *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); - } - if (i < DestRect->right) - { - Dest = *DestBits; - for (; i < DestRect->right; i++) - { - if (UsesSource) - { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = (Brush->iSolidColor & 0xFFFF) | - ((Brush->iSolidColor & 0xFFFF) << 16); - } - DIB_16BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF); - Dest >>= 16; - } - } - sy++; + UsesPattern = FALSE; + } else + if (Brush->iSolidColor == 0xFFFFFFFF) + { + PBITMAPOBJ PatternBitmap; + + GdiBrush = CONTAINING_RECORD( + Brush, + GDIBRUSHOBJ, + BrushObject); + + PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern); + PatternSurface = BitmapToSurf(PatternBitmap, NULL); + BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern); + + PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface); + PatternWidth = PatternObj->sizlBitmap.cx; + PatternHeight = PatternObj->sizlBitmap.cy; } - } - return TRUE; + } + + RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x1); + SourceY = SourcePoint->y; + DestBits = (PULONG)( + DestSurf->pvScan0 + + (DestRect->left << 1) + + DestRect->top * DestSurf->lDelta); + + for (Y = DestRect->top; Y < DestRect->bottom; Y++) + { + SourceX = SourcePoint->x; + for (X = DestRect->left; X < RoundedRight; X += 2, DestBits++, SourceX += 2) + { + Dest = *DestBits; + + if (UsesSource) + { + Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation); + Source |= DIB_GetSource(SourceSurf, SourceGDI, SourceX + 1, SourceY, ColorTranslation) << 16; + } + + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + { + Pattern = (DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack); + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + 1) % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 16; + } + else + { + Pattern = (Brush->iSolidColor & 0xFFFF) | + ((Brush->iSolidColor & 0xFFFF) << 16); + } + } + + *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); + } + + if (X < DestRect->right) + { + Dest = *((PUSHORT)DestBits); + + if (UsesSource) + { + Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation); + } + + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack; + else + Pattern = Brush->iSolidColor & 0xFFFF; + } + + DIB_16BPP_PutPixel(DestSurf, X, Y, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF); + DestBits = (PULONG)((ULONG_PTR)DestBits + 2); + } + + SourceY++; + DestBits = (PULONG)( + (ULONG_PTR)DestBits - + ((DestRect->right - DestRect->left) << 1) + + DestSurf->lDelta); + } + + if (PatternSurface != NULL) + EngDeleteSurface(PatternSurface); + + return TRUE; } diff --git a/reactos/subsys/win32k/dib/dib1bpp.c b/reactos/subsys/win32k/dib/dib1bpp.c index 7cdacd83ad8..b252dafcb03 100644 --- a/reactos/subsys/win32k/dib/dib1bpp.c +++ b/reactos/subsys/win32k/dib/dib1bpp.c @@ -16,13 +16,15 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib1bpp.c,v 1.16 2004/03/28 23:24:57 navaraf Exp $ */ +/* $Id: dib1bpp.c,v 1.17 2004/04/05 21:26:24 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include #include +#include #include +#include #include #include #include "../eng/objects.h" @@ -351,68 +353,175 @@ DIB_1BPP_BitBlt( PBRUSHOBJ Brush, PPOINTL BrushOrigin, XLATEOBJ *ColorTranslation, ULONG Rop4) { - LONG i, j, k, sx, sy; - ULONG Dest, Source, Pattern; - PULONG DestBits; - BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); - BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); - LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7); + ULONG X, Y, SourceX, SourceY, k; + ULONG Dest, Source, Pattern; + PULONG DestBits; + BOOL UsesSource; + BOOL UsesPattern; + LONG RoundedRight; + BYTE NoBits; + /* Pattern brushes */ + PGDIBRUSHOBJ GdiBrush; + HBITMAP PatternSurface = NULL; + PSURFOBJ PatternObj; + ULONG PatternWidth, PatternHeight; - if (Rop4 == SRCCOPY) - { - return(DIB_1BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); - } - else - { - sy = SourcePoint->y; + if (Rop4 == SRCCOPY) + { + return DIB_1BPP_BitBltSrcCopy( + DestSurf, + SourceSurf, + DestGDI, + SourceGDI, + DestRect, + SourcePoint, + ColorTranslation); + } - for (j=DestRect->top; jbottom; j++) - { - sx = SourcePoint->x; - DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left>>3) + j * DestSurf->lDelta); - for (i=DestRect->left; ileft) + k, sy, ColorTranslation) << (7 - k)); - Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k + 8, sy, ColorTranslation) << (8 + (7 - k))); - Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k + 16, sy, ColorTranslation) << (16 + (7 - k))); - Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k + 24, sy, ColorTranslation) << (24 + (7 - k))); - } - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000; - } - *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); - } - if (i < DestRect->right) - { - Dest = *DestBits; - for (; i < DestRect->right; i++) - { - if (UsesSource) - { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000; - } - DIB_1BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF); - Dest >>= 1; - } - } - sy++; - } - } - return TRUE; + if (UsesPattern) + { + if (Brush == NULL) + { + UsesPattern = FALSE; + } else + if (Brush->iSolidColor == 0xFFFFFFFF) + { + PBITMAPOBJ PatternBitmap; + + GdiBrush = CONTAINING_RECORD( + Brush, + GDIBRUSHOBJ, + BrushObject); + + PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern); + PatternSurface = BitmapToSurf(PatternBitmap, NULL); + BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern); + + PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface); + PatternWidth = PatternObj->sizlBitmap.cx; + PatternHeight = PatternObj->sizlBitmap.cy; + } + } + + UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); + UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); + RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7); + SourceY = SourcePoint->y; + + for (Y = DestRect->top; Y < DestRect->bottom; Y++) + { + SourceX = SourcePoint->x; + DestBits = (PULONG)( + DestSurf->pvScan0 + + (DestRect->left >> 3) + + Y * DestSurf->lDelta); + + X = DestRect->left; + if (X & 7) + { + Dest = *((PBYTE)DestBits); + NoBits = 7 - (X & 7); + + if (UsesSource) + { + Source = 0; + for (k = 7 - NoBits; k < NoBits; k++) + Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k, SourceY, ColorTranslation) << (7 - k)); + } + + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + { + Pattern = 0; + for (k = 7 - NoBits; k < NoBits; k++) + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k) % PatternWidth, Y % PatternHeight) << (7 - k)); + } + else + { + Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000; + } + } + + Dest = DIB_DoRop(Rop4, Dest, Source, Pattern); + Dest &= ~((1 << (7 - NoBits)) - 1); + Dest |= *((PBYTE)DestBits) & ((1 << (7 - NoBits)) - 1); + + X += NoBits; + SourceX += NoBits; + } + + for (; X < RoundedRight; X += 32, DestBits++, SourceX++) + { + Dest = *DestBits; + + if (UsesSource) + { + Source = 0; + for (k = 0; k < 8; k++) + { + Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k, SourceY, ColorTranslation) << (7 - k)); + Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k + 8, SourceY, ColorTranslation) << (8 + (7 - k))); + Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k + 16, SourceY, ColorTranslation) << (16 + (7 - k))); + Source |= (DIB_GetSource(SourceSurf, SourceGDI, SourceX + k + 24, SourceY, ColorTranslation) << (24 + (7 - k))); + } + } + + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + { + Pattern = 0; + for (k = 0; k < 8; k++) + { + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k) % PatternWidth, Y % PatternHeight) << (7 - k)); + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k + 8) % PatternWidth, Y % PatternHeight) << (8 + (7 - k))); + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k + 16) % PatternWidth, Y % PatternHeight) << (16 + (7 - k))); + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (X + k + 24) % PatternWidth, Y % PatternHeight) << (24 + (7 - k))); + } + } + else + { + Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000; + } + } + + *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); + } + + if (X < DestRect->right) + { +// Dest = *DestBits; + for (; X < DestRect->right; X++, SourceX++) + { +// Dest = *DestBits; + Dest = DIB_1BPP_GetPixel(DestSurf, X, Y); + + if (UsesSource) + { + Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation); + } + + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight); + else + Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000; + } + + DIB_1BPP_PutPixel(DestSurf, X, Y, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF); +// Dest >>= 1; + } + } + + SourceY++; + } + + if (PatternSurface != NULL) + EngDeleteSurface(PatternSurface); + + return TRUE; } BOOLEAN diff --git a/reactos/subsys/win32k/dib/dib24bpp.c b/reactos/subsys/win32k/dib/dib24bpp.c index bb0aec678ca..56b39f312ca 100644 --- a/reactos/subsys/win32k/dib/dib24bpp.c +++ b/reactos/subsys/win32k/dib/dib24bpp.c @@ -16,13 +16,15 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib24bpp.c,v 1.17 2004/03/28 23:25:48 navaraf Exp $ */ +/* $Id: dib24bpp.c,v 1.18 2004/04/05 21:26:24 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include #include +#include #include #include +#include #include #include "../eng/objects.h" #include "dib.h" @@ -251,44 +253,102 @@ DIB_24BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, PBRUSHOBJ Brush, PPOINTL BrushOrigin, XLATEOBJ *ColorTranslation, ULONG Rop4) { - LONG i, j, sx, sy; - ULONG Dest, Source, Pattern; - PBYTE DestBits; - BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); - BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); + ULONG X, Y; + ULONG SourceX, SourceY; + ULONG Dest, Source, Pattern; + PBYTE DestBits; + BOOL UsesSource; + BOOL UsesPattern; + /* Pattern brushes */ + PGDIBRUSHOBJ GdiBrush; + HBITMAP PatternSurface = NULL; + PSURFOBJ PatternObj; + ULONG PatternWidth, PatternHeight; - if (Rop4 == SRCCOPY) - { - return(DIB_24BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); - } - else - { - sy = SourcePoint->y; + if (Rop4 == SRCCOPY) + { + return DIB_24BPP_BitBltSrcCopy( + DestSurf, + SourceSurf, + DestGDI, + SourceGDI, + DestRect, + SourcePoint, + ColorTranslation); + } - for (j = DestRect->top; j < DestRect->bottom; j++) + UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); + UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); + + if (UsesPattern) + { + if (Brush == NULL) { - sx = SourcePoint->x; - DestBits = (PBYTE)(DestSurf->pvScan0 + 3 * DestRect->left + j * DestSurf->lDelta); - for (i=DestRect->left; iright; i++, DestBits+=3) - { - Dest = *(PUSHORT)(DestBits) + (*(DestBits + 2) << 16); - if (UsesSource) - { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation) & 0x00ffffff; - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = Brush->iSolidColor; - } - Dest = DIB_DoRop(Rop4, Dest, Source, Pattern); - *(PUSHORT)(DestBits) = Dest & 0xFFFF; - *(DestBits + 2) = Dest >> 16; - } - sy++; + UsesPattern = FALSE; + } else + if (Brush->iSolidColor == 0xFFFFFFFF) + { + PBITMAPOBJ PatternBitmap; + + GdiBrush = CONTAINING_RECORD( + Brush, + GDIBRUSHOBJ, + BrushObject); + + PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern); + PatternSurface = BitmapToSurf(PatternBitmap, NULL); + BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern); + + PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface); + PatternWidth = PatternObj->sizlBitmap.cx; + PatternHeight = PatternObj->sizlBitmap.cy; } - } - return TRUE; + } + + SourceY = SourcePoint->y; + DestBits = (PBYTE)( + DestSurf->pvScan0 + + (DestRect->left << 1) + DestRect->left + + DestRect->top * DestSurf->lDelta); + + for (Y = DestRect->top; Y < DestRect->bottom; Y++) + { + SourceX = SourcePoint->x; + for (X = DestRect->left; X < DestRect->right; X++, DestBits += 3, SourceX++) + { + Dest = *((PUSHORT)DestBits) + (*(DestBits + 2) << 16); + + if (UsesSource) + { + Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation); + } + + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + { + Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack; + } + else + { + Pattern = Brush->iSolidColor; + } + } + + Dest = DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFFFF; + *(PUSHORT)(DestBits) = Dest & 0xFFFF; + *(DestBits + 2) = Dest >> 16; + } + + SourceY++; + DestBits -= (DestRect->right - DestRect->left) * 3; + DestBits += DestSurf->lDelta; + } + + if (PatternSurface != NULL) + EngDeleteSurface(PatternSurface); + + return TRUE; } BOOLEAN DIB_24BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, diff --git a/reactos/subsys/win32k/dib/dib32bpp.c b/reactos/subsys/win32k/dib/dib32bpp.c index a3ed08c273b..2fe3bd2978d 100644 --- a/reactos/subsys/win32k/dib/dib32bpp.c +++ b/reactos/subsys/win32k/dib/dib32bpp.c @@ -16,14 +16,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib32bpp.c,v 1.17 2004/04/04 16:40:05 gvg Exp $ */ +/* $Id: dib32bpp.c,v 1.18 2004/04/05 21:26:24 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include #include +#include #include #include #include +#include #include "../eng/objects.h" #include "dib.h" @@ -300,42 +302,103 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, PBRUSHOBJ Brush, PPOINTL BrushOrigin, XLATEOBJ *ColorTranslation, ULONG Rop4) { - LONG i, j, sx, sy; - ULONG Dest, Source, Pattern; - PULONG DestBits; - BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); - BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); + ULONG X, Y; + ULONG SourceX, SourceY; + ULONG Dest, Source, Pattern; + PULONG DestBits; + BOOL UsesSource; + BOOL UsesPattern; + /* Pattern brushes */ + PGDIBRUSHOBJ GdiBrush; + HBITMAP PatternSurface = NULL; + PSURFOBJ PatternObj; + ULONG PatternWidth, PatternHeight; - if (Rop4 == SRCCOPY) - { - return(DIB_32BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); - } - else - { - sy = SourcePoint->y; + if (Rop4 == SRCCOPY) + { + return DIB_32BPP_BitBltSrcCopy( + DestSurf, + SourceSurf, + DestGDI, + SourceGDI, + DestRect, + SourcePoint, + ColorTranslation); + } - for (j=DestRect->top; jbottom; j++) + UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); + UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); + + if (UsesPattern) + { + if (Brush == NULL) { - sx = SourcePoint->x; - DestBits = (PULONG)(DestSurf->pvScan0 + 4 * DestRect->left + j * DestSurf->lDelta); - for (i=DestRect->left; iright; i++, DestBits++) - { - Dest = *DestBits; - if (UsesSource) - { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = Brush->iSolidColor; - } - *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); - } - sy++; + UsesPattern = FALSE; + } else + if (Brush->iSolidColor == 0xFFFFFFFF) + { + PBITMAPOBJ PatternBitmap; + + GdiBrush = CONTAINING_RECORD( + Brush, + GDIBRUSHOBJ, + BrushObject); + + PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern); + PatternSurface = BitmapToSurf(PatternBitmap, NULL); + BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern); + + PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface); + PatternWidth = PatternObj->sizlBitmap.cx; + PatternHeight = PatternObj->sizlBitmap.cy; } - } - return TRUE; + } + + SourceY = SourcePoint->y; + DestBits = (PULONG)( + DestSurf->pvScan0 + + (DestRect->left << 2) + + DestRect->top * DestSurf->lDelta); + + for (Y = DestRect->top; Y < DestRect->bottom; Y++) + { + SourceX = SourcePoint->x; + + for (X = DestRect->left; X < DestRect->right; X++, DestBits++, SourceX++) + { + Dest = *DestBits; + + if (UsesSource) + { + Source = DIB_GetSource(SourceSurf, SourceGDI, SourceX, SourceY, ColorTranslation); + } + + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + { + Pattern = DIB_1BPP_GetPixel(PatternObj, X % PatternWidth, Y % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack; + } + else + { + Pattern = Brush->iSolidColor; + } + } + + *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); + } + + SourceY++; + DestBits = (PULONG)( + (ULONG_PTR)DestBits - + ((DestRect->right - DestRect->left) << 2) + + DestSurf->lDelta); + } + + if (PatternSurface != NULL) + EngDeleteSurface(PatternSurface); + + return TRUE; } /* diff --git a/reactos/subsys/win32k/dib/dib4bpp.c b/reactos/subsys/win32k/dib/dib4bpp.c index dfa08ef979a..e210aa881ea 100644 --- a/reactos/subsys/win32k/dib/dib4bpp.c +++ b/reactos/subsys/win32k/dib/dib4bpp.c @@ -16,13 +16,15 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib4bpp.c,v 1.23 2004/02/08 09:27:39 navaraf Exp $ */ +/* $Id: dib4bpp.c,v 1.24 2004/04/05 21:26:24 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include #include +#include #include #include +#include #include #include "../eng/objects.h" #include "dib.h" @@ -30,18 +32,15 @@ VOID DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c) { - PBYTE addr = SurfObj->pvScan0; - - addr += (x>>1) + y * SurfObj->lDelta; - *addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2)); + PBYTE addr = SurfObj->pvScan0 + (x>>1) + y * SurfObj->lDelta; + *addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2)); } ULONG DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y) { - PBYTE addr = SurfObj->pvScan0; - - return (addr[(x>>1) + y * SurfObj->lDelta] >> ((1-(x&1))<<2) ) & 0x0f; + PBYTE addr = SurfObj->pvScan0 + (x>>1) + y * SurfObj->lDelta; + return (*addr >> ((1-(x&1))<<2)) & 0x0f; } VOID @@ -141,8 +140,8 @@ DIB_4BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, for (i=DestRect->left; iright; i++) { - *DestLine = (*DestLine & notmask[i&1]) | - ((XLATEOBJ_iXlate(ColorTranslation, *SourceLine_8BPP)) << ((4 * (1-(i & 1))))); + *DestLine = (*DestLine & notmask[f2]) | + ((XLATEOBJ_iXlate(ColorTranslation, *SourceLine_8BPP)) << ((4 * (1 - f2)))); if(f2 == 1) { DestLine++; f2 = 0; } else { f2 = 1; } SourceLine_8BPP++; } @@ -165,8 +164,8 @@ DIB_4BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, for (i = DestRect->left; i < DestRect->right; i++) { xColor = *((PWORD) SourceBits); - *DestBits = (*DestBits & notmask[i&1]) | - ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1-(i & 1))))); + *DestBits = (*DestBits & notmask[f2]) | + ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1 - f2)))); if(f2 == 1) { DestBits++; f2 = 0; } else { f2 = 1; } SourceBits += 2; } @@ -190,8 +189,8 @@ DIB_4BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, xColor = (*(SourceLine_24BPP + 2) << 0x10) + (*(SourceLine_24BPP + 1) << 0x08) + (*(SourceLine_24BPP)); - *DestLine = (*DestLine & notmask[i&1]) | - ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1-(i & 1))))); + *DestLine = (*DestLine & notmask[f2]) | + ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1 - f2)))); if(f2 == 1) { DestLine++; f2 = 0; } else { f2 = 1; } SourceLine_24BPP+=3; } @@ -214,8 +213,8 @@ DIB_4BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, for (i = DestRect->left; i < DestRect->right; i++) { xColor = *((PDWORD) SourceBits); - *DestBits = (*DestBits & notmask[i&1]) | - ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1-(i & 1))))); + *DestBits = (*DestBits & notmask[f2]) | + ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1 - f2)))); if(f2 == 1) { DestBits++; f2 = 0; } else { f2 = 1; } SourceBits += 4; } @@ -242,9 +241,14 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, LONG i, j, sx, sy; ULONG Dest, Source, Pattern; PULONG DestBits; - BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); - BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); - LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7); + BOOL UsesSource; + BOOL UsesPattern; + LONG RoundedRight; + /* Pattern brushes */ + PGDIBRUSHOBJ GdiBrush; + HBITMAP PatternSurface = NULL; + PSURFOBJ PatternObj; + ULONG PatternWidth, PatternHeight; static const ULONG ExpandSolidColor[16] = { 0x00000000 /* 0 */, @@ -267,74 +271,135 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, if (Rop4 == SRCCOPY) { - return(DIB_4BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); + return DIB_4BPP_BitBltSrcCopy( + DestSurf, + SourceSurf, + DestGDI, + SourceGDI, + DestRect, + SourcePoint, + ColorTranslation); } - else + + UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); + UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); + + if (UsesPattern) { - sy = SourcePoint->y; - - for (j = DestRect->top; j < DestRect->bottom; j++, sy++) + if (Brush == NULL) { - DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left >> 1) + j * DestSurf->lDelta); - sx = SourcePoint->x; + UsesPattern = FALSE; + } else + if (Brush->iSolidColor == 0xFFFFFFFF) + { + PBITMAPOBJ PatternBitmap; - /* Process all pixels on the left that aren't DWORD aligned */ - for (i = DestRect->left; i & 0x7; i++, sx++) - { - Dest = DIB_4BPP_GetPixel(DestSurf, i, j); - if (UsesSource) - { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation); - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF]; - } - DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF); - } + GdiBrush = CONTAINING_RECORD( + Brush, + GDIBRUSHOBJ, + BrushObject); - /* Process all DWORD aligned pixels */ - for (; i < RoundedRight; i += 8, sx += 8, DestBits++) - { - Dest = *DestBits; - if (UsesSource) - { - Source = - (DIB_GetSource(SourceSurf, SourceGDI, sx + 1, sy, ColorTranslation)) | - (DIB_GetSource(SourceSurf, SourceGDI, sx + 0, sy, ColorTranslation) << 4) | - (DIB_GetSource(SourceSurf, SourceGDI, sx + 3, sy, ColorTranslation) << 8) | - (DIB_GetSource(SourceSurf, SourceGDI, sx + 2, sy, ColorTranslation) << 12) | - (DIB_GetSource(SourceSurf, SourceGDI, sx + 5, sy, ColorTranslation) << 16) | - (DIB_GetSource(SourceSurf, SourceGDI, sx + 4, sy, ColorTranslation) << 20) | - (DIB_GetSource(SourceSurf, SourceGDI, sx + 7, sy, ColorTranslation) << 24) | - (DIB_GetSource(SourceSurf, SourceGDI, sx + 6, sy, ColorTranslation) << 28); - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF]; - } - *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); - } + PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern); + PatternSurface = BitmapToSurf(PatternBitmap, NULL); + BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern); - /* Process the rest of pixel on the line */ - for (; i < DestRect->right; i++, sx++) - { - Dest = DIB_4BPP_GetPixel(DestSurf, i, j); - if (UsesSource) - { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation); - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF]; - } - DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF); - } + PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface); + PatternWidth = PatternObj->sizlBitmap.cx; + PatternHeight = PatternObj->sizlBitmap.cy; } } + + sy = SourcePoint->y; + RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7); + + for (j = DestRect->top; j < DestRect->bottom; j++, sy++) + { + DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left >> 1) + j * DestSurf->lDelta); + sx = SourcePoint->x; + i = DestRect->left; + + if (i & 0x1) + { + Dest = DIB_4BPP_GetPixel(DestSurf, i, j); + + if (UsesSource) + { + Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation); + } + + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack; + else + Pattern = Brush->iSolidColor & 0xF; + } + + DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF); + + i++; + sx++; + DestBits++; + } + + for (; i < RoundedRight; i += 8, sx += 8, DestBits++) + { + Dest = *DestBits; + if (UsesSource) + { + Source = + (DIB_GetSource(SourceSurf, SourceGDI, sx + 1, sy, ColorTranslation)) | + (DIB_GetSource(SourceSurf, SourceGDI, sx + 0, sy, ColorTranslation) << 4) | + (DIB_GetSource(SourceSurf, SourceGDI, sx + 3, sy, ColorTranslation) << 8) | + (DIB_GetSource(SourceSurf, SourceGDI, sx + 2, sy, ColorTranslation) << 12) | + (DIB_GetSource(SourceSurf, SourceGDI, sx + 5, sy, ColorTranslation) << 16) | + (DIB_GetSource(SourceSurf, SourceGDI, sx + 4, sy, ColorTranslation) << 20) | + (DIB_GetSource(SourceSurf, SourceGDI, sx + 7, sy, ColorTranslation) << 24) | + (DIB_GetSource(SourceSurf, SourceGDI, sx + 6, sy, ColorTranslation) << 28); + } + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + { + Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack; + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 1) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 4; + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 2) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 8; + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 3) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 12; + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 4) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 16; + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 5) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 20; + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 6) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 24; + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 7) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 28; + } + else + { + Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF]; + } + } + *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); + } + + /* Process the rest of pixel on the line */ + for (; i < DestRect->right; i++, sx++) + { + Dest = DIB_4BPP_GetPixel(DestSurf, i, j); + if (UsesSource) + { + Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation); + } + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack; + else + Pattern = Brush->iSolidColor & 0xF; + } + DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF); + } + } + + if (PatternSurface != NULL) + EngDeleteSurface(PatternSurface); + return TRUE; } diff --git a/reactos/subsys/win32k/dib/dib8bpp.c b/reactos/subsys/win32k/dib/dib8bpp.c index 7a64a801c30..c0d2e3c4cf1 100644 --- a/reactos/subsys/win32k/dib/dib8bpp.c +++ b/reactos/subsys/win32k/dib/dib8bpp.c @@ -16,13 +16,15 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib8bpp.c,v 1.16 2004/03/28 23:25:48 navaraf Exp $ */ +/* $Id: dib8bpp.c,v 1.17 2004/04/05 21:26:24 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include #include +#include #include #include +#include #include #include "../eng/objects.h" #include "dib.h" @@ -274,71 +276,127 @@ DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, PBRUSHOBJ Brush, PPOINTL BrushOrigin, XLATEOBJ *ColorTranslation, ULONG Rop4) { - LONG i, j, k, sx, sy; - ULONG Dest, Source, Pattern; - PULONG DestBits; - BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); - BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); - LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x3); + LONG i, j, k, sx, sy; + ULONG Dest, Source, Pattern; + PULONG DestBits; + BOOL UsesSource; + BOOL UsesPattern; + LONG RoundedRight; + /* Pattern brushes */ + PGDIBRUSHOBJ GdiBrush; + HBITMAP PatternSurface = NULL; + PSURFOBJ PatternObj; + ULONG PatternWidth, PatternHeight; - if (Rop4 == SRCCOPY) - { - return(DIB_8BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); - } - else - { - sy = SourcePoint->y; + if (Rop4 == SRCCOPY) + { + return DIB_8BPP_BitBltSrcCopy( + DestSurf, + SourceSurf, + DestGDI, + SourceGDI, + DestRect, + SourcePoint, + ColorTranslation); + } - for (j=DestRect->top; jbottom; j++) + UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); + UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); + + if (UsesPattern) + { + if (Brush == NULL) { - sx = SourcePoint->x; - DestBits = (PULONG)(DestSurf->pvScan0 + DestRect->left + j * DestSurf->lDelta); - for (i=DestRect->left; ileft) + k, sy, ColorTranslation) << (k * 8)); - } - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = (Brush->iSolidColor & 0xFF) | - ((Brush->iSolidColor & 0xFF) << 8) | - ((Brush->iSolidColor & 0xFF) << 16) | - ((Brush->iSolidColor & 0xFF) << 24); - } - *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); - } - if (i < DestRect->right) - { - Dest = *DestBits; - for (; i < DestRect->right; i++) - { - if (UsesSource) - { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); - } - if (UsesPattern) - { - /* FIXME: No support for pattern brushes. */ - Pattern = (Brush->iSolidColor & 0xFF) | - ((Brush->iSolidColor & 0xFF) << 8) | - ((Brush->iSolidColor & 0xFF) << 16) | - ((Brush->iSolidColor & 0xFF) << 24); - } - DIB_8BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF); - Dest >>= 8; - } - } - sy++; + UsesPattern = FALSE; + } else + if (Brush->iSolidColor == 0xFFFFFFFF) + { + PBITMAPOBJ PatternBitmap; + + GdiBrush = CONTAINING_RECORD( + Brush, + GDIBRUSHOBJ, + BrushObject); + + PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern); + PatternSurface = BitmapToSurf(PatternBitmap, NULL); + BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern); + + PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface); + PatternWidth = PatternObj->sizlBitmap.cx; + PatternHeight = PatternObj->sizlBitmap.cy; } - } - return TRUE; + } + + RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x3); + sy = SourcePoint->y; + + for (j = DestRect->top; j < DestRect->bottom; j++) + { + sx = SourcePoint->x; + DestBits = (PULONG)(DestSurf->pvScan0 + DestRect->left + j * DestSurf->lDelta); + + for (i = DestRect->left; i < RoundedRight; i += 4, DestBits++) + { + Dest = *DestBits; + + if (UsesSource) + { + Source = 0; + for (k = 0; k < 4; k++) + Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 8)); + } + + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + { + Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack; + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 1) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 8; + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 2) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 16; + Pattern |= (DIB_1BPP_GetPixel(PatternObj, (i + 3) % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack) << 24; + } + else + { + Pattern = (Brush->iSolidColor & 0xFF) | + ((Brush->iSolidColor & 0xFF) << 8) | + ((Brush->iSolidColor & 0xFF) << 16) | + ((Brush->iSolidColor & 0xFF) << 24); + } + } + *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); + } + + if (i < DestRect->right) + { + Dest = *DestBits; + for (; i < DestRect->right; i++) + { + if (UsesSource) + { + Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); + } + + if (UsesPattern) + { + if (Brush->iSolidColor == 0xFFFFFFFF) + Pattern = DIB_1BPP_GetPixel(PatternObj, i % PatternWidth, j % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack; + else + Pattern = Brush->iSolidColor & 0xFF; + } + + DIB_8BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF); + Dest >>= 8; + } + } + + sy++; + } + + if (PatternSurface != NULL) + EngDeleteSurface(PatternSurface); + + return TRUE; } /* @@ -393,7 +451,7 @@ void ScaleRectAvg8(PIXEL *Target, PIXEL *Source, int SrcWidth, int SrcHeight, int TgtWidth, int TgtHeight, int srcPitch, int dstPitch) { int NumPixels = TgtHeight; - int IntPart = ((SrcHeight / TgtHeight) * srcPitch) >> 1; //(SrcHeight / TgtHeight) * SrcWidth; + int IntPart = ((SrcHeight / TgtHeight) * srcPitch); //(SrcHeight / TgtHeight) * SrcWidth; int FractPart = SrcHeight % TgtHeight; int Mid = TgtHeight >> 1; int E = 0; diff --git a/reactos/subsys/win32k/eng/bitblt.c b/reactos/subsys/win32k/eng/bitblt.c index 532974773d8..bc094eefc3a 100644 --- a/reactos/subsys/win32k/eng/bitblt.c +++ b/reactos/subsys/win32k/eng/bitblt.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: bitblt.c,v 1.43 2004/03/22 14:58:56 weiden Exp $ +/* $Id: bitblt.c,v 1.44 2004/04/05 21:26:24 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -109,41 +109,74 @@ BltMask(SURFOBJ* Dest, POINTL* BrushPoint, ROP4 Rop4) { - LONG i, j, dx, dy, c8; - BYTE *tMask, *lMask; - static BYTE maskbit[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; + LONG i, j, dx, dy, c8; + BYTE *tMask, *lMask; + static BYTE maskbit[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; + /* Pattern brushes */ + PGDIBRUSHOBJ GdiBrush; + HBITMAP PatternSurface = NULL; + PSURFOBJ PatternObj; + ULONG PatternWidth, PatternHeight; - dx = DestRect->right - DestRect->left; - dy = DestRect->bottom - DestRect->top; + if (Mask == NULL) + { + return FALSE; + } - if (Mask != NULL) - { - tMask = Mask->pvBits + SourcePoint->y * Mask->lDelta + (SourcePoint->x >> 3); - for (j = 0; j < dy; j++) - { - lMask = tMask; - c8 = SourcePoint->x & 0x07; - for (i = 0; i < dx; i++) - { - if (0 != (*lMask & maskbit[c8])) - { - DestGDI->DIB_PutPixel(Dest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor); - } - c8++; - if (8 == c8) - { - lMask++; - c8=0; - } - } - tMask += Mask->lDelta; - } - return TRUE; - } - else - { - return FALSE; - } + dx = DestRect->right - DestRect->left; + dy = DestRect->bottom - DestRect->top; + + if (Brush->iSolidColor == 0xFFFFFFFF) + { + PBITMAPOBJ PatternBitmap; + + GdiBrush = CONTAINING_RECORD( + Brush, + GDIBRUSHOBJ, + BrushObject); + + PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern); + PatternSurface = BitmapToSurf(PatternBitmap, Dest->hdev); + BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern); + + PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface); + PatternWidth = PatternObj->sizlBitmap.cx; + PatternHeight = PatternObj->sizlBitmap.cy; + } + + tMask = Mask->pvScan0 + SourcePoint->y * Mask->lDelta + (SourcePoint->x >> 3); + for (j = 0; j < dy; j++) + { + lMask = tMask; + c8 = SourcePoint->x & 0x07; + for (i = 0; i < dx; i++) + { + if (0 != (*lMask & maskbit[c8])) + { + if (PatternSurface == NULL) + { + DestGDI->DIB_PutPixel(Dest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor); + } + else + { + DestGDI->DIB_PutPixel(Dest, DestRect->left + i, DestRect->top + j, + DIB_1BPP_GetPixel(PatternObj, (DestRect->left + i) % PatternWidth, (DestRect->top + j) % PatternHeight) ? GdiBrush->crFore : GdiBrush->crBack); + } + } + c8++; + if (8 == c8) + { + lMask++; + c8 = 0; + } + } + tMask += Mask->lDelta; + } + + if (PatternSurface != NULL) + EngDeleteSurface(PatternSurface); + + return TRUE; } static BOOLEAN STDCALL @@ -345,7 +378,14 @@ EngBitBlt(SURFOBJ *DestObj, } else if (PATCOPY == Rop4) { +#if 0 BltRectFunc = BltPatCopy; +#else + if (Brush->iSolidColor == 0xFFFFFFFF) + BltRectFunc = CallDibBitBlt; + else + BltRectFunc = BltPatCopy; +#endif } else { diff --git a/reactos/subsys/win32k/include/object.h b/reactos/subsys/win32k/include/object.h index 4d166532a44..b2a2b931e7f 100644 --- a/reactos/subsys/win32k/include/object.h +++ b/reactos/subsys/win32k/include/object.h @@ -132,14 +132,6 @@ PPOINT FASTCALL GDI_Bezier (const POINT *Points, INT count, PINT nPtsOut); /* objects/objconv.c */ -BRUSHOBJ* -FASTCALL -PenToBrushObj(BRUSHOBJ *brush, PENOBJ *pen); - -BRUSHOBJ* -FASTCALL -HPenToBrushObj ( BRUSHOBJ *brush, HPEN hpen ); - HBITMAP FASTCALL BitmapToSurf ( PBITMAPOBJ BitmapObj, HDEV GDIDevice ); diff --git a/reactos/subsys/win32k/objects/bitmaps.c b/reactos/subsys/win32k/objects/bitmaps.c index 27d9013cfef..1181245dd7d 100644 --- a/reactos/subsys/win32k/objects/bitmaps.c +++ b/reactos/subsys/win32k/objects/bitmaps.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: bitmaps.c,v 1.66 2004/04/03 21:25:20 weiden Exp $ */ +/* $Id: bitmaps.c,v 1.67 2004/04/05 21:26:25 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -62,7 +62,7 @@ NtGdiBitBlt( PXLATEOBJ XlateObj = NULL; HPALETTE SourcePalette, DestPalette; ULONG SourceMode, DestMode; - PBRUSHOBJ BrushObj; + PGDIBRUSHOBJ BrushObj; BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000); BOOL UsesPattern = TRUE;//((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000); HPALETTE Mono = NULL; @@ -244,7 +244,7 @@ NtGdiBitBlt( /* Perform the bitblt operation */ Status = IntEngBitBlt(SurfDest, SurfSrc, NULL, DCDest->CombinedClip, XlateObj, - &DestRect, &SourcePoint, NULL, BrushObj, NULL, ROP); + &DestRect, &SourcePoint, NULL, &BrushObj->BrushObject, NULL, ROP); EngDeleteXlate(XlateObj); if (NULL != Mono) @@ -1099,7 +1099,7 @@ NtGdiStretchBlt( PXLATEOBJ XlateObj = NULL; HPALETTE SourcePalette, DestPalette; ULONG SourceMode, DestMode; - PBRUSHOBJ BrushObj; + PGDIBRUSHOBJ BrushObj; BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000); BOOL UsesPattern = ((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000); @@ -1307,7 +1307,7 @@ BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp) return -1; #endif - return ((bmWidth * bpp + 31) & ~31) >> 3; + return ((bmWidth * bpp + 15) & ~15) >> 3; } HBITMAP FASTCALL diff --git a/reactos/subsys/win32k/objects/brush.c b/reactos/subsys/win32k/objects/brush.c index 988633f644b..5e25bbef477 100644 --- a/reactos/subsys/win32k/objects/brush.c +++ b/reactos/subsys/win32k/objects/brush.c @@ -1,24 +1,24 @@ /* - * ReactOS W32 Subsystem - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team + * ReactOS Win32 Subsystem * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Copyright (C) 1998 - 2004 ReactOS Team * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: brush.c,v 1.33 2004/04/05 21:26:25 navaraf Exp $ */ -/* $Id: brush.c,v 1.32 2004/02/19 21:12:10 weiden Exp $ - */ - #undef WIN32_LEAN_AND_MEAN #include @@ -26,375 +26,352 @@ #include #include #include -//#include #include #include #include #include - #define NDEBUG #include HBRUSH FASTCALL -IntGdiCreateBrushIndirect(PLOGBRUSH lb) +IntGdiCreateBrushIndirect(PLOGBRUSH LogBrush) { - PBRUSHOBJ brushPtr; - HBRUSH hBrush; + PGDIBRUSHOBJ BrushObject; + HBRUSH hBrush; - hBrush = BRUSHOBJ_AllocBrush(); - if (hBrush == NULL) - { - return 0; - } + hBrush = BRUSHOBJ_AllocBrush(); + if (hBrush == NULL) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return NULL; + } - brushPtr = BRUSHOBJ_LockBrush (hBrush); -/* FIXME: Occurs! FiN */ -/* ASSERT( brushPtr ); *///I want to know if this ever occurs + BrushObject = BRUSHOBJ_LockBrush(hBrush); - if( brushPtr ){ - brushPtr->iSolidColor = lb->lbColor; - brushPtr->logbrush.lbStyle = lb->lbStyle; - brushPtr->logbrush.lbColor = lb->lbColor; - brushPtr->logbrush.lbHatch = lb->lbHatch; + switch (LogBrush->lbStyle) + { + case BS_NULL: + BrushObject->flAttrs = GDIBRUSH_IS_NULL; + break; + + /* FIXME */ + case BS_HATCHED: - BRUSHOBJ_UnlockBrush( hBrush ); - return hBrush; - } - return NULL; -} + case BS_SOLID: + BrushObject->flAttrs = GDIBRUSH_IS_SOLID; + BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF; + BrushObject->BrushObject.iSolidColor = BrushObject->BrushAttr.lbColor; + /* FIXME: Fill in the rest of fields!!! */ + break; -HBRUSH FASTCALL -IntGdiCreateDIBPatternBrush(HGLOBAL hDIBPacked, - UINT ColorSpec) -{ - return NULL; -#if 0 - LOGBRUSH logbrush; - PBITMAPINFO info, newInfo; - INT size; + case BS_PATTERN: + BrushObject->flAttrs = GDIBRUSH_IS_BITMAP; + BrushObject->hbmPattern = BITMAPOBJ_CopyBitmap((HBITMAP)LogBrush->lbHatch); + BrushObject->BrushObject.iSolidColor = 0xFFFFFFFF; + /* FIXME: Fill in the rest of fields!!! */ + break; - DPRINT("%04x\n", hbitmap ); + default: + DPRINT1("Brush Style: %d\n", LogBrush->lbStyle); + UNIMPLEMENTED; + } - logbrush.lbStyle = BS_DIBPATTERN; - logbrush.lbColor = coloruse; - logbrush.lbHatch = 0; - - /* Make a copy of the bitmap */ - if (!(info = (BITMAPINFO *)GlobalLock( hbitmap ))) - { - return 0; - } - - - if (info->bmiHeader.biCompression) size = info->bmiHeader.biSizeImage; - else - size = DIB_GetDIBImageBytes(info->bmiHeader.biWidth, info->bmiHeader.biHeight, info->bmiHeader.biBitCount); - size += DIB_BitmapInfoSize(info, coloruse); - - if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size ))) - { - GlobalUnlock16( hbitmap ); - return 0; - } - newInfo = (BITMAPINFO *) GlobalLock16((HGLOBAL16)logbrush.lbHatch); - memcpy(newInfo, info, size); - GlobalUnlock16((HGLOBAL16)logbrush.lbHatch); - GlobalUnlock(hbitmap); - return IntGdiCreateBrushIndirect(&logbrush); -#endif -} - -HBRUSH FASTCALL -IntGdiCreateDIBPatternBrushPt(CONST VOID *PackedDIB, - UINT Usage) -{ - INT size; - LOGBRUSH logbrush; - PBITMAPINFO info; - PBITMAPINFO newInfo; - - info = (BITMAPINFO *) PackedDIB; - if (info == NULL) - { - return 0; - } - DPRINT ("%p %ldx%ld %dbpp\n", - info, - info->bmiHeader.biWidth, - info->bmiHeader.biHeight, - info->bmiHeader.biBitCount); - - logbrush.lbStyle = BS_DIBPATTERN; - logbrush.lbColor = Usage; - logbrush.lbHatch = 0; - - /* Make a copy of the bitmap */ - - if (info->bmiHeader.biCompression) - { - size = info->bmiHeader.biSizeImage; - } - else - { - size = DIB_GetDIBImageBytes (info->bmiHeader.biWidth, info->bmiHeader.biHeight, info->bmiHeader.biBitCount); - } - size += DIB_BitmapInfoSize (info, Usage); - - logbrush.lbHatch = (LONG) GDIOBJ_AllocObj(size, GDI_OBJECT_TYPE_DONTCARE, NULL); - if (logbrush.lbHatch == 0) - { - return 0; - } - newInfo = (PBITMAPINFO) GDIOBJ_LockObj ((HGDIOBJ) logbrush.lbHatch, GDI_OBJECT_TYPE_DONTCARE); - ASSERT(newInfo); - memcpy(newInfo, info, size); - GDIOBJ_UnlockObj((HGDIOBJ) logbrush.lbHatch, GDI_OBJECT_TYPE_DONTCARE); - - return IntGdiCreateBrushIndirect (&logbrush); + BRUSHOBJ_UnlockBrush(hBrush); + return hBrush; } BOOL FASTCALL -IntPatBlt(DC *dc, - INT XLeft, - INT YLeft, - INT Width, - INT Height, - DWORD ROP, - PBRUSHOBJ BrushObj) +IntPatBlt( + PDC dc, + INT XLeft, + INT YLeft, + INT Width, + INT Height, + DWORD ROP, + PGDIBRUSHOBJ BrushObj) { - RECT DestRect; - PSURFOBJ SurfObj; - BOOL ret; + RECT DestRect; + PSURFOBJ SurfObj; + BOOL ret; - SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface); - if (NULL == SurfObj) - { + SurfObj = (SURFOBJ *)AccessUserObject((ULONG)dc->Surface); + if (SurfObj == NULL) + { SetLastWin32Error(ERROR_INVALID_HANDLE); return FALSE; - } + } - assert(BrushObj); - if (BrushObj->logbrush.lbStyle != BS_NULL) - { + ASSERT(BrushObj); + if (!(BrushObj->flAttrs & GDIBRUSH_IS_NULL)) + { if (Width > 0) - { - DestRect.left = XLeft + dc->w.DCOrgX; - DestRect.right = XLeft + Width + dc->w.DCOrgX; - } + { + DestRect.left = XLeft + dc->w.DCOrgX; + DestRect.right = XLeft + Width + dc->w.DCOrgX; + } else - { - DestRect.left = XLeft + Width + 1 + dc->w.DCOrgX; - DestRect.right = XLeft + dc->w.DCOrgX + 1; - } - if (Height > 0) - { - DestRect.top = YLeft + dc->w.DCOrgY; - DestRect.bottom = YLeft + Height + dc->w.DCOrgY; - } - else - { - DestRect.top = YLeft + Height + dc->w.DCOrgY + 1; - DestRect.bottom = YLeft + dc->w.DCOrgY + 1; - } - ret = IntEngBitBlt(SurfObj, - NULL, - NULL, - dc->CombinedClip, - NULL, - &DestRect, - NULL, - NULL, - BrushObj, - NULL, - ROP); - } + { + DestRect.left = XLeft + Width + 1 + dc->w.DCOrgX; + DestRect.right = XLeft + dc->w.DCOrgX + 1; + } - return ret; + if (Height > 0) + { + DestRect.top = YLeft + dc->w.DCOrgY; + DestRect.bottom = YLeft + Height + dc->w.DCOrgY; + } + else + { + DestRect.top = YLeft + Height + dc->w.DCOrgY + 1; + DestRect.bottom = YLeft + dc->w.DCOrgY + 1; + } + + ret = IntEngBitBlt( + SurfObj, + NULL, + NULL, + dc->CombinedClip, + NULL, + &DestRect, + NULL, + NULL, + &BrushObj->BrushObject, + NULL, + ROP); + } + + return ret; } BOOL FASTCALL -IntGdiPolyPatBlt(HDC hDC, - DWORD dwRop, - PPATRECT pRects, - int cRects, - ULONG Reserved) +IntGdiPolyPatBlt( + HDC hDC, + DWORD dwRop, + PPATRECT pRects, + int cRects, + ULONG Reserved) { - int i; - PPATRECT r; - PBRUSHOBJ BrushObj; - DC *dc; + int i; + PPATRECT r; + PGDIBRUSHOBJ BrushObj; + DC *dc; - dc = DC_LockDc(hDC); - if (dc == NULL) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return(FALSE); - } - - for (r = pRects, i = 0; i < cRects; i++) - { - BrushObj = BRUSHOBJ_LockBrush(r->hBrush); - IntPatBlt(dc,r->r.left,r->r.top,r->r.right,r->r.bottom,dwRop,BrushObj); - BRUSHOBJ_UnlockBrush(r->hBrush); - r++; - } - DC_UnlockDc( hDC ); - - return(TRUE); -} - -/******************************************************************************/ - -HBRUSH STDCALL NtGdiCreateBrushIndirect(CONST LOGBRUSH *lb) -{ - LOGBRUSH Safelb; - NTSTATUS Status; - - Status = MmCopyFromCaller(&Safelb, lb, sizeof(LOGBRUSH)); - if(!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - return 0; - } - - return IntGdiCreateBrushIndirect(&Safelb); -} - -HBRUSH STDCALL NtGdiCreateDIBPatternBrush(HGLOBAL hDIBPacked, - UINT ColorSpec) -{ - /* IntGdiCreateDIBPatternBrush() */ - UNIMPLEMENTED; -} - -HBRUSH STDCALL NtGdiCreateDIBPatternBrushPt(CONST VOID *PackedDIB, - UINT Usage) -{ - /* FIXME - copy PackedDIB memory first! */ - return IntGdiCreateDIBPatternBrushPt(PackedDIB, Usage); -} - -HBRUSH STDCALL NtGdiCreateHatchBrush(INT Style, - COLORREF Color) -{ - LOGBRUSH logbrush; - - DPRINT("%d %06lx\n", Style, Color); - - if (Style < 0 || Style >= NB_HATCH_STYLES) - { - return 0; - } - logbrush.lbStyle = BS_HATCHED; - logbrush.lbColor = Color; - logbrush.lbHatch = Style; - - return IntGdiCreateBrushIndirect (&logbrush); -} - -HBRUSH STDCALL NtGdiCreatePatternBrush(HBITMAP hBitmap) -{ - LOGBRUSH logbrush = { BS_PATTERN, 0, 0 }; - - DPRINT ("%04x\n", hBitmap); - logbrush.lbHatch = (INT) BITMAPOBJ_CopyBitmap (hBitmap); - if(!logbrush.lbHatch) - { - return 0; - } - else - { - return IntGdiCreateBrushIndirect( &logbrush ); - } -} - -HBRUSH STDCALL NtGdiCreateSolidBrush(COLORREF Color) -{ - LOGBRUSH logbrush; - - logbrush.lbStyle = BS_SOLID; - logbrush.lbColor = Color; - logbrush.lbHatch = 0; - - return IntGdiCreateBrushIndirect(&logbrush); -} - -BOOL STDCALL NtGdiFixBrushOrgEx(VOID) -{ - return FALSE; -} - -BOOL STDCALL NtGdiPolyPatBlt(HDC hDC, - DWORD dwRop, - PPATRECT pRects, - int cRects, - ULONG Reserved) -{ - PPATRECT rb; - NTSTATUS Status; - BOOL Ret; - - if(cRects > 0) - { - rb = ExAllocatePoolWithTag(PagedPool, sizeof(PATRECT) * cRects, TAG_PATBLT); - if(!rb) - { - SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - Status = MmCopyFromCaller(rb, pRects, sizeof(PATRECT) * cRects); - if(!NT_SUCCESS(Status)) - { - ExFreePool(rb); - SetLastNtError(Status); - return FALSE; - } - } - - Ret = IntGdiPolyPatBlt(hDC, dwRop, pRects, cRects, Reserved); - - if(cRects > 0) - ExFreePool(rb); - return Ret; -} - -BOOL STDCALL NtGdiPatBlt(HDC hDC, - INT XLeft, - INT YLeft, - INT Width, - INT Height, - DWORD ROP) -{ - PBRUSHOBJ BrushObj; - DC *dc = DC_LockDc(hDC); - BOOL ret; - - if (NULL == dc) - { + dc = DC_LockDc(hDC); + if (dc == NULL) + { SetLastWin32Error(ERROR_INVALID_HANDLE); return FALSE; - } + } + + for (r = pRects, i = 0; i < cRects; i++) + { + BrushObj = BRUSHOBJ_LockBrush(r->hBrush); + IntPatBlt( + dc, + r->r.left, + r->r.top, + r->r.right, + r->r.bottom, + dwRop, + BrushObj); + BRUSHOBJ_UnlockBrush(r->hBrush); + r++; + } - BrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush); - if (NULL == BrushObj) - { + DC_UnlockDc( hDC ); + + return TRUE; +} + +/* PUBLIC FUNCTIONS ***********************************************************/ + +HBRUSH STDCALL +NtGdiCreateBrushIndirect(CONST LOGBRUSH *LogBrush) +{ + LOGBRUSH SafeLogBrush; + NTSTATUS Status; + + Status = MmCopyFromCaller(&SafeLogBrush, LogBrush, sizeof(LOGBRUSH)); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return 0; + } + + return IntGdiCreateBrushIndirect(&SafeLogBrush); +} + +HBRUSH STDCALL +NtGdiCreateDIBPatternBrush(HGLOBAL hDIBPacked, UINT ColorSpec) +{ + UNIMPLEMENTED; + return 0; +} + +HBRUSH STDCALL +NtGdiCreateDIBPatternBrushPt(CONST VOID *PackedDIB, UINT Usage) +{ + UNIMPLEMENTED; + return 0; +} + +HBRUSH STDCALL +NtGdiCreateHatchBrush(INT Style, COLORREF Color) +{ + LOGBRUSH LogBrush; + + if (Style < 0 || Style >= NB_HATCH_STYLES) + return 0; + + LogBrush.lbStyle = BS_HATCHED; + LogBrush.lbColor = Color; + LogBrush.lbHatch = Style; + + return IntGdiCreateBrushIndirect(&LogBrush); +} + +HBRUSH STDCALL +NtGdiCreatePatternBrush(HBITMAP hBitmap) +{ + LOGBRUSH LogBrush; + + LogBrush.lbStyle = BS_PATTERN; + LogBrush.lbColor = 0; + LogBrush.lbHatch = (ULONG)hBitmap; + + return IntGdiCreateBrushIndirect(&LogBrush); +} + +HBRUSH STDCALL +NtGdiCreateSolidBrush(COLORREF Color) +{ + LOGBRUSH LogBrush; + + LogBrush.lbStyle = BS_SOLID; + LogBrush.lbColor = Color; + LogBrush.lbHatch = 0; + + return IntGdiCreateBrushIndirect(&LogBrush); +} + +BOOL STDCALL +NtGdiFixBrushOrgEx(VOID) +{ + return FALSE; +} + +/* + * NtGdiSetBrushOrgEx + * + * The NtGdiSetBrushOrgEx function sets the brush origin that GDI assigns to + * the next brush an application selects into the specified device context. + * + * Status + * @implemented + */ + +BOOL STDCALL +NtGdiSetBrushOrgEx(HDC hDC, INT XOrg, INT YOrg, LPPOINT Point) +{ + PDC dc = DC_LockDc(hDC); + if (dc == NULL) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + return FALSE; + } + + if (Point != NULL) + { + POINT SafePoint; + SafePoint.x = dc->w.brushOrgX; + SafePoint.y = dc->w.brushOrgY; + MmCopyToCaller(Point, &SafePoint, sizeof(POINT)); + } + + dc->w.brushOrgX = XOrg; + dc->w.brushOrgY = YOrg; + DC_UnlockDc(hDC); + + return TRUE; +} + +BOOL STDCALL +NtGdiPolyPatBlt( + HDC hDC, + DWORD dwRop, + PPATRECT pRects, + INT cRects, + ULONG Reserved) +{ + PPATRECT rb; + NTSTATUS Status; + BOOL Ret; + + if (cRects > 0) + { + rb = ExAllocatePoolWithTag(PagedPool, sizeof(PATRECT) * cRects, TAG_PATBLT); + if (!rb) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + Status = MmCopyFromCaller(rb, pRects, sizeof(PATRECT) * cRects); + if (!NT_SUCCESS(Status)) + { + ExFreePool(rb); + SetLastNtError(Status); + return FALSE; + } + } + + Ret = IntGdiPolyPatBlt(hDC, dwRop, pRects, cRects, Reserved); + + if (cRects > 0) + ExFreePool(rb); + + return Ret; +} + +BOOL STDCALL +NtGdiPatBlt( + HDC hDC, + INT XLeft, + INT YLeft, + INT Width, + INT Height, + DWORD ROP) +{ + PGDIBRUSHOBJ BrushObj; + DC *dc = DC_LockDc(hDC); + BOOL ret; + + if (dc == NULL) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + return FALSE; + } + + BrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush); + if (BrushObj == NULL) + { SetLastWin32Error(ERROR_INVALID_HANDLE); DC_UnlockDc(hDC); return FALSE; - } + } - ret = IntPatBlt(dc,XLeft,YLeft,Width,Height,ROP,BrushObj); + ret = IntPatBlt( + dc, + XLeft, + YLeft, + Width, + Height, + ROP, + BrushObj); - BRUSHOBJ_UnlockBrush(dc->w.hBrush); - DC_UnlockDc(hDC); - return ret; + BRUSHOBJ_UnlockBrush(dc->w.hBrush); + DC_UnlockDc(hDC); + + return ret; } -BOOL STDCALL NtGdiSetBrushOrgEx(HDC hDC, - INT XOrg, - INT YOrg, - LPPOINT Point) -{ - UNIMPLEMENTED; -} /* EOF */ diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index 6733eb45118..c701346e884 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dc.c,v 1.125 2004/03/23 19:46:50 gvg Exp $ +/* $Id: dc.c,v 1.126 2004/04/05 21:26:25 navaraf Exp $ * * DC.C - Device context functions * @@ -995,13 +995,16 @@ NtGdiSetBkColor(HDC hDC, COLORREF color) { COLORREF oldColor; PDC dc = DC_LockDc(hDC); + HBRUSH hBrush; if ( !dc ) return 0x80000000; oldColor = dc->w.backgroundColor; dc->w.backgroundColor = color; + hBrush = dc->w.hBrush; DC_UnlockDc ( hDC ); + NtGdiSelectObject(hDC, hBrush); return oldColor; } @@ -1702,8 +1705,8 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj) HGDIOBJ objOrg = NULL; // default to failure BITMAPOBJ *pb; PDC dc; - PPENOBJ pen; - PBRUSHOBJ brush; + PGDIBRUSHOBJ pen; + PGDIBRUSHOBJ brush; PXLATEOBJ XlateObj; PPALGDI PalGDI; DWORD objectType; @@ -1740,7 +1743,17 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj) pen = PENOBJ_LockPen((HPEN) hGDIObj); if (NULL != pen) { - pen->iSolidColor = XLATEOBJ_iXlate(XlateObj, pen->logpen.lopnColor); + if (pen->flAttrs & GDIBRUSH_IS_SOLID) + { + pen->BrushObject.iSolidColor = + XLATEOBJ_iXlate(XlateObj, pen->BrushAttr.lbColor); + } + else + { + pen->BrushObject.iSolidColor = 0xFFFFFFFF; + } + pen->crBack = XLATEOBJ_iXlate(XlateObj, dc->w.backgroundColor); + pen->crFore = XLATEOBJ_iXlate(XlateObj, dc->w.textColor); PENOBJ_UnlockPen((HPEN) hGDIObj); objOrg = (HGDIOBJ)dc->w.hPen; dc->w.hPen = hGDIObj; @@ -1776,7 +1789,17 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj) brush = BRUSHOBJ_LockBrush((HBRUSH) hGDIObj); if (NULL != brush) { - brush->iSolidColor = XLATEOBJ_iXlate(XlateObj, brush->logbrush.lbColor); + if (brush->flAttrs & GDIBRUSH_IS_SOLID) + { + brush->BrushObject.iSolidColor = + XLATEOBJ_iXlate(XlateObj, brush->BrushAttr.lbColor); + } + else + { + brush->BrushObject.iSolidColor = 0xFFFFFFFF; + } + brush->crBack = XLATEOBJ_iXlate(XlateObj, dc->w.backgroundColor); + brush->crFore = XLATEOBJ_iXlate(XlateObj, dc->w.textColor); BRUSHOBJ_UnlockBrush((HBRUSH) hGDIObj); objOrg = (HGDIOBJ)dc->w.hBrush; dc->w.hBrush = (HBRUSH) hGDIObj; diff --git a/reactos/subsys/win32k/objects/fillshap.c b/reactos/subsys/win32k/objects/fillshap.c index 12dc3e8b5d3..4f63d61b8f5 100644 --- a/reactos/subsys/win32k/objects/fillshap.c +++ b/reactos/subsys/win32k/objects/fillshap.c @@ -16,11 +16,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: fillshap.c,v 1.45 2004/03/27 00:35:02 weiden Exp $ */ +/* $Id: fillshap.c,v 1.46 2004/04/05 21:26:25 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include +#include #include #include #include @@ -46,7 +47,7 @@ #define PUTPIXEL(x,y,brushObj) \ ret = ret && IntEngLineTo(SurfObj, \ dc->CombinedClip, \ - brushObj, \ + &brushObj->BrushObject, \ x, y, (x)+1, y, \ &RectBounds, \ dc->w.ROPmode); @@ -54,7 +55,7 @@ #define PUTLINE(x1,y1,x2,y2,brushObj) \ ret = ret && IntEngLineTo(SurfObj, \ dc->CombinedClip, \ - brushObj, \ + &brushObj->BrushObject, \ x1, y1, x2, y2, \ &RectBounds, \ dc->w.ROPmode); @@ -65,7 +66,7 @@ IntGdiPolygon(PDC dc, int Count) { SURFOBJ *SurfObj; - BRUSHOBJ PenBrushObj, *FillBrushObj; + PGDIBRUSHOBJ PenBrushObj, FillBrushObj; BOOL ret = FALSE; // default to failure PRECTL RectBounds; RECTL DestRect; @@ -113,16 +114,16 @@ IntGdiPolygon(PDC dc, /* Now fill the polygon with the current brush. */ FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush); ASSERT(FillBrushObj); - if ( FillBrushObj->logbrush.lbStyle != BS_NULL ) - ret = FillPolygon ( dc, SurfObj, FillBrushObj, dc->w.ROPmode, UnsafePoints, Count, DestRect ); + if (!(FillBrushObj->flAttrs & GDIBRUSH_IS_NULL)) + ret = FillPolygon ( dc, SurfObj, &FillBrushObj->BrushObject, dc->w.ROPmode, UnsafePoints, Count, DestRect ); BRUSHOBJ_UnlockBrush(dc->w.hBrush); #endif - /* make BRUSHOBJ from current pen. */ - HPenToBrushObj ( &PenBrushObj, dc->w.hPen ); + /* get BRUSHOBJ from current pen. */ + PenBrushObj = PENOBJ_LockPen(dc->w.hPen); // Draw the Polygon Edges with the current pen ( if not a NULL pen ) - if ( PenBrushObj.logbrush.lbStyle != BS_NULL ) + if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL)) { for ( CurrentPoint = 0; CurrentPoint < Count; ++CurrentPoint ) { @@ -141,7 +142,7 @@ IntGdiPolygon(PDC dc, //DPRINT("Polygon Making line from (%d,%d) to (%d,%d)\n", From.x, From.y, To.x, To.y ); ret = IntEngLineTo(SurfObj, dc->CombinedClip, - &PenBrushObj, + &PenBrushObj->BrushObject, From.x, From.y, To.x, @@ -160,6 +161,7 @@ IntGdiPolygon(PDC dc, #endif } + PENOBJ_UnlockPen( dc->w.hPen ); RGNDATA_UnlockRgn(dc->w.hGCClipRgn); return ret; @@ -239,8 +241,7 @@ NtGdiEllipse( int CenterX, CenterY; int RadiusX, RadiusY; int Temp; - BRUSHOBJ PenBrush; - PBRUSHOBJ FillBrush; + PGDIBRUSHOBJ FillBrush, PenBrush; PSURFOBJ SurfObj; RECTL RectBounds; PDC dc; @@ -275,8 +276,16 @@ NtGdiEllipse( return FALSE; } + PenBrush = PENOBJ_LockPen(dc->w.hPen); + if (NULL == PenBrush) + { + PENOBJ_UnlockPen(dc->w.hPen); + DC_UnlockDc(hDC); + SetLastWin32Error(ERROR_INTERNAL_ERROR); + return FALSE; + } + SurfObj = (PSURFOBJ)AccessUserObject((ULONG)dc->Surface); - HPenToBrushObj(&PenBrush, dc->w.hPen); nLeftRect += dc->w.DCOrgX; nRightRect += dc->w.DCOrgX - 1; @@ -370,32 +379,33 @@ NtGdiEllipse( if (Cond1) { - PUTPIXEL(CenterX + C, CenterY + B, &PenBrush); + PUTPIXEL(CenterX + C, CenterY + B, PenBrush); if (C) - PUTPIXEL(CenterX - C, CenterY + B, &PenBrush); + PUTPIXEL(CenterX - C, CenterY + B, PenBrush); if (B) { - PUTPIXEL(CenterX + C, CenterY - B, &PenBrush); + PUTPIXEL(CenterX + C, CenterY - B, PenBrush); if (C) - PUTPIXEL(CenterX - C, CenterY - B, &PenBrush); + PUTPIXEL(CenterX - C, CenterY - B, PenBrush); } } if (Cond2) { - PUTPIXEL(CenterX + D, CenterY + A, &PenBrush); + PUTPIXEL(CenterX + D, CenterY + A, PenBrush); if (D) - PUTPIXEL(CenterX - D, CenterY + A, &PenBrush); + PUTPIXEL(CenterX - D, CenterY + A, PenBrush); if (A) { - PUTPIXEL(CenterX + D, CenterY - A, &PenBrush); + PUTPIXEL(CenterX + D, CenterY - A, PenBrush); if (D) - PUTPIXEL(CenterX - D, CenterY - A, &PenBrush); + PUTPIXEL(CenterX - D, CenterY - A, PenBrush); } } } while (B > A); BRUSHOBJ_UnlockBrush(dc->w.hBrush); + PENOBJ_UnlockPen(dc->w.hPen); DC_UnlockDc(hDC); return ret; @@ -945,7 +955,7 @@ IntRectangle(PDC dc, int BottomRect) { SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface); - BRUSHOBJ PenBrushObj, *FillBrushObj; + PGDIBRUSHOBJ PenBrushObj, FillBrushObj; BOOL ret = FALSE; // default to failure RECTL DestRect; @@ -971,7 +981,7 @@ IntRectangle(PDC dc, if ( FillBrushObj ) { - if ( FillBrushObj->logbrush.lbStyle != BS_NULL ) + if (!(FillBrushObj->flAttrs & GDIBRUSH_IS_NULL)) { ret = IntEngBitBlt(SurfObj, NULL, @@ -981,7 +991,7 @@ IntRectangle(PDC dc, &DestRect, NULL, NULL, - FillBrushObj, + &FillBrushObj->BrushObject, NULL, PATCOPY); } @@ -989,43 +999,50 @@ IntRectangle(PDC dc, BRUSHOBJ_UnlockBrush(dc->w.hBrush); - /* make BRUSHOBJ from current pen. */ - HPenToBrushObj ( &PenBrushObj, dc->w.hPen ); + /* get BRUSHOBJ from current pen. */ + PenBrushObj = PENOBJ_LockPen(dc->w.hPen); + if (PenBrushObj == NULL) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + return FALSE; + } // Draw the rectangle with the current pen ret = TRUE; // change default to success - if ( PenBrushObj.logbrush.lbStyle != BS_NULL ) + if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL)) { ret = ret && IntEngLineTo(SurfObj, dc->CombinedClip, - &PenBrushObj, + &PenBrushObj->BrushObject, LeftRect, TopRect, RightRect, TopRect, &DestRect, // Bounding rectangle dc->w.ROPmode); // MIX ret = ret && IntEngLineTo(SurfObj, dc->CombinedClip, - &PenBrushObj, + &PenBrushObj->BrushObject, RightRect, TopRect, RightRect, BottomRect, &DestRect, // Bounding rectangle dc->w.ROPmode); // MIX ret = ret && IntEngLineTo(SurfObj, dc->CombinedClip, - &PenBrushObj, + &PenBrushObj->BrushObject, RightRect, BottomRect, LeftRect, BottomRect, &DestRect, // Bounding rectangle dc->w.ROPmode); // MIX ret = ret && IntEngLineTo(SurfObj, dc->CombinedClip, - &PenBrushObj, + &PenBrushObj->BrushObject, LeftRect, BottomRect, LeftRect, TopRect, &DestRect, // Bounding rectangle dc->w.ROPmode); // MIX */ } + + PENOBJ_UnlockPen(dc->w.hPen); } /* Move current position in DC? @@ -1071,7 +1088,7 @@ IntRoundRect( int yCurveDiameter) { SURFOBJ *SurfObj; - BRUSHOBJ PenBrush, *PenBrushObj, *FillBrushObj; + PGDIBRUSHOBJ PenBrushObj, FillBrushObj; RECTL RectBounds; int i, col, row, width, height, x1, x1start, x2, x2start, y1, y2; int xradius, yradius; @@ -1106,14 +1123,19 @@ IntRoundRect( FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush); ASSERT(FillBrushObj); - if ( FillBrushObj->logbrush.lbStyle == BS_NULL ) + if (FillBrushObj->flAttrs & GDIBRUSH_IS_NULL) + { + BRUSHOBJ_UnlockBrush(dc->w.hBrush); FillBrushObj = NULL; // make null brush check simpler... + } - HPenToBrushObj ( &PenBrush, dc->w.hPen ); - if ( PenBrush.logbrush.lbStyle != BS_NULL ) - PenBrushObj = &PenBrush; - else + PenBrushObj = PENOBJ_LockPen(dc->w.hPen); + ASSERT(PenBrushObj); + if (PenBrushObj->flAttrs & GDIBRUSH_IS_NULL) + { + PENOBJ_UnlockPen(dc->w.hPen); PenBrushObj = NULL; + } right--; bottom--; @@ -1292,6 +1314,7 @@ IntRoundRect( PUTLINE ( left, y2, left, y1, PenBrushObj ); } + PENOBJ_UnlockPen(dc->w.hPen); BRUSHOBJ_UnlockBrush(dc->w.hBrush); return ret; diff --git a/reactos/subsys/win32k/objects/gdiobj.c b/reactos/subsys/win32k/objects/gdiobj.c index a20bbcd68b9..07a2260dfac 100644 --- a/reactos/subsys/win32k/objects/gdiobj.c +++ b/reactos/subsys/win32k/objects/gdiobj.c @@ -19,7 +19,7 @@ /* * GDIOBJ.C - GDI object manipulation routines * - * $Id: gdiobj.c,v 1.64 2004/04/03 20:33:39 gvg Exp $ + * $Id: gdiobj.c,v 1.65 2004/04/05 21:26:25 navaraf Exp $ * */ @@ -110,8 +110,8 @@ GDI_OBJ_SIZE ObjSizes[] = {GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAPOBJ)}, {GDI_OBJECT_TYPE_DC, sizeof(DC)}, {GDI_OBJECT_TYPE_PALETTE, sizeof(PALGDI)}, - {GDI_OBJECT_TYPE_BRUSH, sizeof(BRUSHOBJ)}, - {GDI_OBJECT_TYPE_PEN, sizeof(PENOBJ)}, + {GDI_OBJECT_TYPE_BRUSH, sizeof(GDIBRUSHOBJ)}, + {GDI_OBJECT_TYPE_PEN, sizeof(GDIBRUSHOBJ)}, {GDI_OBJECT_TYPE_FONT, sizeof(TEXTOBJ)}, {GDI_OBJECT_TYPE_DCE, sizeof(DCE)}, /* diff --git a/reactos/subsys/win32k/objects/line.c b/reactos/subsys/win32k/objects/line.c index 2048e216308..ae45f631531 100644 --- a/reactos/subsys/win32k/objects/line.c +++ b/reactos/subsys/win32k/objects/line.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: line.c,v 1.27 2004/02/19 21:12:10 weiden Exp $ */ +/* $Id: line.c,v 1.28 2004/04/05 21:26:25 navaraf Exp $ */ // Some code from the WINE project source (www.winehq.com) @@ -71,7 +71,7 @@ IntGdiLineTo(DC *dc, { SURFOBJ *SurfObj; BOOL Ret; - BRUSHOBJ PenBrushObj; + PGDIBRUSHOBJ PenBrushObj; RECT Bounds; SurfObj = (SURFOBJ*)AccessUserObject ( (ULONG)dc->Surface ); @@ -119,16 +119,22 @@ IntGdiLineTo(DC *dc, Bounds.top += dc->w.DCOrgY; Bounds.bottom += dc->w.DCOrgY; - /* make BRUSHOBJ from current pen. */ - HPenToBrushObj ( &PenBrushObj, dc->w.hPen ); + /* get BRUSHOBJ from current pen. */ + PenBrushObj = PENOBJ_LockPen( dc->w.hPen ); + ASSERT(PenBrushObj); - Ret = IntEngLineTo(SurfObj, - dc->CombinedClip, - &PenBrushObj, - dc->w.DCOrgX + dc->w.CursPosX, dc->w.DCOrgY + dc->w.CursPosY, - dc->w.DCOrgX + XEnd, dc->w.DCOrgY + YEnd, - &Bounds, - dc->w.ROPmode); + if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL)) + { + Ret = IntEngLineTo(SurfObj, + dc->CombinedClip, + &PenBrushObj->BrushObject, + dc->w.DCOrgX + dc->w.CursPosX, dc->w.DCOrgY + dc->w.CursPosY, + dc->w.DCOrgX + XEnd, dc->w.DCOrgY + YEnd, + &Bounds, + dc->w.ROPmode); + } + + PENOBJ_UnlockPen( dc->w.hPen ); } if (Ret) @@ -209,7 +215,7 @@ IntGdiPolyline(DC *dc, BOOL ret = FALSE; // default to failure LONG i; PROSRGNDATA reg; - BRUSHOBJ PenBrushObj; + PGDIBRUSHOBJ PenBrushObj; POINT *pts; SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface); @@ -236,16 +242,22 @@ IntGdiPolyline(DC *dc, pts[i].y += dc->w.DCOrgY; } - /* make BRUSHOBJ from current pen. */ - HPenToBrushObj ( &PenBrushObj, dc->w.hPen ); + /* get BRUSHOBJ from current pen. */ + PenBrushObj = PENOBJ_LockPen( dc->w.hPen ); + ASSERT(PenBrushObj); - //get IntEngPolyline to do the drawing. - ret = IntEngPolyline(SurfObj, - dc->CombinedClip, - &PenBrushObj, - pts, - Count, - dc->w.ROPmode); + if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL)) + { + //get IntEngPolyline to do the drawing. + ret = IntEngPolyline(SurfObj, + dc->CombinedClip, + &PenBrushObj->BrushObject, + pts, + Count, + dc->w.ROPmode); + } + + PENOBJ_UnlockPen( dc->w.hPen ); } ExFreePool ( pts ); diff --git a/reactos/subsys/win32k/objects/objconv.c b/reactos/subsys/win32k/objects/objconv.c index c5d08647935..4858e3c2d00 100644 --- a/reactos/subsys/win32k/objects/objconv.c +++ b/reactos/subsys/win32k/objects/objconv.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: objconv.c,v 1.15 2004/02/01 15:45:41 gvg Exp $ */ +/* $Id: objconv.c,v 1.16 2004/04/05 21:26:25 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include @@ -38,35 +38,6 @@ //#define NDEBUG #include - -BRUSHOBJ* -FASTCALL -PenToBrushObj ( BRUSHOBJ *brush, PENOBJ *pen ) -{ - ASSERT ( pen ); - ASSERT ( brush ); - memset ( brush, 0, sizeof(BRUSHOBJ) ); - if ( pen->logpen.lopnStyle == PS_NULL ) - brush->logbrush.lbStyle = BS_NULL; - else - brush->iSolidColor = pen->iSolidColor; - return brush; -} - -BRUSHOBJ* -FASTCALL -HPenToBrushObj ( BRUSHOBJ *brush, HPEN hpen ) -{ - PENOBJ *pen; - ASSERT ( hpen ); - ASSERT ( brush ); - pen = PENOBJ_LockPen(hpen); - ASSERT ( pen ); - PenToBrushObj ( brush, pen ); - PENOBJ_UnlockPen(hpen); - return brush; -} - HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice) { HBITMAP BitmapHandle; @@ -87,11 +58,12 @@ HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice) BitmapFormat(BitmapObj->bitmap.bmBitsPixel, BI_RGB), 0, BitmapObj->bitmap.bmBits); } - if (NULL != BitmapHandle) + if (NULL != BitmapHandle && NULL != GDIDevice) { EngAssociateSurface(BitmapHandle, GDIDevice, 0); } return BitmapHandle; } + /* EOF */ diff --git a/reactos/subsys/win32k/objects/path.c b/reactos/subsys/win32k/objects/path.c index 87516286efb..6e76b9ae936 100644 --- a/reactos/subsys/win32k/objects/path.c +++ b/reactos/subsys/win32k/objects/path.c @@ -16,10 +16,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: path.c,v 1.18 2004/02/19 21:12:10 weiden Exp $ */ +/* $Id: path.c,v 1.19 2004/04/05 21:26:25 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include +#include #include #include #include diff --git a/reactos/subsys/win32k/objects/pen.c b/reactos/subsys/win32k/objects/pen.c index 71a7eba3fdd..72801cf1b03 100644 --- a/reactos/subsys/win32k/objects/pen.c +++ b/reactos/subsys/win32k/objects/pen.c @@ -1,95 +1,129 @@ /* - * ReactOS W32 Subsystem - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team + * ReactOS Win32 Subsystem * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Copyright (C) 1998 - 2004 ReactOS Team * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: pen.c,v 1.14 2004/04/05 21:26:25 navaraf Exp $ */ -/* $Id: pen.c,v 1.13 2003/12/12 15:47:37 weiden Exp $ */ + #undef WIN32_LEAN_AND_MEAN #include #include +#include #include +#include #include #include - #define NDEBUG #include +/* PRIVATE FUNCTIONS **********************************************************/ + HPEN FASTCALL -IntGdiCreatePenIndirect(PLOGPEN lgpn) +IntGdiCreatePenIndirect(PLOGPEN LogPen) { - HPEN hpen; - PPENOBJ penPtr; + HPEN hPen; + PGDIBRUSHOBJ PenObject; + static const WORD wPatternAlternate[] = {0x5555}; - if (lgpn->lopnStyle > PS_INSIDEFRAME) return 0; + if (LogPen->lopnStyle > PS_INSIDEFRAME) + return 0; - hpen = PENOBJ_AllocPen(); - if (!hpen) return 0; + hPen = PENOBJ_AllocPen(); + if (!hPen) + { + SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); + DPRINT("Can't allocate pen\n"); + return 0; + } - penPtr = PENOBJ_LockPen( hpen ); - ASSERT( penPtr ); + PenObject = PENOBJ_LockPen(hPen); + PenObject->ptPenWidth = LogPen->lopnWidth; + PenObject->ulPenStyle = LogPen->lopnStyle; + PenObject->BrushAttr.lbColor = LogPen->lopnColor; + PenObject->BrushObject.iSolidColor = LogPen->lopnColor; + PenObject->flAttrs = GDIBRUSH_IS_OLDSTYLEPEN; + switch (LogPen->lopnStyle) + { + case PS_NULL: + PenObject->flAttrs |= GDIBRUSH_IS_NULL; + break; - penPtr->logpen.lopnStyle = lgpn->lopnStyle; - penPtr->logpen.lopnWidth = lgpn->lopnWidth; - penPtr->logpen.lopnColor = lgpn->lopnColor; - PENOBJ_UnlockPen( hpen ); + case PS_SOLID: + PenObject->flAttrs |= GDIBRUSH_IS_SOLID; + break; + + case PS_ALTERNATE: + PenObject->flAttrs |= GDIBRUSH_IS_BITMAP; + PenObject->hbmPattern = NtGdiCreateBitmap(8, 1, 1, 1, wPatternAlternate); + break; + + default: + UNIMPLEMENTED; + } + + PENOBJ_UnlockPen(hPen); - return hpen; + return hPen; } -/******************************************************************************/ +/* PUBLIC FUNCTIONS ***********************************************************/ -HPEN -STDCALL -NtGdiCreatePen(INT PenStyle, INT Width, COLORREF Color) +HPEN STDCALL +NtGdiCreatePen( + INT PenStyle, + INT Width, + COLORREF Color) { - LOGPEN logpen; + LOGPEN LogPen; - logpen.lopnStyle = PenStyle; - logpen.lopnWidth.x = Width; - logpen.lopnWidth.y = 0; - logpen.lopnColor = Color; + LogPen.lopnStyle = PenStyle; + LogPen.lopnWidth.x = Width; + LogPen.lopnWidth.y = 0; + LogPen.lopnColor = Color; - return IntGdiCreatePenIndirect(&logpen); + return IntGdiCreatePenIndirect(&LogPen); } -HPEN -STDCALL -NtGdiCreatePenIndirect(CONST PLOGPEN lgpn) +HPEN STDCALL +NtGdiCreatePenIndirect(CONST PLOGPEN LogPen) { - LOGPEN Safelgpn; - NTSTATUS Status; + LOGPEN SafeLogPen; + NTSTATUS Status; - Status = MmCopyFromCaller(&Safelgpn, lgpn, sizeof(LOGPEN)); - if(!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - return 0; - } + Status = MmCopyFromCaller(&SafeLogPen, LogPen, sizeof(LOGPEN)); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return 0; + } - return IntGdiCreatePenIndirect(&Safelgpn); + return IntGdiCreatePenIndirect(&SafeLogPen); } -HPEN -STDCALL -NtGdiExtCreatePen(DWORD PenStyle, - DWORD Width, - CONST PLOGBRUSH lb, - DWORD StyleCount, - CONST PDWORD Style) +HPEN STDCALL +NtGdiExtCreatePen( + DWORD PenStyle, + DWORD Width, + CONST PLOGBRUSH LogBrush, + DWORD StyleCount, + CONST PDWORD Style) { - UNIMPLEMENTED; + UNIMPLEMENTED; } + /* EOF */ diff --git a/reactos/subsys/win32k/objects/region.c b/reactos/subsys/win32k/objects/region.c index ea820837e1f..e82bd3e85f0 100644 --- a/reactos/subsys/win32k/objects/region.c +++ b/reactos/subsys/win32k/objects/region.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: region.c,v 1.46 2004/04/03 20:36:56 gvg Exp $ */ +/* $Id: region.c,v 1.47 2004/04/05 21:26:25 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -2005,7 +2005,7 @@ NtGdiPaintRgn(HDC hDC, PROSRGNDATA visrgn; CLIPOBJ* ClipRegion; BOOL bRet = FALSE; - PBRUSHOBJ pBrush; + PGDIBRUSHOBJ pBrush; POINTL BrushOrigin; SURFOBJ *SurfObj; @@ -2048,7 +2048,7 @@ NtGdiPaintRgn(HDC hDC, bRet = IntEngPaint(SurfObj, ClipRegion, - pBrush, + &pBrush->BrushObject, &BrushOrigin, 0xFFFF);//FIXME:don't know what to put here diff --git a/reactos/subsys/win32k/objects/text.c b/reactos/subsys/win32k/objects/text.c index f8031fb2987..437c9073025 100644 --- a/reactos/subsys/win32k/objects/text.c +++ b/reactos/subsys/win32k/objects/text.c @@ -22,12 +22,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: text.c,v 1.87 2004/04/04 15:28:43 gvg Exp $ */ +/* $Id: text.c,v 1.88 2004/04/05 21:26:25 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include +#include #include #include #include @@ -1493,9 +1494,9 @@ NtGdiExtTextOut( RECTL DestRect, MaskRect; POINTL SourcePoint, BrushOrigin; HBRUSH hBrushFg = NULL; - PBRUSHOBJ BrushFg = NULL; + PGDIBRUSHOBJ BrushFg = NULL; HBRUSH hBrushBg = NULL; - PBRUSHOBJ BrushBg = NULL; + PGDIBRUSHOBJ BrushBg = NULL; HBITMAP HSourceGlyph; PSURFOBJ SourceGlyphSurf; SIZEL bitSize; @@ -1638,7 +1639,7 @@ NtGdiExtTextOut( &DestRect, &SourcePoint, &SourcePoint, - BrushBg, + &BrushBg->BrushObject, &BrushOrigin, PATCOPY); fuOptions &= ~ETO_OPAQUE; @@ -1799,7 +1800,7 @@ NtGdiExtTextOut( &DestRect, &SourcePoint, &SourcePoint, - BrushBg, + &BrushBg->BrushObject, &BrushOrigin, PATCOPY); BackgroundLeft = DestRect.right; @@ -1838,7 +1839,7 @@ NtGdiExtTextOut( &DestRect, &SourcePoint, (PPOINTL)&MaskRect, - BrushFg, + &BrushFg->BrushObject, &BrushOrigin); EngDeleteSurface(HSourceGlyph); @@ -2578,6 +2579,7 @@ NtGdiSetTextColor(HDC hDC, { COLORREF oldColor; PDC dc = DC_LockDc(hDC); + HBRUSH hBrush; if (!dc) { @@ -2586,7 +2588,9 @@ NtGdiSetTextColor(HDC hDC, oldColor = dc->w.textColor; dc->w.textColor = color; + hBrush = dc->w.hBrush; DC_UnlockDc( hDC ); + NtGdiSelectObject(hDC, hBrush); return oldColor; }