Commit 2a2321bb authored by Alexandre Julliard's avatar Alexandre Julliard

Authors: Alexandre Julliard <julliard@codeweavers.com> (for Corel), Albert den…

Authors: Alexandre Julliard <julliard@codeweavers.com> (for Corel), Albert den Haan <albertd@corel.com> Added syslevel locking for GDI operations. Propagate the changes through the graphics code.
parent 9fcb4f55
......@@ -107,7 +107,7 @@ HRESULT WINAPI DGA_IDirectDrawSurface4Impl_SetPalette(
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
GDI_HEAP_UNLOCK(This->s.DIBsection);
GDI_ReleaseObj(This->s.DIBsection);
}
TSXFlush(display);
}
......@@ -137,7 +137,7 @@ ULONG WINAPI DGA_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) {
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dib->colorMap = dspriv->oldDIBmap;
GDI_HEAP_UNLOCK(This->s.DIBsection);
GDI_ReleaseObj(This->s.DIBsection);
SelectObject(This->s.hdc, This->s.holdbitmap);
DeleteDC(This->s.hdc);
......@@ -173,7 +173,7 @@ HRESULT WINAPI DGA_IDirectDrawSurface4Impl_GetDC(LPDIRECTDRAWSURFACE4 iface,HDC*
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dspriv->oldDIBmap = dib->colorMap;
dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
GDI_HEAP_UNLOCK(This->s.DIBsection);
GDI_ReleaseObj(This->s.DIBsection);
}
return result;
}
......
......@@ -401,7 +401,7 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_SetPalette(
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
GDI_HEAP_UNLOCK(This->s.DIBsection);
GDI_ReleaseObj(This->s.DIBsection);
}
}
return DD_OK;
......@@ -453,7 +453,7 @@ ULONG WINAPI Xlib_IDirectDrawSurface4Impl_Release(LPDIRECTDRAWSURFACE4 iface) {
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(This->s.DIBsection, BITMAP_MAGIC);
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dib->colorMap = dspriv->oldDIBmap;
GDI_HEAP_UNLOCK(This->s.DIBsection);
GDI_ReleaseObj(This->s.DIBsection);
SelectObject(This->s.hdc, This->s.holdbitmap);
DeleteDC(This->s.hdc);
......@@ -479,7 +479,7 @@ HRESULT WINAPI Xlib_IDirectDrawSurface4Impl_GetDC(LPDIRECTDRAWSURFACE4 iface,HDC
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *)bmp->dib;
dspriv->oldDIBmap = dib->colorMap;
dib->colorMap = This->s.palette ? This->s.palette->screen_palents : NULL;
GDI_HEAP_UNLOCK(This->s.DIBsection);
GDI_ReleaseObj(This->s.DIBsection);
}
return result;
}
......
......@@ -15,15 +15,9 @@
/***********************************************************************
* GDI initialisation routine
*/
BOOL WINAPI MAIN_GdiInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
BOOL WINAPI MAIN_GdiInit(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved)
{
HINSTANCE16 instance;
if ( GDI_HeapSel ) return TRUE;
/* Create GDI heap */
if ((instance = LoadLibrary16( "GDI.EXE" )) < 32) return FALSE;
GDI_HeapSel = GlobalHandleToSel16( instance );
if (reason != DLL_PROCESS_ATTACH) return TRUE;
if (!TWEAK_Init()) return FALSE;
......
......@@ -69,6 +69,7 @@ INT16 WINAPI StartDoc16( HDC16 hdc, const DOCINFO16 *lpdoc )
*/
INT WINAPI StartDocA(HDC hdc, const DOCINFOA* doc)
{
INT ret;
DC *dc = DC_GetDCPtr( hdc );
TRACE("DocName = '%s' Output = '%s' Datatype = '%s'\n",
......@@ -77,10 +78,12 @@ INT WINAPI StartDocA(HDC hdc, const DOCINFOA* doc)
if(!dc) return SP_ERROR;
if(dc->funcs->pStartDoc)
return dc->funcs->pStartDoc( dc, doc );
ret = dc->funcs->pStartDoc( dc, doc );
else
return Escape(hdc, STARTDOC, strlen(doc->lpszDocName),
ret = Escape(hdc, STARTDOC, strlen(doc->lpszDocName),
doc->lpszDocName, (LPVOID)doc);
GDI_ReleaseObj( hdc );
return ret;
}
/*************************************************************************
......@@ -128,13 +131,16 @@ INT16 WINAPI EndDoc16(HDC16 hdc)
*/
INT WINAPI EndDoc(HDC hdc)
{
INT ret;
DC *dc = DC_GetDCPtr( hdc );
if(!dc) return SP_ERROR;
if(dc->funcs->pEndDoc)
return dc->funcs->pEndDoc( dc );
ret = dc->funcs->pEndDoc( dc );
else
return Escape(hdc, ENDDOC, 0, 0, 0);
ret = Escape(hdc, ENDDOC, 0, 0, 0);
GDI_ReleaseObj( hdc );
return ret;
}
/******************************************************************
......@@ -152,14 +158,16 @@ INT16 WINAPI StartPage16(HDC16 hdc)
*/
INT WINAPI StartPage(HDC hdc)
{
INT ret = 1;
DC *dc = DC_GetDCPtr( hdc );
if(!dc) return SP_ERROR;
if(dc->funcs->pStartPage)
return dc->funcs->pStartPage( dc );
FIXME("stub\n");
return 1;
ret = dc->funcs->pStartPage( dc );
else
FIXME("stub\n");
GDI_ReleaseObj( hdc );
return ret;
}
/******************************************************************
......@@ -177,13 +185,16 @@ INT16 WINAPI EndPage16( HDC16 hdc )
*/
INT WINAPI EndPage(HDC hdc)
{
INT ret;
DC *dc = DC_GetDCPtr( hdc );
if(!dc) return SP_ERROR;
if(dc->funcs->pEndPage)
return dc->funcs->pEndPage( dc );
ret = dc->funcs->pEndPage( dc );
else
return Escape(hdc, NEWFRAME, 0, 0, 0);
ret = Escape(hdc, NEWFRAME, 0, 0, 0);
GDI_ReleaseObj( hdc );
return ret;
}
/******************************************************************************
......@@ -199,13 +210,16 @@ INT16 WINAPI AbortDoc16(HDC16 hdc)
*/
INT WINAPI AbortDoc(HDC hdc)
{
INT ret;
DC *dc = DC_GetDCPtr( hdc );
if(!dc) return SP_ERROR;
if(dc->funcs->pAbortDoc)
return dc->funcs->pAbortDoc( dc );
ret = dc->funcs->pAbortDoc( dc );
else
return Escape(hdc, ABORTDOC, 0, 0, 0);
ret = Escape(hdc, ABORTDOC, 0, 0, 0);
GDI_ReleaseObj( hdc );
return ret;
}
/**********************************************************************
......@@ -219,6 +233,7 @@ INT WINAPI AbortDoc(HDC hdc)
*/
BOOL16 WINAPI QueryAbort16(HDC16 hdc, INT16 reserved)
{
BOOL ret = TRUE;
DC *dc = DC_GetDCPtr( hdc );
if(!dc) {
......@@ -226,9 +241,9 @@ BOOL16 WINAPI QueryAbort16(HDC16 hdc, INT16 reserved)
return FALSE;
}
if(!dc->w.pAbortProc)
return TRUE;
return dc->w.pAbortProc(hdc, 0);
if (dc->w.pAbortProc) ret = dc->w.pAbortProc(hdc, 0);
GDI_ReleaseObj( hdc );
return ret;
}
/* ### start build ### */
......@@ -256,6 +271,7 @@ INT WINAPI SetAbortProc(HDC hdc, ABORTPROC abrtprc)
if(dc->w.pAbortProc) THUNK_Free((FARPROC)dc->w.pAbortProc);
dc->w.pAbortProc = abrtprc;
GDI_ReleaseObj( hdc );
return TRUE;
}
......
......@@ -91,6 +91,7 @@ HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
{
BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( hWinGBitmap, BITMAP_MAGIC );
SEGPTR res = 0;
TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
if (!bmp) return (SEGPTR)NULL;
......@@ -99,10 +100,11 @@ SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
FIXME(": Todo - implement setting BITMAPINFO\n");
#ifndef X_DISPLAY_MISSING
return PTR_SEG_OFF_TO_SEGPTR(((X11DRV_DIBSECTION *) bmp->dib)->selector, 0);
#else /* !defined(X_DISPLAY_MISSING) */
return NULL;
res = PTR_SEG_OFF_TO_SEGPTR(((X11DRV_DIBSECTION *) bmp->dib)->selector, 0);
#endif /* !defined(X_DISPLAY_MISSING) */
GDI_ReleaseObj( hWinGBitmap );
return res;
}
/***********************************************************************
......
......@@ -94,6 +94,7 @@ HGLRC WINAPI wglCreateContext(HDC hdc) {
if (vis == NULL) {
ERR("NULL visual !!!\n");
/* Need to set errors here */
GDI_ReleaseObj( hdc );
return NULL;
}
......@@ -106,6 +107,7 @@ HGLRC WINAPI wglCreateContext(HDC hdc) {
TRACE(" creating context %p (GL context creation delayed)\n", ret);
GDI_ReleaseObj( hdc );
return (HGLRC) ret;
}
......@@ -342,6 +344,7 @@ BOOL WINAPI wglMakeCurrent(HDC hdc,
physDev->drawable,
ctx->ctx);
LEAVE_GL();
GDI_ReleaseObj( hdc );
}
}
TRACE(" returning %s\n", (ret ? "True" : "False"));
......@@ -431,7 +434,7 @@ BOOL WINAPI wglUseFontBitmapsA(HDC hdc,
/* I assume that the glyphs are at the same position for X and for Windows */
glXUseXFont(fid, first, count, listBase);
LEAVE_GL();
GDI_ReleaseObj( hdc );
return TRUE;
}
......
......@@ -55,7 +55,7 @@ LONG TTYDRV_DC_BitmapBits(HBITMAP hbitmap, void *bits, LONG count, WORD flags)
result = 0;
}
GDI_HEAP_UNLOCK(hbitmap);
GDI_ReleaseObj(hbitmap);
return result;
}
......@@ -73,7 +73,7 @@ BOOL TTYDRV_DC_CreateBitmap(HBITMAP hbitmap)
return FALSE;
if(!(physBitmap = TTYDRV_DC_AllocBitmap(bitmap))) {
GDI_HEAP_UNLOCK(hbitmap);
GDI_ReleaseObj(hbitmap);
return FALSE;
}
......@@ -84,7 +84,7 @@ BOOL TTYDRV_DC_CreateBitmap(HBITMAP hbitmap)
DDB_SET );
}
GDI_HEAP_UNLOCK(hbitmap);
GDI_ReleaseObj(hbitmap);
return TRUE;
}
......
......@@ -232,7 +232,7 @@ BOOL TTYDRV_DC_CreateDC(DC *dc, LPCSTR driver, LPCSTR device,
dc->w.totalExtent.bottom = bmp->bitmap.bmHeight;
dc->w.hVisRgn = CreateRectRgnIndirect( &dc->w.totalExtent );
GDI_HEAP_UNLOCK( dc->w.hBitmap );
GDI_ReleaseObj( dc->w.hBitmap );
} else {
physDev->window = TTYDRV_GetRootWindow();
physDev->cellWidth = cell_width;
......
......@@ -98,7 +98,7 @@ HGDIOBJ TTYDRV_DC_SelectObject(DC *dc, HGDIOBJ handle)
ERR("handle (0x%04x) has unknown magic (0x%04x)\n", handle, ptr->wMagic);
}
GDI_HEAP_UNLOCK(handle);
GDI_ReleaseObj(handle);
return result;
}
......@@ -129,7 +129,7 @@ BOOL TTYDRV_DC_DeleteObject(HGDIOBJ handle)
result = FALSE;
}
GDI_HEAP_UNLOCK(handle);
GDI_ReleaseObj(handle);
return result;
}
......@@ -230,20 +230,20 @@ void TTYDRV_WND_SetDrawable(WND *wndPtr, HDC hdc, WORD flags, BOOL bSetClipOrigi
if (!dc) return;
TRACE("(%p, %p, %d, %d)\n", wndPtr, dc, flags, bSetClipOrigin);
/* FIXME: Should be done in the common code instead */
if(!wndPtr) {
dc->w.DCOrgX = 0;
dc->w.DCOrgY = 0;
} else {
if(flags & DCX_WINDOW) {
dc->w.DCOrgX = wndPtr->rectWindow.left;
dc->w.DCOrgY = wndPtr->rectWindow.top;
/* FIXME: Should be done in the common code instead */
if(!wndPtr) {
dc->w.DCOrgX = 0;
dc->w.DCOrgY = 0;
} else {
dc->w.DCOrgX = wndPtr->rectClient.left;
dc->w.DCOrgY = wndPtr->rectClient.top;
if(flags & DCX_WINDOW) {
dc->w.DCOrgX = wndPtr->rectWindow.left;
dc->w.DCOrgY = wndPtr->rectWindow.top;
} else {
dc->w.DCOrgX = wndPtr->rectClient.left;
dc->w.DCOrgY = wndPtr->rectClient.top;
}
}
}
GDI_HEAP_UNLOCK( hdc );
GDI_ReleaseObj( hdc );
}
/***********************************************************************
......
......@@ -60,6 +60,7 @@ HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush, BRUSHOBJ * brush )
*/
static BOOL PSDRV_SetBrush(DC *dc)
{
BOOL ret = TRUE;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC );
......@@ -78,11 +79,12 @@ static BOOL PSDRV_SetBrush(DC *dc)
break;
default:
return FALSE;
ret = FALSE;
break;
}
physDev->brush.set = TRUE;
GDI_ReleaseObj( dc->w.hBrush );
return TRUE;
}
......@@ -121,6 +123,7 @@ static BOOL PSDRV_Clip(DC *dc, BOOL EO)
*/
BOOL PSDRV_Brush(DC *dc, BOOL EO)
{
BOOL ret = TRUE;
BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->w.hBrush, BRUSH_MAGIC );
PSDRV_PDEVICE *physDev = dc->physDev;
......@@ -135,7 +138,6 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
PSDRV_WriteGSave(dc);
PSDRV_Fill(dc, EO);
PSDRV_WriteGRestore(dc);
return TRUE;
break;
case BS_HATCHED:
......@@ -185,13 +187,12 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
default:
ERR("Unknown hatch style\n");
return FALSE;
ret = FALSE;
break;
}
return TRUE;
break;
case BS_NULL:
return TRUE;
break;
case BS_PATTERN:
......@@ -212,18 +213,19 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
PSDRV_WriteGRestore(dc);
} else {
FIXME("Trying to set a pattern brush on a level 1 printer\n");
ret = FALSE;
}
HeapFree(PSDRV_Heap, 0, bits);
return TRUE;
}
break;
default:
return FALSE;
ret = FALSE;
break;
}
GDI_ReleaseObj( dc->w.hBrush );
return ret;
}
......
......@@ -8,6 +8,8 @@
#include "winspool.h"
#include "psdrv.h"
#include "debugtools.h"
#include "dc.h"
#include "winerror.h"
DEFAULT_DEBUG_CHANNEL(psdrv)
......@@ -265,11 +267,15 @@ BOOL PSDRV_SetFont( DC *dc )
/***********************************************************************
* PSDRV_GetFontMetric
*/
static UINT PSDRV_GetFontMetric(DC *dc, AFM *pafm, NEWTEXTMETRIC16 *pTM,
static UINT PSDRV_GetFontMetric(HDC hdc, AFM *pafm, NEWTEXTMETRIC16 *pTM,
ENUMLOGFONTEX16 *pLF, INT16 size)
{
DC *dc = DC_GetDCPtr( hdc );
float scale = size / (pafm->FullAscender - pafm->Descender);
if (!dc) return FALSE;
memset( pLF, 0, sizeof(*pLF) );
memset( pTM, 0, sizeof(*pTM) );
......@@ -300,8 +306,8 @@ static UINT PSDRV_GetFontMetric(DC *dc, AFM *pafm, NEWTEXTMETRIC16 *pTM,
*(INT*)&pTM->tmFirstChar = 32;
GDI_ReleaseObj( hdc );
/* return font type */
return DEVICE_FONTTYPE;
}
......@@ -309,7 +315,7 @@ static UINT PSDRV_GetFontMetric(DC *dc, AFM *pafm, NEWTEXTMETRIC16 *pTM,
/***********************************************************************
* PSDRV_EnumDeviceFonts
*/
BOOL PSDRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf,
BOOL PSDRV_EnumDeviceFonts( HDC hdc, LPLOGFONT16 plf,
DEVICEFONTENUMPROC proc, LPARAM lp )
{
ENUMLOGFONTEX16 lf;
......@@ -317,7 +323,14 @@ BOOL PSDRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf,
BOOL b, bRet = 0;
AFMLISTENTRY *afmle;
FONTFAMILY *family;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
PSDRV_PDEVICE *physDev;
DC *dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
physDev = (PSDRV_PDEVICE *)dc->physDev;
/* FIXME!! should reevaluate dc->physDev after every callback */
GDI_ReleaseObj( hdc );
if( plf->lfFaceName[0] ) {
TRACE("lfFaceName = '%s'\n", plf->lfFaceName);
......@@ -330,7 +343,7 @@ BOOL PSDRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf,
for(afmle = family->afmlist; afmle; afmle = afmle->next) {
TRACE("Got '%s'\n", afmle->afm->FontName);
if( (b = (*proc)( &lf, &tm,
PSDRV_GetFontMetric( dc, afmle->afm, &tm, &lf, 200 ),
PSDRV_GetFontMetric( hdc, afmle->afm, &tm, &lf, 200 ),
lp )) )
bRet = b;
else break;
......@@ -343,7 +356,7 @@ BOOL PSDRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf,
afmle = family->afmlist;
TRACE("Got '%s'\n", afmle->afm->FontName);
if( (b = (*proc)( &lf, &tm,
PSDRV_GetFontMetric( dc, afmle->afm, &tm, &lf, 200 ),
PSDRV_GetFontMetric( hdc, afmle->afm, &tm, &lf, 200 ),
lp )) )
bRet = b;
else break;
......
......@@ -57,6 +57,6 @@ HGDIOBJ PSDRV_SelectObject( DC *dc, HGDIOBJ handle )
ERR("Unknown object magic %04x\n", ptr->wMagic);
break;
}
GDI_HEAP_UNLOCK( handle );
GDI_ReleaseObj( handle );
return ret;
}
......@@ -324,7 +324,7 @@ extern BOOL PSDRV_Ellipse( DC *dc, INT left, INT top, INT right,
INT bottom );
extern INT PSDRV_EndDoc( DC *dc );
extern INT PSDRV_EndPage( DC *dc );
extern BOOL PSDRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf,
extern BOOL PSDRV_EnumDeviceFonts( HDC hdc, LPLOGFONT16 plf,
DEVICEFONTENUMPROC proc, LPARAM lp );
extern INT PSDRV_Escape( DC *dc, INT nEscape, INT cbInput,
SEGPTR lpInData, SEGPTR lpOutData );
......
......@@ -7,9 +7,7 @@
#include "dc.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(bitblt)
DECLARE_DEBUG_CHANNEL(bitmap)
DECLARE_DEBUG_CHANNEL(gdi)
DEFAULT_DEBUG_CHANNEL(bitblt);
/***********************************************************************
......@@ -18,11 +16,7 @@ DECLARE_DEBUG_CHANNEL(gdi)
BOOL16 WINAPI PatBlt16( HDC16 hdc, INT16 left, INT16 top,
INT16 width, INT16 height, DWORD rop)
{
DC * dc = DC_GetDCPtr( hdc );
if (!dc || !dc->funcs->pPatBlt) return FALSE;
TRACE("%04x %d,%d %dx%d %06lx\n", hdc, left, top, width, height, rop );
return dc->funcs->pPatBlt( dc, left, top, width, height, rop );
return PatBlt( hdc, left, top, width, height, rop );
}
......@@ -33,10 +27,17 @@ BOOL WINAPI PatBlt( HDC hdc, INT left, INT top,
INT width, INT height, DWORD rop)
{
DC * dc = DC_GetDCPtr( hdc );
if (!dc || !dc->funcs->pPatBlt) return FALSE;
BOOL bRet = FALSE;
TRACE("%04x %d,%d %dx%d %06lx\n", hdc, left, top, width, height, rop );
return dc->funcs->pPatBlt( dc, left, top, width, height, rop );
if (!dc) return FALSE;
if (dc->funcs->pPatBlt)
{
TRACE("%04x %d,%d %dx%d %06lx\n", hdc, left, top, width, height, rop );
bRet = dc->funcs->pPatBlt( dc, left, top, width, height, rop );
}
GDI_ReleaseObj( hdc );
return bRet;
}
......@@ -47,17 +48,7 @@ BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
INT16 height, HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
DWORD rop )
{
DC *dcDst, *dcSrc;
if (!(dcDst = DC_GetDCPtr( hdcDst ))) return FALSE;
if (!dcDst->funcs->pBitBlt) return FALSE;
dcSrc = DC_GetDCPtr( hdcSrc );
TRACE("hdcSrc=%04x %d,%d %d bpp->hdcDest=%04x %d,%d %dx%dx%d rop=%06lx\n",
hdcSrc, xSrc, ySrc, dcSrc ? dcSrc->w.bitsPerPixel : 0,
hdcDst, xDst, yDst, width, height, dcDst->w.bitsPerPixel, rop);
return dcDst->funcs->pBitBlt( dcDst, xDst, yDst, width, height,
dcSrc, xSrc, ySrc, rop );
return BitBlt( hdcDst, xDst, yDst, width, height, hdcSrc, xSrc, ySrc, rop );
}
......@@ -65,20 +56,26 @@ BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
* BitBlt (GDI32.10)
*/
BOOL WINAPI BitBlt( HDC hdcDst, INT xDst, INT yDst, INT width,
INT height, HDC hdcSrc, INT xSrc, INT ySrc,
DWORD rop )
INT height, HDC hdcSrc, INT xSrc, INT ySrc, DWORD rop )
{
BOOL ret = FALSE;
DC *dcDst, *dcSrc;
if (!(dcDst = DC_GetDCPtr( hdcDst ))) return FALSE;
if (!dcDst->funcs->pBitBlt) return FALSE;
dcSrc = DC_GetDCPtr( hdcSrc );
TRACE("hdcSrc=%04x %d,%d %d bpp->hdcDest=%04x %d,%d %dx%dx%d rop=%06lx\n",
hdcSrc, xSrc, ySrc, dcSrc ? dcSrc->w.bitsPerPixel : 0,
hdcDst, xDst, yDst, width, height, dcDst->w.bitsPerPixel, rop);
return dcDst->funcs->pBitBlt( dcDst, xDst, yDst, width, height,
dcSrc, xSrc, ySrc, rop );
if ((dcSrc = DC_GetDCUpdate( hdcSrc ))) GDI_ReleaseObj( hdcSrc );
/* FIXME: there is a race condition here */
if ((dcDst = DC_GetDCUpdate( hdcDst )))
{
dcSrc = DC_GetDCPtr( hdcSrc );
TRACE("hdcSrc=%04x %d,%d %d bpp->hdcDest=%04x %d,%d %dx%dx%d rop=%06lx\n",
hdcSrc, xSrc, ySrc, dcSrc ? dcSrc->w.bitsPerPixel : 0,
hdcDst, xDst, yDst, width, height, dcDst->w.bitsPerPixel, rop);
if (dcDst->funcs->pBitBlt)
ret = dcDst->funcs->pBitBlt( dcDst, xDst, yDst, width, height,
dcSrc, xSrc, ySrc, rop );
if (dcSrc) GDI_ReleaseObj( hdcSrc );
GDI_ReleaseObj( hdcDst );
}
return ret;
}
......@@ -90,19 +87,8 @@ BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
INT16 widthSrc, INT16 heightSrc, DWORD rop )
{
DC *dcDst, *dcSrc;
if (!(dcDst = DC_GetDCPtr( hdcDst ))) return FALSE;
if (!dcDst->funcs->pStretchBlt) return FALSE;
dcSrc = DC_GetDCPtr( hdcSrc );
TRACE("%04x %d,%d %dx%dx%d -> %04x %d,%d %dx%dx%d rop=%06lx\n",
hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
dcSrc ? dcSrc->w.bitsPerPixel : 0, hdcDst, xDst, yDst,
widthDst, heightDst, dcDst->w.bitsPerPixel, rop );
return dcDst->funcs->pStretchBlt( dcDst, xDst, yDst, widthDst, heightDst,
dcSrc, xSrc, ySrc, widthSrc, heightSrc,
rop );
return StretchBlt( hdcDst, xDst, yDst, widthDst, heightDst,
hdcSrc, xSrc, ySrc, widthSrc, heightSrc, rop );
}
......@@ -112,21 +98,32 @@ BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
BOOL WINAPI StretchBlt( HDC hdcDst, INT xDst, INT yDst,
INT widthDst, INT heightDst,
HDC hdcSrc, INT xSrc, INT ySrc,
INT widthSrc, INT heightSrc, DWORD rop )
INT widthSrc, INT heightSrc,
DWORD rop )
{
BOOL ret = FALSE;
DC *dcDst, *dcSrc;
if (!(dcDst = DC_GetDCPtr( hdcDst ))) return FALSE;
if (!dcDst->funcs->pStretchBlt) return FALSE;
dcSrc = DC_GetDCPtr( hdcSrc );
TRACE("%04x %d,%d %dx%dx%d -> %04x %d,%d %dx%dx%d rop=%06lx\n",
hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
dcSrc ? dcSrc->w.bitsPerPixel : 0, hdcDst, xDst, yDst,
widthDst, heightDst, dcDst->w.bitsPerPixel, rop );
return dcDst->funcs->pStretchBlt( dcDst, xDst, yDst, widthDst, heightDst,
dcSrc, xSrc, ySrc, widthSrc, heightSrc,
rop );
if ((dcSrc = DC_GetDCUpdate( hdcSrc ))) GDI_ReleaseObj( hdcSrc );
/* FIXME: there is a race condition here */
if ((dcDst = DC_GetDCUpdate( hdcDst )))
{
dcSrc = DC_GetDCPtr( hdcSrc );
TRACE("%04x %d,%d %dx%dx%d -> %04x %d,%d %dx%dx%d rop=%06lx\n",
hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
dcSrc ? dcSrc->w.bitsPerPixel : 0, hdcDst, xDst, yDst,
widthDst, heightDst, dcDst->w.bitsPerPixel, rop );
if (dcSrc) {
if (dcDst->funcs->pStretchBlt)
ret = dcDst->funcs->pStretchBlt( dcDst, xDst, yDst, widthDst, heightDst,
dcSrc, xSrc, ySrc, widthSrc, heightSrc, rop );
GDI_ReleaseObj( hdcSrc );
}
GDI_ReleaseObj( hdcDst );
}
return ret;
}
......@@ -147,7 +144,10 @@ BOOL16 WINAPI FastWindowFrame16( HDC16 hdc, const RECT16 *rect,
rect->bottom - rect->top - height, rop );
SelectObject( hdc, hbrush );
return TRUE;
}
/***********************************************************************
* MaskBlt [GDI32.252]
*/
......@@ -156,7 +156,7 @@ BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest,
INT nXSrc, INT nYSrc, HBITMAP hbmMask,
INT xMask, INT yMask, DWORD dwRop)
{
FIXME_(bitmap)("(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%ld): stub\n",
FIXME("(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%ld): stub\n",
hdcDest,nXDest,nYDest,nWidth,nHeight,hdcSource,nXSrc,nYSrc,
hbmMask,xMask,yMask,dwRop);
return 1;
......@@ -170,7 +170,7 @@ BOOL WINAPI PlgBlt( HDC hdcDest, const POINT *lpPoint,
HDC hdcSrc, INT nXDest, INT nYDest, INT nWidth,
INT nHeight, HBITMAP hbmMask, INT xMask, INT yMask)
{
FIXME_(gdi)("PlgBlt, stub\n");
FIXME("PlgBlt, stub\n");
return 1;
}
......@@ -129,7 +129,7 @@ static BOOL EMFDRV_DeleteDC( DC *dc )
if (physDev->emh) HeapFree( GetProcessHeap(), 0, physDev->emh );
HeapFree( GetProcessHeap(), 0, physDev );
dc->physDev = NULL;
GDI_FreeObject(dc->hSelf);
GDI_FreeObject( dc->hSelf, dc );
return TRUE;
}
......@@ -245,6 +245,7 @@ HDC WINAPI CreateEnhMetaFileW(
LPCWSTR description /* optional description */
)
{
HDC ret;
DC *dc;
HDC hRefDC = hdc ? hdc : CreateDCA("DISPLAY",NULL,NULL,NULL); /* If no ref, use current display */
EMFDRV_PDEVICE *physDev;
......@@ -258,7 +259,7 @@ HDC WINAPI CreateEnhMetaFileW(
physDev = (EMFDRV_PDEVICE *)HeapAlloc(GetProcessHeap(),0,sizeof(*physDev));
if (!physDev) {
GDI_HEAP_FREE( dc->hSelf );
GDI_FreeObject( dc->hSelf, dc );
return 0;
}
dc->physDev = physDev;
......@@ -273,7 +274,7 @@ HDC WINAPI CreateEnhMetaFileW(
if (!(physDev->emh = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size))) {
HeapFree( GetProcessHeap(), 0, physDev );
GDI_HEAP_FREE( dc->hSelf );
GDI_FreeObject( dc->hSelf, dc );
return 0;
}
......@@ -337,8 +338,9 @@ HDC WINAPI CreateEnhMetaFileW(
DeleteDC( hRefDC );
TRACE("returning %04x\n", dc->hSelf);
return dc->hSelf;
ret = dc->hSelf;
GDI_ReleaseObj( dc->hSelf );
return ret;
}
/******************************************************************
......
......@@ -89,9 +89,9 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
break;
default:
FIXME("Unknown style %x\n", brushObj->logbrush.lbStyle);
return FALSE;
break;
}
GDI_HEAP_UNLOCK( hBrush );
GDI_ReleaseObj( hBrush );
return index;
}
......@@ -170,7 +170,7 @@ static BOOL EMFDRV_CreateFontIndirect(DC *dc, HFONT hFont )
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0;
GDI_HEAP_UNLOCK( hFont );
GDI_ReleaseObj( hFont );
return index;
}
......@@ -233,7 +233,7 @@ static HPEN EMFDRV_CreatePenIndirect(DC *dc, HPEN hPen )
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0;
GDI_HEAP_UNLOCK( hPen );
GDI_ReleaseObj( hPen );
return index;
}
......@@ -303,7 +303,7 @@ HGDIOBJ EMFDRV_SelectObject( DC *dc, HGDIOBJ handle )
ret = EMFDRV_BITMAP_SelectObject( dc, handle );
break;
}
GDI_HEAP_UNLOCK( handle );
GDI_ReleaseObj( handle );
return ret;
}
......
......@@ -21,10 +21,18 @@ DEFAULT_DEBUG_CHANNEL(driver);
INT16 WINAPI Escape16( HDC16 hdc, INT16 nEscape, INT16 cbInput,
SEGPTR lpszInData, SEGPTR lpvOutData )
{
INT16 ret = 0;
DC * dc = DC_GetDCPtr( hdc );
if (!dc || !dc->funcs->pEscape) return 0;
if(nEscape == SETABORTPROC) SetAbortProc16(hdc, lpszInData);
return dc->funcs->pEscape( dc, nEscape, cbInput, lpszInData, lpvOutData );
if (dc)
{
if (dc->funcs->pEscape)
{
if(nEscape == SETABORTPROC) SetAbortProc16(hdc, lpszInData);
ret = dc->funcs->pEscape( dc, nEscape, cbInput, lpszInData, lpvOutData );
}
GDI_ReleaseObj( hdc );
}
return ret;
}
/************************************************************************
......@@ -34,9 +42,10 @@ INT WINAPI Escape( HDC hdc, INT nEscape, INT cbInput,
LPCSTR lpszInData, LPVOID lpvOutData )
{
SEGPTR segin,segout;
INT ret;
INT ret = 0;
DC * dc = DC_GetDCPtr( hdc );
if (!dc || !dc->funcs->pEscape) return 0;
if (!dc) return 0;
if (!dc->funcs->pEscape) goto done;
segin = (SEGPTR)lpszInData;
segout = (SEGPTR)lpvOutData;
......@@ -227,6 +236,8 @@ INT WINAPI Escape( HDC hdc, INT nEscape, INT cbInput,
default:
break;
}
done:
GDI_ReleaseObj( hdc );
return ret;
}
......
......@@ -48,6 +48,7 @@ BOOL16 WINAPI DPtoLP16( HDC16 hdc, LPPOINT16 points, INT16 count )
points->y = YDPTOLP( dc, points->y );
points++;
}
GDI_ReleaseObj( hdc );
return TRUE;
}
......@@ -63,10 +64,11 @@ BOOL WINAPI DPtoLP( HDC hdc, LPPOINT points, INT count )
while (count--)
{
if (!INTERNAL_DPTOLP( dc, points ))
return FALSE;
break;
points++;
}
return TRUE;
GDI_ReleaseObj( hdc );
return (count < 0);
}
......@@ -84,6 +86,7 @@ BOOL16 WINAPI LPtoDP16( HDC16 hdc, LPPOINT16 points, INT16 count )
points->y = YLPTODP( dc, points->y );
points++;
}
GDI_ReleaseObj( hdc );
return TRUE;
}
......@@ -101,6 +104,7 @@ BOOL WINAPI LPtoDP( HDC hdc, LPPOINT points, INT count )
INTERNAL_LPTODP( dc, points );
points++;
}
GDI_ReleaseObj( hdc );
return TRUE;
}
......@@ -122,7 +126,11 @@ INT WINAPI SetMapMode( HDC hdc, INT mode )
INT prevMode;
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return 0;
if (dc->funcs->pSetMapMode) return dc->funcs->pSetMapMode( dc, mode );
if (dc->funcs->pSetMapMode)
{
prevMode = dc->funcs->pSetMapMode( dc, mode );
goto done;
}
TRACE("%04x %d\n", hdc, mode );
......@@ -176,10 +184,12 @@ INT WINAPI SetMapMode( HDC hdc, INT mode )
break;
default:
return prevMode;
goto done;
}
dc->w.MapMode = mode;
DC_UpdateXforms( dc );
done:
GDI_ReleaseObj( hdc );
return prevMode;
}
......@@ -212,23 +222,33 @@ BOOL16 WINAPI SetViewportExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
*/
BOOL WINAPI SetViewportExtEx( HDC hdc, INT x, INT y, LPSIZE size )
{
BOOL ret = TRUE;
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
if (dc->funcs->pSetViewportExt)
return dc->funcs->pSetViewportExt( dc, x, y );
{
ret = dc->funcs->pSetViewportExt( dc, x, y );
goto done;
}
if (size)
{
size->cx = dc->vportExtX;
size->cy = dc->vportExtY;
}
if ((dc->w.MapMode != MM_ISOTROPIC) && (dc->w.MapMode != MM_ANISOTROPIC))
return TRUE;
if (!x || !y) return FALSE;
goto done;
if (!x || !y)
{
ret = FALSE;
goto done;
}
dc->vportExtX = x;
dc->vportExtY = y;
if (dc->w.MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
DC_UpdateXforms( dc );
return TRUE;
done:
GDI_ReleaseObj( hdc );
return ret;
}
......@@ -260,19 +280,24 @@ BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
*/
BOOL WINAPI SetViewportOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
{
BOOL ret = TRUE;
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
if (dc->funcs->pSetViewportOrg)
return dc->funcs->pSetViewportOrg( dc, x, y );
if (pt)
ret = dc->funcs->pSetViewportOrg( dc, x, y );
else
{
pt->x = dc->vportOrgX;
pt->y = dc->vportOrgY;
if (pt)
{
pt->x = dc->vportOrgX;
pt->y = dc->vportOrgY;
}
dc->vportOrgX = x;
dc->vportOrgY = y;
DC_UpdateXforms( dc );
}
dc->vportOrgX = x;
dc->vportOrgY = y;
DC_UpdateXforms( dc );
return TRUE;
GDI_ReleaseObj( hdc );
return ret;
}
......@@ -304,22 +329,33 @@ BOOL16 WINAPI SetWindowExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
*/
BOOL WINAPI SetWindowExtEx( HDC hdc, INT x, INT y, LPSIZE size )
{
BOOL ret = TRUE;
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
if (dc->funcs->pSetWindowExt) return dc->funcs->pSetWindowExt( dc, x, y );
if (dc->funcs->pSetWindowExt)
{
ret = dc->funcs->pSetWindowExt( dc, x, y );
goto done;
}
if (size)
{
size->cx = dc->wndExtX;
size->cy = dc->wndExtY;
}
if ((dc->w.MapMode != MM_ISOTROPIC) && (dc->w.MapMode != MM_ANISOTROPIC))
return TRUE;
if (!x || !y) return FALSE;
goto done;
if (!x || !y)
{
ret = FALSE;
goto done;
}
dc->wndExtX = x;
dc->wndExtY = y;
if (dc->w.MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
DC_UpdateXforms( dc );
return TRUE;
done:
GDI_ReleaseObj( hdc );
return ret;
}
......@@ -351,18 +387,23 @@ BOOL16 WINAPI SetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
*/
BOOL WINAPI SetWindowOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
{
BOOL ret = TRUE;
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
if (dc->funcs->pSetWindowOrg) return dc->funcs->pSetWindowOrg( dc, x, y );
if (pt)
if (dc->funcs->pSetWindowOrg) ret = dc->funcs->pSetWindowOrg( dc, x, y );
else
{
pt->x = dc->wndOrgX;
pt->y = dc->wndOrgY;
if (pt)
{
pt->x = dc->wndOrgX;
pt->y = dc->wndOrgY;
}
dc->wndOrgX = x;
dc->wndOrgY = y;
DC_UpdateXforms( dc );
}
dc->wndOrgX = x;
dc->wndOrgY = y;
DC_UpdateXforms( dc );
return TRUE;
GDI_ReleaseObj( hdc );
return ret;
}
......@@ -394,19 +435,24 @@ BOOL16 WINAPI OffsetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt)
*/
BOOL WINAPI OffsetViewportOrgEx( HDC hdc, INT x, INT y, LPPOINT pt)
{
BOOL ret = TRUE;
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
if (dc->funcs->pOffsetViewportOrg)
return dc->funcs->pOffsetViewportOrg( dc, x, y );
if (pt)
ret = dc->funcs->pOffsetViewportOrg( dc, x, y );
else
{
pt->x = dc->vportOrgX;
pt->y = dc->vportOrgY;
if (pt)
{
pt->x = dc->vportOrgX;
pt->y = dc->vportOrgY;
}
dc->vportOrgX += x;
dc->vportOrgY += y;
DC_UpdateXforms( dc );
}
dc->vportOrgX += x;
dc->vportOrgY += y;
DC_UpdateXforms( dc );
return TRUE;
GDI_ReleaseObj( hdc );
return ret;
}
......@@ -438,19 +484,24 @@ BOOL16 WINAPI OffsetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
*/
BOOL WINAPI OffsetWindowOrgEx( HDC hdc, INT x, INT y, LPPOINT pt )
{
BOOL ret = TRUE;
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
if (dc->funcs->pOffsetWindowOrg)
return dc->funcs->pOffsetWindowOrg( dc, x, y );
if (pt)
ret = dc->funcs->pOffsetWindowOrg( dc, x, y );
else
{
pt->x = dc->wndOrgX;
pt->y = dc->wndOrgY;
if (pt)
{
pt->x = dc->wndOrgX;
pt->y = dc->wndOrgY;
}
dc->wndOrgX += x;
dc->wndOrgY += y;
DC_UpdateXforms( dc );
}
dc->wndOrgX += x;
dc->wndOrgY += y;
DC_UpdateXforms( dc );
return TRUE;
GDI_ReleaseObj( hdc );
return ret;
}
......@@ -487,25 +538,35 @@ BOOL16 WINAPI ScaleViewportExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
BOOL WINAPI ScaleViewportExtEx( HDC hdc, INT xNum, INT xDenom,
INT yNum, INT yDenom, LPSIZE size )
{
BOOL ret = TRUE;
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
if (dc->funcs->pScaleViewportExt)
return dc->funcs->pScaleViewportExt( dc, xNum, xDenom, yNum, yDenom );
{
ret = dc->funcs->pScaleViewportExt( dc, xNum, xDenom, yNum, yDenom );
goto done;
}
if (size)
{
size->cx = dc->vportExtX;
size->cy = dc->vportExtY;
}
if ((dc->w.MapMode != MM_ISOTROPIC) && (dc->w.MapMode != MM_ANISOTROPIC))
return TRUE;
if (!xNum || !xDenom || !xNum || !yDenom) return FALSE;
goto done;
if (!xNum || !xDenom || !xNum || !yDenom)
{
ret = FALSE;
goto done;
}
dc->vportExtX = (dc->vportExtX * xNum) / xDenom;
dc->vportExtY = (dc->vportExtY * yNum) / yDenom;
if (dc->vportExtX == 0) dc->vportExtX = 1;
if (dc->vportExtY == 0) dc->vportExtY = 1;
if (dc->w.MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
DC_UpdateXforms( dc );
return TRUE;
done:
GDI_ReleaseObj( hdc );
return ret;
}
......@@ -542,23 +603,33 @@ BOOL16 WINAPI ScaleWindowExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
BOOL WINAPI ScaleWindowExtEx( HDC hdc, INT xNum, INT xDenom,
INT yNum, INT yDenom, LPSIZE size )
{
BOOL ret = TRUE;
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
if (dc->funcs->pScaleWindowExt)
return dc->funcs->pScaleWindowExt( dc, xNum, xDenom, yNum, yDenom );
{
ret = dc->funcs->pScaleWindowExt( dc, xNum, xDenom, yNum, yDenom );
goto done;
}
if (size)
{
size->cx = dc->wndExtX;
size->cy = dc->wndExtY;
}
if ((dc->w.MapMode != MM_ISOTROPIC) && (dc->w.MapMode != MM_ANISOTROPIC))
return TRUE;
if (!xNum || !xDenom || !xNum || !yDenom) return FALSE;
goto done;
if (!xNum || !xDenom || !xNum || !yDenom)
{
ret = FALSE;
goto done;
}
dc->wndExtX = (dc->wndExtX * xNum) / xDenom;
dc->wndExtY = (dc->wndExtY * yNum) / yDenom;
if (dc->wndExtX == 0) dc->wndExtX = 1;
if (dc->wndExtY == 0) dc->wndExtY = 1;
if (dc->w.MapMode == MM_ISOTROPIC) MAPPING_FixIsotropic( dc );
DC_UpdateXforms( dc );
return TRUE;
done:
GDI_ReleaseObj( hdc );
return ret;
}
......@@ -133,7 +133,7 @@ static DC *MFDRV_AllocMetaFile(void)
physDev = (METAFILEDRV_PDEVICE *)HeapAlloc(GetProcessHeap(),0,sizeof(*physDev));
if (!physDev)
{
GDI_HEAP_FREE( dc->hSelf );
GDI_FreeObject( dc->hSelf, dc );
return NULL;
}
dc->physDev = physDev;
......@@ -141,7 +141,7 @@ static DC *MFDRV_AllocMetaFile(void)
if (!(physDev->mh = HeapAlloc( GetProcessHeap(), 0, sizeof(*physDev->mh) )))
{
HeapFree( GetProcessHeap(), 0, physDev );
GDI_HEAP_FREE( dc->hSelf );
GDI_FreeObject( dc->hSelf, dc );
return NULL;
}
......@@ -169,7 +169,7 @@ static BOOL MFDRV_DeleteDC( DC *dc )
if (physDev->mh) HeapFree( GetProcessHeap(), 0, physDev->mh );
HeapFree( GetProcessHeap(), 0, physDev );
dc->physDev = NULL;
GDI_FreeObject(dc->hSelf);
GDI_FreeObject( dc->hSelf, dc );
return TRUE;
}
......@@ -186,6 +186,7 @@ HDC16 WINAPI CreateMetaFile16(
LPCSTR filename /* Filename of disk metafile */
)
{
HDC ret;
DC *dc;
METAFILEDRV_PDEVICE *physDev;
HFILE hFile;
......@@ -217,7 +218,9 @@ HDC16 WINAPI CreateMetaFile16(
physDev->mh->mtType = METAFILE_MEMORY;
TRACE("returning %04x\n", dc->hSelf);
return dc->hSelf;
ret = dc->hSelf;
GDI_ReleaseObj( dc->hSelf );
return ret;
}
/**********************************************************************
......
......@@ -35,7 +35,7 @@ static HBITMAP16 MFDRV_BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap,
INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
{
INT16 index;
INT16 index = -1;
DWORD size;
METARECORD *mr;
BRUSHOBJ *brushObj = (BRUSHOBJ *)GDI_GetObjPtr( hBrush, BRUSH_MAGIC );
......@@ -68,7 +68,7 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
GetObjectA(brushObj->logbrush.lbHatch, sizeof(bm), &bm);
if(bm.bmBitsPixel != 1 || bm.bmPlanes != 1) {
FIXME("Trying to store a colour pattern brush\n");
return FALSE;
goto done;
}
bmSize = DIB_GetDIBImageBytes(bm.bmWidth, bm.bmHeight, 1);
......@@ -77,7 +77,7 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
sizeof(RGBQUAD) + bmSize;
mr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if(!mr) return FALSE;
if(!mr) goto done;
mr->rdFunction = META_DIBCREATEPATTERNBRUSH;
mr->rdSize = size / 2;
mr->rdParm[0] = BS_PATTERN;
......@@ -114,7 +114,7 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
LOWORD(brushObj->logbrush.lbColor));
size = sizeof(METARECORD) + biSize + bmSize + 2;
mr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if(!mr) return FALSE;
if(!mr) goto done;
mr->rdFunction = META_DIBCREATEPATTERNBRUSH;
mr->rdSize = size / 2;
*(mr->rdParm) = brushObj->logbrush.lbStyle;
......@@ -130,7 +130,8 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
if(!MFDRV_WriteRecord( dc, mr, mr->rdSize * 2))
index = -1;
HeapFree(GetProcessHeap(), 0, mr);
GDI_HEAP_UNLOCK( hBrush );
done:
GDI_ReleaseObj( hBrush );
return index;
}
......@@ -260,7 +261,7 @@ HGDIOBJ MFDRV_SelectObject( DC *dc, HGDIOBJ handle )
ret = (HGDIOBJ16)SelectClipRgn16( dc->hSelf, handle );
break;
}
GDI_HEAP_UNLOCK( handle );
GDI_ReleaseObj( handle );
return ret;
}
......
......@@ -11,6 +11,7 @@
#include "module.h"
#include "font.h"
#include "heap.h"
#include "dc.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(win16drv)
......@@ -179,15 +180,21 @@ BOOL WIN16DRV_GetCharWidth( DC *dc, UINT firstChar, UINT lastChar,
* WIN16DRV_EnumDeviceFonts
*/
BOOL WIN16DRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf,
BOOL WIN16DRV_EnumDeviceFonts( HDC hdc, LPLOGFONT16 plf,
DEVICEFONTENUMPROC proc, LPARAM lp )
{
WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
WIN16DRV_PDEVICE *physDev;
WORD wRet;
WEPFC wepfc;
DC *dc;
/* EnumDFontCallback is GDI.158 */
FARPROC16 pfnCallback = NE_GetEntryPoint( GetModuleHandle16("GDI"), 158 );
if (!(dc = DC_GetDCPtr( hdc ))) return 0;
physDev = (WIN16DRV_PDEVICE *)dc->physDev;
/* FIXME!! */
GDI_ReleaseObj( hdc );
wepfc.proc = (int (*)(LPENUMLOGFONT16,LPNEWTEXTMETRIC16,UINT16,LPARAM))proc;
wepfc.lp = lp;
......
......@@ -54,6 +54,6 @@ HGDIOBJ WIN16DRV_SelectObject( DC *dc, HGDIOBJ handle )
ret = (HGDIOBJ16)SelectClipRgn16( dc->hSelf, handle );
break;
}
GDI_HEAP_UNLOCK( handle );
GDI_ReleaseObj( handle );
return ret;
}
......@@ -84,24 +84,20 @@ HBITMAP X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap,
return 0;
}
hrgn = CreateRectRgn(0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight);
if (!hrgn) return 0;
dc->w.totalExtent.left = 0;
dc->w.totalExtent.top = 0;
dc->w.totalExtent.right = bmp->bitmap.bmWidth;
dc->w.totalExtent.bottom = bmp->bitmap.bmHeight;
if (dc->w.hVisRgn)
SetRectRgn( dc->w.hVisRgn, 0, 0,
bmp->bitmap.bmWidth, bmp->bitmap.bmHeight );
else
{
hrgn = CreateRectRgn(0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight);
if (!hrgn) return 0;
dc->w.hVisRgn = hrgn;
}
physDev->drawable = (Pixmap)bmp->physBitmap;
dc->w.hBitmap = hbitmap;
SelectVisRgn16( dc->hSelf, hrgn );
DeleteObject( hrgn );
/* Change GC depth if needed */
if (dc->w.bitsPerPixel != bmp->bitmap.bmBitsPixel)
......@@ -112,7 +108,6 @@ HBITMAP X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap,
dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
DC_InitDC( dc );
}
else CLIPPING_UpdateGCRegion( dc ); /* Just update GC clip region */
return prevHandle;
}
......@@ -158,13 +153,17 @@ BOOL X11DRV_CreateBitmap( HBITMAP hbitmap )
}
/* Check parameters */
if (bmp->bitmap.bmPlanes != 1) return 0;
if (bmp->bitmap.bmPlanes != 1)
{
GDI_ReleaseObj( hbitmap );
return 0;
}
if ((bmp->bitmap.bmBitsPixel != 1) &&
(bmp->bitmap.bmBitsPixel != X11DRV_GetDepth()))
{
ERR("Trying to make bitmap with planes=%d, bpp=%d\n",
bmp->bitmap.bmPlanes, bmp->bitmap.bmBitsPixel);
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return FALSE;
}
......@@ -177,7 +176,7 @@ BOOL X11DRV_CreateBitmap( HBITMAP hbitmap )
bmp->bitmap.bmBitsPixel)))
{
WARN("Can't create Pixmap\n");
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return FALSE;
}
bmp->funcs = &X11DRV_DC_Funcs;
......@@ -187,7 +186,7 @@ BOOL X11DRV_CreateBitmap( HBITMAP hbitmap )
bmp->bitmap.bmHeight * bmp->bitmap.bmWidthBytes,
DDB_SET );
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return TRUE;
}
......@@ -476,8 +475,7 @@ LONG X11DRV_BitmapBits(HBITMAP hbitmap, void *bits, LONG count, WORD flags)
ERR("Unknown flags value %d\n", flags);
ret = 0;
}
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return ret;
}
......@@ -526,6 +524,7 @@ HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap)
pBmp->funcs = &X11DRV_DC_Funcs;
pBmp->physBitmap = (void *)pixmap;
GDI_ReleaseObj( hBmp );
END:
TRACE("\tReturning HBITMAP %x\n", hBmp);
......@@ -612,7 +611,10 @@ Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc )
*/
Pixmap X11DRV_BITMAP_Pixmap(HBITMAP hbitmap)
{
Pixmap pixmap;
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
return (Pixmap)bmp->physBitmap;
pixmap = (Pixmap)bmp->physBitmap;
GDI_ReleaseObj( hbitmap );
return pixmap;
}
......@@ -172,17 +172,18 @@ static void BRUSH_SelectSolidBrush( DC *dc, COLORREF color )
*/
static BOOL BRUSH_SelectPatternBrush( DC * dc, HBITMAP hbitmap )
{
BOOL ret = FALSE;
X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
if (!bmp) return FALSE;
if(!bmp->physBitmap)
if(!X11DRV_CreateBitmap(hbitmap))
return 0;
goto done;
if(bmp->funcs != dc->funcs) {
WARN("Trying to select non-X11 DDB into an X11 dc\n");
return 0;
goto done;
}
if ((dc->w.bitsPerPixel == 1) && (bmp->bitmap.bmBitsPixel != 1))
......@@ -211,8 +212,10 @@ static BOOL BRUSH_SelectPatternBrush( DC * dc, HBITMAP hbitmap )
physDev->brush.fillStyle = FillOpaqueStippled;
physDev->brush.pixel = -1; /* Special case (see DC_SetupGCForBrush) */
}
GDI_HEAP_UNLOCK( hbitmap );
return TRUE;
ret = TRUE;
done:
GDI_ReleaseObj( hbitmap );
return ret;
}
......
......@@ -49,7 +49,7 @@ void X11DRV_SetDeviceClipping( DC * dc )
if(!pXrect)
{
WARN("Can't alloc buffer\n");
GDI_HEAP_UNLOCK( dc->w.hGCClipRgn );
GDI_ReleaseObj( dc->w.hGCClipRgn );
return;
}
......@@ -70,6 +70,6 @@ void X11DRV_SetDeviceClipping( DC * dc )
if(pXrect)
HeapFree( GetProcessHeap(), 0, pXrect );
GDI_HEAP_UNLOCK( dc->w.hGCClipRgn );
GDI_ReleaseObj( dc->w.hGCClipRgn );
}
......@@ -2595,9 +2595,6 @@ int X11DRV_DIB_SetImageBits( const X11DRV_DIB_IMAGEBITS_DESCR *descr )
int lines = descr->lines >= 0 ? descr->lines : -descr->lines;
XImage *bmpImage;
if ( descr->dc && descr->dc->w.flags & DC_DIRTY )
CLIPPING_UpdateGCRegion( descr->dc );
if (descr->image)
bmpImage = descr->image;
else {
......@@ -2984,11 +2981,18 @@ INT X11DRV_DIB_GetDIBits(
*/
if( info->bmiHeader.biHeight < 0 && lines > 0) lines = -lines;
if( startscan >= bmp->bitmap.bmHeight ) return FALSE;
if( startscan >= bmp->bitmap.bmHeight )
{
lines = 0;
goto done;
}
if (DIB_GetBitmapInfo( &info->bmiHeader, &descr.infoWidth, &descr.lines,
&descr.infoBpp, &descr.compression ) == -1)
return FALSE;
{
lines = 0;
goto done;
}
switch (descr.infoBpp)
{
......@@ -3060,7 +3064,8 @@ INT X11DRV_DIB_GetDIBits(
info->bmiHeader.biCompression = 0;
GDI_HEAP_UNLOCK( dc->w.hPalette );
done:
GDI_ReleaseObj( dc->w.hPalette );
return lines;
}
......@@ -3193,7 +3198,7 @@ static BOOL X11DRV_DIB_FaultHandler( LPVOID res, LPCVOID addr )
break;
}
GDI_HEAP_UNLOCK( (HBITMAP)res );
GDI_ReleaseObj( (HBITMAP)res );
return handled;
}
......@@ -3276,7 +3281,7 @@ void X11DRV_DIB_UpdateDIBSection2(HBITMAP hbmp, BOOL toDIB)
X11DRV_DIB_CmnUpdateDIBSection(bmp, toDIB);
GDI_HEAP_UNLOCK(hbmp);
GDI_ReleaseObj(hbmp);
}
/***********************************************************************
......@@ -3325,12 +3330,11 @@ HBITMAP16 X11DRV_DIB_CreateDIBSection16(
TRACE("ptr = %p, size =%d, selector = %04x, segptr = %ld\n",
dib->dsBm.bmBits, size, ((X11DRV_DIBSECTION *) bmp->dib)->selector,
PTR_SEG_OFF_TO_SEGPTR(((X11DRV_DIBSECTION *) bmp->dib)->selector, 0));
}
GDI_HEAP_UNLOCK( res );
if ( bits )
*bits = PTR_SEG_OFF_TO_SEGPTR( ((X11DRV_DIBSECTION *) bmp->dib)->selector, 0 );
}
if (bmp) GDI_ReleaseObj( res );
}
return res;
}
......@@ -3545,6 +3549,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
if (dib && dib->image) { XDestroyImage(dib->image); dib->image = NULL; }
if (colorMap) { HeapFree(GetProcessHeap(), 0, colorMap); colorMap = NULL; }
if (dib) { HeapFree(GetProcessHeap(), 0, dib); dib = NULL; }
if (bmp) { GDI_ReleaseObj(res); bmp = NULL; }
if (res) { DeleteObject(res); res = 0; }
}
......@@ -3567,7 +3572,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
}
/* Return BITMAP handle and storage location */
if (res) GDI_HEAP_UNLOCK(res);
if (bmp) GDI_ReleaseObj(res);
if (bm.bmBits && bits) *bits = bm.bmBits;
return res;
}
......@@ -3642,6 +3647,7 @@ HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixma
pBmp->physBitmap = NULL;
pBmp->funcs = NULL;
}
GDI_ReleaseObj( hBmp );
DeleteObject(hBmp);
END:
......@@ -3695,6 +3701,7 @@ Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc )
pBmp->funcs = NULL;
/* Delete the DDB we created earlier now that we have stolen its pixmap */
GDI_ReleaseObj( hBmp );
DeleteObject(hBmp);
TRACE("\tReturning Pixmap %ld\n", pixmap);
......
......@@ -99,8 +99,6 @@ BOOL X11DRV_SetupGCForPatBlt( DC * dc, GC gc, BOOL fMapColors )
val.background = X11DRV_PALETTE_XPixelToPalette[val.background];
}
if (dc->w.flags & DC_DIRTY) CLIPPING_UpdateGCRegion(dc);
val.function = X11DRV_XROPfunction[dc->w.ROPmode-1];
/*
** Let's replace GXinvert by GXxor with (black xor white)
......@@ -187,8 +185,6 @@ BOOL X11DRV_SetupGCForPen( DC * dc )
if (physDev->pen.style == PS_NULL) return FALSE;
if (dc->w.flags & DC_DIRTY) CLIPPING_UpdateGCRegion(dc);
switch (dc->w.ROPmode)
{
case R2_BLACK :
......@@ -275,8 +271,6 @@ BOOL X11DRV_SetupGCForText( DC * dc )
{
XGCValues val;
if (dc->w.flags & DC_DIRTY) CLIPPING_UpdateGCRegion(dc);
val.function = GXcopy; /* Text is always GXcopy */
val.foreground = physDev->textPixel;
val.background = physDev->backgroundPixel;
......
......@@ -240,9 +240,13 @@ static BOOL X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
dc->w.devCaps = &X11DRV_DevCaps;
if (dc->w.flags & DC_MEMORY)
{
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->w.hBitmap,
BITMAP_MAGIC );
if (!bmp->physBitmap) X11DRV_CreateBitmap( dc->w.hBitmap );
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->w.hBitmap, BITMAP_MAGIC );
if (!bmp)
{
HeapFree( GetProcessHeap(), 0, physDev );
return FALSE;
}
if (!bmp->physBitmap) X11DRV_CreateBitmap( dc->w.hBitmap );
physDev->drawable = (Pixmap)bmp->physBitmap;
physDev->gc = TSXCreateGC(display, physDev->drawable, 0, NULL);
dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
......@@ -253,7 +257,7 @@ static BOOL X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
dc->w.totalExtent.bottom = bmp->bitmap.bmHeight;
dc->w.hVisRgn = CreateRectRgnIndirect( &dc->w.totalExtent );
GDI_HEAP_UNLOCK( dc->w.hBitmap );
GDI_ReleaseObj( dc->w.hBitmap );
}
else
{
......@@ -274,6 +278,7 @@ static BOOL X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
if (!dc->w.hVisRgn)
{
TSXFreeGC( display, physDev->gc );
HeapFree( GetProcessHeap(), 0, physDev );
return FALSE;
}
......
......@@ -58,7 +58,7 @@ HGDIOBJ X11DRV_SelectObject( DC *dc, HGDIOBJ handle )
ret = (HGDIOBJ16)SelectClipRgn16( dc->hSelf, handle );
break;
}
GDI_HEAP_UNLOCK( handle );
GDI_ReleaseObj( handle );
return ret;
}
......@@ -83,7 +83,7 @@ BOOL X11DRV_DeleteObject( HGDIOBJ handle )
ret = FALSE;
break;
}
GDI_HEAP_UNLOCK( handle );
GDI_ReleaseObj( handle );
return ret;
}
......@@ -341,15 +341,12 @@ static BOOL OBM_InitColorSymbols()
static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height,
WORD bpp, Pixmap pixmap )
{
HBITMAP16 hbitmap;
HBITMAP hbitmap;
BITMAPOBJ * bmpObjPtr;
if (!pixmap) return 0;
hbitmap = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC );
if (!hbitmap) return 0;
bmpObjPtr = (BITMAPOBJ *) GDI_HEAP_LOCK( hbitmap );
if (!(bmpObjPtr = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC, &hbitmap ))) return 0;
bmpObjPtr->size.cx = width;
bmpObjPtr->size.cy = height;
bmpObjPtr->bitmap.bmType = 0;
......@@ -364,7 +361,7 @@ static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height,
bmpObjPtr->funcs = &X11DRV_DC_Funcs;
bmpObjPtr->physBitmap = (void *)pixmap;
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return hbitmap;
}
#endif /* defined(HAVE_LIBXXPM) */
......@@ -412,8 +409,8 @@ static BOOL OBM_CreateBitmaps( OBM_BITMAP_DESCR *descr )
{
if (pixmap) XFreePixmap( display, pixmap );
if (pixmask) XFreePixmap( display, pixmask );
if (descr->bitmap) GDI_FreeObject( descr->bitmap );
if (descr->need_mask && descr->mask) GDI_FreeObject( descr->mask );
if (descr->bitmap) DeleteObject( descr->bitmap );
if (descr->need_mask && descr->mask) DeleteObject( descr->mask );
return FALSE;
}
else return TRUE;
......@@ -512,11 +509,7 @@ static HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL fCursor )
if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
{
DeleteObject( descr.bitmap );
DeleteObject( descr.mask );
return 0;
}
goto done;
pInfo = (CURSORICONINFO *)GlobalLock16( handle );
pInfo->ptHotSpot.x = descr.hotspot.x;
......@@ -554,11 +547,12 @@ static HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL fCursor )
if (descr.mask) GetBitmapBits( descr.mask, sizeAnd, (char *)(pInfo + 1));
else memset( (char *)(pInfo + 1), 0xff, sizeAnd );
GetBitmapBits( descr.bitmap, sizeXor, (char *)(pInfo + 1) + sizeAnd );
if (fCursor) OBM_Cursors[id] = handle;
done:
GDI_ReleaseObj( descr.mask );
GDI_ReleaseObj( descr.bitmap );
DeleteObject( descr.bitmap );
DeleteObject( descr.mask );
if (fCursor) OBM_Cursors[id] = handle;
return handle;
}
......
......@@ -692,14 +692,15 @@ int X11DRV_PALETTE_ToPhysical( DC *dc, COLORREF color )
if( (idx = color & 0xffff) >= palPtr->logpalette.palNumEntries)
{
WARN("RGB(%lx) : idx %d is out of bounds, assuming black\n", color, idx);
GDI_HEAP_UNLOCK( hPal );
GDI_ReleaseObj( hPal );
return 0;
}
if( palPtr->mapping )
{
GDI_HEAP_UNLOCK( hPal );
return palPtr->mapping[idx];
int ret = palPtr->mapping[idx];
GDI_ReleaseObj( hPal );
return ret;
}
color = *(COLORREF*)(palPtr->logpalette.palPalEntry + idx);
break;
......@@ -711,7 +712,7 @@ int X11DRV_PALETTE_ToPhysical( DC *dc, COLORREF color )
case 0: /* RGB */
if( dc && (dc->w.bitsPerPixel == 1) )
{
GDI_HEAP_UNLOCK( hPal );
GDI_ReleaseObj( hPal );
return (((color >> 16) & 0xff) +
((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? 1 : 0;
}
......@@ -723,7 +724,7 @@ int X11DRV_PALETTE_ToPhysical( DC *dc, COLORREF color )
if (X11DRV_PALETTE_Graymax)
{
/* grayscale only; return scaled value */
GDI_HEAP_UNLOCK( hPal );
GDI_ReleaseObj( hPal );
return ( (red * 30 + green * 69 + blue * 11) * X11DRV_PALETTE_Graymax) / 25500;
}
else
......@@ -736,7 +737,7 @@ int X11DRV_PALETTE_ToPhysical( DC *dc, COLORREF color )
if (X11DRV_PALETTE_Bluemax != 255)
blue = MulDiv(blue, X11DRV_PALETTE_Bluemax, 255);
GDI_HEAP_UNLOCK( hPal );
GDI_ReleaseObj( hPal );
return (red << X11DRV_PALETTE_Redshift) | (green << X11DRV_PALETTE_Greenshift) | (blue << X11DRV_PALETTE_Blueshift);
}
}
......@@ -755,7 +756,7 @@ int X11DRV_PALETTE_ToPhysical( DC *dc, COLORREF color )
case 0: /* RGB */
if( dc && (dc->w.bitsPerPixel == 1) )
{
GDI_HEAP_UNLOCK( hPal );
GDI_ReleaseObj( hPal );
return (((color >> 16) & 0xff) +
((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? 1 : 0;
}
......@@ -786,7 +787,7 @@ int X11DRV_PALETTE_ToPhysical( DC *dc, COLORREF color )
}
}
GDI_HEAP_UNLOCK( hPal );
GDI_ReleaseObj( hPal );
return index;
}
......
......@@ -2991,7 +2991,7 @@ HFONT X11DRV_FONT_SelectObject( DC* dc, HFONT hfont, FONTOBJ* font )
*
* X11DRV_EnumDeviceFonts
*/
BOOL X11DRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf,
BOOL X11DRV_EnumDeviceFonts( HDC hdc, LPLOGFONT16 plf,
DEVICEFONTENUMPROC proc, LPARAM lp )
{
ENUMLOGFONTEX16 lf;
......
......@@ -16,6 +16,7 @@
extern DC * DC_AllocDC( const DC_FUNCTIONS *funcs );
extern DC * DC_GetDCPtr( HDC hdc );
extern DC * DC_GetDCUpdate( HDC hdc );
extern void DC_InitDC( DC * dc );
extern void DC_UpdateXforms( DC * dc );
......
......@@ -193,7 +193,7 @@ typedef struct tagDC_FUNCS
INT (*pEndDoc)(DC*);
INT (*pEndPage)(DC*);
BOOL (*pEndPath)(DC*);
BOOL (*pEnumDeviceFonts)(DC*,LPLOGFONT16,DEVICEFONTENUMPROC,LPARAM);
BOOL (*pEnumDeviceFonts)(HDC,LPLOGFONT16,DEVICEFONTENUMPROC,LPARAM);
INT (*pEscape)(DC*,INT,INT,SEGPTR,SEGPTR);
INT (*pExcludeClipRect)(DC*,INT,INT,INT,INT);
INT (*pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,
......@@ -444,30 +444,12 @@ static inline void WINE_UNUSED INTERNAL_LPTODP(DC *dc, LPPOINT point)
/* GDI local heap */
extern WORD GDI_HeapSel;
#define GDI_HEAP_ALLOC(size) \
LOCAL_Alloc( GDI_HeapSel, LMEM_FIXED, (size) )
#define GDI_HEAP_ALLOC_MOVEABLE(size) \
LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, (size) )
#define GDI_HEAP_REALLOC(handle,size) \
LOCAL_ReAlloc( GDI_HeapSel, (handle), (size), LMEM_FIXED )
#define GDI_HEAP_FREE(handle) \
LOCAL_Free( GDI_HeapSel, (handle) )
#define GDI_HEAP_LOCK(handle) \
LOCAL_Lock( GDI_HeapSel, (handle) )
#define GDI_HEAP_LOCK_SEGPTR(handle) \
LOCAL_LockSegptr( GDI_HeapSel, (handle) )
#define GDI_HEAP_UNLOCK(handle) \
((((HGDIOBJ16)(handle) >= FIRST_STOCK_HANDLE) && \
((HGDIOBJ16)(handle)<=LAST_STOCK_HANDLE)) ? \
0 : LOCAL_Unlock( GDI_HeapSel, (handle) ))
extern BOOL GDI_Init(void);
extern HGDIOBJ GDI_AllocObject( WORD, WORD );
extern BOOL GDI_FreeObject( HGDIOBJ );
extern GDIOBJHDR * GDI_GetObjPtr( HGDIOBJ, WORD );
extern void *GDI_AllocObject( WORD, WORD, HGDIOBJ * );
extern void *GDI_ReallocObject( WORD, HGDIOBJ, void *obj );
extern BOOL GDI_FreeObject( HGDIOBJ, void *obj );
extern void *GDI_GetObjPtr( HGDIOBJ, WORD );
extern void GDI_ReleaseObj( HGDIOBJ );
extern BOOL DRIVER_RegisterDriver( LPCSTR name, const DC_FUNCTIONS *funcs );
extern const DC_FUNCTIONS *DRIVER_FindDriver( LPCSTR name );
......
......@@ -19,8 +19,6 @@ extern HGLOBAL16 GLOBAL_Alloc( WORD flags, DWORD size, HGLOBAL16 hOwner,
BOOL16 isCode, BOOL16 is32Bit,
BOOL16 isReadOnly );
extern WORD WINAPI GlobalHandleToSel16( HGLOBAL16 handle );
/* memory/virtual.c */
extern DWORD VIRTUAL_GetPageSize(void);
extern DWORD VIRTUAL_GetGranularity(void);
......
......@@ -42,22 +42,24 @@ extern void PATH_DestroyGdiPath(GdiPath *pPath);
extern BOOL PATH_AssignGdiPath(GdiPath *pPathDest,
const GdiPath *pPathSrc);
extern BOOL PATH_MoveTo(HDC hdc);
extern BOOL PATH_LineTo(HDC hdc, INT x, INT y);
extern BOOL PATH_Rectangle(HDC hdc, INT x1, INT y1,
struct tagDC;
extern BOOL PATH_MoveTo(struct tagDC *dc);
extern BOOL PATH_LineTo(struct tagDC *dc, INT x, INT y);
extern BOOL PATH_Rectangle(struct tagDC *dc, INT x1, INT y1,
INT x2, INT y2);
extern BOOL PATH_Ellipse(HDC hdc, INT x1, INT y1,
extern BOOL PATH_Ellipse(struct tagDC *dc, INT x1, INT y1,
INT x2, INT y2);
extern BOOL PATH_Arc(HDC hdc, INT x1, INT y1, INT x2, INT y2,
extern BOOL PATH_Arc(struct tagDC *dc, INT x1, INT y1, INT x2, INT y2,
INT xStart, INT yStart, INT xEnd, INT yEnd);
extern BOOL PATH_PolyBezierTo(HDC hdc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_PolyBezier(HDC hdc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_PolylineTo(HDC hdc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_Polyline(HDC hdc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_Polygon(HDC hdc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_PolyPolyline(HDC hdc, const POINT *pt, const DWORD *counts,
extern BOOL PATH_PolyBezierTo(struct tagDC *dc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_PolyBezier(struct tagDC *dc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_PolylineTo(struct tagDC *dc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_Polyline(struct tagDC *dc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_Polygon(struct tagDC *dc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_PolyPolyline(struct tagDC *dc, const POINT *pt, const DWORD *counts,
DWORD polylines);
extern BOOL PATH_PolyPolygon(HDC hdc, const POINT *pt, const INT *counts,
extern BOOL PATH_PolyPolygon(struct tagDC *dc, const POINT *pt, const INT *counts,
UINT polygons);
#endif /* __WINE_PATH_H */
......
......@@ -54,7 +54,6 @@ typedef enum
struct tagCLASS;
struct tagDCE;
struct tagDC;
struct tagMESSAGEQUEUE;
struct tagWND_DRIVER;
......
......@@ -225,7 +225,7 @@ extern HGDIOBJ WIN16DRV_SelectObject( DC *dc, HGDIOBJ handle );
extern BOOL WIN16DRV_PatBlt( struct tagDC *dc, INT left, INT top,
INT width, INT height, DWORD rop );
extern BOOL WIN16DRV_Ellipse(DC *dc, INT left, INT top, INT right, INT bottom);
extern BOOL WIN16DRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf,
extern BOOL WIN16DRV_EnumDeviceFonts( HDC hdc, LPLOGFONT16 plf,
DEVICEFONTENUMPROC proc, LPARAM lp );
extern INT WIN16DRV_ExtDeviceMode(LPSTR lpszDriver, HWND hwnd,
......
......@@ -71,6 +71,7 @@ DWORD WINAPI GlobalDOSAlloc16(DWORD);
WORD WINAPI GlobalDOSFree16(WORD);
void WINAPI GlobalFreeAll16(HGLOBAL16);
DWORD WINAPI GlobalHandleNoRIP16(WORD);
WORD WINAPI GlobalHandleToSel16(HGLOBAL16);
HGLOBAL16 WINAPI GlobalLRUNewest16(HGLOBAL16);
HGLOBAL16 WINAPI GlobalLRUOldest16(HGLOBAL16);
VOID WINAPI GlobalNotify16(FARPROC16);
......
......@@ -90,7 +90,7 @@ extern const DC_FUNCTIONS X11DRV_DC_Funcs;
extern BOOL X11DRV_BitBlt( struct tagDC *dcDst, INT xDst, INT yDst,
INT width, INT height, struct tagDC *dcSrc,
INT xSrc, INT ySrc, DWORD rop );
extern BOOL X11DRV_EnumDeviceFonts( struct tagDC *dc, LPLOGFONT16 plf,
extern BOOL X11DRV_EnumDeviceFonts( HDC hdc, LPLOGFONT16 plf,
DEVICEFONTENUMPROC dfeproc, LPARAM lp );
extern BOOL X11DRV_GetCharWidth( struct tagDC *dc, UINT firstChar,
UINT lastChar, LPINT buffer );
......
......@@ -110,7 +110,6 @@ typedef struct
#define LOCAL_HEAP_MAGIC 0x484c /* 'LH' */
WORD USER_HeapSel = 0; /* USER heap selector */
WORD GDI_HeapSel = 0; /* GDI heap selector */
/* All local heap allocations are aligned on 4-byte boundaries */
#define LALIGN(word) (((word) + 3) & ~3)
......@@ -842,6 +841,29 @@ static HLOCAL16 LOCAL_FindFreeBlock( HANDLE16 ds, WORD size )
return 0;
}
/***********************************************************************
* get_heap_name
*/
static const char *get_heap_name( WORD ds )
{
HINSTANCE16 inst = LoadLibrary16( "GDI" );
if (ds == GlobalHandleToSel16( inst ))
{
FreeLibrary16( inst );
return "GDI";
}
FreeLibrary16( inst );
inst = LoadLibrary16( "USER" );
if (ds == GlobalHandleToSel16( inst ))
{
FreeLibrary16( inst );
return "USER";
}
FreeLibrary16( inst );
return "local";
}
/***********************************************************************
* LOCAL_GetBlock
* The segment may get moved around in this function, so all callers
......@@ -890,16 +912,8 @@ notify_done:
arena = LOCAL_FindFreeBlock( ds, size );
}
if (arena == 0) {
if (ds == GDI_HeapSel) {
ERR("not enough space in GDI local heap "
"(%04x) for %d bytes\n", ds, size );
} else if (ds == USER_HeapSel) {
ERR("not enough space in USER local heap "
"(%04x) for %d bytes\n", ds, size );
} else {
ERR("not enough space in local heap "
"%04x for %d bytes\n", ds, size );
}
ERR( "not enough space in %s heap %04x for %d bytes\n",
get_heap_name(ds), ds, size );
#if 0
if ((pInfo->notify) &&
/* FIXME: "size" correct ? (should indicate bytes needed) */
......
......@@ -122,14 +122,11 @@ HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes,
if (width < 0) width = -width;
/* Create the BITMAPOBJ */
hbitmap = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC );
if (!hbitmap) return 0;
if (!(bmp = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC, &hbitmap ))) return 0;
TRACE("%dx%d, %d colors returning %08x\n", width, height,
1 << (planes*bpp), hbitmap);
bmp = (BITMAPOBJ *) GDI_HEAP_LOCK( hbitmap );
bmp->size.cx = 0;
bmp->size.cy = 0;
bmp->bitmap.bmType = 0;
......@@ -147,7 +144,7 @@ HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes,
if (bits) /* Set bitmap bits */
SetBitmapBits( hbitmap, height * bmp->bitmap.bmWidthBytes,
bits );
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return hbitmap;
}
......@@ -193,7 +190,7 @@ HBITMAP WINAPI CreateCompatibleBitmap( HDC hdc, INT width, INT height)
dc->funcs->pCreateBitmap( hbmpRet );
}
TRACE("\t\t%04x\n", hbmpRet);
GDI_HEAP_UNLOCK(hdc);
GDI_ReleaseObj(hdc);
return hbmpRet;
}
......@@ -251,7 +248,10 @@ LONG WINAPI GetBitmapBits(
/* If the bits vector is null, the function should return the read size */
if(bits == NULL)
return bmp->bitmap.bmWidthBytes * bmp->bitmap.bmHeight;
{
ret = bmp->bitmap.bmWidthBytes * bmp->bitmap.bmHeight;
goto done;
}
if (count < 0) {
WARN("(%ld): Negative number of bytes passed???\n", count );
......@@ -265,8 +265,8 @@ LONG WINAPI GetBitmapBits(
if (count == 0)
{
WARN("Less then one entire line requested\n");
GDI_HEAP_UNLOCK( hbitmap );
return 0;
ret = 0;
goto done;
}
......@@ -295,8 +295,8 @@ LONG WINAPI GetBitmapBits(
}
}
GDI_HEAP_UNLOCK( hbitmap );
done:
GDI_ReleaseObj( hbitmap );
return ret;
}
......@@ -365,7 +365,7 @@ LONG WINAPI SetBitmapBits(
}
}
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return ret;
}
......@@ -393,7 +393,7 @@ HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
HeapFree( GetProcessHeap(), 0, buf );
}
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return res;
}
......@@ -410,7 +410,7 @@ BOOL BITMAP_DeleteObject( HBITMAP16 hbitmap, BITMAPOBJ * bmp )
DIB_DeleteDIBSection( bmp );
return GDI_FreeObject( hbitmap );
return GDI_FreeObject( hbitmap, bmp );
}
......@@ -523,7 +523,7 @@ BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
if (!bmp) return FALSE;
CONV_SIZE32TO16( &bmp->size, size );
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return TRUE;
}
......@@ -542,7 +542,7 @@ BOOL WINAPI GetBitmapDimensionEx(
BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
if (!bmp) return FALSE;
*size = bmp->size;
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return TRUE;
}
......@@ -569,7 +569,7 @@ BOOL16 WINAPI SetBitmapDimensionEx16( HBITMAP16 hbitmap, INT16 x, INT16 y,
if (prevSize) CONV_SIZE32TO16( &bmp->size, prevSize );
bmp->size.cx = x;
bmp->size.cy = y;
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return TRUE;
}
......@@ -592,7 +592,7 @@ BOOL WINAPI SetBitmapDimensionEx(
if (prevSize) *prevSize = bmp->size;
bmp->size.cx = x;
bmp->size.cy = y;
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
return TRUE;
}
......
......@@ -105,19 +105,19 @@ HBRUSH16 WINAPI CreateBrushIndirect16( const LOGBRUSH16 * brush )
{
BOOL success;
BRUSHOBJ * brushPtr;
HBRUSH16 hbrush = GDI_AllocObject( sizeof(BRUSHOBJ), BRUSH_MAGIC );
if (!hbrush) return 0;
brushPtr = (BRUSHOBJ *) GDI_HEAP_LOCK( hbrush );
HBRUSH hbrush;
if (!(brushPtr = GDI_AllocObject( sizeof(BRUSHOBJ), BRUSH_MAGIC, &hbrush ))) return 0;
brushPtr->logbrush.lbStyle = brush->lbStyle;
brushPtr->logbrush.lbColor = brush->lbColor;
brushPtr->logbrush.lbHatch = brush->lbHatch;
success = create_brush_indirect(brushPtr, TRUE);
GDI_HEAP_UNLOCK( hbrush );
if(!success)
{
GDI_FreeObject(hbrush);
GDI_FreeObject( hbrush, brushPtr );
hbrush = 0;
}
else GDI_ReleaseObj( hbrush );
TRACE("%04x\n", hbrush);
return hbrush;
}
......@@ -136,19 +136,18 @@ HBRUSH WINAPI CreateBrushIndirect( const LOGBRUSH * brush )
{
BOOL success;
BRUSHOBJ * brushPtr;
HBRUSH hbrush = GDI_AllocObject( sizeof(BRUSHOBJ), BRUSH_MAGIC );
if (!hbrush) return 0;
brushPtr = (BRUSHOBJ *) GDI_HEAP_LOCK( hbrush );
HBRUSH hbrush;
if (!(brushPtr = GDI_AllocObject( sizeof(BRUSHOBJ), BRUSH_MAGIC, &hbrush ))) return 0;
brushPtr->logbrush.lbStyle = brush->lbStyle;
brushPtr->logbrush.lbColor = brush->lbColor;
brushPtr->logbrush.lbHatch = brush->lbHatch;
success = create_brush_indirect(brushPtr, FALSE);
GDI_HEAP_UNLOCK( hbrush );
if(!success)
{
GDI_FreeObject(hbrush);
GDI_FreeObject( hbrush, brushPtr );
hbrush = 0;
}
else GDI_ReleaseObj( hbrush );
TRACE("%08x\n", hbrush);
return hbrush;
}
......@@ -319,6 +318,7 @@ DWORD WINAPI SetBrushOrg16( HDC16 hdc, INT16 x, INT16 y )
retval = dc->w.brushOrgX | (dc->w.brushOrgY << 16);
dc->w.brushOrgX = x;
dc->w.brushOrgY = y;
GDI_ReleaseObj( hdc );
return retval;
}
......@@ -338,6 +338,7 @@ BOOL WINAPI SetBrushOrgEx( HDC hdc, INT x, INT y, LPPOINT oldorg )
}
dc->w.brushOrgX = x;
dc->w.brushOrgY = y;
GDI_ReleaseObj( hdc );
return TRUE;
}
......@@ -365,7 +366,7 @@ BOOL BRUSH_DeleteObject( HBRUSH16 hbrush, BRUSHOBJ * brush )
GlobalFree16( (HGLOBAL16)brush->logbrush.lbHatch );
break;
}
return GDI_FreeObject( hbrush );
return GDI_FreeObject( hbrush, brush );
}
......
......@@ -5,31 +5,55 @@
*
*/
#include "winbase.h"
#include "winerror.h"
#include "gdi.h"
#include "dc.h"
#define COLORREF16 COLORREF /*hack*/
#define DC_GET_VAL_16( func_type, func_name, dc_field ) \
func_type WINAPI func_name( HDC16 hdc ) \
{ \
func_type ret = 0; \
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
if (!dc) return 0; \
return dc->dc_field; \
if (dc) \
{ \
ret = dc->dc_field; \
GDI_ReleaseObj( hdc ); \
} \
return ret; \
}
#define DC_GET_VAL_32( func_type, func_name, dc_field ) \
#define DC_GET_VAL( func_type, func_name, dc_field ) \
func_type##16 WINAPI func_name##16( HDC16 hdc ) \
{ \
return func_name( hdc ); \
} \
\
func_type WINAPI func_name( HDC hdc ) \
{ \
func_type ret = 0; \
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
if (!dc) return 0; \
return dc->dc_field; \
if (dc) \
{ \
ret = dc->dc_field; \
GDI_ReleaseObj( hdc ); \
} \
return ret; \
}
#define DC_GET_X_Y( func_type, func_name, ret_x, ret_y ) \
func_type WINAPI func_name( HDC16 hdc ) \
{ \
func_type ret = 0; \
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
if (!dc) return 0; \
return MAKELONG( dc->ret_x, dc->ret_y ); \
if (dc) \
{ \
ret = MAKELONG( dc->ret_x, dc->ret_y ); \
GDI_ReleaseObj( hdc ); \
} \
return ret; \
}
/* DC_GET_VAL_EX is used to define functions returning a POINT or a SIZE. It is
......@@ -43,15 +67,17 @@ BOOL16 WINAPI func_name##16( HDC16 hdc, LP##type##16 pt ) \
if (!dc) return FALSE; \
((LPPOINT16)pt)->x = dc->ret_x; \
((LPPOINT16)pt)->y = dc->ret_y; \
GDI_ReleaseObj( hdc ); \
return TRUE; \
} \
\
BOOL WINAPI func_name( HDC hdc, LP##type pt ) \
{ \
DC * dc = (DC *) GDI_GetObjPtr( (HDC16)hdc, DC_MAGIC ); \
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \
if (!dc) return FALSE; \
((LPPOINT)pt)->x = dc->ret_x; \
((LPPOINT)pt)->y = dc->ret_y; \
GDI_ReleaseObj( hdc ); \
return TRUE; \
}
......@@ -64,16 +90,19 @@ INT16 WINAPI func_name##16( HDC16 hdc, INT16 mode ) \
INT WINAPI func_name( HDC hdc, INT mode ) \
{ \
INT prevMode; \
DC *dc = DC_GetDCPtr( hdc ); \
if(!dc) return 0; \
if ((mode < min_val) || (mode > max_val)) return 0; \
DC *dc; \
if ((mode < min_val) || (mode > max_val)) { \
SetLastError(ERROR_INVALID_PARAMETER); \
return 0; \
} \
if (!(dc = DC_GetDCPtr( hdc ))) return 0; \
if (dc->funcs->p##func_name) { \
prevMode = dc->funcs->p##func_name( dc, mode ); \
} else { \
prevMode = dc->dc_field; \
dc->dc_field = mode; \
} \
GDI_HEAP_UNLOCK( hdc ); \
GDI_ReleaseObj( hdc ); \
return prevMode; \
}
......@@ -104,24 +133,14 @@ DC_SET_MODE( SetPolyFillMode, w.polyFillMode, ALTERNATE, WINDING )
DC_SET_MODE( SetStretchBltMode, w.stretchBltMode, BLACKONWHITE, HALFTONE )
/***********************************************************************
* GetBkColor16 (GDI.75)
* GetBkColor (GDI.75) (GDI32.145)
*/
DC_GET_VAL_16( COLORREF, GetBkColor16, w.backgroundColor )
DC_GET_VAL( COLORREF, GetBkColor, w.backgroundColor )
/***********************************************************************
* GetBkColor (GDI32.145)
* GetBkMode (GDI.76) (GDI32.146)
*/
DC_GET_VAL_32( COLORREF, GetBkColor, w.backgroundColor )
/***********************************************************************
* GetBkMode16 (GDI.76)
*/
DC_GET_VAL_16( INT16, GetBkMode16, w.backgroundMode )
/***********************************************************************
* GetBkMode (GDI32.146)
*/
DC_GET_VAL_32( INT, GetBkMode, w.backgroundMode )
DC_GET_VAL( INT, GetBkMode, w.backgroundMode )
/***********************************************************************
* GetCurrentPosition16 (GDI.78)
......@@ -129,34 +148,19 @@ DC_GET_VAL_32( INT, GetBkMode, w.backgroundMode )
DC_GET_X_Y( DWORD, GetCurrentPosition16, w.CursPosX, w.CursPosY )
/***********************************************************************
* GetMapMode16 (GDI.81)
* GetMapMode (GDI.81) (GDI32.196)
*/
DC_GET_VAL_16( INT16, GetMapMode16, w.MapMode )
DC_GET_VAL( INT, GetMapMode, w.MapMode )
/***********************************************************************
* GetMapMode (GDI32.196)
* GetPolyFillMode (GDI.84) (GDI32.213)
*/
DC_GET_VAL_32( INT, GetMapMode, w.MapMode )
DC_GET_VAL( INT, GetPolyFillMode, w.polyFillMode )
/***********************************************************************
* GetPolyFillMode16 (GDI.84)
* GetROP2 (GDI.85) (GDI32.214)
*/
DC_GET_VAL_16( INT16, GetPolyFillMode16, w.polyFillMode )
/***********************************************************************
* GetPolyFillMode (GDI32.213)
*/
DC_GET_VAL_32( INT, GetPolyFillMode, w.polyFillMode )
/***********************************************************************
* GetROP216 (GDI.85)
*/
DC_GET_VAL_16( INT16, GetROP216, w.ROPmode )
/***********************************************************************
* GetROP2 (GDI32.214)
*/
DC_GET_VAL_32( INT, GetROP2, w.ROPmode )
DC_GET_VAL( INT, GetROP2, w.ROPmode )
/***********************************************************************
* GetRelAbs16 (GDI.86)
......@@ -164,24 +168,14 @@ DC_GET_VAL_32( INT, GetROP2, w.ROPmode )
DC_GET_VAL_16( INT16, GetRelAbs16, w.relAbsMode )
/***********************************************************************
* GetStretchBltMode16 (GDI.88)
*/
DC_GET_VAL_16( INT16, GetStretchBltMode16, w.stretchBltMode )
/***********************************************************************
* GetStretchBltMode (GDI32.221)
*/
DC_GET_VAL_32( INT, GetStretchBltMode, w.stretchBltMode )
/***********************************************************************
* GetTextColor16 (GDI.90)
* GetStretchBltMode (GDI.88) (GDI32.221)
*/
DC_GET_VAL_16( COLORREF, GetTextColor16, w.textColor )
DC_GET_VAL( INT, GetStretchBltMode, w.stretchBltMode )
/***********************************************************************
* GetTextColor (GDI32.227)
* GetTextColor (GDI.90) (GDI32.227)
*/
DC_GET_VAL_32( COLORREF, GetTextColor, w.textColor )
DC_GET_VAL( COLORREF, GetTextColor, w.textColor )
/***********************************************************************
* GetViewportExt16 (GDI.94)
......@@ -219,19 +213,24 @@ DC_GET_VAL_16( HRGN16, GetClipRgn16, w.hClipRgn )
DC_GET_X_Y( DWORD, GetBrushOrg16, w.brushOrgX, w.brushOrgY )
/***********************************************************************
* GetTextAlign16 (GDI.345)
* GetTextAlign (GDI.345) (GDI32,224)
*/
DC_GET_VAL_16( UINT16, GetTextAlign16, w.textAlign )
DC_GET_VAL( UINT, GetTextAlign, w.textAlign )
/***********************************************************************
* GetTextAlign (GDI32.224)
* GetCurLogFont16 (GDI.411)
*/
DC_GET_VAL_32( UINT, GetTextAlign, w.textAlign )
DC_GET_VAL_16( HFONT16, GetCurLogFont16, w.hFont )
/***********************************************************************
* GetCurLogFont16 (GDI.411)
* GetArcDirection (GDI.524) (GDI32.141)
*/
DC_GET_VAL_16( HFONT16, GetCurLogFont16, w.hFont )
DC_GET_VAL( INT, GetArcDirection, w.ArcDirection )
/***********************************************************************
* GetGraphicsMode (GDI32.188)
*/
DC_GET_VAL( INT, GetGraphicsMode, w.GraphicsMode)
/***********************************************************************
* GetBrushOrgEx (GDI.469) (GDI32.148)
......
......@@ -133,11 +133,11 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
INT heightSrc, const void *bits,
const BITMAPINFO *info, UINT wUsage, DWORD dwRop )
{
DC *dc = DC_GetDCPtr( hdc );
DC *dc = DC_GetDCUpdate( hdc );
if(!dc) return FALSE;
if(dc->funcs->pStretchDIBits)
return dc->funcs->pStretchDIBits(dc, xDst, yDst, widthDst,
heightSrc = dc->funcs->pStretchDIBits(dc, xDst, yDst, widthDst,
heightDst, xSrc, ySrc, widthSrc,
heightSrc, bits, info, wUsage,
dwRop);
......@@ -157,8 +157,9 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
SelectObject( hdcMem, hOldBitmap );
DeleteDC( hdcMem );
DeleteObject( hBitmap );
return heightSrc;
}
GDI_ReleaseObj( hdc );
return heightSrc;
}
......@@ -198,16 +199,11 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
INT result;
/* Check parameters */
dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc)
{
dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if (!dc) return 0;
}
if (!(dc = DC_GetDCUpdate( hdc ))) return 0;
if (!(bitmap = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
{
GDI_HEAP_UNLOCK( hdc );
GDI_ReleaseObj( hdc );
return 0;
}
......@@ -215,8 +211,8 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
lines, bits, info,
coloruse, hbitmap);
GDI_HEAP_UNLOCK( hdc );
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hbitmap );
GDI_ReleaseObj( hdc );
return result;
}
......@@ -246,7 +242,7 @@ INT WINAPI SetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx,
INT ret;
DC *dc;
if (!(dc = DC_GetDCPtr( hdc ))) return 0;
if (!(dc = DC_GetDCUpdate( hdc ))) return 0;
if(dc->funcs->pSetDIBitsToDevice)
ret = dc->funcs->pSetDIBitsToDevice( dc, xDest, yDest, cx, cy, xSrc,
......@@ -257,7 +253,7 @@ INT WINAPI SetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx,
ret = 0;
}
GDI_HEAP_UNLOCK( hdc );
GDI_ReleaseObj( hdc );
return ret;
}
......@@ -281,15 +277,11 @@ UINT WINAPI SetDIBColorTable( HDC hdc, UINT startpos, UINT entries,
PALETTEOBJ * palette;
RGBQUAD *end;
dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc)
{
dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if (!dc) return 0;
}
if (!(dc = DC_GetDCUpdate( hdc ))) return 0;
if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
{
GDI_ReleaseObj( hdc );
return 0;
}
......@@ -312,7 +304,8 @@ UINT WINAPI SetDIBColorTable( HDC hdc, UINT startpos, UINT entries,
} else {
entries = 0;
}
GDI_HEAP_UNLOCK( dc->w.hPalette );
GDI_ReleaseObj( dc->w.hPalette );
GDI_ReleaseObj( hdc );
return entries;
}
......@@ -336,15 +329,11 @@ UINT WINAPI GetDIBColorTable( HDC hdc, UINT startpos, UINT entries,
PALETTEOBJ * palette;
RGBQUAD *end;
dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc)
{
dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if (!dc) return 0;
}
if (!(dc = DC_GetDCUpdate( hdc ))) return 0;
if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
{
GDI_ReleaseObj( hdc );
return 0;
}
......@@ -365,7 +354,8 @@ UINT WINAPI GetDIBColorTable( HDC hdc, UINT startpos, UINT entries,
} else {
entries = 0;
}
GDI_HEAP_UNLOCK( dc->w.hPalette );
GDI_ReleaseObj( dc->w.hPalette );
GDI_ReleaseObj( hdc );
return entries;
}
......@@ -456,21 +446,16 @@ INT WINAPI GetDIBits(
int i;
if (!info) return 0;
dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc)
{
dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if (!dc) return 0;
}
if (!(dc = DC_GetDCUpdate( hdc ))) return 0;
if (!(bmp = (BITMAPOBJ *)GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
{
GDI_HEAP_UNLOCK( hdc );
GDI_ReleaseObj( hdc );
return 0;
}
if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
{
GDI_HEAP_UNLOCK( hdc );
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hdc );
GDI_ReleaseObj( hbitmap );
return 0;
}
......@@ -530,7 +515,7 @@ INT WINAPI GetDIBits(
}
}
GDI_HEAP_UNLOCK( dc->w.hPalette );
GDI_ReleaseObj( dc->w.hPalette );
if (bits && lines)
{
......@@ -728,10 +713,10 @@ INT WINAPI GetDIBits(
/* Otherwise, get bits from the XImage */
else if(!BITMAP_Driver->pGetDIBits(bmp, dc, startscan, lines, bits, info, coloruse, hbitmap))
{
GDI_HEAP_UNLOCK( hdc );
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hdc );
GDI_ReleaseObj( hbitmap );
return FALSE;
return 0;
}
}
else if( info->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) )
......@@ -763,8 +748,8 @@ INT WINAPI GetDIBits(
info->bmiHeader.biSizeImage, info->bmiHeader.biWidth,
info->bmiHeader.biHeight);
GDI_HEAP_UNLOCK( hdc );
GDI_HEAP_UNLOCK( hbitmap );
GDI_ReleaseObj( hdc );
GDI_ReleaseObj( hbitmap );
return lines;
}
......@@ -870,7 +855,7 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage,
SEGPTR *bits, HANDLE section,
DWORD offset)
{
HBITMAP16 hbitmap;
HBITMAP16 hbitmap = 0;
DC *dc;
BOOL bDesktopDC = FALSE;
......@@ -881,13 +866,11 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage,
bDesktopDC = TRUE;
}
dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC);
if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if(!dc) return (HBITMAP16) NULL;
hbitmap = dc->funcs->pCreateDIBSection16(dc, bmi, usage, bits, section, offset, 0);
GDI_HEAP_UNLOCK(hdc);
if ((dc = DC_GetDCPtr( hdc )))
{
hbitmap = dc->funcs->pCreateDIBSection16(dc, bmi, usage, bits, section, offset, 0);
GDI_ReleaseObj(hdc);
}
if (bDesktopDC)
DeleteDC(hdc);
......@@ -902,7 +885,7 @@ HBITMAP DIB_CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
LPVOID *bits, HANDLE section,
DWORD offset, DWORD ovr_pitch)
{
HBITMAP hbitmap;
HBITMAP hbitmap = 0;
DC *dc;
BOOL bDesktopDC = FALSE;
......@@ -913,13 +896,11 @@ HBITMAP DIB_CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
bDesktopDC = TRUE;
}
dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC);
if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if(!dc) return (HBITMAP) NULL;
hbitmap = dc->funcs->pCreateDIBSection(dc, bmi, usage, bits, section, offset, ovr_pitch);
GDI_HEAP_UNLOCK(hdc);
if ((dc = DC_GetDCPtr( hdc )))
{
hbitmap = dc->funcs->pCreateDIBSection(dc, bmi, usage, bits, section, offset, ovr_pitch);
GDI_ReleaseObj(hdc);
}
if (bDesktopDC)
DeleteDC(hdc);
......@@ -976,6 +957,7 @@ HGLOBAL DIB_CreateDIBFromBitmap(HDC hdc, HBITMAP hBmp)
/* Get a pointer to the BITMAPOBJ structure */
pBmp = (BITMAPOBJ *)GDI_GetObjPtr( hBmp, BITMAP_MAGIC );
if (!pBmp) return hPackedDIB;
/* Get the bitmap dimensions */
width = pBmp->bitmap.bmWidth;
......@@ -1042,5 +1024,6 @@ HGLOBAL DIB_CreateDIBFromBitmap(HDC hdc, HBITMAP hBmp)
}
END:
GDI_ReleaseObj( hBmp );
return hPackedDIB;
}
......@@ -35,13 +35,16 @@ DEFAULT_DEBUG_CHANNEL(enhmetafile)
HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, HFILE hFile, HANDLE
hMapping )
{
HENHMETAFILE hmf = GDI_AllocObject( sizeof(ENHMETAFILEOBJ),
ENHMETAFILE_MAGIC );
ENHMETAFILEOBJ *metaObj = (ENHMETAFILEOBJ *)GDI_HEAP_LOCK( hmf );
HENHMETAFILE hmf = 0;
ENHMETAFILEOBJ *metaObj = GDI_AllocObject( sizeof(ENHMETAFILEOBJ),
ENHMETAFILE_MAGIC, &hmf );
if (metaObj)
{
metaObj->emh = emh;
metaObj->hFile = hFile;
metaObj->hMapping = hMapping;
GDI_HEAP_UNLOCK( hmf );
GDI_ReleaseObj( hmf );
}
return hmf;
}
......@@ -59,7 +62,7 @@ static BOOL EMF_Delete_HENHMETAFILE( HENHMETAFILE hmf )
CloseHandle( metaObj->hFile );
} else
HeapFree( GetProcessHeap(), 0, metaObj->emh );
return GDI_FreeObject( hmf );
return GDI_FreeObject( hmf, metaObj );
}
/******************************************************************
......@@ -81,9 +84,9 @@ static ENHMETAHEADER *EMF_GetEnhMetaHeader( HENHMETAFILE hmf )
*
* Releases ENHMETAHEADER associated with HENHMETAFILE
*/
static BOOL EMF_ReleaseEnhMetaHeader( HENHMETAFILE hmf )
static void EMF_ReleaseEnhMetaHeader( HENHMETAFILE hmf )
{
return GDI_HEAP_UNLOCK( hmf );
GDI_ReleaseObj( hmf );
}
/*****************************************************************************
......
......@@ -73,10 +73,13 @@ static int MF_AddHandle(HANDLETABLE16 *ht, WORD htlen, HGDIOBJ16 hobj)
*/
HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh)
{
HMETAFILE hmf = GDI_AllocObject( sizeof(METAFILEOBJ), METAFILE_MAGIC );
METAFILEOBJ *metaObj = (METAFILEOBJ *)GDI_HEAP_LOCK( hmf );
HMETAFILE hmf = 0;
METAFILEOBJ *metaObj = GDI_AllocObject( sizeof(METAFILEOBJ), METAFILE_MAGIC, &hmf );
if (metaObj)
{
metaObj->mh = mh;
GDI_HEAP_UNLOCK( hmf );
GDI_ReleaseObj( hmf );
}
return hmf;
}
......@@ -130,9 +133,9 @@ static METAHEADER *MF_GetMetaHeader16( HMETAFILE16 hmf )
*
* Releases METAHEADER associated with HMETAFILE
*/
static BOOL MF_ReleaseMetaHeader( HMETAFILE hmf )
static void MF_ReleaseMetaHeader( HMETAFILE hmf )
{
return GDI_HEAP_UNLOCK( hmf );
GDI_ReleaseObj( hmf );
}
/******************************************************************
......@@ -162,11 +165,10 @@ BOOL16 WINAPI DeleteMetaFile16( HMETAFILE16 hmf )
BOOL WINAPI DeleteMetaFile( HMETAFILE hmf )
{
METAHEADER *mh = MF_GetMetaHeader( hmf );
if(!mh) return FALSE;
HeapFree( GetProcessHeap(), 0, mh );
GDI_FreeObject( hmf );
METAFILEOBJ * metaObj = (METAFILEOBJ *)GDI_GetObjPtr( hmf, METAFILE_MAGIC );
if (!metaObj) return FALSE;
HeapFree( GetProcessHeap(), 0, metaObj->mh );
GDI_FreeObject( hmf, metaObj );
return TRUE;
}
......@@ -475,7 +477,7 @@ static BOOL MF_PlayMetaFile( HDC hdc, METAHEADER *mh)
BOOL loaded = FALSE;
if (!mh) return FALSE;
if(mh->mtType == METAFILE_DISK) { /* Create a memoery-based copy */
if(mh->mtType == METAFILE_DISK) { /* Create a memory-based copy */
mh = MF_LoadDiskBasedMetaFile(mh);
if(!mh) return FALSE;
loaded = TRUE;
......@@ -580,7 +582,7 @@ BOOL16 WINAPI EnumMetaFile16( HDC16 hdc, HMETAFILE16 hmf,
if(!mh) return FALSE;
if(mh->mtType == METAFILE_DISK) { /* Create a memoery-based copy */
if(mh->mtType == METAFILE_DISK) { /* Create a memory-based copy */
mh = MF_LoadDiskBasedMetaFile(mh);
if(!mh) return FALSE;
loaded = TRUE;
......@@ -668,7 +670,7 @@ BOOL WINAPI EnumMetaFile(
TRACE("(%08x,%08x,%p,%p)\n",
hdc, hmf, lpEnumFunc, (void*)lpData);
if (!mh) return 0;
if(mh->mtType == METAFILE_DISK) { /* Create a memoery-based copy */
if(mh->mtType == METAFILE_DISK) { /* Create a memory-based copy */
mh = MF_LoadDiskBasedMetaFile(mh);
if(!mh) return 0;
loaded = TRUE;
......
......@@ -54,16 +54,14 @@ HPEN WINAPI CreatePen( INT style, INT width, COLORREF color )
HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
{
PENOBJ * penPtr;
HPEN16 hpen;
HPEN hpen;
if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
if (!hpen) return 0;
penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
penPtr->logpen.lopnStyle = pen->lopnStyle;
penPtr->logpen.lopnColor = pen->lopnColor;
CONV_POINT16TO32( &pen->lopnWidth, &penPtr->logpen.lopnWidth );
GDI_HEAP_UNLOCK( hpen );
GDI_ReleaseObj( hpen );
return hpen;
}
......@@ -77,13 +75,11 @@ HPEN WINAPI CreatePenIndirect( const LOGPEN * pen )
HPEN hpen;
if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
if (!hpen) return 0;
penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
penPtr->logpen.lopnStyle = pen->lopnStyle;
penPtr->logpen.lopnWidth = pen->lopnWidth;
penPtr->logpen.lopnColor = pen->lopnColor;
GDI_HEAP_UNLOCK( hpen );
GDI_ReleaseObj( hpen );
return hpen;
}
......@@ -106,9 +102,7 @@ HPEN WINAPI ExtCreatePen( DWORD style, DWORD width,
if (brush->lbHatch)
FIXME("Hatches not implemented\n");
hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
if (!hpen) return 0;
penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
penPtr->logpen.lopnStyle = style & ~PS_TYPE_MASK;
/* PS_USERSTYLE and PS_ALTERNATE workaround */
......@@ -119,7 +113,7 @@ HPEN WINAPI ExtCreatePen( DWORD style, DWORD width,
penPtr->logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1;
penPtr->logpen.lopnWidth.y = 0;
penPtr->logpen.lopnColor = brush->lbColor;
GDI_HEAP_UNLOCK( hpen );
GDI_ReleaseObj( hpen );
return hpen;
}
......
......@@ -92,9 +92,15 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR str, UINT count,
const INT *lpDx )
{
DC * dc = DC_GetDCPtr( hdc );
return dc && dc->funcs->pExtTextOut &&
dc->funcs->pExtTextOut(dc,x,y,flags,lprect,str,count,lpDx);
BOOL ret = FALSE;
DC * dc = DC_GetDCUpdate( hdc );
if (dc)
{
if(dc->funcs->pExtTextOut)
ret = dc->funcs->pExtTextOut(dc,x,y,flags,lprect,str,count,lpDx);
GDI_ReleaseObj( hdc );
}
return ret;
}
......
......@@ -613,8 +613,8 @@ static HGLOBAL16 CURSORICON_CreateFromResource( HINSTANCE16 hInstance, HGLOBAL16
GlobalUnlock16( hObj );
}
DeleteObject( hXorBits );
DeleteObject( hAndBits );
DeleteObject( hXorBits );
return hObj;
}
......@@ -1897,7 +1897,7 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
{
CURSORICONINFO *ptr = (CURSORICONINFO *)GlobalLock16 (hIcon);
HDC hDC_off = 0, hMemDC = CreateCompatibleDC (hdc);
BOOL result = FALSE, DoOffscreen = FALSE;
BOOL result = FALSE, DoOffscreen;
HBITMAP hB_off = 0, hOld = 0;
if (!ptr) return FALSE;
......@@ -1923,17 +1923,8 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
cyWidth = ptr->nHeight;
}
if (!(DoOffscreen = (hbr >= STOCK_WHITE_BRUSH) && (hbr <=
STOCK_HOLLOW_BRUSH)))
{
GDIOBJHDR *object = (GDIOBJHDR *) GDI_HEAP_LOCK(hbr);
if (object)
{
UINT16 magic = object->wMagic;
GDI_HEAP_UNLOCK(hbr);
DoOffscreen = magic == BRUSH_MAGIC;
}
}
DoOffscreen = (GetObjectType( hbr ) == OBJ_BRUSH);
if (DoOffscreen) {
RECT r;
......@@ -1948,7 +1939,7 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
hOld = SelectObject(hDC_off, hB_off);
FillRect(hDC_off, &r, hbr);
}
};
}
if (hMemDC && (!DoOffscreen || (hDC_off && hB_off)))
{
......
......@@ -603,7 +603,7 @@ static void DCE_OffsetVisRgn( HDC hDC, HRGN hVisRgn )
OffsetRgn( hVisRgn, dc->w.DCOrgX, dc->w.DCOrgY );
GDI_HEAP_UNLOCK( hDC );
GDI_ReleaseObj( hDC );
}
/***********************************************************************
......@@ -807,6 +807,8 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
/* recompute visible region */
wndPtr->pDriver->pSetDrawable( wndPtr, hdc, flags, bUpdateClipOrigin );
dc->w.flags &= ~DC_DIRTY;
GDI_ReleaseObj( hdc );
if( bUpdateVisRgn )
{
......@@ -846,7 +848,6 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
DCE_OffsetVisRgn( hdc, hrgnVisible );
}
dc->w.flags &= ~DC_DIRTY;
dce->DCXflags &= ~DCX_DCEDIRTY;
SelectVisRgn16( hdc, hrgnVisible );
}
......@@ -999,7 +1000,7 @@ BOOL16 WINAPI DCHook16( HDC16 hDC, WORD code, DWORD data, LPARAM lParam )
/* Update stale DC in DCX */
wndPtr = WIN_FindWndPtr( dce->hwndCurrent);
if (wndPtr) wndPtr->pDriver->pSetDrawable( wndPtr, hDC, dce->DCXflags, TRUE);
if (wndPtr) wndPtr->pDriver->pSetDrawable( wndPtr, dce->hDC, dce->DCXflags, TRUE);
SetHookFlags16(hDC, DCHF_VALIDATEVISRGN);
hVisRgn = DCE_GetVisRgn(dce->hwndCurrent, dce->DCXflags, 0, 0);
......
......@@ -81,7 +81,7 @@ BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
{
RECT rect, rClip, rSrc;
POINT src, dest;
DC *dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC);
DC *dc = DC_GetDCUpdate( hdc );
TRACE("%04x %d,%d hrgnUpdate=%04x rcUpdate = %p cliprc = (%d,%d-%d,%d), rc=(%d,%d-%d,%d)\n",
(HDC16)hdc, dx, dy, hrgnUpdate, rcUpdate,
......@@ -126,7 +126,7 @@ BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
rSrc.right - rSrc.left, rSrc.bottom - rSrc.top,
hdc, src.x, src.y, SRCCOPY))
{
GDI_HEAP_UNLOCK( hdc );
GDI_ReleaseObj( hdc );
return FALSE;
}
}
......@@ -171,7 +171,7 @@ BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
if (rcUpdate) SetRectEmpty(rcUpdate);
}
GDI_HEAP_UNLOCK( hdc );
GDI_ReleaseObj( hdc );
return TRUE;
}
......@@ -254,7 +254,6 @@ INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy,
if (!IsRectEmpty(&cliprc) && (dx || dy))
{
DC* dc;
HDC hDC;
BOOL bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE));
HRGN hrgnClip = CreateRectRgnIndirect(&cliprc);
......@@ -276,13 +275,15 @@ rc.left, rc.top, rc.right, rc.bottom, (UINT16)flags );
hDC = GetDCEx( hwnd, hrgnClip, DCX_CACHE | DCX_USESTYLE |
DCX_KEEPCLIPRGN | DCX_INTERSECTRGN |
((flags & SW_SCROLLCHILDREN) ? DCX_NOCLIPCHILDREN : 0) );
if( (dc = (DC *)GDI_GetObjPtr(hDC, DC_MAGIC)) )
if (hDC)
{
if (dc->w.hVisRgn) {
wnd->pDriver->pSurfaceCopy(wnd,hDC,dx,dy,&rc,bUpdate);
if( bUpdate )
{
DC* dc;
if( (dc = DC_GetDCPtr(hDC)) )
{
OffsetRgn( hrgnTemp, dc->w.DCOrgX, dc->w.DCOrgY );
CombineRgn( hrgnTemp, hrgnTemp, dc->w.hVisRgn,
RGN_AND );
......@@ -295,10 +296,10 @@ rc.left, rc.top, rc.right, rc.bottom, (UINT16)flags );
RGN_DIFF );
if( rcUpdate ) GetRgnBox( hrgnUpdate, rcUpdate );
GDI_ReleaseObj( hDC );
}
}
ReleaseDC(hwnd, hDC);
GDI_HEAP_UNLOCK( hDC );
}
if( wnd->hrgnUpdate > 1 )
......
......@@ -12,7 +12,6 @@
#include "winuser.h"
#include "heap.h"
#include "user.h"
#include "gdi.h"
#include "task.h"
#include "queue.h"
#include "class.h"
......@@ -43,8 +42,13 @@ DECLARE_DEBUG_CHANNEL(win32);
*/
WORD WINAPI GetFreeSystemResources16( WORD resType )
{
HINSTANCE16 gdi_inst;
WORD gdi_heap;
int userPercent, gdiPercent;
if ((gdi_inst = LoadLibrary16( "GDI" )) < 32) return 0;
gdi_heap = GlobalHandleToSel16( gdi_inst );
switch(resType)
{
case GFSR_USERRESOURCES:
......@@ -54,21 +58,23 @@ WORD WINAPI GetFreeSystemResources16( WORD resType )
break;
case GFSR_GDIRESOURCES:
gdiPercent = (int)LOCAL_CountFree( GDI_HeapSel ) * 100 /
LOCAL_HeapSize( GDI_HeapSel );
gdiPercent = (int)LOCAL_CountFree( gdi_inst ) * 100 /
LOCAL_HeapSize( gdi_inst );
userPercent = 100;
break;
case GFSR_SYSTEMRESOURCES:
userPercent = (int)LOCAL_CountFree( USER_HeapSel ) * 100 /
LOCAL_HeapSize( USER_HeapSel );
gdiPercent = (int)LOCAL_CountFree( GDI_HeapSel ) * 100 /
LOCAL_HeapSize( GDI_HeapSel );
gdiPercent = (int)LOCAL_CountFree( gdi_inst ) * 100 /
LOCAL_HeapSize( gdi_inst );
break;
default:
return 0;
userPercent = gdiPercent = 0;
break;
}
FreeLibrary16( gdi_inst );
return (WORD)min( userPercent, gdiPercent );
}
......
......@@ -890,10 +890,10 @@ void X11DRV_WND_SurfaceCopy(WND* wndPtr, HDC hdc, INT dx, INT dy,
dst.x, dst.y );
if (bUpdate)
TSXSetGraphicsExposures( display, physDev->gc, False );
GDI_ReleaseObj( hdc );
if (bUpdate) /* Make sure exposure events have been processed */
EVENT_Synchronize();
GDI_HEAP_UNLOCK( hdc );
}
/***********************************************************************
......@@ -975,7 +975,7 @@ void X11DRV_WND_SetDrawable(WND *wndPtr, HDC hdc, WORD flags, BOOL bSetClipOrigi
TSXSetClipOrigin( display, physDev->gc, dc->w.DCOrgX, dc->w.DCOrgY );
#endif
}
GDI_HEAP_UNLOCK( hdc );
GDI_ReleaseObj( hdc );
}
/***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment