gdi32: Replace DC_GetDCUpdate by get_dc_ptr+update_dc in the bitmap functions.

This commit is contained in:
Alexandre Julliard 2007-09-17 16:48:56 +02:00
parent f3f792d064
commit baa8d22543
2 changed files with 58 additions and 47 deletions

View File

@ -35,7 +35,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(bitblt);
BOOL WINAPI PatBlt( HDC hdc, INT left, INT top,
INT width, INT height, DWORD rop)
{
DC * dc = DC_GetDCUpdate( hdc );
DC * dc = get_dc_ptr( hdc );
BOOL bRet = FALSE;
if (!dc) return FALSE;
@ -43,9 +43,10 @@ BOOL WINAPI PatBlt( HDC hdc, INT left, INT top,
if (dc->funcs->pPatBlt)
{
TRACE("%p %d,%d %dx%d %06x\n", hdc, left, top, width, height, rop );
update_dc( dc );
bRet = dc->funcs->pPatBlt( dc->physDev, left, top, width, height, rop );
}
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
return bRet;
}
@ -59,22 +60,23 @@ BOOL WINAPI BitBlt( HDC hdcDst, INT xDst, INT yDst, INT width,
BOOL ret = FALSE;
DC *dcDst, *dcSrc;
if ((dcDst = DC_GetDCUpdate( hdcDst )) && dcDst->funcs->pBitBlt)
if (!(dcDst = get_dc_ptr( hdcDst ))) return FALSE;
if (dcDst->funcs->pBitBlt)
{
DC_ReleaseDCPtr( dcDst );
/* FIXME: there is a race condition here */
dcSrc = DC_GetDCUpdate( hdcSrc );
dcDst = DC_GetDCPtr( hdcDst );
update_dc( dcDst );
dcSrc = get_dc_ptr( hdcSrc );
if (dcSrc) update_dc( dcSrc );
TRACE("hdcSrc=%p %d,%d -> hdcDest=%p %d,%d %dx%d rop=%06x\n",
hdcSrc, xSrc, ySrc, hdcDst, xDst, yDst, width, height, rop);
ret = dcDst->funcs->pBitBlt( dcDst->physDev, xDst, yDst, width, height,
dcSrc ? dcSrc->physDev : NULL, xSrc, ySrc, rop );
DC_ReleaseDCPtr( dcDst );
if (dcSrc) DC_ReleaseDCPtr( dcSrc );
release_dc_ptr( dcDst );
if (dcSrc) release_dc_ptr( dcSrc );
}
else if(dcDst && dcDst->funcs->pStretchDIBits)
else if (dcDst->funcs->pStretchDIBits)
{
BITMAP bm;
BITMAPINFOHEADER info_hdr;
@ -82,7 +84,7 @@ BOOL WINAPI BitBlt( HDC hdcDst, INT xDst, INT yDst, INT width,
LPVOID bits;
INT lines;
DC_ReleaseDCPtr( dcDst );
release_dc_ptr( dcDst );
if(GetObjectType( hdcSrc ) != OBJ_MEMDC)
{
@ -118,8 +120,7 @@ BOOL WINAPI BitBlt( HDC hdcDst, INT xDst, INT yDst, INT width,
HeapFree(GetProcessHeap(), 0, bits);
return (lines == height);
}
else if(dcDst)
DC_ReleaseDCPtr( dcDst );
else release_dc_ptr( dcDst );
return ret;
}
@ -137,13 +138,14 @@ BOOL WINAPI StretchBlt( HDC hdcDst, INT xDst, INT yDst,
BOOL ret = FALSE;
DC *dcDst, *dcSrc;
if ((dcDst = DC_GetDCUpdate( hdcDst )) && dcDst->funcs->pStretchBlt)
if (!(dcDst = get_dc_ptr( hdcDst ))) return FALSE;
if (dcDst->funcs->pStretchBlt)
{
DC_ReleaseDCPtr( dcDst );
/* FIXME: there is a race condition here */
if ((dcSrc = DC_GetDCUpdate( hdcSrc )))
if ((dcSrc = get_dc_ptr( hdcSrc )))
{
dcDst = DC_GetDCPtr( hdcDst );
update_dc( dcDst );
update_dc( dcSrc );
TRACE("%p %d,%d %dx%d -> %p %d,%d %dx%d rop=%06x\n",
hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
@ -152,11 +154,11 @@ BOOL WINAPI StretchBlt( HDC hdcDst, INT xDst, INT yDst,
ret = dcDst->funcs->pStretchBlt( dcDst->physDev, xDst, yDst, widthDst, heightDst,
dcSrc->physDev, xSrc, ySrc, widthSrc, heightSrc,
rop );
DC_ReleaseDCPtr( dcDst );
DC_ReleaseDCPtr( dcSrc );
release_dc_ptr( dcDst );
release_dc_ptr( dcSrc );
}
}
else if(dcDst && dcDst->funcs->pStretchDIBits)
else if (dcDst->funcs->pStretchDIBits)
{
BITMAP bm;
BITMAPINFOHEADER info_hdr;
@ -164,7 +166,7 @@ BOOL WINAPI StretchBlt( HDC hdcDst, INT xDst, INT yDst,
LPVOID bits;
INT lines;
DC_ReleaseDCPtr( dcDst );
release_dc_ptr( dcDst );
if(GetObjectType( hdcSrc ) != OBJ_MEMDC) return FALSE;
@ -196,8 +198,7 @@ BOOL WINAPI StretchBlt( HDC hdcDst, INT xDst, INT yDst,
HeapFree(GetProcessHeap(), 0, bits);
return (lines == heightSrc);
}
else if(dcDst)
DC_ReleaseDCPtr( dcDst );
else release_dc_ptr( dcDst );
return ret;
}
@ -496,11 +497,11 @@ BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heig
BOOL ret = FALSE;
DC *dcDst, *dcSrc;
if ((dcSrc = DC_GetDCUpdate( hdcSrc ))) DC_ReleaseDCPtr( dcSrc );
/* FIXME: there is a race condition here */
if ((dcDst = DC_GetDCUpdate( hdcDst )))
dcSrc = get_dc_ptr( hdcSrc );
if ((dcDst = get_dc_ptr( hdcDst )))
{
dcSrc = DC_GetDCPtr( hdcSrc );
if (dcSrc) update_dc( dcSrc );
update_dc( dcDst );
TRACE("%p %d,%d %dx%d -> %p %d,%d %dx%d op=%02x flags=%02x srcconstalpha=%02x alphafmt=%02x\n",
hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
hdcDst, xDst, yDst, widthDst, heightDst,
@ -510,9 +511,9 @@ BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heig
ret = dcDst->funcs->pAlphaBlend( dcDst->physDev, xDst, yDst, widthDst, heightDst,
dcSrc ? dcSrc->physDev : NULL,
xSrc, ySrc, widthSrc, heightSrc, blendFunction );
if (dcSrc) DC_ReleaseDCPtr( dcSrc );
DC_ReleaseDCPtr( dcDst );
release_dc_ptr( dcDst );
}
if (dcSrc) release_dc_ptr( dcSrc );
return ret;
}

View File

@ -193,15 +193,15 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
if (!bits || !info)
return 0;
dc = DC_GetDCUpdate( hdc );
if(!dc) return FALSE;
if (!(dc = get_dc_ptr( hdc ))) return FALSE;
if(dc->funcs->pStretchDIBits)
{
update_dc( dc );
heightSrc = dc->funcs->pStretchDIBits(dc->physDev, xDst, yDst, widthDst,
heightDst, xSrc, ySrc, widthSrc,
heightSrc, bits, info, wUsage, dwRop);
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
}
else /* use StretchBlt */
{
@ -213,7 +213,7 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
WORD planes, bpp;
DWORD compr, size;
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
if (DIB_GetBitmapInfo( &info->bmiHeader, &width, &height, &planes, &bpp, &compr, &size ) == -1)
{
@ -303,29 +303,35 @@ INT WINAPI SetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan,
BITMAPOBJ *bitmap;
INT result = 0;
if (!(dc = DC_GetDCUpdate( hdc )))
if (!(dc = get_dc_ptr( hdc )))
{
if (coloruse == DIB_RGB_COLORS) FIXME( "shouldn't require a DC for DIB_RGB_COLORS\n" );
return 0;
}
update_dc( dc );
if (!(bitmap = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
{
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
return 0;
}
if (!bitmap->funcs && !BITMAP_SetOwnerDC( hbitmap, dc )) goto done;
if (bitmap->funcs && bitmap->funcs->pSetDIBits)
result = bitmap->funcs->pSetDIBits( dc->physDev, hbitmap, startscan, lines,
result = lines;
if (bitmap->funcs)
{
if (bitmap->funcs != dc->funcs)
ERR( "not supported: DDB bitmap %p not belonging to device %p\n", hbitmap, hdc );
else if (dc->funcs->pSetDIBits)
result = dc->funcs->pSetDIBits( dc->physDev, hbitmap, startscan, lines,
bits, info, coloruse );
else
result = lines;
}
done:
GDI_ReleaseObj( hbitmap );
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
return result;
}
@ -343,18 +349,21 @@ INT WINAPI SetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx,
if (!bits) return 0;
if (!(dc = DC_GetDCUpdate( hdc ))) return 0;
if (!(dc = get_dc_ptr( hdc ))) return 0;
if(dc->funcs->pSetDIBitsToDevice)
{
update_dc( dc );
ret = dc->funcs->pSetDIBitsToDevice( dc->physDev, xDest, yDest, cx, cy, xSrc,
ySrc, startscan, lines, bits,
info, coloruse );
}
else {
FIXME("unimplemented on hdc %p\n", hdc);
ret = 0;
}
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
return ret;
}
@ -563,14 +572,15 @@ INT WINAPI GetDIBits(
return 0;
}
core_header = (bitmap_type == 0);
if (!(dc = DC_GetDCUpdate( hdc )))
if (!(dc = get_dc_ptr( hdc )))
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
update_dc( dc );
if (!(bmp = (BITMAPOBJ *)GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
{
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
return 0;
}
@ -622,7 +632,7 @@ INT WINAPI GetDIBits(
memset( palEntry, 0, sizeof(palEntry) );
if (!GetPaletteEntries( dc->hPalette, 0, 1 << bmp->bitmap.bmBitsPixel, palEntry ))
{
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
GDI_ReleaseObj( hbitmap );
return 0;
}
@ -1019,7 +1029,7 @@ INT WINAPI GetDIBits(
}
TRACE("biWidth = %d, biHeight = %d\n", width, height);
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
GDI_ReleaseObj( hbitmap );
return lines;
}