gdi32: Use the hdc from the generic physdev structure in enhanced metafiles.

This commit is contained in:
Alexandre Julliard 2011-04-04 12:27:09 +02:00
parent edb68487f4
commit 71c6f48269
5 changed files with 34 additions and 44 deletions

View File

@ -42,7 +42,7 @@ BOOL CDECL EMFDRV_RestoreDC( PHYSDEV dev, INT level )
{ {
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pRestoreDC ); PHYSDEV next = GET_NEXT_PHYSDEV( dev, pRestoreDC );
EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev; EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev;
DC *dc = get_dc_ptr( physDev->hdc ); DC *dc = get_dc_ptr( dev->hdc );
EMRRESTOREDC emr; EMRRESTOREDC emr;
BOOL ret; BOOL ret;
@ -357,10 +357,9 @@ BOOL CDECL EMFDRV_OffsetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
{ {
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pOffsetViewportOrgEx ); PHYSDEV next = GET_NEXT_PHYSDEV( dev, pOffsetViewportOrgEx );
EMRSETVIEWPORTORGEX emr; EMRSETVIEWPORTORGEX emr;
EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev;
POINT prev; POINT prev;
GetViewportOrgEx(physDev->hdc, &prev); GetViewportOrgEx( dev->hdc, &prev );
emr.emr.iType = EMR_SETVIEWPORTORGEX; emr.emr.iType = EMR_SETVIEWPORTORGEX;
emr.emr.nSize = sizeof(emr); emr.emr.nSize = sizeof(emr);
@ -375,10 +374,9 @@ BOOL CDECL EMFDRV_OffsetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
{ {
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pOffsetWindowOrgEx ); PHYSDEV next = GET_NEXT_PHYSDEV( dev, pOffsetWindowOrgEx );
EMRSETWINDOWORGEX emr; EMRSETWINDOWORGEX emr;
EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev;
POINT prev; POINT prev;
GetWindowOrgEx(physDev->hdc, &prev); GetWindowOrgEx( dev->hdc, &prev );
emr.emr.iType = EMR_SETWINDOWORGEX; emr.emr.iType = EMR_SETWINDOWORGEX;
emr.emr.nSize = sizeof(emr); emr.emr.nSize = sizeof(emr);

View File

@ -33,7 +33,6 @@
typedef struct typedef struct
{ {
struct gdi_physdev dev; struct gdi_physdev dev;
HDC hdc;
ENHMETAHEADER *emh; /* Pointer to enhanced metafile header */ ENHMETAHEADER *emh; /* Pointer to enhanced metafile header */
UINT handles_size, cur_handles; UINT handles_size, cur_handles;
HGDIOBJ *handles; HGDIOBJ *handles;

View File

@ -58,7 +58,6 @@ EMFDRV_LineTo( PHYSDEV dev, INT x, INT y )
POINT pt; POINT pt;
EMRLINETO emr; EMRLINETO emr;
RECTL bounds; RECTL bounds;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
emr.emr.iType = EMR_LINETO; emr.emr.iType = EMR_LINETO;
emr.emr.nSize = sizeof(emr); emr.emr.nSize = sizeof(emr);
@ -68,7 +67,7 @@ EMFDRV_LineTo( PHYSDEV dev, INT x, INT y )
if(!EMFDRV_WriteRecord( dev, &emr.emr )) if(!EMFDRV_WriteRecord( dev, &emr.emr ))
return FALSE; return FALSE;
GetCurrentPositionEx(physDev->hdc, &pt); GetCurrentPositionEx( dev->hdc, &pt );
bounds.left = min(x, pt.x); bounds.left = min(x, pt.x);
bounds.top = min(y, pt.y); bounds.top = min(y, pt.y);
@ -93,14 +92,13 @@ EMFDRV_ArcChordPie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
double xinterStart, yinterStart, xinterEnd, yinterEnd; double xinterStart, yinterStart, xinterEnd, yinterEnd;
EMRARC emr; EMRARC emr;
RECTL bounds; RECTL bounds;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
if(left == right || top == bottom) return FALSE; if(left == right || top == bottom) return FALSE;
if(left > right) {temp = left; left = right; right = temp;} if(left > right) {temp = left; left = right; right = temp;}
if(top > bottom) {temp = top; top = bottom; bottom = temp;} if(top > bottom) {temp = top; top = bottom; bottom = temp;}
if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) { if(GetGraphicsMode(dev->hdc) == GM_COMPATIBLE) {
right--; right--;
bottom--; bottom--;
} }
@ -227,7 +225,6 @@ EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
{ {
EMRELLIPSE emr; EMRELLIPSE emr;
INT temp; INT temp;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
TRACE("%d,%d - %d,%d\n", left, top, right, bottom); TRACE("%d,%d - %d,%d\n", left, top, right, bottom);
@ -236,7 +233,7 @@ EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
if(left > right) {temp = left; left = right; right = temp;} if(left > right) {temp = left; left = right; right = temp;}
if(top > bottom) {temp = top; top = bottom; bottom = temp;} if(top > bottom) {temp = top; top = bottom; bottom = temp;}
if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) { if(GetGraphicsMode( dev->hdc ) == GM_COMPATIBLE) {
right--; right--;
bottom--; bottom--;
} }
@ -260,7 +257,6 @@ EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
{ {
EMRRECTANGLE emr; EMRRECTANGLE emr;
INT temp; INT temp;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
TRACE("%d,%d - %d,%d\n", left, top, right, bottom); TRACE("%d,%d - %d,%d\n", left, top, right, bottom);
@ -269,7 +265,7 @@ EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
if(left > right) {temp = left; left = right; right = temp;} if(left > right) {temp = left; left = right; right = temp;}
if(top > bottom) {temp = top; top = bottom; bottom = temp;} if(top > bottom) {temp = top; top = bottom; bottom = temp;}
if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) { if(GetGraphicsMode( dev->hdc ) == GM_COMPATIBLE) {
right--; right--;
bottom--; bottom--;
} }
@ -294,14 +290,13 @@ EMFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
{ {
EMRROUNDRECT emr; EMRROUNDRECT emr;
INT temp; INT temp;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
if(left == right || top == bottom) return FALSE; if(left == right || top == bottom) return FALSE;
if(left > right) {temp = left; left = right; right = temp;} if(left > right) {temp = left; left = right; right = temp;}
if(top > bottom) {temp = top; top = bottom; bottom = temp;} if(top > bottom) {temp = top; top = bottom; bottom = temp;}
if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) { if(GetGraphicsMode( dev->hdc ) == GM_COMPATIBLE) {
right--; right--;
bottom--; bottom--;
} }
@ -687,11 +682,10 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
EMREXTTEXTOUTW *pemr; EMREXTTEXTOUTW *pemr;
DWORD nSize; DWORD nSize;
BOOL ret; BOOL ret;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
int textHeight = 0; int textHeight = 0;
int textWidth = 0; int textWidth = 0;
const UINT textAlign = GetTextAlign(physDev->hdc); const UINT textAlign = GetTextAlign( dev->hdc );
const INT graphicsMode = GetGraphicsMode(physDev->hdc); const INT graphicsMode = GetGraphicsMode( dev->hdc );
FLOAT exScale, eyScale; FLOAT exScale, eyScale;
nSize = sizeof(*pemr) + ((count+1) & ~1) * sizeof(WCHAR) + count * sizeof(INT); nSize = sizeof(*pemr) + ((count+1) & ~1) * sizeof(WCHAR) + count * sizeof(INT);
@ -702,14 +696,14 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
if (graphicsMode == GM_COMPATIBLE) if (graphicsMode == GM_COMPATIBLE)
{ {
const INT horzSize = GetDeviceCaps(physDev->hdc, HORZSIZE); const INT horzSize = GetDeviceCaps( dev->hdc, HORZSIZE );
const INT horzRes = GetDeviceCaps(physDev->hdc, HORZRES); const INT horzRes = GetDeviceCaps( dev->hdc, HORZRES );
const INT vertSize = GetDeviceCaps(physDev->hdc, VERTSIZE); const INT vertSize = GetDeviceCaps( dev->hdc, VERTSIZE );
const INT vertRes = GetDeviceCaps(physDev->hdc, VERTRES); const INT vertRes = GetDeviceCaps( dev->hdc, VERTRES );
SIZE wndext, vportext; SIZE wndext, vportext;
GetViewportExtEx(physDev->hdc, &vportext); GetViewportExtEx( dev->hdc, &vportext );
GetWindowExtEx(physDev->hdc, &wndext); GetWindowExtEx( dev->hdc, &wndext );
exScale = 100.0 * ((FLOAT)horzSize / (FLOAT)horzRes) / exScale = 100.0 * ((FLOAT)horzSize / (FLOAT)horzRes) /
((FLOAT)wndext.cx / (FLOAT)vportext.cx); ((FLOAT)wndext.cx / (FLOAT)vportext.cx);
eyScale = 100.0 * ((FLOAT)vertSize / (FLOAT)vertRes) / eyScale = 100.0 * ((FLOAT)vertSize / (FLOAT)vertRes) /
@ -750,7 +744,7 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
textWidth += lpDx[i]; textWidth += lpDx[i];
} }
if (GetTextExtentPoint32W(physDev->hdc, str, count, &strSize)) if (GetTextExtentPoint32W( dev->hdc, str, count, &strSize ))
textHeight = strSize.cy; textHeight = strSize.cy;
} }
else { else {
@ -758,7 +752,7 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
INT *dx = (INT *)((char*)pemr + pemr->emrtext.offDx); INT *dx = (INT *)((char*)pemr + pemr->emrtext.offDx);
SIZE charSize; SIZE charSize;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (GetTextExtentPoint32W(physDev->hdc, str + i, 1, &charSize)) { if (GetTextExtentPoint32W( dev->hdc, str + i, 1, &charSize )) {
dx[i] = charSize.cx; dx[i] = charSize.cx;
textWidth += charSize.cx; textWidth += charSize.cx;
textHeight = max(textHeight, charSize.cy); textHeight = max(textHeight, charSize.cy);
@ -793,7 +787,7 @@ BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
switch (textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE)) { switch (textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE)) {
case TA_BASELINE: { case TA_BASELINE: {
TEXTMETRICW tm; TEXTMETRICW tm;
if (!GetTextMetricsW(physDev->hdc, &tm)) if (!GetTextMetricsW( dev->hdc, &tm ))
tm.tmDescent = 0; tm.tmDescent = 0;
/* Play safe here... it's better to have a bounding box */ /* Play safe here... it's better to have a bounding box */
/* that is too big than too small. */ /* that is too big than too small. */

View File

@ -169,7 +169,7 @@ static BOOL CDECL EMFDRV_DeleteDC( PHYSDEV dev )
if (physDev->emh) HeapFree( GetProcessHeap(), 0, physDev->emh ); if (physDev->emh) HeapFree( GetProcessHeap(), 0, physDev->emh );
for(index = 0; index < physDev->handles_size; index++) for(index = 0; index < physDev->handles_size; index++)
if(physDev->handles[index]) if(physDev->handles[index])
GDI_hdc_not_using_object(physDev->handles[index], physDev->hdc); GDI_hdc_not_using_object(physDev->handles[index], dev->hdc);
HeapFree( GetProcessHeap(), 0, physDev->handles ); HeapFree( GetProcessHeap(), 0, physDev->handles );
HeapFree( GetProcessHeap(), 0, physDev ); HeapFree( GetProcessHeap(), 0, physDev );
return TRUE; return TRUE;
@ -223,8 +223,8 @@ void EMFDRV_UpdateBBox( PHYSDEV dev, RECTL *rect )
RECTL *bounds = &physDev->emh->rclBounds; RECTL *bounds = &physDev->emh->rclBounds;
RECTL vportRect = *rect; RECTL vportRect = *rect;
LPtoDP(physDev->hdc, (LPPOINT)&vportRect, 2); LPtoDP( dev->hdc, (LPPOINT)&vportRect, 2 );
/* The coordinate systems may be mirrored /* The coordinate systems may be mirrored
(LPtoDP handles points, not rectangles) */ (LPtoDP handles points, not rectangles) */
if (vportRect.left > vportRect.right) if (vportRect.left > vportRect.right)
@ -334,7 +334,6 @@ HDC WINAPI CreateEnhMetaFileW(
} }
push_dc_driver( dc, &physDev->dev, &EMFDRV_Funcs ); push_dc_driver( dc, &physDev->dev, &EMFDRV_Funcs );
physDev->hdc = dc->hSelf;
physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0])); physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0]));
physDev->handles_size = HANDLE_LIST_INC; physDev->handles_size = HANDLE_LIST_INC;
@ -356,7 +355,7 @@ HDC WINAPI CreateEnhMetaFileW(
physDev->numcolors = GetDeviceCaps(hRefDC, NUMCOLORS); physDev->numcolors = GetDeviceCaps(hRefDC, NUMCOLORS);
physDev->restoring = 0; physDev->restoring = 0;
SetVirtualResolution(dc->hSelf, 0, 0, 0, 0); SetVirtualResolution(physDev->dev.hdc, 0, 0, 0, 0);
physDev->emh->iType = EMR_HEADER; physDev->emh->iType = EMR_HEADER;
physDev->emh->nSize = size; physDev->emh->nSize = size;
@ -415,8 +414,8 @@ HDC WINAPI CreateEnhMetaFileW(
physDev->hFile = hFile; physDev->hFile = hFile;
} }
TRACE("returning %p\n", dc->hSelf); TRACE("returning %p\n", physDev->dev.hdc);
ret = dc->hSelf; ret = physDev->dev.hdc;
release_dc_ptr( dc ); release_dc_ptr( dc );
if( !hdc ) if( !hdc )
@ -446,7 +445,7 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
} }
if (dc->refcount != 1) if (dc->refcount != 1)
{ {
FIXME( "not deleting busy DC %p refcount %u\n", dc->hSelf, dc->refcount ); FIXME( "not deleting busy DC %p refcount %u\n", hdc, dc->refcount );
release_dc_ptr( dc ); release_dc_ptr( dc );
return NULL; return NULL;
} }

View File

@ -299,7 +299,7 @@ HBRUSH CDECL EMFDRV_SelectBrush(PHYSDEV dev, HBRUSH hBrush )
goto found; goto found;
if (!(index = EMFDRV_CreateBrushIndirect(dev, hBrush ))) return 0; if (!(index = EMFDRV_CreateBrushIndirect(dev, hBrush ))) return 0;
GDI_hdc_using_object(hBrush, physDev->hdc); GDI_hdc_using_object(hBrush, dev->hdc);
found: found:
emr.emr.iType = EMR_SELECTOBJECT; emr.emr.iType = EMR_SELECTOBJECT;
@ -380,7 +380,7 @@ HFONT CDECL EMFDRV_SelectFont( PHYSDEV dev, HFONT hFont, HANDLE gdiFont )
goto found; goto found;
if (!(index = EMFDRV_CreateFontIndirect(dev, hFont ))) return HGDI_ERROR; if (!(index = EMFDRV_CreateFontIndirect(dev, hFont ))) return HGDI_ERROR;
GDI_hdc_using_object(hFont, physDev->hdc); GDI_hdc_using_object(hFont, dev->hdc);
found: found:
emr.emr.iType = EMR_SELECTOBJECT; emr.emr.iType = EMR_SELECTOBJECT;
@ -460,7 +460,7 @@ HPEN CDECL EMFDRV_SelectPen(PHYSDEV dev, HPEN hPen )
goto found; goto found;
if (!(index = EMFDRV_CreatePenIndirect(dev, hPen))) return 0; if (!(index = EMFDRV_CreatePenIndirect(dev, hPen))) return 0;
GDI_hdc_using_object(hPen, physDev->hdc); GDI_hdc_using_object(hPen, dev->hdc);
found: found:
emr.emr.iType = EMR_SELECTOBJECT; emr.emr.iType = EMR_SELECTOBJECT;
@ -519,7 +519,7 @@ HPALETTE CDECL EMFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPal, BOOL force )
goto found; goto found;
if (!(index = EMFDRV_CreatePalette( dev, hPal ))) return 0; if (!(index = EMFDRV_CreatePalette( dev, hPal ))) return 0;
GDI_hdc_using_object( hPal, physDev->hdc ); GDI_hdc_using_object( hPal, dev->hdc );
found: found:
emr.emr.iType = EMR_SELECTPALETTE; emr.emr.iType = EMR_SELECTPALETTE;
@ -537,12 +537,12 @@ COLORREF CDECL EMFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color )
EMRSELECTOBJECT emr; EMRSELECTOBJECT emr;
DWORD index; DWORD index;
if (GetCurrentObject( physDev->hdc, OBJ_BRUSH ) != GetStockObject( DC_BRUSH )) return color; if (GetCurrentObject( dev->hdc, OBJ_BRUSH ) != GetStockObject( DC_BRUSH )) return color;
if (physDev->dc_brush) DeleteObject( physDev->dc_brush ); if (physDev->dc_brush) DeleteObject( physDev->dc_brush );
if (!(physDev->dc_brush = CreateSolidBrush( color ))) return CLR_INVALID; if (!(physDev->dc_brush = CreateSolidBrush( color ))) return CLR_INVALID;
if (!(index = EMFDRV_CreateBrushIndirect(dev, physDev->dc_brush ))) return CLR_INVALID; if (!(index = EMFDRV_CreateBrushIndirect(dev, physDev->dc_brush ))) return CLR_INVALID;
GDI_hdc_using_object( physDev->dc_brush, physDev->hdc ); GDI_hdc_using_object( physDev->dc_brush, dev->hdc );
emr.emr.iType = EMR_SELECTOBJECT; emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr); emr.emr.nSize = sizeof(emr);
emr.ihObject = index; emr.ihObject = index;
@ -559,12 +559,12 @@ COLORREF CDECL EMFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color )
DWORD index; DWORD index;
LOGPEN logpen = { PS_SOLID, { 0, 0 }, color }; LOGPEN logpen = { PS_SOLID, { 0, 0 }, color };
if (GetCurrentObject( physDev->hdc, OBJ_PEN ) != GetStockObject( DC_PEN )) return color; if (GetCurrentObject( dev->hdc, OBJ_PEN ) != GetStockObject( DC_PEN )) return color;
if (physDev->dc_pen) DeleteObject( physDev->dc_pen ); if (physDev->dc_pen) DeleteObject( physDev->dc_pen );
if (!(physDev->dc_pen = CreatePenIndirect( &logpen ))) return CLR_INVALID; if (!(physDev->dc_pen = CreatePenIndirect( &logpen ))) return CLR_INVALID;
if (!(index = EMFDRV_CreatePenIndirect(dev, physDev->dc_pen))) return CLR_INVALID; if (!(index = EMFDRV_CreatePenIndirect(dev, physDev->dc_pen))) return CLR_INVALID;
GDI_hdc_using_object( physDev->dc_pen, physDev->hdc ); GDI_hdc_using_object( physDev->dc_pen, dev->hdc );
emr.emr.iType = EMR_SELECTOBJECT; emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr); emr.emr.nSize = sizeof(emr);
emr.ihObject = index; emr.ihObject = index;