Eliminate some unnecessary direct accesses to DC internals from EMF driver

Dmitry Timoshkov dmitry at baikal.ru
Tue Mar 9 22:57:55 CST 2004


Hello,

while looking around that code I thought that I could fix that as well.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Eliminate some unnecessary direct accesses to DC internals from EMF driver.

diff -u cvs/hq/wine/dlls/gdi/enhmfdrv/bitblt.c wine/dlls/gdi/enhmfdrv/bitblt.c
--- cvs/hq/wine/dlls/gdi/enhmfdrv/bitblt.c	2004-03-07 17:24:47.000000000 +0800
+++ wine/dlls/gdi/enhmfdrv/bitblt.c	2004-03-10 12:46:43.000000000 +0800
@@ -85,7 +85,7 @@ static BOOL EMFDRV_BitBlockTransfer( 
     WORD nBPP;
     LPBITMAPINFOHEADER lpBmiH;
     EMFDRV_PDEVICE* physDevSrc = (EMFDRV_PDEVICE*)devSrc;
-    DC* dcSrc = physDevSrc->dc;
+    HBITMAP hBitmap = GetCurrentObject(physDevSrc->hdc, OBJ_BITMAP);
 
     if (emrType == EMR_BITBLT)
         emrSize = sizeof(EMRBITBLT);
@@ -94,7 +94,7 @@ static BOOL EMFDRV_BitBlockTransfer( 
     else
         return FALSE;
 
-    GetObjectA(dcSrc->hBitmap, sizeof(BITMAP), &BM);
+    GetObjectW(hBitmap, sizeof(BITMAP), &BM);
 
     nBPP = BM.bmPlanes * BM.bmBitsPixel;
     if(nBPP > 8) nBPP = 24; /* FIXME Can't get 16bpp to work for some reason */
@@ -127,7 +127,7 @@ static BOOL EMFDRV_BitBlockTransfer( 
     pEMR->xformSrc.eM22 = 1.0;  /** Where should we  */
     pEMR->xformSrc.eDx = 0.0;   /** get that info    */
     pEMR->xformSrc.eDy = 0.0;   /** ????             */
-    pEMR->crBkColorSrc = dcSrc->backgroundColor;
+    pEMR->crBkColorSrc = GetBkColor(physDevSrc->hdc);
     pEMR->iUsageSrc = DIB_RGB_COLORS;
     pEMR->offBmiSrc = emrSize;
     pEMR->cbBmiSrc = bmiSize;
@@ -152,16 +152,16 @@ static BOOL EMFDRV_BitBlockTransfer( 
     lpBmiH->biCompression = BI_RGB;
     lpBmiH->biSizeImage = bitsSize;
     lpBmiH->biYPelsPerMeter = /* 1 meter  = 39.37 inch */
-        MulDiv(GetDeviceCaps(dcSrc->hSelf,LOGPIXELSX),3937,100);
+        MulDiv(GetDeviceCaps(physDevSrc->hdc,LOGPIXELSX),3937,100);
     lpBmiH->biXPelsPerMeter = 
-        MulDiv(GetDeviceCaps(dcSrc->hSelf,LOGPIXELSY),3937,100);
+        MulDiv(GetDeviceCaps(physDevSrc->hdc,LOGPIXELSY),3937,100);
     lpBmiH->biClrUsed   = nBPP <= 8 ? 1 << nBPP : 0;
     /* Set biClrImportant to 0, indicating that all of the 
        device colors are important. */
     lpBmiH->biClrImportant = 0; 
 
     /* Initiliaze bitmap bits */
-    if (GetDIBits(dcSrc->hSelf, dcSrc->hBitmap, 0, (UINT)lpBmiH->biHeight,
+    if (GetDIBits(physDevSrc->hdc, hBitmap, 0, (UINT)lpBmiH->biHeight,
                   (BYTE*)pEMR + pEMR->offBitsSrc,
                   (LPBITMAPINFO)lpBmiH, DIB_RGB_COLORS))
     {
diff -u cvs/hq/wine/dlls/gdi/enhmfdrv/graphics.c wine/dlls/gdi/enhmfdrv/graphics.c
--- cvs/hq/wine/dlls/gdi/enhmfdrv/graphics.c	2004-03-04 12:57:51.000000000 +0800
+++ wine/dlls/gdi/enhmfdrv/graphics.c	2004-03-10 12:15:08.000000000 +0800
@@ -52,10 +52,10 @@ EMFDRV_MoveTo(PHYSDEV dev, INT x, INT y)
 BOOL
 EMFDRV_LineTo( PHYSDEV dev, INT x, INT y )
 {
+    POINT pt;
     EMRLINETO emr;
     RECTL bounds;
     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
-    DC *dc = physDev->dc;
 
     emr.emr.iType = EMR_LINETO;
     emr.emr.nSize = sizeof(emr);
@@ -65,10 +65,12 @@ EMFDRV_LineTo( PHYSDEV dev, INT x, INT y
     if(!EMFDRV_WriteRecord( dev, &emr.emr ))
     	return FALSE;
 
-    bounds.left   = min(x, dc->CursPosX);
-    bounds.top    = min(y, dc->CursPosY);
-    bounds.right  = max(x, dc->CursPosX);
-    bounds.bottom = max(y, dc->CursPosY);
+    GetCurrentPositionEx(physDev->hdc, &pt);
+
+    bounds.left   = min(x, pt.x);
+    bounds.top    = min(y, pt.y);
+    bounds.right  = max(x, pt.x);
+    bounds.bottom = max(y, pt.y);
 
     EMFDRV_UpdateBBox( dev, &bounds );
 
@@ -89,14 +91,13 @@ EMFDRV_ArcChordPie( PHYSDEV dev, INT lef
     EMRARC emr;
     RECTL bounds;
     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
-    DC *dc = physDev->dc;
 
     if(left == right || top == bottom) return FALSE;
 
     if(left > right) {temp = left; left = right; right = temp;}
     if(top > bottom) {temp = top; top = bottom; bottom = temp;}
 
-    if(dc->GraphicsMode == GM_COMPATIBLE) {
+    if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) {
         right--;
 	bottom--;
     }
@@ -224,7 +225,6 @@ EMFDRV_Ellipse( PHYSDEV dev, INT left, I
     EMRELLIPSE emr;
     INT temp;
     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
-    DC *dc = physDev->dc;
 
     TRACE("%d,%d - %d,%d\n", left, top, right, bottom);
 
@@ -233,7 +233,7 @@ EMFDRV_Ellipse( PHYSDEV dev, INT left, I
     if(left > right) {temp = left; left = right; right = temp;}
     if(top > bottom) {temp = top; top = bottom; bottom = temp;}
 
-    if(dc->GraphicsMode == GM_COMPATIBLE) {
+    if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) {
         right--;
 	bottom--;
     }
@@ -258,7 +258,6 @@ EMFDRV_Rectangle(PHYSDEV dev, INT left, 
     EMRRECTANGLE emr;
     INT temp;
     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
-    DC *dc = physDev->dc;
 
     TRACE("%d,%d - %d,%d\n", left, top, right, bottom);
 
@@ -267,7 +266,7 @@ EMFDRV_Rectangle(PHYSDEV dev, INT left, 
     if(left > right) {temp = left; left = right; right = temp;}
     if(top > bottom) {temp = top; top = bottom; bottom = temp;}
 
-    if(dc->GraphicsMode == GM_COMPATIBLE) {
+    if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) {
         right--;
 	bottom--;
     }
@@ -293,14 +292,13 @@ EMFDRV_RoundRect( PHYSDEV dev, INT left,
     EMRROUNDRECT emr;
     INT temp;
     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
-    DC *dc = physDev->dc;
 
     if(left == right || top == bottom) return FALSE;
 
     if(left > right) {temp = left; left = right; right = temp;}
     if(top > bottom) {temp = top; top = bottom; bottom = temp;}
 
-    if(dc->GraphicsMode == GM_COMPATIBLE) {
+    if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) {
         right--;
 	bottom--;
     }
diff -u cvs/hq/wine/dlls/gdi/enhmfdrv/mapping.c wine/dlls/gdi/enhmfdrv/mapping.c
--- cvs/hq/wine/dlls/gdi/enhmfdrv/mapping.c	2003-10-10 22:05:24.000000000 +0900
+++ wine/dlls/gdi/enhmfdrv/mapping.c	2004-03-10 12:15:08.000000000 +0800
@@ -133,26 +133,32 @@ BOOL EMFDRV_ModifyWorldTransform( PHYSDE
 
 INT EMFDRV_OffsetViewportOrg( PHYSDEV dev, INT x, INT y )
 {
+    POINT pt;
     EMRSETVIEWPORTORGEX emr;
     EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev;
 
+    GetViewportOrgEx(physDev->hdc, &pt);
+
     emr.emr.iType = EMR_SETVIEWPORTORGEX;
     emr.emr.nSize = sizeof(emr);
-    emr.ptlOrigin.x = physDev->dc->vportOrgX + x;
-    emr.ptlOrigin.y = physDev->dc->vportOrgY + y;
+    emr.ptlOrigin.x = pt.x + x;
+    emr.ptlOrigin.y = pt.y + y;
 
     return EMFDRV_WriteRecord( dev, &emr.emr );
 }
 
 INT EMFDRV_OffsetWindowOrg( PHYSDEV dev, INT x, INT y )
 {
+    POINT pt;
     EMRSETWINDOWORGEX emr;
     EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev;
 
+    GetWindowOrgEx(physDev->hdc, &pt);
+
     emr.emr.iType = EMR_SETWINDOWORGEX;
     emr.emr.nSize = sizeof(emr);
-    emr.ptlOrigin.x = physDev->dc->wndOrgX + x;
-    emr.ptlOrigin.y = physDev->dc->wndOrgY + y;
+    emr.ptlOrigin.x = pt.x + x;
+    emr.ptlOrigin.y = pt.y + y;
 
     return EMFDRV_WriteRecord( dev, &emr.emr );
 }






More information about the wine-patches mailing list