- Changed the internal brush object to be (almost) Win32k compatible.

- Changed Pen implementation to use brushes internally.
- Added support for pattern brushes.
- Fixed 8bpp StretchBlt.
- Fixed 4bpp to 4bpp non-SRCCOPY blits.
- Fixed 1bpp to 1bpp non-SRCCOPY blits to work when the destination doesn't
  start at exact byte.
- Reenabled 55AA brush for scrollbar.
- Fixed BITMAPOBJ_GetWidthBits to do WORD alignment and not DWORD.

svn path=/trunk/; revision=8981
This commit is contained in:
Filip Navara 2004-04-05 21:26:25 +00:00
parent beedced608
commit ba87a9d7a1
22 changed files with 1533 additions and 993 deletions

View file

@ -3,90 +3,136 @@
#include <win32k/gdiobj.h> #include <win32k/gdiobj.h>
/* Internal interface */ /* Internal interface */
#define NB_HATCH_STYLES 6 #define NB_HATCH_STYLES 6
#define BRUSHOBJ_AllocBrush() \ /*
((HBRUSH) GDIOBJ_AllocObj (sizeof (BRUSHOBJ), GDI_OBJECT_TYPE_BRUSH, NULL)) * The layout of this structure is taken from "Windows Graphics Programming"
#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH, GDIOBJFLAG_DEFAULT) * book written by Feng Yuan.
#define BRUSHOBJ_LockBrush(hBrush) ((PBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)) *
* 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) #define BRUSHOBJ_UnlockBrush(hBrush) GDIOBJ_UnlockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)
HBRUSH HBRUSH STDCALL
STDCALL NtGdiCreateBrushIndirect(
NtGdiCreateBrushIndirect ( CONST LOGBRUSH *LogBrush);
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
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

View file

@ -1,35 +1,32 @@
#ifndef __WIN32K_PEN_H #ifndef __WIN32K_PEN_H
#define __WIN32K_PEN_H #define __WIN32K_PEN_H
#include <win32k/gdiobj.h> #include <win32k/gdiobj.h>
#include <win32k/brush.h>
/* GDI logical pen object */ /* Internal interface */
typedef struct
{
LOGPEN logpen;
ULONG iSolidColor;
} PENOBJ, *PPENOBJ;
/* 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 STDCALL
((HPEN) GDIOBJ_AllocObj (sizeof (PENOBJ), GDI_OBJECT_TYPE_PEN, NULL)) NtGdiCreatePen(
#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN, GDIOBJFLAG_DEFAULT) INT PenStyle,
#define PENOBJ_LockPen(hBMObj) ((PPENOBJ)GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)) INT Width,
#define PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN) COLORREF Color);
HPEN STDCALL NtGdiCreatePen(INT PenStyle, HPEN STDCALL
INT Width, NtGdiCreatePenIndirect(
COLORREF Color); CONST PLOGPEN LogBrush);
HPEN STDCALL NtGdiCreatePenIndirect(CONST PLOGPEN lgpn); HPEN STDCALL
NtGdiExtCreatePen(
HPEN STDCALL NtGdiExtCreatePen(DWORD PenStyle, DWORD PenStyle,
DWORD Width, DWORD Width,
CONST PLOGBRUSH lb, CONST PLOGBRUSH LogBrush,
DWORD StyleCount, DWORD StyleCount,
CONST PDWORD Style); CONST PDWORD Style);
#endif #endif

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
@ -902,7 +902,6 @@ DefWndHandleWindowPosChanged(HWND hWnd, WINDOWPOS* Pos)
HBRUSH HBRUSH
DefWndControlColor(HDC hDC, UINT ctlType) DefWndControlColor(HDC hDC, UINT ctlType)
{ {
#if 0 /* FIXME: Re-enable when pattern brushes are implemented */
if (CTLCOLOR_SCROLLBAR == ctlType) if (CTLCOLOR_SCROLLBAR == ctlType)
{ {
HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR); HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
@ -933,7 +932,6 @@ DefWndControlColor(HDC hDC, UINT ctlType)
UnrealizeObject(hb); UnrealizeObject(hb);
return hb; return hb;
} }
#endif
SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));

View file

@ -16,15 +16,17 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <win32k/bitmaps.h>
#include <win32k/debug.h>
#include <debug.h> #include <debug.h>
#include <ddk/winddi.h> #include <ddk/winddi.h>
#include <win32k/bitmaps.h>
#include <win32k/brush.h>
#include <win32k/debug.h>
#include <include/object.h>
#include "../eng/objects.h" #include "../eng/objects.h"
#include "dib.h" #include "dib.h"
@ -279,64 +281,128 @@ DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PBRUSHOBJ Brush, PPOINTL BrushOrigin, PBRUSHOBJ Brush, PPOINTL BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Rop4) XLATEOBJ *ColorTranslation, ULONG Rop4)
{ {
LONG i, j, sx, sy; ULONG X, Y;
ULONG Dest, Source, Pattern; ULONG SourceX, SourceY;
PULONG DestBits; ULONG Dest, Source, Pattern = 0;
BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); PULONG DestBits;
BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); BOOL UsesSource;
LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x1); BOOL UsesPattern;
LONG RoundedRight;
/* Pattern brushes */
PGDIBRUSHOBJ GdiBrush;
HBITMAP PatternSurface = NULL;
PSURFOBJ PatternObj;
ULONG PatternWidth, PatternHeight;
if (Rop4 == SRCCOPY) if (Rop4 == SRCCOPY)
{ {
return(DIB_16BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); return DIB_16BPP_BitBltSrcCopy(
} DestSurf,
else SourceSurf,
{ DestGDI,
sy = SourcePoint->y; 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; UsesPattern = FALSE;
DestBits = (PULONG)(DestSurf->pvScan0 + 2 * DestRect->left + j * DestSurf->lDelta); } else
for (i=DestRect->left; i<RoundedRight; i+=2, DestBits++) if (Brush->iSolidColor == 0xFFFFFFFF)
{ {
Dest = *DestBits; PBITMAPOBJ PatternBitmap;
if (UsesSource)
{ GdiBrush = CONTAINING_RECORD(
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); Brush,
Source |= DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + 1, sy, ColorTranslation) << 16; GDIBRUSHOBJ,
} BrushObject);
if (UsesPattern)
{ PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
/* FIXME: No support for pattern brushes. */ PatternSurface = BitmapToSurf(PatternBitmap, NULL);
Pattern = (Brush->iSolidColor & 0xFFFF) | BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
((Brush->iSolidColor & 0xFFFF) << 16);
} PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
*DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); PatternWidth = PatternObj->sizlBitmap.cx;
} PatternHeight = PatternObj->sizlBitmap.cy;
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++;
} }
} }
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;
} }

View file

@ -16,13 +16,15 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
#include <win32k/bitmaps.h> #include <win32k/bitmaps.h>
#include <win32k/brush.h>
#include <win32k/debug.h> #include <win32k/debug.h>
#include <include/object.h>
#include <debug.h> #include <debug.h>
#include <ddk/winddi.h> #include <ddk/winddi.h>
#include "../eng/objects.h" #include "../eng/objects.h"
@ -351,68 +353,175 @@ DIB_1BPP_BitBlt(
PBRUSHOBJ Brush, PPOINTL BrushOrigin, PBRUSHOBJ Brush, PPOINTL BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Rop4) XLATEOBJ *ColorTranslation, ULONG Rop4)
{ {
LONG i, j, k, sx, sy; ULONG X, Y, SourceX, SourceY, k;
ULONG Dest, Source, Pattern; ULONG Dest, Source, Pattern;
PULONG DestBits; PULONG DestBits;
BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); BOOL UsesSource;
BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); BOOL UsesPattern;
LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7); LONG RoundedRight;
BYTE NoBits;
/* Pattern brushes */
PGDIBRUSHOBJ GdiBrush;
HBITMAP PatternSurface = NULL;
PSURFOBJ PatternObj;
ULONG PatternWidth, PatternHeight;
if (Rop4 == SRCCOPY) if (Rop4 == SRCCOPY)
{ {
return(DIB_1BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); return DIB_1BPP_BitBltSrcCopy(
} DestSurf,
else SourceSurf,
{ DestGDI,
sy = SourcePoint->y; SourceGDI,
DestRect,
SourcePoint,
ColorTranslation);
}
for (j=DestRect->top; j<DestRect->bottom; j++) if (UsesPattern)
{ {
sx = SourcePoint->x; if (Brush == NULL)
DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left>>3) + j * DestSurf->lDelta); {
for (i=DestRect->left; i<RoundedRight; i+=32, DestBits++) UsesPattern = FALSE;
{ } else
Dest = *DestBits; if (Brush->iSolidColor == 0xFFFFFFFF)
if (UsesSource) {
{ PBITMAPOBJ PatternBitmap;
Source = 0;
for (k = 0; k < 8; k++) GdiBrush = CONTAINING_RECORD(
{ Brush,
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (7 - k)); GDIBRUSHOBJ,
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k + 8, sy, ColorTranslation) << (8 + (7 - k))); BrushObject);
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))); PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
} PatternSurface = BitmapToSurf(PatternBitmap, NULL);
} BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
if (UsesPattern)
{ PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
/* FIXME: No support for pattern brushes. */ PatternWidth = PatternObj->sizlBitmap.cx;
Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000; PatternHeight = PatternObj->sizlBitmap.cy;
} }
*DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); }
}
if (i < DestRect->right) UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
{ UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);
Dest = *DestBits; RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7);
for (; i < DestRect->right; i++) SourceY = SourcePoint->y;
{
if (UsesSource) for (Y = DestRect->top; Y < DestRect->bottom; Y++)
{ {
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); SourceX = SourcePoint->x;
} DestBits = (PULONG)(
if (UsesPattern) DestSurf->pvScan0 +
{ (DestRect->left >> 3) +
/* FIXME: No support for pattern brushes. */ Y * DestSurf->lDelta);
Pattern = Brush->iSolidColor ? 0xFFFFFFFF : 0x00000000;
} X = DestRect->left;
DIB_1BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF); if (X & 7)
Dest >>= 1; {
} Dest = *((PBYTE)DestBits);
} NoBits = 7 - (X & 7);
sy++;
} if (UsesSource)
} {
return TRUE; 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 BOOLEAN

View file

@ -16,13 +16,15 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
#include <win32k/bitmaps.h> #include <win32k/bitmaps.h>
#include <win32k/brush.h>
#include <win32k/debug.h> #include <win32k/debug.h>
#include <debug.h> #include <debug.h>
#include <include/object.h>
#include <ddk/winddi.h> #include <ddk/winddi.h>
#include "../eng/objects.h" #include "../eng/objects.h"
#include "dib.h" #include "dib.h"
@ -251,44 +253,102 @@ DIB_24BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PBRUSHOBJ Brush, PPOINTL BrushOrigin, PBRUSHOBJ Brush, PPOINTL BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Rop4) XLATEOBJ *ColorTranslation, ULONG Rop4)
{ {
LONG i, j, sx, sy; ULONG X, Y;
ULONG Dest, Source, Pattern; ULONG SourceX, SourceY;
PBYTE DestBits; ULONG Dest, Source, Pattern;
BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); PBYTE DestBits;
BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); BOOL UsesSource;
BOOL UsesPattern;
/* Pattern brushes */
PGDIBRUSHOBJ GdiBrush;
HBITMAP PatternSurface = NULL;
PSURFOBJ PatternObj;
ULONG PatternWidth, PatternHeight;
if (Rop4 == SRCCOPY) if (Rop4 == SRCCOPY)
{ {
return(DIB_24BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); return DIB_24BPP_BitBltSrcCopy(
} DestSurf,
else SourceSurf,
{ DestGDI,
sy = SourcePoint->y; 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; UsesPattern = FALSE;
DestBits = (PBYTE)(DestSurf->pvScan0 + 3 * DestRect->left + j * DestSurf->lDelta); } else
for (i=DestRect->left; i<DestRect->right; i++, DestBits+=3) if (Brush->iSolidColor == 0xFFFFFFFF)
{ {
Dest = *(PUSHORT)(DestBits) + (*(DestBits + 2) << 16); PBITMAPOBJ PatternBitmap;
if (UsesSource)
{ GdiBrush = CONTAINING_RECORD(
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation) & 0x00ffffff; Brush,
} GDIBRUSHOBJ,
if (UsesPattern) BrushObject);
{
/* FIXME: No support for pattern brushes. */ PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
Pattern = Brush->iSolidColor; PatternSurface = BitmapToSurf(PatternBitmap, NULL);
} BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
Dest = DIB_DoRop(Rop4, Dest, Source, Pattern);
*(PUSHORT)(DestBits) = Dest & 0xFFFF; PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
*(DestBits + 2) = Dest >> 16; PatternWidth = PatternObj->sizlBitmap.cx;
} PatternHeight = PatternObj->sizlBitmap.cy;
sy++;
} }
} }
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, BOOLEAN DIB_24BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,

View file

@ -16,14 +16,16 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
#include <win32k/bitmaps.h> #include <win32k/bitmaps.h>
#include <win32k/brush.h>
#include <win32k/debug.h> #include <win32k/debug.h>
#include <debug.h> #include <debug.h>
#include <ddk/winddi.h> #include <ddk/winddi.h>
#include <include/object.h>
#include "../eng/objects.h" #include "../eng/objects.h"
#include "dib.h" #include "dib.h"
@ -300,42 +302,103 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PBRUSHOBJ Brush, PPOINTL BrushOrigin, PBRUSHOBJ Brush, PPOINTL BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Rop4) XLATEOBJ *ColorTranslation, ULONG Rop4)
{ {
LONG i, j, sx, sy; ULONG X, Y;
ULONG Dest, Source, Pattern; ULONG SourceX, SourceY;
PULONG DestBits; ULONG Dest, Source, Pattern;
BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); PULONG DestBits;
BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); BOOL UsesSource;
BOOL UsesPattern;
/* Pattern brushes */
PGDIBRUSHOBJ GdiBrush;
HBITMAP PatternSurface = NULL;
PSURFOBJ PatternObj;
ULONG PatternWidth, PatternHeight;
if (Rop4 == SRCCOPY) if (Rop4 == SRCCOPY)
{ {
return(DIB_32BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); return DIB_32BPP_BitBltSrcCopy(
} DestSurf,
else SourceSurf,
{ DestGDI,
sy = SourcePoint->y; 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; UsesPattern = FALSE;
DestBits = (PULONG)(DestSurf->pvScan0 + 4 * DestRect->left + j * DestSurf->lDelta); } else
for (i=DestRect->left; i<DestRect->right; i++, DestBits++) if (Brush->iSolidColor == 0xFFFFFFFF)
{ {
Dest = *DestBits; PBITMAPOBJ PatternBitmap;
if (UsesSource)
{ GdiBrush = CONTAINING_RECORD(
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); Brush,
} GDIBRUSHOBJ,
if (UsesPattern) BrushObject);
{
/* FIXME: No support for pattern brushes. */ PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
Pattern = Brush->iSolidColor; PatternSurface = BitmapToSurf(PatternBitmap, NULL);
} BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
*DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);
} PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
sy++; 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;
} }
/* /*

View file

@ -16,13 +16,15 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
#include <win32k/bitmaps.h> #include <win32k/bitmaps.h>
#include <win32k/brush.h>
#include <win32k/debug.h> #include <win32k/debug.h>
#include <debug.h> #include <debug.h>
#include <include/object.h>
#include <ddk/winddi.h> #include <ddk/winddi.h>
#include "../eng/objects.h" #include "../eng/objects.h"
#include "dib.h" #include "dib.h"
@ -30,18 +32,15 @@
VOID VOID
DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c) DIB_4BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
{ {
PBYTE addr = SurfObj->pvScan0; PBYTE addr = SurfObj->pvScan0 + (x>>1) + y * SurfObj->lDelta;
*addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2));
addr += (x>>1) + y * SurfObj->lDelta;
*addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2));
} }
ULONG ULONG
DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y) DIB_4BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
{ {
PBYTE addr = SurfObj->pvScan0; PBYTE addr = SurfObj->pvScan0 + (x>>1) + y * SurfObj->lDelta;
return (*addr >> ((1-(x&1))<<2)) & 0x0f;
return (addr[(x>>1) + y * SurfObj->lDelta] >> ((1-(x&1))<<2) ) & 0x0f;
} }
VOID VOID
@ -141,8 +140,8 @@ DIB_4BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
for (i=DestRect->left; i<DestRect->right; i++) for (i=DestRect->left; i<DestRect->right; i++)
{ {
*DestLine = (*DestLine & notmask[i&1]) | *DestLine = (*DestLine & notmask[f2]) |
((XLATEOBJ_iXlate(ColorTranslation, *SourceLine_8BPP)) << ((4 * (1-(i & 1))))); ((XLATEOBJ_iXlate(ColorTranslation, *SourceLine_8BPP)) << ((4 * (1 - f2))));
if(f2 == 1) { DestLine++; f2 = 0; } else { f2 = 1; } if(f2 == 1) { DestLine++; f2 = 0; } else { f2 = 1; }
SourceLine_8BPP++; SourceLine_8BPP++;
} }
@ -165,8 +164,8 @@ DIB_4BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
for (i = DestRect->left; i < DestRect->right; i++) for (i = DestRect->left; i < DestRect->right; i++)
{ {
xColor = *((PWORD) SourceBits); xColor = *((PWORD) SourceBits);
*DestBits = (*DestBits & notmask[i&1]) | *DestBits = (*DestBits & notmask[f2]) |
((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1-(i & 1))))); ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1 - f2))));
if(f2 == 1) { DestBits++; f2 = 0; } else { f2 = 1; } if(f2 == 1) { DestBits++; f2 = 0; } else { f2 = 1; }
SourceBits += 2; SourceBits += 2;
} }
@ -190,8 +189,8 @@ DIB_4BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
xColor = (*(SourceLine_24BPP + 2) << 0x10) + xColor = (*(SourceLine_24BPP + 2) << 0x10) +
(*(SourceLine_24BPP + 1) << 0x08) + (*(SourceLine_24BPP + 1) << 0x08) +
(*(SourceLine_24BPP)); (*(SourceLine_24BPP));
*DestLine = (*DestLine & notmask[i&1]) | *DestLine = (*DestLine & notmask[f2]) |
((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1-(i & 1))))); ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1 - f2))));
if(f2 == 1) { DestLine++; f2 = 0; } else { f2 = 1; } if(f2 == 1) { DestLine++; f2 = 0; } else { f2 = 1; }
SourceLine_24BPP+=3; SourceLine_24BPP+=3;
} }
@ -214,8 +213,8 @@ DIB_4BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
for (i = DestRect->left; i < DestRect->right; i++) for (i = DestRect->left; i < DestRect->right; i++)
{ {
xColor = *((PDWORD) SourceBits); xColor = *((PDWORD) SourceBits);
*DestBits = (*DestBits & notmask[i&1]) | *DestBits = (*DestBits & notmask[f2]) |
((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1-(i & 1))))); ((XLATEOBJ_iXlate(ColorTranslation, xColor)) << ((4 * (1 - f2))));
if(f2 == 1) { DestBits++; f2 = 0; } else { f2 = 1; } if(f2 == 1) { DestBits++; f2 = 0; } else { f2 = 1; }
SourceBits += 4; SourceBits += 4;
} }
@ -242,9 +241,14 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
LONG i, j, sx, sy; LONG i, j, sx, sy;
ULONG Dest, Source, Pattern; ULONG Dest, Source, Pattern;
PULONG DestBits; PULONG DestBits;
BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); BOOL UsesSource;
BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); BOOL UsesPattern;
LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7); LONG RoundedRight;
/* Pattern brushes */
PGDIBRUSHOBJ GdiBrush;
HBITMAP PatternSurface = NULL;
PSURFOBJ PatternObj;
ULONG PatternWidth, PatternHeight;
static const ULONG ExpandSolidColor[16] = static const ULONG ExpandSolidColor[16] =
{ {
0x00000000 /* 0 */, 0x00000000 /* 0 */,
@ -267,74 +271,135 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
if (Rop4 == SRCCOPY) 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; if (Brush == NULL)
for (j = DestRect->top; j < DestRect->bottom; j++, sy++)
{ {
DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left >> 1) + j * DestSurf->lDelta); UsesPattern = FALSE;
sx = SourcePoint->x; } else
if (Brush->iSolidColor == 0xFFFFFFFF)
{
PBITMAPOBJ PatternBitmap;
/* Process all pixels on the left that aren't DWORD aligned */ GdiBrush = CONTAINING_RECORD(
for (i = DestRect->left; i & 0x7; i++, sx++) Brush,
{ GDIBRUSHOBJ,
Dest = DIB_4BPP_GetPixel(DestSurf, i, j); BrushObject);
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);
}
/* Process all DWORD aligned pixels */ PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
for (; i < RoundedRight; i += 8, sx += 8, DestBits++) PatternSurface = BitmapToSurf(PatternBitmap, NULL);
{ BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
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);
}
/* Process the rest of pixel on the line */ PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
for (; i < DestRect->right; i++, sx++) PatternWidth = PatternObj->sizlBitmap.cx;
{ PatternHeight = PatternObj->sizlBitmap.cy;
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);
}
} }
} }
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; return TRUE;
} }

View file

@ -16,13 +16,15 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
#include <win32k/bitmaps.h> #include <win32k/bitmaps.h>
#include <win32k/brush.h>
#include <win32k/debug.h> #include <win32k/debug.h>
#include <debug.h> #include <debug.h>
#include <include/object.h>
#include <ddk/winddi.h> #include <ddk/winddi.h>
#include "../eng/objects.h" #include "../eng/objects.h"
#include "dib.h" #include "dib.h"
@ -274,71 +276,127 @@ DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PBRUSHOBJ Brush, PPOINTL BrushOrigin, PBRUSHOBJ Brush, PPOINTL BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Rop4) XLATEOBJ *ColorTranslation, ULONG Rop4)
{ {
LONG i, j, k, sx, sy; LONG i, j, k, sx, sy;
ULONG Dest, Source, Pattern; ULONG Dest, Source, Pattern;
PULONG DestBits; PULONG DestBits;
BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); BOOL UsesSource;
BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); BOOL UsesPattern;
LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x3); LONG RoundedRight;
/* Pattern brushes */
PGDIBRUSHOBJ GdiBrush;
HBITMAP PatternSurface = NULL;
PSURFOBJ PatternObj;
ULONG PatternWidth, PatternHeight;
if (Rop4 == SRCCOPY) if (Rop4 == SRCCOPY)
{ {
return(DIB_8BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); return DIB_8BPP_BitBltSrcCopy(
} DestSurf,
else SourceSurf,
{ DestGDI,
sy = SourcePoint->y; 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; UsesPattern = FALSE;
DestBits = (PULONG)(DestSurf->pvScan0 + DestRect->left + j * DestSurf->lDelta); } else
for (i=DestRect->left; i<RoundedRight; i+=4, DestBits++) if (Brush->iSolidColor == 0xFFFFFFFF)
{ {
Dest = *DestBits; PBITMAPOBJ PatternBitmap;
if (UsesSource)
{ GdiBrush = CONTAINING_RECORD(
Source = 0; Brush,
for (k = 0; k < 4; k++) GDIBRUSHOBJ,
{ BrushObject);
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 8));
} PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
} PatternSurface = BitmapToSurf(PatternBitmap, NULL);
if (UsesPattern) BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
{
/* FIXME: No support for pattern brushes. */ PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
Pattern = (Brush->iSolidColor & 0xFF) | PatternWidth = PatternObj->sizlBitmap.cx;
((Brush->iSolidColor & 0xFF) << 8) | PatternHeight = PatternObj->sizlBitmap.cy;
((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++;
} }
} }
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 TgtWidth, int TgtHeight, int srcPitch, int dstPitch)
{ {
int NumPixels = TgtHeight; 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 FractPart = SrcHeight % TgtHeight;
int Mid = TgtHeight >> 1; int Mid = TgtHeight >> 1;
int E = 0; int E = 0;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -109,41 +109,74 @@ BltMask(SURFOBJ* Dest,
POINTL* BrushPoint, POINTL* BrushPoint,
ROP4 Rop4) ROP4 Rop4)
{ {
LONG i, j, dx, dy, c8; LONG i, j, dx, dy, c8;
BYTE *tMask, *lMask; BYTE *tMask, *lMask;
static BYTE maskbit[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; 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; if (Mask == NULL)
dy = DestRect->bottom - DestRect->top; {
return FALSE;
}
if (Mask != NULL) dx = DestRect->right - DestRect->left;
{ dy = DestRect->bottom - DestRect->top;
tMask = Mask->pvBits + SourcePoint->y * Mask->lDelta + (SourcePoint->x >> 3);
for (j = 0; j < dy; j++) if (Brush->iSolidColor == 0xFFFFFFFF)
{ {
lMask = tMask; PBITMAPOBJ PatternBitmap;
c8 = SourcePoint->x & 0x07;
for (i = 0; i < dx; i++) GdiBrush = CONTAINING_RECORD(
{ Brush,
if (0 != (*lMask & maskbit[c8])) GDIBRUSHOBJ,
{ BrushObject);
DestGDI->DIB_PutPixel(Dest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor);
} PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->hbmPattern);
c8++; PatternSurface = BitmapToSurf(PatternBitmap, Dest->hdev);
if (8 == c8) BITMAPOBJ_UnlockBitmap(GdiBrush->hbmPattern);
{
lMask++; PatternObj = (PSURFOBJ)AccessUserObject((ULONG)PatternSurface);
c8=0; PatternWidth = PatternObj->sizlBitmap.cx;
} PatternHeight = PatternObj->sizlBitmap.cy;
} }
tMask += Mask->lDelta;
} tMask = Mask->pvScan0 + SourcePoint->y * Mask->lDelta + (SourcePoint->x >> 3);
return TRUE; for (j = 0; j < dy; j++)
} {
else lMask = tMask;
{ c8 = SourcePoint->x & 0x07;
return FALSE; 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 static BOOLEAN STDCALL
@ -345,7 +378,14 @@ EngBitBlt(SURFOBJ *DestObj,
} }
else if (PATCOPY == Rop4) else if (PATCOPY == Rop4)
{ {
#if 0
BltRectFunc = BltPatCopy; BltRectFunc = BltPatCopy;
#else
if (Brush->iSolidColor == 0xFFFFFFFF)
BltRectFunc = CallDibBitBlt;
else
BltRectFunc = BltPatCopy;
#endif
} }
else else
{ {

View file

@ -132,14 +132,6 @@ PPOINT FASTCALL GDI_Bezier (const POINT *Points, INT count, PINT nPtsOut);
/* objects/objconv.c */ /* objects/objconv.c */
BRUSHOBJ*
FASTCALL
PenToBrushObj(BRUSHOBJ *brush, PENOBJ *pen);
BRUSHOBJ*
FASTCALL
HPenToBrushObj ( BRUSHOBJ *brush, HPEN hpen );
HBITMAP HBITMAP
FASTCALL FASTCALL
BitmapToSurf ( PBITMAPOBJ BitmapObj, HDEV GDIDevice ); BitmapToSurf ( PBITMAPOBJ BitmapObj, HDEV GDIDevice );

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
@ -62,7 +62,7 @@ NtGdiBitBlt(
PXLATEOBJ XlateObj = NULL; PXLATEOBJ XlateObj = NULL;
HPALETTE SourcePalette, DestPalette; HPALETTE SourcePalette, DestPalette;
ULONG SourceMode, DestMode; ULONG SourceMode, DestMode;
PBRUSHOBJ BrushObj; PGDIBRUSHOBJ BrushObj;
BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000); BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000);
BOOL UsesPattern = TRUE;//((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000); BOOL UsesPattern = TRUE;//((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000);
HPALETTE Mono = NULL; HPALETTE Mono = NULL;
@ -244,7 +244,7 @@ NtGdiBitBlt(
/* Perform the bitblt operation */ /* Perform the bitblt operation */
Status = IntEngBitBlt(SurfDest, SurfSrc, NULL, DCDest->CombinedClip, XlateObj, Status = IntEngBitBlt(SurfDest, SurfSrc, NULL, DCDest->CombinedClip, XlateObj,
&DestRect, &SourcePoint, NULL, BrushObj, NULL, ROP); &DestRect, &SourcePoint, NULL, &BrushObj->BrushObject, NULL, ROP);
EngDeleteXlate(XlateObj); EngDeleteXlate(XlateObj);
if (NULL != Mono) if (NULL != Mono)
@ -1099,7 +1099,7 @@ NtGdiStretchBlt(
PXLATEOBJ XlateObj = NULL; PXLATEOBJ XlateObj = NULL;
HPALETTE SourcePalette, DestPalette; HPALETTE SourcePalette, DestPalette;
ULONG SourceMode, DestMode; ULONG SourceMode, DestMode;
PBRUSHOBJ BrushObj; PGDIBRUSHOBJ BrushObj;
BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000); BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000);
BOOL UsesPattern = ((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000); BOOL UsesPattern = ((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000);
@ -1307,7 +1307,7 @@ BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp)
return -1; return -1;
#endif #endif
return ((bmWidth * bpp + 31) & ~31) >> 3; return ((bmWidth * bpp + 15) & ~15) >> 3;
} }
HBITMAP FASTCALL HBITMAP FASTCALL

View file

@ -1,24 +1,24 @@
/* /*
* ReactOS W32 Subsystem * ReactOS Win32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 1998 - 2004 ReactOS Team
* 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.
* *
* This program is distributed in the hope that it will be useful, * This program is free software; you can redistribute it and/or modify
* but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation; either version 2 of the License, or
* GNU General Public License for more details. * (at your option) any later version.
* *
* You should have received a copy of the GNU General Public License * This program is distributed in the hope that it will be useful,
* along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
@ -26,375 +26,352 @@
#include <win32k/bitmaps.h> #include <win32k/bitmaps.h>
#include <win32k/brush.h> #include <win32k/brush.h>
#include <internal/safe.h> #include <internal/safe.h>
//#include <win32k/debug.h>
#include <include/object.h> #include <include/object.h>
#include <include/inteng.h> #include <include/inteng.h>
#include <include/error.h> #include <include/error.h>
#include <include/tags.h> #include <include/tags.h>
#define NDEBUG #define NDEBUG
#include <win32k/debug1.h> #include <win32k/debug1.h>
HBRUSH FASTCALL HBRUSH FASTCALL
IntGdiCreateBrushIndirect(PLOGBRUSH lb) IntGdiCreateBrushIndirect(PLOGBRUSH LogBrush)
{ {
PBRUSHOBJ brushPtr; PGDIBRUSHOBJ BrushObject;
HBRUSH hBrush; HBRUSH hBrush;
hBrush = BRUSHOBJ_AllocBrush(); hBrush = BRUSHOBJ_AllocBrush();
if (hBrush == NULL) if (hBrush == NULL)
{ {
return 0; SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
} return NULL;
}
brushPtr = BRUSHOBJ_LockBrush (hBrush); BrushObject = BRUSHOBJ_LockBrush(hBrush);
/* FIXME: Occurs! FiN */
/* ASSERT( brushPtr ); *///I want to know if this ever occurs
if( brushPtr ){ switch (LogBrush->lbStyle)
brushPtr->iSolidColor = lb->lbColor; {
brushPtr->logbrush.lbStyle = lb->lbStyle; case BS_NULL:
brushPtr->logbrush.lbColor = lb->lbColor; BrushObject->flAttrs = GDIBRUSH_IS_NULL;
brushPtr->logbrush.lbHatch = lb->lbHatch; break;
/* FIXME */
case BS_HATCHED:
BRUSHOBJ_UnlockBrush( hBrush ); case BS_SOLID:
return hBrush; BrushObject->flAttrs = GDIBRUSH_IS_SOLID;
} BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF;
return NULL; BrushObject->BrushObject.iSolidColor = BrushObject->BrushAttr.lbColor;
} /* FIXME: Fill in the rest of fields!!! */
break;
HBRUSH FASTCALL case BS_PATTERN:
IntGdiCreateDIBPatternBrush(HGLOBAL hDIBPacked, BrushObject->flAttrs = GDIBRUSH_IS_BITMAP;
UINT ColorSpec) BrushObject->hbmPattern = BITMAPOBJ_CopyBitmap((HBITMAP)LogBrush->lbHatch);
{ BrushObject->BrushObject.iSolidColor = 0xFFFFFFFF;
return NULL; /* FIXME: Fill in the rest of fields!!! */
#if 0 break;
LOGBRUSH logbrush;
PBITMAPINFO info, newInfo;
INT size;
DPRINT("%04x\n", hbitmap ); default:
DPRINT1("Brush Style: %d\n", LogBrush->lbStyle);
UNIMPLEMENTED;
}
logbrush.lbStyle = BS_DIBPATTERN; BRUSHOBJ_UnlockBrush(hBrush);
logbrush.lbColor = coloruse; return hBrush;
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);
} }
BOOL FASTCALL BOOL FASTCALL
IntPatBlt(DC *dc, IntPatBlt(
INT XLeft, PDC dc,
INT YLeft, INT XLeft,
INT Width, INT YLeft,
INT Height, INT Width,
DWORD ROP, INT Height,
PBRUSHOBJ BrushObj) DWORD ROP,
PGDIBRUSHOBJ BrushObj)
{ {
RECT DestRect; RECT DestRect;
PSURFOBJ SurfObj; PSURFOBJ SurfObj;
BOOL ret; BOOL ret;
SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface); SurfObj = (SURFOBJ *)AccessUserObject((ULONG)dc->Surface);
if (NULL == SurfObj) if (SurfObj == NULL)
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE); SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE; return FALSE;
} }
assert(BrushObj); ASSERT(BrushObj);
if (BrushObj->logbrush.lbStyle != BS_NULL) if (!(BrushObj->flAttrs & GDIBRUSH_IS_NULL))
{ {
if (Width > 0) if (Width > 0)
{ {
DestRect.left = XLeft + dc->w.DCOrgX; DestRect.left = XLeft + dc->w.DCOrgX;
DestRect.right = XLeft + Width + dc->w.DCOrgX; DestRect.right = XLeft + Width + dc->w.DCOrgX;
} }
else else
{ {
DestRect.left = XLeft + Width + 1 + dc->w.DCOrgX; DestRect.left = XLeft + Width + 1 + dc->w.DCOrgX;
DestRect.right = XLeft + dc->w.DCOrgX + 1; 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);
}
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 BOOL FASTCALL
IntGdiPolyPatBlt(HDC hDC, IntGdiPolyPatBlt(
DWORD dwRop, HDC hDC,
PPATRECT pRects, DWORD dwRop,
int cRects, PPATRECT pRects,
ULONG Reserved) int cRects,
ULONG Reserved)
{ {
int i; int i;
PPATRECT r; PPATRECT r;
PBRUSHOBJ BrushObj; PGDIBRUSHOBJ BrushObj;
DC *dc; DC *dc;
dc = DC_LockDc(hDC); dc = DC_LockDc(hDC);
if (dc == NULL) 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)
{
SetLastWin32Error(ERROR_INVALID_HANDLE); SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE; 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); DC_UnlockDc( hDC );
if (NULL == BrushObj)
{ 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); SetLastWin32Error(ERROR_INVALID_HANDLE);
DC_UnlockDc(hDC); DC_UnlockDc(hDC);
return FALSE; 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); BRUSHOBJ_UnlockBrush(dc->w.hBrush);
DC_UnlockDc(hDC); DC_UnlockDc(hDC);
return ret;
return ret;
} }
BOOL STDCALL NtGdiSetBrushOrgEx(HDC hDC,
INT XOrg,
INT YOrg,
LPPOINT Point)
{
UNIMPLEMENTED;
}
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * DC.C - Device context functions
* *
@ -995,13 +995,16 @@ NtGdiSetBkColor(HDC hDC, COLORREF color)
{ {
COLORREF oldColor; COLORREF oldColor;
PDC dc = DC_LockDc(hDC); PDC dc = DC_LockDc(hDC);
HBRUSH hBrush;
if ( !dc ) if ( !dc )
return 0x80000000; return 0x80000000;
oldColor = dc->w.backgroundColor; oldColor = dc->w.backgroundColor;
dc->w.backgroundColor = color; dc->w.backgroundColor = color;
hBrush = dc->w.hBrush;
DC_UnlockDc ( hDC ); DC_UnlockDc ( hDC );
NtGdiSelectObject(hDC, hBrush);
return oldColor; return oldColor;
} }
@ -1702,8 +1705,8 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj)
HGDIOBJ objOrg = NULL; // default to failure HGDIOBJ objOrg = NULL; // default to failure
BITMAPOBJ *pb; BITMAPOBJ *pb;
PDC dc; PDC dc;
PPENOBJ pen; PGDIBRUSHOBJ pen;
PBRUSHOBJ brush; PGDIBRUSHOBJ brush;
PXLATEOBJ XlateObj; PXLATEOBJ XlateObj;
PPALGDI PalGDI; PPALGDI PalGDI;
DWORD objectType; DWORD objectType;
@ -1740,7 +1743,17 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj)
pen = PENOBJ_LockPen((HPEN) hGDIObj); pen = PENOBJ_LockPen((HPEN) hGDIObj);
if (NULL != pen) 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); PENOBJ_UnlockPen((HPEN) hGDIObj);
objOrg = (HGDIOBJ)dc->w.hPen; objOrg = (HGDIOBJ)dc->w.hPen;
dc->w.hPen = hGDIObj; dc->w.hPen = hGDIObj;
@ -1776,7 +1789,17 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj)
brush = BRUSHOBJ_LockBrush((HBRUSH) hGDIObj); brush = BRUSHOBJ_LockBrush((HBRUSH) hGDIObj);
if (NULL != brush) 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); BRUSHOBJ_UnlockBrush((HBRUSH) hGDIObj);
objOrg = (HGDIOBJ)dc->w.hBrush; objOrg = (HGDIOBJ)dc->w.hBrush;
dc->w.hBrush = (HBRUSH) hGDIObj; dc->w.hBrush = (HBRUSH) hGDIObj;

View file

@ -16,11 +16,12 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ddk/winddi.h>
#include <win32k/fillshap.h> #include <win32k/fillshap.h>
#include <win32k/brush.h> #include <win32k/brush.h>
#include <win32k/dc.h> #include <win32k/dc.h>
@ -46,7 +47,7 @@
#define PUTPIXEL(x,y,brushObj) \ #define PUTPIXEL(x,y,brushObj) \
ret = ret && IntEngLineTo(SurfObj, \ ret = ret && IntEngLineTo(SurfObj, \
dc->CombinedClip, \ dc->CombinedClip, \
brushObj, \ &brushObj->BrushObject, \
x, y, (x)+1, y, \ x, y, (x)+1, y, \
&RectBounds, \ &RectBounds, \
dc->w.ROPmode); dc->w.ROPmode);
@ -54,7 +55,7 @@
#define PUTLINE(x1,y1,x2,y2,brushObj) \ #define PUTLINE(x1,y1,x2,y2,brushObj) \
ret = ret && IntEngLineTo(SurfObj, \ ret = ret && IntEngLineTo(SurfObj, \
dc->CombinedClip, \ dc->CombinedClip, \
brushObj, \ &brushObj->BrushObject, \
x1, y1, x2, y2, \ x1, y1, x2, y2, \
&RectBounds, \ &RectBounds, \
dc->w.ROPmode); dc->w.ROPmode);
@ -65,7 +66,7 @@ IntGdiPolygon(PDC dc,
int Count) int Count)
{ {
SURFOBJ *SurfObj; SURFOBJ *SurfObj;
BRUSHOBJ PenBrushObj, *FillBrushObj; PGDIBRUSHOBJ PenBrushObj, FillBrushObj;
BOOL ret = FALSE; // default to failure BOOL ret = FALSE; // default to failure
PRECTL RectBounds; PRECTL RectBounds;
RECTL DestRect; RECTL DestRect;
@ -113,16 +114,16 @@ IntGdiPolygon(PDC dc,
/* Now fill the polygon with the current brush. */ /* Now fill the polygon with the current brush. */
FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush); FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
ASSERT(FillBrushObj); ASSERT(FillBrushObj);
if ( FillBrushObj->logbrush.lbStyle != BS_NULL ) if (!(FillBrushObj->flAttrs & GDIBRUSH_IS_NULL))
ret = FillPolygon ( dc, SurfObj, FillBrushObj, dc->w.ROPmode, UnsafePoints, Count, DestRect ); ret = FillPolygon ( dc, SurfObj, &FillBrushObj->BrushObject, dc->w.ROPmode, UnsafePoints, Count, DestRect );
BRUSHOBJ_UnlockBrush(dc->w.hBrush); BRUSHOBJ_UnlockBrush(dc->w.hBrush);
#endif #endif
/* make BRUSHOBJ from current pen. */ /* get BRUSHOBJ from current pen. */
HPenToBrushObj ( &PenBrushObj, dc->w.hPen ); PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
// Draw the Polygon Edges with the current pen ( if not a NULL pen ) // 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 ) 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 ); //DPRINT("Polygon Making line from (%d,%d) to (%d,%d)\n", From.x, From.y, To.x, To.y );
ret = IntEngLineTo(SurfObj, ret = IntEngLineTo(SurfObj,
dc->CombinedClip, dc->CombinedClip,
&PenBrushObj, &PenBrushObj->BrushObject,
From.x, From.x,
From.y, From.y,
To.x, To.x,
@ -160,6 +161,7 @@ IntGdiPolygon(PDC dc,
#endif #endif
} }
PENOBJ_UnlockPen( dc->w.hPen );
RGNDATA_UnlockRgn(dc->w.hGCClipRgn); RGNDATA_UnlockRgn(dc->w.hGCClipRgn);
return ret; return ret;
@ -239,8 +241,7 @@ NtGdiEllipse(
int CenterX, CenterY; int CenterX, CenterY;
int RadiusX, RadiusY; int RadiusX, RadiusY;
int Temp; int Temp;
BRUSHOBJ PenBrush; PGDIBRUSHOBJ FillBrush, PenBrush;
PBRUSHOBJ FillBrush;
PSURFOBJ SurfObj; PSURFOBJ SurfObj;
RECTL RectBounds; RECTL RectBounds;
PDC dc; PDC dc;
@ -275,8 +276,16 @@ NtGdiEllipse(
return FALSE; 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); SurfObj = (PSURFOBJ)AccessUserObject((ULONG)dc->Surface);
HPenToBrushObj(&PenBrush, dc->w.hPen);
nLeftRect += dc->w.DCOrgX; nLeftRect += dc->w.DCOrgX;
nRightRect += dc->w.DCOrgX - 1; nRightRect += dc->w.DCOrgX - 1;
@ -370,32 +379,33 @@ NtGdiEllipse(
if (Cond1) if (Cond1)
{ {
PUTPIXEL(CenterX + C, CenterY + B, &PenBrush); PUTPIXEL(CenterX + C, CenterY + B, PenBrush);
if (C) if (C)
PUTPIXEL(CenterX - C, CenterY + B, &PenBrush); PUTPIXEL(CenterX - C, CenterY + B, PenBrush);
if (B) if (B)
{ {
PUTPIXEL(CenterX + C, CenterY - B, &PenBrush); PUTPIXEL(CenterX + C, CenterY - B, PenBrush);
if (C) if (C)
PUTPIXEL(CenterX - C, CenterY - B, &PenBrush); PUTPIXEL(CenterX - C, CenterY - B, PenBrush);
} }
} }
if (Cond2) if (Cond2)
{ {
PUTPIXEL(CenterX + D, CenterY + A, &PenBrush); PUTPIXEL(CenterX + D, CenterY + A, PenBrush);
if (D) if (D)
PUTPIXEL(CenterX - D, CenterY + A, &PenBrush); PUTPIXEL(CenterX - D, CenterY + A, PenBrush);
if (A) if (A)
{ {
PUTPIXEL(CenterX + D, CenterY - A, &PenBrush); PUTPIXEL(CenterX + D, CenterY - A, PenBrush);
if (D) if (D)
PUTPIXEL(CenterX - D, CenterY - A, &PenBrush); PUTPIXEL(CenterX - D, CenterY - A, PenBrush);
} }
} }
} while (B > A); } while (B > A);
BRUSHOBJ_UnlockBrush(dc->w.hBrush); BRUSHOBJ_UnlockBrush(dc->w.hBrush);
PENOBJ_UnlockPen(dc->w.hPen);
DC_UnlockDc(hDC); DC_UnlockDc(hDC);
return ret; return ret;
@ -945,7 +955,7 @@ IntRectangle(PDC dc,
int BottomRect) int BottomRect)
{ {
SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface); SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface);
BRUSHOBJ PenBrushObj, *FillBrushObj; PGDIBRUSHOBJ PenBrushObj, FillBrushObj;
BOOL ret = FALSE; // default to failure BOOL ret = FALSE; // default to failure
RECTL DestRect; RECTL DestRect;
@ -971,7 +981,7 @@ IntRectangle(PDC dc,
if ( FillBrushObj ) if ( FillBrushObj )
{ {
if ( FillBrushObj->logbrush.lbStyle != BS_NULL ) if (!(FillBrushObj->flAttrs & GDIBRUSH_IS_NULL))
{ {
ret = IntEngBitBlt(SurfObj, ret = IntEngBitBlt(SurfObj,
NULL, NULL,
@ -981,7 +991,7 @@ IntRectangle(PDC dc,
&DestRect, &DestRect,
NULL, NULL,
NULL, NULL,
FillBrushObj, &FillBrushObj->BrushObject,
NULL, NULL,
PATCOPY); PATCOPY);
} }
@ -989,43 +999,50 @@ IntRectangle(PDC dc,
BRUSHOBJ_UnlockBrush(dc->w.hBrush); BRUSHOBJ_UnlockBrush(dc->w.hBrush);
/* make BRUSHOBJ from current pen. */ /* get BRUSHOBJ from current pen. */
HPenToBrushObj ( &PenBrushObj, dc->w.hPen ); PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
if (PenBrushObj == NULL)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
// Draw the rectangle with the current pen // Draw the rectangle with the current pen
ret = TRUE; // change default to success ret = TRUE; // change default to success
if ( PenBrushObj.logbrush.lbStyle != BS_NULL ) if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
{ {
ret = ret && IntEngLineTo(SurfObj, ret = ret && IntEngLineTo(SurfObj,
dc->CombinedClip, dc->CombinedClip,
&PenBrushObj, &PenBrushObj->BrushObject,
LeftRect, TopRect, RightRect, TopRect, LeftRect, TopRect, RightRect, TopRect,
&DestRect, // Bounding rectangle &DestRect, // Bounding rectangle
dc->w.ROPmode); // MIX dc->w.ROPmode); // MIX
ret = ret && IntEngLineTo(SurfObj, ret = ret && IntEngLineTo(SurfObj,
dc->CombinedClip, dc->CombinedClip,
&PenBrushObj, &PenBrushObj->BrushObject,
RightRect, TopRect, RightRect, BottomRect, RightRect, TopRect, RightRect, BottomRect,
&DestRect, // Bounding rectangle &DestRect, // Bounding rectangle
dc->w.ROPmode); // MIX dc->w.ROPmode); // MIX
ret = ret && IntEngLineTo(SurfObj, ret = ret && IntEngLineTo(SurfObj,
dc->CombinedClip, dc->CombinedClip,
&PenBrushObj, &PenBrushObj->BrushObject,
RightRect, BottomRect, LeftRect, BottomRect, RightRect, BottomRect, LeftRect, BottomRect,
&DestRect, // Bounding rectangle &DestRect, // Bounding rectangle
dc->w.ROPmode); // MIX dc->w.ROPmode); // MIX
ret = ret && IntEngLineTo(SurfObj, ret = ret && IntEngLineTo(SurfObj,
dc->CombinedClip, dc->CombinedClip,
&PenBrushObj, &PenBrushObj->BrushObject,
LeftRect, BottomRect, LeftRect, TopRect, LeftRect, BottomRect, LeftRect, TopRect,
&DestRect, // Bounding rectangle &DestRect, // Bounding rectangle
dc->w.ROPmode); // MIX */ dc->w.ROPmode); // MIX */
} }
PENOBJ_UnlockPen(dc->w.hPen);
} }
/* Move current position in DC? /* Move current position in DC?
@ -1071,7 +1088,7 @@ IntRoundRect(
int yCurveDiameter) int yCurveDiameter)
{ {
SURFOBJ *SurfObj; SURFOBJ *SurfObj;
BRUSHOBJ PenBrush, *PenBrushObj, *FillBrushObj; PGDIBRUSHOBJ PenBrushObj, FillBrushObj;
RECTL RectBounds; RECTL RectBounds;
int i, col, row, width, height, x1, x1start, x2, x2start, y1, y2; int i, col, row, width, height, x1, x1start, x2, x2start, y1, y2;
int xradius, yradius; int xradius, yradius;
@ -1106,14 +1123,19 @@ IntRoundRect(
FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush); FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
ASSERT(FillBrushObj); 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... FillBrushObj = NULL; // make null brush check simpler...
}
HPenToBrushObj ( &PenBrush, dc->w.hPen ); PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
if ( PenBrush.logbrush.lbStyle != BS_NULL ) ASSERT(PenBrushObj);
PenBrushObj = &PenBrush; if (PenBrushObj->flAttrs & GDIBRUSH_IS_NULL)
else {
PENOBJ_UnlockPen(dc->w.hPen);
PenBrushObj = NULL; PenBrushObj = NULL;
}
right--; right--;
bottom--; bottom--;
@ -1292,6 +1314,7 @@ IntRoundRect(
PUTLINE ( left, y2, left, y1, PenBrushObj ); PUTLINE ( left, y2, left, y1, PenBrushObj );
} }
PENOBJ_UnlockPen(dc->w.hPen);
BRUSHOBJ_UnlockBrush(dc->w.hBrush); BRUSHOBJ_UnlockBrush(dc->w.hBrush);
return ret; return ret;

View file

@ -19,7 +19,7 @@
/* /*
* GDIOBJ.C - GDI object manipulation routines * 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_BITMAP, sizeof(BITMAPOBJ)},
{GDI_OBJECT_TYPE_DC, sizeof(DC)}, {GDI_OBJECT_TYPE_DC, sizeof(DC)},
{GDI_OBJECT_TYPE_PALETTE, sizeof(PALGDI)}, {GDI_OBJECT_TYPE_PALETTE, sizeof(PALGDI)},
{GDI_OBJECT_TYPE_BRUSH, sizeof(BRUSHOBJ)}, {GDI_OBJECT_TYPE_BRUSH, sizeof(GDIBRUSHOBJ)},
{GDI_OBJECT_TYPE_PEN, sizeof(PENOBJ)}, {GDI_OBJECT_TYPE_PEN, sizeof(GDIBRUSHOBJ)},
{GDI_OBJECT_TYPE_FONT, sizeof(TEXTOBJ)}, {GDI_OBJECT_TYPE_FONT, sizeof(TEXTOBJ)},
{GDI_OBJECT_TYPE_DCE, sizeof(DCE)}, {GDI_OBJECT_TYPE_DCE, sizeof(DCE)},
/* /*

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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) // Some code from the WINE project source (www.winehq.com)
@ -71,7 +71,7 @@ IntGdiLineTo(DC *dc,
{ {
SURFOBJ *SurfObj; SURFOBJ *SurfObj;
BOOL Ret; BOOL Ret;
BRUSHOBJ PenBrushObj; PGDIBRUSHOBJ PenBrushObj;
RECT Bounds; RECT Bounds;
SurfObj = (SURFOBJ*)AccessUserObject ( (ULONG)dc->Surface ); SurfObj = (SURFOBJ*)AccessUserObject ( (ULONG)dc->Surface );
@ -119,16 +119,22 @@ IntGdiLineTo(DC *dc,
Bounds.top += dc->w.DCOrgY; Bounds.top += dc->w.DCOrgY;
Bounds.bottom += dc->w.DCOrgY; Bounds.bottom += dc->w.DCOrgY;
/* make BRUSHOBJ from current pen. */ /* get BRUSHOBJ from current pen. */
HPenToBrushObj ( &PenBrushObj, dc->w.hPen ); PenBrushObj = PENOBJ_LockPen( dc->w.hPen );
ASSERT(PenBrushObj);
Ret = IntEngLineTo(SurfObj, if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
dc->CombinedClip, {
&PenBrushObj, Ret = IntEngLineTo(SurfObj,
dc->w.DCOrgX + dc->w.CursPosX, dc->w.DCOrgY + dc->w.CursPosY, dc->CombinedClip,
dc->w.DCOrgX + XEnd, dc->w.DCOrgY + YEnd, &PenBrushObj->BrushObject,
&Bounds, dc->w.DCOrgX + dc->w.CursPosX, dc->w.DCOrgY + dc->w.CursPosY,
dc->w.ROPmode); dc->w.DCOrgX + XEnd, dc->w.DCOrgY + YEnd,
&Bounds,
dc->w.ROPmode);
}
PENOBJ_UnlockPen( dc->w.hPen );
} }
if (Ret) if (Ret)
@ -209,7 +215,7 @@ IntGdiPolyline(DC *dc,
BOOL ret = FALSE; // default to failure BOOL ret = FALSE; // default to failure
LONG i; LONG i;
PROSRGNDATA reg; PROSRGNDATA reg;
BRUSHOBJ PenBrushObj; PGDIBRUSHOBJ PenBrushObj;
POINT *pts; POINT *pts;
SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface); SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface);
@ -236,16 +242,22 @@ IntGdiPolyline(DC *dc,
pts[i].y += dc->w.DCOrgY; pts[i].y += dc->w.DCOrgY;
} }
/* make BRUSHOBJ from current pen. */ /* get BRUSHOBJ from current pen. */
HPenToBrushObj ( &PenBrushObj, dc->w.hPen ); PenBrushObj = PENOBJ_LockPen( dc->w.hPen );
ASSERT(PenBrushObj);
//get IntEngPolyline to do the drawing. if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
ret = IntEngPolyline(SurfObj, {
dc->CombinedClip, //get IntEngPolyline to do the drawing.
&PenBrushObj, ret = IntEngPolyline(SurfObj,
pts, dc->CombinedClip,
Count, &PenBrushObj->BrushObject,
dc->w.ROPmode); pts,
Count,
dc->w.ROPmode);
}
PENOBJ_UnlockPen( dc->w.hPen );
} }
ExFreePool ( pts ); ExFreePool ( pts );

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
@ -38,35 +38,6 @@
//#define NDEBUG //#define NDEBUG
#include <win32k/debug1.h> #include <win32k/debug1.h>
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 FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice)
{ {
HBITMAP BitmapHandle; HBITMAP BitmapHandle;
@ -87,11 +58,12 @@ HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice)
BitmapFormat(BitmapObj->bitmap.bmBitsPixel, BI_RGB), BitmapFormat(BitmapObj->bitmap.bmBitsPixel, BI_RGB),
0, BitmapObj->bitmap.bmBits); 0, BitmapObj->bitmap.bmBits);
} }
if (NULL != BitmapHandle) if (NULL != BitmapHandle && NULL != GDIDevice)
{ {
EngAssociateSurface(BitmapHandle, GDIDevice, 0); EngAssociateSurface(BitmapHandle, GDIDevice, 0);
} }
return BitmapHandle; return BitmapHandle;
} }
/* EOF */ /* EOF */

View file

@ -16,10 +16,11 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ddk/winddi.h>
#include <win32k/brush.h> #include <win32k/brush.h>
#include <win32k/dc.h> #include <win32k/dc.h>
#include <win32k/path.h> #include <win32k/path.h>

View file

@ -1,95 +1,129 @@
/* /*
* ReactOS W32 Subsystem * ReactOS Win32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
* *
* This program is free software; you can redistribute it and/or modify * Copyright (C) 1998 - 2004 ReactOS Team
* 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.
* *
* This program is distributed in the hope that it will be useful, * This program is free software; you can redistribute it and/or modify
* but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation; either version 2 of the License, or
* GNU General Public License for more details. * (at your option) any later version.
* *
* You should have received a copy of the GNU General Public License * This program is distributed in the hope that it will be useful,
* along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ddk/winddi.h>
#include <win32k/pen.h> #include <win32k/pen.h>
#include <win32k/bitmaps.h>
#include <include/error.h> #include <include/error.h>
#include <internal/safe.h> #include <internal/safe.h>
#define NDEBUG #define NDEBUG
#include <win32k/debug1.h> #include <win32k/debug1.h>
/* PRIVATE FUNCTIONS **********************************************************/
HPEN FASTCALL HPEN FASTCALL
IntGdiCreatePenIndirect(PLOGPEN lgpn) IntGdiCreatePenIndirect(PLOGPEN LogPen)
{ {
HPEN hpen; HPEN hPen;
PPENOBJ penPtr; PGDIBRUSHOBJ PenObject;
static const WORD wPatternAlternate[] = {0x5555};
if (lgpn->lopnStyle > PS_INSIDEFRAME) return 0; if (LogPen->lopnStyle > PS_INSIDEFRAME)
return 0;
hpen = PENOBJ_AllocPen(); hPen = PENOBJ_AllocPen();
if (!hpen) return 0; if (!hPen)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
DPRINT("Can't allocate pen\n");
return 0;
}
penPtr = PENOBJ_LockPen( hpen ); PenObject = PENOBJ_LockPen(hPen);
ASSERT( penPtr ); 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; case PS_SOLID:
penPtr->logpen.lopnWidth = lgpn->lopnWidth; PenObject->flAttrs |= GDIBRUSH_IS_SOLID;
penPtr->logpen.lopnColor = lgpn->lopnColor; break;
PENOBJ_UnlockPen( hpen );
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 HPEN STDCALL
STDCALL NtGdiCreatePen(
NtGdiCreatePen(INT PenStyle, INT Width, COLORREF Color) INT PenStyle,
INT Width,
COLORREF Color)
{ {
LOGPEN logpen; LOGPEN LogPen;
logpen.lopnStyle = PenStyle; LogPen.lopnStyle = PenStyle;
logpen.lopnWidth.x = Width; LogPen.lopnWidth.x = Width;
logpen.lopnWidth.y = 0; LogPen.lopnWidth.y = 0;
logpen.lopnColor = Color; LogPen.lopnColor = Color;
return IntGdiCreatePenIndirect(&logpen); return IntGdiCreatePenIndirect(&LogPen);
} }
HPEN HPEN STDCALL
STDCALL NtGdiCreatePenIndirect(CONST PLOGPEN LogPen)
NtGdiCreatePenIndirect(CONST PLOGPEN lgpn)
{ {
LOGPEN Safelgpn; LOGPEN SafeLogPen;
NTSTATUS Status; NTSTATUS Status;
Status = MmCopyFromCaller(&Safelgpn, lgpn, sizeof(LOGPEN)); Status = MmCopyFromCaller(&SafeLogPen, LogPen, sizeof(LOGPEN));
if(!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastNtError(Status); SetLastNtError(Status);
return 0; return 0;
} }
return IntGdiCreatePenIndirect(&Safelgpn); return IntGdiCreatePenIndirect(&SafeLogPen);
} }
HPEN HPEN STDCALL
STDCALL NtGdiExtCreatePen(
NtGdiExtCreatePen(DWORD PenStyle, DWORD PenStyle,
DWORD Width, DWORD Width,
CONST PLOGBRUSH lb, CONST PLOGBRUSH LogBrush,
DWORD StyleCount, DWORD StyleCount,
CONST PDWORD Style) CONST PDWORD Style)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
@ -2005,7 +2005,7 @@ NtGdiPaintRgn(HDC hDC,
PROSRGNDATA visrgn; PROSRGNDATA visrgn;
CLIPOBJ* ClipRegion; CLIPOBJ* ClipRegion;
BOOL bRet = FALSE; BOOL bRet = FALSE;
PBRUSHOBJ pBrush; PGDIBRUSHOBJ pBrush;
POINTL BrushOrigin; POINTL BrushOrigin;
SURFOBJ *SurfObj; SURFOBJ *SurfObj;
@ -2048,7 +2048,7 @@ NtGdiPaintRgn(HDC hDC,
bRet = IntEngPaint(SurfObj, bRet = IntEngPaint(SurfObj,
ClipRegion, ClipRegion,
pBrush, &pBrush->BrushObject,
&BrushOrigin, &BrushOrigin,
0xFFFF);//FIXME:don't know what to put here 0xFFFF);//FIXME:don't know what to put here

View file

@ -22,12 +22,13 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ddk/winddi.h>
#include <napi/win32.h> #include <napi/win32.h>
#include <internal/safe.h> #include <internal/safe.h>
#include <win32k/brush.h> #include <win32k/brush.h>
@ -1493,9 +1494,9 @@ NtGdiExtTextOut(
RECTL DestRect, MaskRect; RECTL DestRect, MaskRect;
POINTL SourcePoint, BrushOrigin; POINTL SourcePoint, BrushOrigin;
HBRUSH hBrushFg = NULL; HBRUSH hBrushFg = NULL;
PBRUSHOBJ BrushFg = NULL; PGDIBRUSHOBJ BrushFg = NULL;
HBRUSH hBrushBg = NULL; HBRUSH hBrushBg = NULL;
PBRUSHOBJ BrushBg = NULL; PGDIBRUSHOBJ BrushBg = NULL;
HBITMAP HSourceGlyph; HBITMAP HSourceGlyph;
PSURFOBJ SourceGlyphSurf; PSURFOBJ SourceGlyphSurf;
SIZEL bitSize; SIZEL bitSize;
@ -1638,7 +1639,7 @@ NtGdiExtTextOut(
&DestRect, &DestRect,
&SourcePoint, &SourcePoint,
&SourcePoint, &SourcePoint,
BrushBg, &BrushBg->BrushObject,
&BrushOrigin, &BrushOrigin,
PATCOPY); PATCOPY);
fuOptions &= ~ETO_OPAQUE; fuOptions &= ~ETO_OPAQUE;
@ -1799,7 +1800,7 @@ NtGdiExtTextOut(
&DestRect, &DestRect,
&SourcePoint, &SourcePoint,
&SourcePoint, &SourcePoint,
BrushBg, &BrushBg->BrushObject,
&BrushOrigin, &BrushOrigin,
PATCOPY); PATCOPY);
BackgroundLeft = DestRect.right; BackgroundLeft = DestRect.right;
@ -1838,7 +1839,7 @@ NtGdiExtTextOut(
&DestRect, &DestRect,
&SourcePoint, &SourcePoint,
(PPOINTL)&MaskRect, (PPOINTL)&MaskRect,
BrushFg, &BrushFg->BrushObject,
&BrushOrigin); &BrushOrigin);
EngDeleteSurface(HSourceGlyph); EngDeleteSurface(HSourceGlyph);
@ -2578,6 +2579,7 @@ NtGdiSetTextColor(HDC hDC,
{ {
COLORREF oldColor; COLORREF oldColor;
PDC dc = DC_LockDc(hDC); PDC dc = DC_LockDc(hDC);
HBRUSH hBrush;
if (!dc) if (!dc)
{ {
@ -2586,7 +2588,9 @@ NtGdiSetTextColor(HDC hDC,
oldColor = dc->w.textColor; oldColor = dc->w.textColor;
dc->w.textColor = color; dc->w.textColor = color;
hBrush = dc->w.hBrush;
DC_UnlockDc( hDC ); DC_UnlockDc( hDC );
NtGdiSelectObject(hDC, hBrush);
return oldColor; return oldColor;
} }