Commit 9d847413 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Avoid some direct accesses to DC internals from metafile driver.

parent b3d64738
...@@ -65,12 +65,17 @@ BOOL MFDRV_StretchBlt( PHYSDEV devDst, INT xDst, INT yDst, INT widthDst, ...@@ -65,12 +65,17 @@ BOOL MFDRV_StretchBlt( PHYSDEV devDst, INT xDst, INT yDst, INT widthDst,
METARECORD *mr; METARECORD *mr;
BITMAP BM; BITMAP BM;
METAFILEDRV_PDEVICE *physDevSrc = (METAFILEDRV_PDEVICE *)devSrc; METAFILEDRV_PDEVICE *physDevSrc = (METAFILEDRV_PDEVICE *)devSrc;
DC *dcSrc = physDevSrc->dc;
#ifdef STRETCH_VIA_DIB #ifdef STRETCH_VIA_DIB
LPBITMAPINFOHEADER lpBMI; LPBITMAPINFOHEADER lpBMI;
WORD nBPP; WORD nBPP;
#endif #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 #ifdef STRETCH_VIA_DIB
nBPP = BM.bmPlanes * BM.bmBitsPixel; nBPP = BM.bmPlanes * BM.bmBitsPixel;
if(nBPP > 8) nBPP = 24; /* FIXME Can't get 16bpp to work for some reason */ if(nBPP > 8) nBPP = 24; /* FIXME Can't get 16bpp to work for some reason */
...@@ -89,14 +94,14 @@ BOOL MFDRV_StretchBlt( PHYSDEV devDst, INT xDst, INT yDst, INT widthDst, ...@@ -89,14 +94,14 @@ BOOL MFDRV_StretchBlt( PHYSDEV devDst, INT xDst, INT yDst, INT widthDst,
lpBMI->biSizeImage = DIB_GetDIBWidthBytes(BM.bmWidth, nBPP) * lpBMI->biHeight; lpBMI->biSizeImage = DIB_GetDIBWidthBytes(BM.bmWidth, nBPP) * lpBMI->biHeight;
lpBMI->biClrUsed = nBPP <= 8 ? 1 << nBPP : 0; lpBMI->biClrUsed = nBPP <= 8 ? 1 << nBPP : 0;
lpBMI->biCompression = BI_RGB; lpBMI->biCompression = BI_RGB;
lpBMI->biXPelsPerMeter = MulDiv(GetDeviceCaps(dcSrc->hSelf,LOGPIXELSX),3937,100); lpBMI->biXPelsPerMeter = MulDiv(GetDeviceCaps(physDevSrc->hdc,LOGPIXELSX),3937,100);
lpBMI->biYPelsPerMeter = MulDiv(GetDeviceCaps(dcSrc->hSelf,LOGPIXELSY),3937,100); lpBMI->biYPelsPerMeter = MulDiv(GetDeviceCaps(physDevSrc->hdc,LOGPIXELSY),3937,100);
lpBMI->biClrImportant = 0; /* 1 meter = 39.37 inch */ lpBMI->biClrImportant = 0; /* 1 meter = 39.37 inch */
TRACE("MF_StretchBltViaDIB->len = %ld rop=%lx PixYPM=%ld Caps=%d\n", TRACE("MF_StretchBltViaDIB->len = %ld rop=%lx PixYPM=%ld Caps=%d\n",
len,rop,lpBMI->biYPelsPerMeter,GetDeviceCaps(dcSrc->hSelf, len,rop,lpBMI->biYPelsPerMeter,GetDeviceCaps(physDevSrc->hdc, LOGPIXELSY));
LOGPIXELSY));
if (GetDIBits(dcSrc->hSelf,dcSrc->hBitmap,0,(UINT)lpBMI->biHeight, if (GetDIBits(physDevSrc->hdc, hBitmap, 0, (UINT)lpBMI->biHeight,
(LPSTR)lpBMI + DIB_BitmapInfoSize( (BITMAPINFO *)lpBMI, (LPSTR)lpBMI + DIB_BitmapInfoSize( (BITMAPINFO *)lpBMI,
DIB_RGB_COLORS ), DIB_RGB_COLORS ),
(LPBITMAPINFO)lpBMI, DIB_RGB_COLORS)) (LPBITMAPINFO)lpBMI, DIB_RGB_COLORS))
...@@ -111,8 +116,7 @@ BOOL MFDRV_StretchBlt( PHYSDEV devDst, INT xDst, INT yDst, INT widthDst, ...@@ -111,8 +116,7 @@ BOOL MFDRV_StretchBlt( PHYSDEV devDst, INT xDst, INT yDst, INT widthDst,
*(mr->rdParm +13) = BM.bmPlanes; *(mr->rdParm +13) = BM.bmPlanes;
*(mr->rdParm +14) = BM.bmBitsPixel; *(mr->rdParm +14) = BM.bmBitsPixel;
TRACE("len = %ld rop=%lx \n",len,rop); TRACE("len = %ld rop=%lx \n",len,rop);
if (GetBitmapBits( dcSrc->hBitmap, BM.bmWidthBytes * BM.bmHeight, if (GetBitmapBits( hBitmap, BM.bmWidthBytes * BM.bmHeight, mr->rdParm + 15))
mr->rdParm +15))
#endif #endif
{ {
mr->rdSize = len / sizeof(INT16); mr->rdSize = len / sizeof(INT16);
......
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