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

View File

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