--- /dev/null
+dist
+errors
{
ULONG iSolidColor;
PVOID pvRbrush;
+
+ /* remainder of fields are for GDI internal use */
+ LOGBRUSH logbrush;
} BRUSHOBJ, *PBRUSHOBJ;
typedef struct _CLIPOBJ
/* GDI logical bitmap object */
typedef struct _BITMAPOBJ
{
- GDIOBJHDR header;
BITMAP bitmap;
SIZE size; /* For SetBitmapDimension() */
/* Internal interface */
#define BITMAPOBJ_AllocBitmap() \
- ((PBITMAPOBJ) GDIOBJ_AllocObject(sizeof(BITMAPOBJ), GO_BITMAP_MAGIC))
-#define BITMAPOBJ_FreeBitmap(hBMObj) GDIOBJ_FreeObject((HGDIOBJ)hBMObj)
+ ((PBITMAPOBJ) GDIOBJ_AllocObject (sizeof (BITMAPOBJ), GO_BITMAP_MAGIC))
+#define BITMAPOBJ_FreeBitmap(hBMObj) GDIOBJ_FreeObject((HGDIOBJ) hBMObj)
#define BITMAPOBJ_HandleToPtr(hBMObj) \
- ((PBITMAPOBJ) GDIOBJ_HandleToPtr((HGDIOBJ)hBMObj, GO_BITMAP_MAGIC))
+ ((PBITMAPOBJ) GDIOBJ_HandleToPtr ((HGDIOBJ) hBMObj, GO_BITMAP_MAGIC))
#define BITMAPOBJ_PtrToHandle(hBMObj) \
- ((HBITMAP) GDIOBJ_HandleToPtr((PGDIOBJ)hBMObj, GO_BITMAP_MAGIC))
-#define BITMAPOBJ_LockBitmap(hBMObj) GDIOBJ_LockObject((HGDIOBJ)hBMObj)
-#define BITMAPOBJ_UnlockBitmap(hBMObj) GDIOBJ_UnlockObject((HGDIOBJ)hBMObj)
+ ((HBITMAP) GDIOBJ_PtrToHandle ((PGDIOBJ) hBMObj, GO_BITMAP_MAGIC))
+#define BITMAPOBJ_LockBitmap(hBMObj) GDIOBJ_LockObject ((HGDIOBJ) hBMObj)
+#define BITMAPOBJ_UnlockBitmap(hBMObj) GDIOBJ_UnlockObject ((HGDIOBJ) hBMObj)
-INT BITMAP_GetWidthBytes (INT bmWidth, INT bpp);
+INT BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp);
+HBITMAP BITMAPOBJ_CopyBitmap (HBITMAP hBitmap);
+int DIB_GetDIBWidthBytes (int width, int depth);
+int DIB_GetDIBImageBytes (int width, int height, int depth);
+int DIB_BitmapInfoSize (const BITMAPINFO * info, WORD coloruse);
/* User Entry Points */
BOOL W32kBitBlt(HDC hDCDest,
#ifndef __WIN32K_BRUSH_H
#define __WIN32K_BRUSH_H
+#include <win32k/gdiobj.h>
+
+/* Internal interface */
+
+#define NB_HATCH_STYLES 6
+
+#define BRUSHOBJ_AllocBrush() \
+ ((PBRUSHOBJ) GDIOBJ_AllocObject (sizeof (BRUSHOBJ), GO_BRUSH_MAGIC))
+#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObject((HGDIOBJ)hBrush)
+#define BRUSHOBJ_HandleToPtr(hBrush) \
+ ((PBRUSHOBJ) GDIOBJ_HandleToPtr ((HGDIOBJ) hBrush, GO_BRUSH_MAGIC))
+#define BRUSHOBJ_PtrToHandle(pBrushObj) \
+ ((HBRUSH) GDIOBJ_PtrToHandle ((PGDIOBJ) pBrushObj, GO_BRUSH_MAGIC))
+#define BRUSHOBJ_LockBrush(hBrush) GDIOBJ_LockObject((HGDIOBJ)hBrush)
+#define BRUSHOBJ_UnlockBrush(hBrush) GDIOBJ_UnlockObject((HGDIOBJ)hBrush)
+
HBRUSH W32kCreateBrushIndirect(CONST LOGBRUSH *lb);
HBRUSH W32kCreateDIBPatternBrush(HGLOBAL hDIBPacked,
UINT ColorSpec);
{
int flags;
const PDEVICECAPS devCaps;
-
HRGN hClipRgn; /* Clip region (may be 0) */
-
-#if 0
- HRGN hVisRgn; /* Visible region (must never be 0) */
- HRGN hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */
-#endif
-
+ HRGN hVisRgn; /* Visible region (must never be 0) */
+ HRGN hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */
HPEN hPen;
HBRUSH hBrush;
HFONT hFont;
typedef struct _DC
{
- GDIOBJHDR header;
HDC hSelf;
DHPDEV PDev;
DEVMODEW DMW;
/* Internal functions */
#define DC_PtrToHandle(pDC) \
- ((HDC) GDIOBJ_PtrToHandle((PGDIOBJ)pDC, GO_DC_MAGIC))
+ ((HDC) GDIOBJ_PtrToHandle ((PGDIOBJ) pDC, GO_DC_MAGIC))
#define DC_HandleToPtr(hDC) \
- ((PDC) GDIOBJ_HandleToPtr((HGDIOBJ)hDC, GO_DC_MAGIC))
-#define DC_LockDC(hDC) GDIOBJ_LockObject((HGDIOBJ)hDC)
-#define DC_UnlockDC(hDC) GDIOBJ_UnlockObject((HGDIOBJ)hDC)
+ ((PDC) GDIOBJ_HandleToPtr ((HGDIOBJ) hDC, GO_DC_MAGIC))
+#define DC_LockDC(hDC) GDIOBJ_LockObject ((HGDIOBJ) hDC)
+#define DC_UnlockDC(hDC) GDIOBJ_UnlockObject ((HGDIOBJ) hDC)
PDC DC_AllocDC(LPCWSTR Driver);
void DC_InitDC(PDC DCToInit);
PDC DC_FindOpenDC(LPCWSTR Driver);
#define GO_ENHMETAFILE_DC_MAGIC 0x4f53
#define GO_MAGIC_DONTCARE 0xffff
+/* (RJJ) swiped stock handles from wine */
+ /* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */
+#define FIRST_STOCK_HANDLE 0xffffff00
+
+ /* Stock objects handles */
+#define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1)
+#define STOCK_WHITE_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+WHITE_BRUSH))
+#define STOCK_LTGRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+LTGRAY_BRUSH))
+#define STOCK_GRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+GRAY_BRUSH))
+#define STOCK_DKGRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+DKGRAY_BRUSH))
+#define STOCK_BLACK_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+BLACK_BRUSH))
+#define STOCK_NULL_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+NULL_BRUSH))
+#define STOCK_HOLLOW_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+HOLLOW_BRUSH))
+#define STOCK_WHITE_PEN ((HPEN)(FIRST_STOCK_HANDLE+WHITE_PEN))
+#define STOCK_BLACK_PEN ((HPEN)(FIRST_STOCK_HANDLE+BLACK_PEN))
+#define STOCK_NULL_PEN ((HPEN)(FIRST_STOCK_HANDLE+NULL_PEN))
+#define STOCK_OEM_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+OEM_FIXED_FONT))
+#define STOCK_ANSI_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+ANSI_FIXED_FONT))
+#define STOCK_ANSI_VAR_FONT ((HFONT)(FIRST_STOCK_HANDLE+ANSI_VAR_FONT))
+#define STOCK_SYSTEM_FONT ((HFONT)(FIRST_STOCK_HANDLE+SYSTEM_FONT))
+#define STOCK_DEVICE_DEFAULT_FONT ((HFONT)(FIRST_STOCK_HANDLE+DEVICE_DEFAULT_FONT))
+#define STOCK_DEFAULT_PALETTE ((HPALETTE)(FIRST_STOCK_HANDLE+DEFAULT_PALETTE))
+#define STOCK_SYSTEM_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+SYSTEM_FIXED_FONT))
+#define STOCK_DEFAULT_GUI_FONT ((HFONT)(FIRST_STOCK_HANDLE+DEFAULT_GUI_FONT))
+#define FIRST_STOCK_FONT STOCK_OEM_FIXED_FONT
+#define LAST_STOCK_FONT STOCK_DEFAULT_GUI_FONT
+#define LAST_STOCK_HANDLE ((DWORD)STOCK_DEFAULT_GUI_FONT)
+
typedef struct _GDIOBJHDR
{
HANDLE hNext;
PGDIOBJ GDIOBJ_HandleToPtr (HGDIOBJ Obj, WORD Magic);
BOOL GDIOBJ_LockObject (HGDIOBJ Obj);
BOOL GDIOBJ_UnlockObject (HGDIOBJ Obj);
+HGDIOBJ GDIOBJ_GetNextObject (HGDIOBJ Obj, WORD Magic);
+HGDIOBJ GDIOBJ_SetNextObject (HGDIOBJ Obj, WORD Magic, HGDIOBJ NextObj);
#endif
#include <win32k/color.h>
#include <win32k/coord.h>
#include <win32k/dc.h>
+#include <win32k/debug.h>
#include <win32k/fillshap.h>
#include <win32k/icm.h>
#include <win32k/line.h>
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
+#include <stdlib.h>
#include <win32k/bitmaps.h>
+#include <win32k/debug.h>
// #define NDEBUG
#include <internal/debug.h>
bmp->bitmap.bmHeight = Height;
bmp->bitmap.bmPlanes = Planes;
bmp->bitmap.bmBitsPixel = BitsPerPel;
- bmp->bitmap.bmWidthBytes = BITMAP_GetWidthBytes (Width, BitsPerPel);
+ bmp->bitmap.bmWidthBytes = BITMAPOBJ_GetWidthBytes (Width, BitsPerPel);
bmp->bitmap.bmBits = NULL;
bmp->DDBitmap = NULL;
bmp->dib = NULL;
INT Width,
INT Height)
{
- UNIMPLEMENTED;
+ /* FIXME: this probably should do something else */
+ return W32kCreateCompatibleBitmap(hDC, Width, Height);
}
BOOL W32kExtFloodFill(HDC hDC,
BOOL W32kGetBitmapDimensionEx(HBITMAP hBitmap,
LPSIZE Dimension)
{
- UNIMPLEMENTED;
+ PBITMAPOBJ bmp;
+
+ bmp = BITMAPOBJ_HandleToPtr (hBitmap);
+ if (bmp == NULL)
+ {
+ return FALSE;
+ }
+
+ *Dimension = bmp->size;
+ BITMAPOBJ_UnlockBitmap (hBitmap);
+
+ return TRUE;
}
UINT W32kGetDIBColorTable(HDC hDC,
DWORD Bytes,
CONST VOID *Bits)
{
- UNIMPLEMENTED;
+ DWORD height, ret;
+ PBITMAPOBJ bmp;
+
+ bmp = BITMAPOBJ_HandleToPtr (hBitmap);
+ if (bmp == NULL || Bits == NULL)
+ {
+ return 0;
+ }
+
+ if (Bytes < 0)
+ {
+ DPRINT ("(%ld): Negative number of bytes passed???\n", Bytes );
+ Bytes = -Bytes;
+ }
+
+ /* Only get entire lines */
+ height = Bytes / bmp->bitmap.bmWidthBytes;
+ if (height > bmp->bitmap.bmHeight)
+ {
+ height = bmp->bitmap.bmHeight;
+ }
+ Bytes = height * bmp->bitmap.bmWidthBytes;
+ DPRINT ("(%08x, %ld, %p) %dx%d %d colors fetched height: %ld\n",
+ hBitmap,
+ Bytes,
+ Bits,
+ bmp->bitmap.bmWidth,
+ bmp->bitmap.bmHeight,
+ 1 << bmp->bitmap.bmBitsPixel,
+ height);
+
+#if 0
+ /* FIXME: call DDI specific function here if available */
+ if(bmp->DDBitmap)
+ {
+ DPRINT ("Calling device specific BitmapBits\n");
+ if (bmp->DDBitmap->funcs->pBitmapBits)
+ {
+ ret = bmp->DDBitmap->funcs->pBitmapBits(hBitmap,
+ (void *) Bits,
+ Bytes,
+ DDB_SET);
+ }
+ else
+ {
+ DPRINT ("BitmapBits == NULL??\n");
+ ret = 0;
+ }
+ }
+ else
+#endif
+ {
+ /* FIXME: Alloc enough for entire bitmap */
+ if (bmp->bitmap.bmBits == NULL)
+ {
+ bmp->bitmap.bmBits = ExAllocatePool (NonPagedPool, Bytes);
+ }
+ if(!bmp->bitmap.bmBits)
+ {
+ DPRINT ("Unable to allocate bit buffer\n");
+ ret = 0;
+ }
+ else
+ {
+ memcpy(bmp->bitmap.bmBits, Bits, Bytes);
+ ret = Bytes;
+ }
+ }
+ BITMAPOBJ_UnlockBitmap (hBitmap);
+
+ return ret;
}
BOOL W32kSetBitmapDimensionEx(HBITMAP hBitmap,
INT Height,
LPSIZE Size)
{
- UNIMPLEMENTED;
+ PBITMAPOBJ bmp;
+
+ bmp = BITMAPOBJ_HandleToPtr (hBitmap);
+ if (bmp == NULL)
+ {
+ return FALSE;
+ }
+
+ if (Size)
+ {
+ *Size = bmp->size;
+ }
+ bmp->size.cx = Width;
+ bmp->size.cy = Height;
+ BITMAPOBJ_UnlockBitmap (hBitmap);
+
+ return TRUE;
}
UINT W32kSetDIBColorTable(HDC hDC,
/* Internal Functions */
INT
-BITMAP_GetWidthBytes (INT bmWidth, INT bpp)
+BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp)
{
switch(bpp)
{
return 2 * ((bmWidth+3) >> 2);
default:
- UNIMPLEMENTED;
+ FIXME ("stub");
}
return -1;
}
+HBITMAP BITMAPOBJ_CopyBitmap(HBITMAP hBitmap)
+{
+ PBITMAPOBJ bmp;
+ HBITMAP res;
+ BITMAP bm;
+
+ bmp = BITMAPOBJ_HandleToPtr (hBitmap);
+ if (bmp == NULL)
+ {
+ return 0;
+ }
+ res = 0;
+
+ bm = bmp->bitmap;
+ bm.bmBits = NULL;
+ res = W32kCreateBitmapIndirect(&bm);
+ if(res)
+ {
+ char *buf;
+
+ buf = ExAllocatePool (NonPagedPool, bm.bmWidthBytes * bm.bmHeight);
+ W32kGetBitmapBits (hBitmap, bm.bmWidthBytes * bm.bmHeight, buf);
+ W32kSetBitmapBits (res, bm.bmWidthBytes * bm.bmHeight, buf);
+ ExFreePool (buf);
+ }
+ BITMAPOBJ_UnlockBitmap (hBitmap);
+
+ return res;
+}
+
+/***********************************************************************
+ * DIB_GetDIBWidthBytes
+ *
+ * Return the width of a DIB bitmap in bytes. DIB bitmap data is 32-bit aligned.
+ * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/struc/src/str01.htm
+ * 11/16/1999 (RJJ) lifted from wine
+ */
+int DIB_GetDIBWidthBytes(int width, int depth)
+{
+ int words;
+
+ switch(depth)
+ {
+ case 1: words = (width + 31) / 32; break;
+ case 4: words = (width + 7) / 8; break;
+ case 8: words = (width + 3) / 4; break;
+ case 15:
+ case 16: words = (width + 1) / 2; break;
+ case 24: words = (width * 3 + 3)/4; break;
+
+ default:
+ DPRINT("(%d): Unsupported depth\n", depth );
+ /* fall through */
+ case 32:
+ words = width;
+ }
+ return 4 * words;
+}
+
+/***********************************************************************
+ * DIB_GetDIBImageBytes
+ *
+ * Return the number of bytes used to hold the image in a DIB bitmap.
+ * 11/16/1999 (RJJ) lifted from wine
+ */
+
+int DIB_GetDIBImageBytes (int width, int height, int depth)
+{
+ return DIB_GetDIBWidthBytes( width, depth ) * abs( height );
+}
+
+/***********************************************************************
+ * DIB_BitmapInfoSize
+ *
+ * Return the size of the bitmap info structure including color table.
+ * 11/16/1999 (RJJ) lifted from wine
+ */
+
+int DIB_BitmapInfoSize (const BITMAPINFO * info, WORD coloruse)
+{
+ int colors;
+
+ if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
+ {
+ BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)info;
+ colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0;
+ return sizeof(BITMAPCOREHEADER) + colors *
+ ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD));
+ }
+ else /* assume BITMAPINFOHEADER */
+ {
+ colors = info->bmiHeader.biClrUsed;
+ if (!colors && (info->bmiHeader.biBitCount <= 8))
+ colors = 1 << info->bmiHeader.biBitCount;
+ return sizeof(BITMAPINFOHEADER) + colors *
+ ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
+ }
+}
+
-/* $Id: brush.c,v 1.5 1999/10/28 23:37:14 rex Exp $
+/* $Id: brush.c,v 1.6 1999/11/17 20:54:05 rex Exp $
*/
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddk/ntddk.h>
+#include <win32k/bitmaps.h>
#include <win32k/brush.h>
+#include <win32k/debug.h>
// #define NDEBUG
#include <internal/debug.h>
HBRUSH W32kCreateBrushIndirect(CONST LOGBRUSH *lb)
{
- UNIMPLEMENTED;
+ PBRUSHOBJ brushPtr;
+ HBRUSH hBrush;
+
+ hBrush = BRUSHOBJ_AllocBrush ();
+ if (hBrush == NULL)
+ {
+ return 0;
+ }
+
+ brushPtr = BRUSHOBJ_HandleToPtr (hBrush);
+ brushPtr->logbrush.lbStyle = lb->lbStyle;
+ brushPtr->logbrush.lbColor = lb->lbColor;
+ brushPtr->logbrush.lbHatch = lb->lbHatch;
+ BRUSHOBJ_UnlockBrush (hBrush);
+ DPRINT("%08x\n", hBrush);
+
+ return hBrush;
}
HBRUSH W32kCreateDIBPatternBrush(HGLOBAL hDIBPacked,
UINT ColorSpec)
{
UNIMPLEMENTED;
+#if 0
+ LOGBRUSH logbrush;
+ PBITMAPINFO info, newInfo;
+ INT size;
+
+ DPRINT("%04x\n", hbitmap );
+
+ logbrush.lbStyle = BS_DIBPATTERN;
+ logbrush.lbColor = coloruse;
+ logbrush.lbHatch = 0;
+
+ /* Make a copy of the bitmap */
+ if (!(info = (BITMAPINFO *)GlobalLock( hbitmap )))
+ {
+ return 0;
+ }
+
+
+ if (info->bmiHeader.biCompression)
+ size = info->bmiHeader.biSizeImage;
+ else
+ size = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
+ info->bmiHeader.biHeight,
+ info->bmiHeader.biBitCount);
+ size += DIB_BitmapInfoSize( info, coloruse );
+
+ if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size )))
+ {
+ GlobalUnlock16( hbitmap );
+ return 0;
+ }
+ newInfo = (BITMAPINFO *) GlobalLock16( (HGLOBAL16)logbrush.lbHatch );
+ memcpy( newInfo, info, size );
+ GlobalUnlock16( (HGLOBAL16)logbrush.lbHatch );
+ GlobalUnlock( hbitmap );
+ return W32kCreateBrushIndirect( &logbrush );
+#endif
}
HBRUSH W32kCreateDIBPatternBrushPt(CONST VOID *PackedDIB,
UINT Usage)
{
- UNIMPLEMENTED;
+ 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 = (INT)
+ GDIOBJ_PtrToHandle (GDIOBJ_AllocObject (size, GO_MAGIC_DONTCARE),
+ GO_MAGIC_DONTCARE);
+ if (logbrush.lbHatch == 0)
+ {
+ return 0;
+ }
+ newInfo = (PBITMAPINFO) GDIOBJ_HandleToPtr ((HGDIOBJ) logbrush.lbHatch,
+ GO_MAGIC_DONTCARE);
+ memcpy (newInfo, info, size);
+ GDIOBJ_UnlockObject ((HGDIOBJ) logbrush.lbHatch);
+
+ return W32kCreateBrushIndirect (&logbrush);
}
HBRUSH W32kCreateHatchBrush(INT Style,
COLORREF Color)
{
- UNIMPLEMENTED;
+ 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 W32kCreateBrushIndirect (&logbrush);
}
HBRUSH W32kCreatePatternBrush(HBITMAP hBitmap)
{
- UNIMPLEMENTED;
+ LOGBRUSH logbrush = { BS_PATTERN, 0, 0 };
+
+ DPRINT ("%04x\n", hBitmap);
+ logbrush.lbHatch = (INT) BITMAPOBJ_CopyBitmap (hBitmap);
+ if(!logbrush.lbHatch)
+ {
+ return 0;
+ }
+ else
+ {
+ return W32kCreateBrushIndirect( &logbrush );
+ }
}
HBRUSH W32kCreateSolidBrush(COLORREF Color)
-/* $Id: dc.c,v 1.8 1999/10/31 22:43:40 ea Exp $
+/* $Id: dc.c,v 1.9 1999/11/17 20:54:05 rex Exp $
*
* DC.C - Device context functions
*
HBITMAP hBitmap;
OrigDC = DC_HandleToPtr(hDC);
-
+ if (OrigDC == NULL)
+ {
+ return 0;
+ }
+
/* Allocate a new DC based on the original DC's device */
NewDC = DC_AllocDC(OrigDC->DriverName);
if (NewDC == NULL)
UNIMPLEMENTED;
DCToDelete = DC_HandleToPtr(DCHandle);
-
- /* FIXME: Verify that is is a valid handle */
+ if (DCToDelete == NULL)
+ {
+ return FALSE;
+ }
DCToDelete->DriverFunctions.DisableSurface(DCToDelete->PDev);
DCToDelete->DriverFunctions.DisablePDev(DCToDelete->PDev);
- DC_FreeDC(DCToDelete);
+ /* First delete all saved DCs */
+ while (DCToDelete->saveLevel)
+ {
+ PDC savedDC;
+ HDC savedHDC;
+
+ savedHDC = GDIOBJ_GetNextObject (DCHandle, GO_DC_MAGIC);
+ savedDC = DC_HandleToPtr (savedHDC);
+ if (savedDC == NULL)
+ {
+ break;
+ }
+ GDIOBJ_SetNextObject (DCHandle, GO_DC_MAGIC, GDIOBJ_GetNextObject (savedHDC, GO_DC_MAGIC));
+ DCToDelete->saveLevel--;
+ DC_UnlockDC (savedDC);
+ W32kDeleteDC (savedHDC);
+ }
+
+ /* Free GDI resources allocated to this DC */
+ if (!(DCToDelete->w.flags & DC_SAVED))
+ {
+ DC_UnlockDC (DCToDelete);
+ SelectObject (DCHandle, STOCK_BLACK_PEN);
+ SelectObject (DCHandle, STOCK_WHITE_BRUSH);
+ SelectObject (DCHandle, STOCK_SYSTEM_FONT);
+ DC_LockDC (DCHandle);
+ if (DCToDelete->w.flags & DC_MEMORY)
+ {
+ W32kDeleteObject (DCToDelete->w.hFirstBitmap);
+ }
+ }
+ if (DCToDelete->w.hClipRgn)
+ {
+ W32kDeleteObject (DCToDelete->w.hClipRgn);
+ }
+ if (DCToDelete->w.hVisRgn)
+ {
+ W32kDeleteObject (DCToDelete->w.hVisRgn);
+ }
+ if (DCToDelete->w.hGCClipRgn)
+ {
+ W32kDeleteObject (DCToDelete->w.hGCClipRgn);
+ }
+#if 0 /* FIXME */
+ PATH_DestroyGdiPath (&DCToDelete->w.path);
+#endif
+
+ DC_FreeDC (DCToDelete);
return STATUS_SUCCESS;
}
success = TRUE;
while (dc->saveLevel >= SaveLevel)
{
- HDC hdcs = dc->header.hNext;
+ HDC hdcs = GDIOBJ_GetNextObject (hDC, GO_DC_MAGIC);
- dcs = DC_HandleToPtr(hdcs);
+ dcs = DC_HandleToPtr (hdcs);
if (dcs == NULL)
{
- DC_UnlockDC(hDC);
+ DC_UnlockDC (hDC);
return FALSE;
}
- dc->header.hNext = dcs->header.hNext;
+ GDIOBJ_SetNextObject (hDC, GO_DC_MAGIC, GDIOBJ_GetNextObject (hdcs, GO_DC_MAGIC));
if (--dc->saveLevel < SaveLevel)
{
- W32kSetDCState16(hDC, hdcs);
+ W32kSetDCState16 (hDC, hdcs);
#if 0
if (!PATH_AssignGdiPath( &dc->w.path, &dcs->w.path ))
{
}
#endif
}
- W32kDeleteDC(hdcs);
+ W32kDeleteDC (hdcs);
}
- DC_UnlockDC(hDC);
+ DC_UnlockDC (hDC);
return success;
}
PDC dc, dcs;
INT ret;
- dc = DC_HandleToPtr(hDC);
+ dc = DC_HandleToPtr (hDC);
if (dc == NULL)
{
return 0;
}
- if (!(hdcs = W32kGetDCState16(hDC)))
+ if (!(hdcs = W32kGetDCState16 (hDC)))
{
- DC_UnlockDC(hDC);
+ DC_UnlockDC (hDC);
return 0;
}
- dcs = DC_HandleToPtr(hdcs);
+ dcs = DC_HandleToPtr (hdcs);
#if 0
/* Copy path. The reason why path saving / restoring is in SaveDC/
* SetDCState doesn't allow us to signal an error (which can happen
* when copying paths).
*/
- if (!PATH_AssignGdiPath(&dcs->w.path, &dc->w.path))
+ if (!PATH_AssignGdiPath (&dcs->w.path, &dc->w.path))
{
- DC_UnlockDC(hdc);
- DC_UnlockDC(hdcs);
- W32kDeleteDC(hdcs);
+ DC_UnlockDC (hdc);
+ DC_UnlockDC (hdcs);
+ W32kDeleteDC (hdcs);
return 0;
}
#endif
- dcs->header.hNext = dc->header.hNext;
- dc->header.hNext = hdcs;
+ GDIOBJ_SetNextObject (hdcs, GO_DC_MAGIC, GDIOBJ_GetNextObject (hDC, GO_DC_MAGIC));
+ GDIOBJ_SetNextObject (hDC, GO_DC_MAGIC, hdcs);
ret = ++dc->saveLevel;
- DC_UnlockDC(hdcs);
- DC_UnlockDC(hDC);
+ DC_UnlockDC (hdcs);
+ DC_UnlockDC (hDC);
return ret;
}
wcslen(Driver) * sizeof(WCHAR));
wcscpy(NewDC->DriverName, Driver);
}
-
+
return NewDC;
}
/*
* GDIOBJ.C - GDI object manipulation routines
*
- * $Id: gdiobj.c,v 1.3 1999/10/29 01:58:20 rex Exp $
+ * $Id: gdiobj.c,v 1.4 1999/11/17 20:54:05 rex Exp $
*
*/
{
PGDIOBJHDR NewObj;
- NewObj = ExAllocatePool(NonPagedPool, Size);
+ NewObj = ExAllocatePool(PagedPool, Size + sizeof (GDIOBJHDR));
if (NewObj == NULL)
{
return NULL;
}
- RtlZeroMemory(NewObj, Size);
+ RtlZeroMemory(NewObj, Size + sizeof (GDIOBJHDR));
NewObj->wMagic = Magic;
#if 0
KeInitializeSpinlock(&NewObj->Lock);
#endif
- return NewObj;
+ return (PGDIOBJ)(((PCHAR) NewObj) + sizeof (GDIOBJHDR));
}
HGDIOBJ GDIOBJ_PtrToHandle (PGDIOBJ Obj, WORD Magic)
{
- if (((PGDIOBJHDR)Obj)->wMagic != Magic)
+ PGDIOBJHDR objHeader;
+
+ objHeader = (PGDIOBJHDR) (((PCHAR)Obj) - sizeof (GDIOBJHDR));
+ if (objHeader->wMagic != Magic)
{
return 0;
}
- return (HGDIOBJ) Obj;
+ return (HGDIOBJ) objHeader;
}
PGDIOBJ GDIOBJ_HandleToPtr (HGDIOBJ Obj, WORD Magic)
{
+ PGDIOBJHDR objHeader;
+
+ objHeader = (PGDIOBJHDR) Obj;
+
/* FIXME: Lock object for duration */
- if (((PGDIOBJHDR)Obj)->wMagic != Magic)
+
+ if (objHeader->wMagic != Magic)
{
return 0;
}
- return (PGDIOBJ) Obj;
+ return (PGDIOBJ) (((PCHAR)Obj) + sizeof (GDIOBJHDR));
}
BOOL GDIOBJ_LockObject (HGDIOBJ Obj)
return TRUE;
}
+HGDIOBJ GDIOBJ_GetNextObject (HGDIOBJ Obj, WORD Magic)
+{
+ PGDIOBJHDR objHeader;
+
+ objHeader = (PGDIOBJHDR) ((PCHAR) Obj - sizeof (GDIOBJHDR));
+ if (objHeader->wMagic != Magic)
+ {
+ return 0;
+ }
+
+ return objHeader->hNext;
+}
+
+HGDIOBJ GDIOBJ_SetNextObject (HGDIOBJ Obj, WORD Magic, HGDIOBJ NextObj)
+{
+ PGDIOBJHDR objHeader;
+ HGDIOBJ oldNext;
+
+ /* FIXME: should we lock/unlock the object here? */
+ objHeader = (PGDIOBJHDR) ((PCHAR) Obj - sizeof (GDIOBJHDR));
+ if (objHeader->wMagic != Magic)
+ {
+ return 0;
+ }
+ oldNext = objHeader->hNext;
+ objHeader->hNext = NextObj;
+
+ return oldNext;
+}
+
+
+
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddk/ntddk.h>
+#include <win32k/debug.h>
#include <win32k/paint.h>
// #define NDEBUG
LPRECT Bounds,
UINT Flags)
{
- UNIMPLEMENTED;
+ FIXME("stub");
+ return DCB_RESET; /* bounding rectangle always empty */
}
COLORREF W32kSetBkColor(HDC hDC,
CONST PRECT Bounds,
UINT Flags)
{
- UNIMPLEMENTED;
+ FIXME("stub");
+ return DCB_DISABLE; /* bounding rectangle always empty */
}