Avoid some direct accesses to DC internals from metafile driver
Dmitry Timoshkov
dmitry at baikal.ru
Tue Nov 23 09:14:48 CST 2004
Hello,
this patch makes BitBlt between x11drv and mfdrv DCs work.
In order to avoid the problem in future I propose to change PHYSDEV
structure definition from
typedef struct { int opaque; } *PHYSDEV; /* PHYSDEV is an opaque pointer */
to
typedef struct { HDC hdc; } *PHYSDEV; /* PHYSDEV is an opaque pointer */
and make sure that all DC driver implementations have HDC as the very first
member of their internal device dependent structure and use PHYSDEV->hdc
when they need an access to hdc. Next we have to make sure that DC drivers
do not dig anything from a passed PHYSDEV until they are sure that it's their
own device.
Does this sound reasonable?
Changelog:
Dmitry Timoshkov <dmitry at codeweavers.com>
Avoid some direct accesses to DC internals from metafile driver.
--- cvs/hq/wine/dlls/gdi/mfdrv/bitblt.c 2004-08-03 13:21:35.000000000 +0900
+++ wine/dlls/gdi/mfdrv/bitblt.c 2004-11-16 16:57:59.000000000 +0800
@@ -65,12 +65,17 @@ BOOL MFDRV_StretchBlt( PHYSDEV devDst, I
METARECORD *mr;
BITMAP BM;
METAFILEDRV_PDEVICE *physDevSrc = (METAFILEDRV_PDEVICE *)devSrc;
- DC *dcSrc = physDevSrc->dc;
#ifdef STRETCH_VIA_DIB
LPBITMAPINFOHEADER lpBMI;
WORD nBPP;
#endif
- GetObjectA(dcSrc->hBitmap, sizeof(BITMAP), &BM);
+ HBITMAP hBitmap = GetCurrentObject(physDevSrc->hdc, OBJ_BITMAP);
+
+ if (GetObjectW(hBitmap, sizeof(BITMAP), &BM) != sizeof(BITMAP))
+ {
+ WARN("bad bitmap object %p passed for hdc %p\n", hBitmap, physDevSrc->hdc);
+ return FALSE;
+ }
#ifdef STRETCH_VIA_DIB
nBPP = BM.bmPlanes * BM.bmBitsPixel;
if(nBPP > 8) nBPP = 24; /* FIXME Can't get 16bpp to work for some reason */
@@ -89,14 +94,14 @@ BOOL MFDRV_StretchBlt( PHYSDEV devDst, I
lpBMI->biSizeImage = DIB_GetDIBWidthBytes(BM.bmWidth, nBPP) * lpBMI->biHeight;
lpBMI->biClrUsed = nBPP <= 8 ? 1 << nBPP : 0;
lpBMI->biCompression = BI_RGB;
- lpBMI->biXPelsPerMeter = MulDiv(GetDeviceCaps(dcSrc->hSelf,LOGPIXELSX),3937,100);
- lpBMI->biYPelsPerMeter = MulDiv(GetDeviceCaps(dcSrc->hSelf,LOGPIXELSY),3937,100);
+ lpBMI->biXPelsPerMeter = MulDiv(GetDeviceCaps(physDevSrc->hdc,LOGPIXELSX),3937,100);
+ lpBMI->biYPelsPerMeter = MulDiv(GetDeviceCaps(physDevSrc->hdc,LOGPIXELSY),3937,100);
lpBMI->biClrImportant = 0; /* 1 meter = 39.37 inch */
TRACE("MF_StretchBltViaDIB->len = %ld rop=%lx PixYPM=%ld Caps=%d\n",
- len,rop,lpBMI->biYPelsPerMeter,GetDeviceCaps(dcSrc->hSelf,
- LOGPIXELSY));
- if (GetDIBits(dcSrc->hSelf,dcSrc->hBitmap,0,(UINT)lpBMI->biHeight,
+ len,rop,lpBMI->biYPelsPerMeter,GetDeviceCaps(physDevSrc->hdc, LOGPIXELSY));
+
+ if (GetDIBits(physDevSrc->hdc, hBitmap, 0, (UINT)lpBMI->biHeight,
(LPSTR)lpBMI + DIB_BitmapInfoSize( (BITMAPINFO *)lpBMI,
DIB_RGB_COLORS ),
(LPBITMAPINFO)lpBMI, DIB_RGB_COLORS))
@@ -111,8 +116,7 @@ BOOL MFDRV_StretchBlt( PHYSDEV devDst, I
*(mr->rdParm +13) = BM.bmPlanes;
*(mr->rdParm +14) = BM.bmBitsPixel;
TRACE("len = %ld rop=%lx \n",len,rop);
- if (GetBitmapBits( dcSrc->hBitmap, BM.bmWidthBytes * BM.bmHeight,
- mr->rdParm +15))
+ if (GetBitmapBits( hBitmap, BM.bmWidthBytes * BM.bmHeight, mr->rdParm + 15))
#endif
{
mr->rdSize = len / sizeof(INT16);
More information about the wine-patches
mailing list