From 7342390852c6c16b966d91c79a0ec5a4a5be354e Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 15 Jan 2004 06:19:35 +0000 Subject: [PATCH] Get rid of the global INTERNAL_[XY]WSTODS macros. --- dlls/gdi/freetype.c | 6 +++--- dlls/wineps/download.c | 8 ++++---- dlls/wineps/graphics.c | 34 ++++++++++++++++++++++++++++++++++ dlls/wineps/pen.c | 2 +- dlls/wineps/psdrv.h | 3 +++ dlls/wineps/text.c | 12 ++++++------ dlls/x11drv/graphics.c | 34 ++++++++++++++++++++++++++++++++++ dlls/x11drv/pen.c | 6 ++---- dlls/x11drv/text.c | 6 +++--- dlls/x11drv/x11drv.h | 2 ++ dlls/x11drv/xfont.c | 7 ++++--- dlls/x11drv/xrender.c | 24 ++++++++++++------------ include/gdi.h | 28 ---------------------------- 13 files changed, 108 insertions(+), 64 deletions(-) diff --git a/dlls/gdi/freetype.c b/dlls/gdi/freetype.c index e03e4ba0920..91ac40eeb62 100644 --- a/dlls/gdi/freetype.c +++ b/dlls/gdi/freetype.c @@ -1182,6 +1182,7 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) GdiFont ret; Face *face; Family *family = NULL; + INT height; BOOL bd, it; LOGFONTW lf; CHARSETINFO csi; @@ -1341,10 +1342,9 @@ not_found: TRACE("Chosen: %s %s\n", debugstr_w(family->FamilyName), debugstr_w(face->StyleName)); + height = GDI_ROUND( (FLOAT)lf.lfHeight * dc->xformWorld2Vport.eM22 ); ret->ft_face = OpenFontFile(ret, face->file, face->face_index, - lf.lfHeight < 0 ? - -abs(INTERNAL_YWSTODS(dc,lf.lfHeight)) : - abs(INTERNAL_YWSTODS(dc, lf.lfHeight))); + lf.lfHeight < 0 ? -abs(height) : abs(height)); if (!ret->ft_face) { free_font( ret ); diff --git a/dlls/wineps/download.c b/dlls/wineps/download.c index 9c48b550c8d..2c66e82f6b7 100644 --- a/dlls/wineps/download.c +++ b/dlls/wineps/download.c @@ -139,10 +139,10 @@ BOOL PSDRV_SelectDownloadFont(PSDRV_PDEVICE *physDev) physDev->font.fontloc = Download; physDev->font.fontinfo.Download = is_font_downloaded(physDev, ps_name); - physDev->font.size = INTERNAL_YWSTODS(physDev->dc, /* ppem */ - potm->otmTextMetrics.tmAscent + - potm->otmTextMetrics.tmDescent - - potm->otmTextMetrics.tmInternalLeading); + physDev->font.size = PSDRV_YWStoDS(physDev, /* ppem */ + potm->otmTextMetrics.tmAscent + + potm->otmTextMetrics.tmDescent - + potm->otmTextMetrics.tmInternalLeading); physDev->font.underlineThickness = potm->otmsUnderscoreSize; physDev->font.underlinePosition = potm->otmsUnderscorePosition; physDev->font.strikeoutThickness = potm->otmsStrikeoutSize; diff --git a/dlls/wineps/graphics.c b/dlls/wineps/graphics.c index f8222c27d8c..f5a040e6284 100644 --- a/dlls/wineps/graphics.c +++ b/dlls/wineps/graphics.c @@ -35,6 +35,40 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv); +/*********************************************************************** + * PSDRV_XWStoDS + * + * Performs a world-to-viewport transformation on the specified width. + */ +INT PSDRV_XWStoDS( PSDRV_PDEVICE *physDev, INT width ) +{ + POINT pt[2]; + + pt[0].x = 0; + pt[0].y = 0; + pt[1].x = width; + pt[1].y = 0; + LPtoDP( physDev->hdc, pt, 2 ); + return pt[1].x - pt[0].x; +} + +/*********************************************************************** + * PSDRV_YWStoDS + * + * Performs a world-to-viewport transformation on the specified height. + */ +INT PSDRV_YWStoDS( PSDRV_PDEVICE *physDev, INT height ) +{ + POINT pt[2]; + + pt[0].x = 0; + pt[0].y = 0; + pt[1].x = 0; + pt[1].y = height; + LPtoDP( physDev->hdc, pt, 2 ); + return pt[1].y - pt[0].y; +} + /*********************************************************************** * PSDRV_DrawLine */ diff --git a/dlls/wineps/pen.c b/dlls/wineps/pen.c index 882197917dd..59318a703a0 100644 --- a/dlls/wineps/pen.c +++ b/dlls/wineps/pen.c @@ -41,7 +41,7 @@ HPEN PSDRV_SelectPen( PSDRV_PDEVICE *physDev, HPEN hpen ) TRACE("hpen = %p colour = %08lx\n", hpen, logpen.lopnColor); - physDev->pen.width = INTERNAL_XWSTODS(physDev->dc, logpen.lopnWidth.x); + physDev->pen.width = PSDRV_XWStoDS(physDev, logpen.lopnWidth.x); if(physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width; diff --git a/dlls/wineps/psdrv.h b/dlls/wineps/psdrv.h index 3eeed843f7f..f08a1b6f7f1 100644 --- a/dlls/wineps/psdrv.h +++ b/dlls/wineps/psdrv.h @@ -395,6 +395,9 @@ extern void PSDRV_FreeAFMList( FONTFAMILY *head ); extern BOOL WINAPI PSDRV_Init(HINSTANCE hinst, DWORD reason, LPVOID reserved); +extern INT PSDRV_XWStoDS( PSDRV_PDEVICE *physDev, INT width ); +extern INT PSDRV_YWStoDS( PSDRV_PDEVICE *physDev, INT height ); + extern BOOL PSDRV_Brush(PSDRV_PDEVICE *physDev, BOOL EO); extern BOOL PSDRV_SetFont( PSDRV_PDEVICE *physDev ); extern BOOL PSDRV_SetPen( PSDRV_PDEVICE *physDev ); diff --git a/dlls/wineps/text.c b/dlls/wineps/text.c index 9c8f97b0e28..3a7bd161b42 100644 --- a/dlls/wineps/text.c +++ b/dlls/wineps/text.c @@ -172,12 +172,12 @@ static BOOL PSDRV_Text(PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags, LPCWSTR sz.cx = tmpsz.cx; /* sz.cy remains untouched */ } - sz.cx = INTERNAL_XWSTODS(dc, sz.cx); - sz.cy = INTERNAL_YWSTODS(dc, sz.cy); + sz.cx = PSDRV_XWStoDS(physDev, sz.cx); + sz.cy = PSDRV_YWStoDS(physDev, sz.cy); GetTextMetricsW(physDev->hdc, &tm); - ascent = INTERNAL_YWSTODS(dc, tm.tmAscent); - descent = INTERNAL_YWSTODS(dc, tm.tmDescent); + ascent = PSDRV_YWStoDS(physDev, tm.tmAscent); + descent = PSDRV_YWStoDS(physDev, tm.tmDescent); TRACE("textAlign = %x\n", align); switch(align & (TA_LEFT | TA_CENTER | TA_RIGHT) ) { @@ -260,8 +260,8 @@ static BOOL PSDRV_Text(PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags, LPCWSTR PSDRV_WriteBuiltinGlyphShow(physDev, str + i, 1); dx += deltas[i] * cos_theta; dy -= deltas[i] * sin_theta; - PSDRV_WriteMoveTo(physDev, x + INTERNAL_XWSTODS(dc, dx), - y + INTERNAL_YWSTODS(dc, dy)); + PSDRV_WriteMoveTo(physDev, x + PSDRV_XWStoDS(physDev, dx), + y + PSDRV_YWStoDS(physDev, dy)); } if(physDev->font.fontloc == Download) PSDRV_WriteDownloadGlyphShow(physDev, glyphs + i, 1); diff --git a/dlls/x11drv/graphics.c b/dlls/x11drv/graphics.c index 0b6a5ccc40f..4fbba3dd8b8 100644 --- a/dlls/x11drv/graphics.c +++ b/dlls/x11drv/graphics.c @@ -293,6 +293,40 @@ BOOL X11DRV_SetupGCForText( X11DRV_PDEVICE *physDev ) return FALSE; } +/*********************************************************************** + * X11DRV_XWStoDS + * + * Performs a world-to-viewport transformation on the specified width. + */ +INT X11DRV_XWStoDS( X11DRV_PDEVICE *physDev, INT width ) +{ + POINT pt[2]; + + pt[0].x = 0; + pt[0].y = 0; + pt[1].x = width; + pt[1].y = 0; + LPtoDP( physDev->hdc, pt, 2 ); + return pt[1].x - pt[0].x; +} + +/*********************************************************************** + * X11DRV_YWStoDS + * + * Performs a world-to-viewport transformation on the specified height. + */ +INT X11DRV_YWStoDS( X11DRV_PDEVICE *physDev, INT height ) +{ + POINT pt[2]; + + pt[0].x = 0; + pt[0].y = 0; + pt[1].x = 0; + pt[1].y = height; + LPtoDP( physDev->hdc, pt, 2 ); + return pt[1].y - pt[0].y; +} + /*********************************************************************** * X11DRV_LineTo */ diff --git a/dlls/x11drv/pen.c b/dlls/x11drv/pen.c index 3d798f75be2..a23cd48f1cb 100644 --- a/dlls/x11drv/pen.c +++ b/dlls/x11drv/pen.c @@ -37,7 +37,6 @@ static const char PEN_alternate[] = { 1,1 }; HPEN X11DRV_SelectPen( X11DRV_PDEVICE *physDev, HPEN hpen ) { LOGPEN logpen; - DC *dc = physDev->dc; if (!GetObjectA( hpen, sizeof(logpen), &logpen )) return 0; @@ -46,12 +45,11 @@ HPEN X11DRV_SelectPen( X11DRV_PDEVICE *physDev, HPEN hpen ) physDev->pen.endcap = logpen.lopnStyle & PS_ENDCAP_MASK; physDev->pen.linejoin = logpen.lopnStyle & PS_JOIN_MASK; - physDev->pen.width = GDI_ROUND((FLOAT)logpen.lopnWidth.x * - dc->xformWorld2Vport.eM11); + physDev->pen.width = X11DRV_XWStoDS( physDev, logpen.lopnWidth.x ); if (physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width; if (physDev->pen.width == 1) physDev->pen.width = 0; /* Faster */ if (hpen == GetStockObject( DC_PEN )) - logpen.lopnColor = dc->dcPenColor; + logpen.lopnColor = GetDCPenColor( physDev->hdc ); physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, logpen.lopnColor ); switch(logpen.lopnStyle & PS_STYLE_MASK) { diff --git a/dlls/x11drv/text.c b/dlls/x11drv/text.c index 93c3e466418..593ad5ee434 100644 --- a/dlls/x11drv/text.c +++ b/dlls/x11drv/text.c @@ -148,7 +148,7 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, if (lpDx) /* have explicit character cell x offsets in logical coordinates */ { for (i = width = 0; i < count; i++) width += lpDx[i]; - width = INTERNAL_XWSTODS(dc, width); + width = X11DRV_XWStoDS(physDev, width); } else { @@ -158,7 +158,7 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, result = FALSE; goto END; } - width = INTERNAL_XWSTODS(dc, sz.cx); + width = X11DRV_XWStoDS(physDev, sz.cx); } ascent = pfo->lpX11Trans ? pfo->lpX11Trans->ascent : font->ascent; descent = pfo->lpX11Trans ? pfo->lpX11Trans->descent : font->descent; @@ -361,7 +361,7 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, x_i, y_i, &str2b[i], 1); if (lpDx) { - offset += INTERNAL_XWSTODS(dc, lpDx[i]); + offset += X11DRV_XWStoDS(physDev, lpDx[i]); } else { diff --git a/dlls/x11drv/x11drv.h b/dlls/x11drv/x11drv.h index 385be73ce73..4b06d07945e 100644 --- a/dlls/x11drv/x11drv.h +++ b/dlls/x11drv/x11drv.h @@ -210,6 +210,8 @@ extern BOOL X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE *physDev, GC gc, BOOL fMapCo extern BOOL X11DRV_SetupGCForBrush( X11DRV_PDEVICE *physDev ); extern BOOL X11DRV_SetupGCForPen( X11DRV_PDEVICE *physDev ); extern BOOL X11DRV_SetupGCForText( X11DRV_PDEVICE *physDev ); +extern INT X11DRV_XWStoDS( X11DRV_PDEVICE *physDev, INT width ); +extern INT X11DRV_YWStoDS( X11DRV_PDEVICE *physDev, INT height ); extern const int X11DRV_XROPfunction[]; diff --git a/dlls/x11drv/xfont.c b/dlls/x11drv/xfont.c index 7b5e3d3f176..c92ad95a9e6 100644 --- a/dlls/x11drv/xfont.c +++ b/dlls/x11drv/xfont.c @@ -3287,14 +3287,15 @@ HFONT X11DRV_SelectFont( X11DRV_PDEVICE *physDev, HFONT hfont ) /* FIXME - check that the other drivers do this correctly */ if (lf.lfWidth) { - lf.lfWidth = GDI_ROUND((FLOAT)lf.lfWidth * fabs(dc->xformWorld2Vport.eM11)); + INT width = X11DRV_XWStoDS( physDev, lf.lfWidth ); + lf.lfWidth = (lf.lfWidth < 0) ? -abs(width) : abs(width); if (lf.lfWidth == 0) lf.lfWidth = 1; /* Minimum width */ } if (lf.lfHeight) { - lf.lfHeight = GDI_ROUND((FLOAT)lf.lfHeight * fabs(dc->xformWorld2Vport.eM22)); - + INT height = X11DRV_YWStoDS( physDev, lf.lfHeight ); + lf.lfHeight = (lf.lfHeight < 0) ? -abs(height) : abs(height); if (lf.lfHeight == 0) lf.lfHeight = MIN_FONT_SIZE; } diff --git a/dlls/x11drv/xrender.c b/dlls/x11drv/xrender.c index eebb7437680..7f106f10db4 100644 --- a/dlls/x11drv/xrender.c +++ b/dlls/x11drv/xrender.c @@ -1070,14 +1070,14 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag } width = sz.cx; } - width = INTERNAL_XWSTODS(dc, width); + width = X11DRV_XWStoDS(physDev, width); xwidth = width * cosEsc; ywidth = width * sinEsc; GetTextMetricsW(hdc, &tm); - tm.tmAscent = INTERNAL_YWSTODS(dc, tm.tmAscent); - tm.tmDescent = INTERNAL_YWSTODS(dc, tm.tmDescent); + tm.tmAscent = X11DRV_YWStoDS(physDev, tm.tmAscent); + tm.tmDescent = X11DRV_YWStoDS(physDev, tm.tmDescent); switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) { case TA_LEFT: if (dc->textAlign & TA_UPDATECP) { @@ -1255,7 +1255,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag 0, 0, physDev->org.x + x + xoff, physDev->org.y + y + yoff, glyphs + idx, 1); - offset += INTERNAL_XWSTODS(dc, deltas[idx]); + offset += X11DRV_XWStoDS(physDev, deltas[idx]); xoff = offset * cosEsc; yoff = offset * -sinEsc; } @@ -1275,8 +1275,8 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag XSetForeground( gdi_display, physDev->gc, physDev->textPixel ); if (lf.lfUnderline) { - linePos = INTERNAL_YWSTODS(dc, otm->otmsUnderscorePosition); - lineWidth = INTERNAL_YWSTODS(dc, otm->otmsUnderscoreSize); + linePos = X11DRV_YWStoDS(physDev, otm->otmsUnderscorePosition); + lineWidth = X11DRV_YWStoDS(physDev, otm->otmsUnderscoreSize); XSetLineAttributes( gdi_display, physDev->gc, lineWidth, LineSolid, CapProjecting, JoinBevel ); @@ -1286,8 +1286,8 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag } if (lf.lfStrikeOut) { - linePos = INTERNAL_YWSTODS(dc, otm->otmsStrikeoutPosition); - lineWidth = INTERNAL_YWSTODS(dc, otm->otmsStrikeoutSize); + linePos = X11DRV_YWStoDS(physDev, otm->otmsStrikeoutPosition); + lineWidth = X11DRV_YWStoDS(physDev, otm->otmsStrikeoutSize); XSetLineAttributes( gdi_display, physDev->gc, lineWidth, LineSolid, CapProjecting, JoinBevel ); @@ -1311,7 +1311,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag entry->bitmaps[glyphs[idx]], &entry->gis[glyphs[idx]]); if(deltas) { - offset += INTERNAL_XWSTODS(dc, deltas[idx]); + offset += X11DRV_XWStoDS(physDev, deltas[idx]); xoff = offset * cosEsc; yoff = offset * -sinEsc; @@ -1327,7 +1327,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag entry->bitmaps[glyphs[idx]], &entry->gis[glyphs[idx]]); if(deltas) { - offset += INTERNAL_XWSTODS(dc, deltas[idx]); + offset += X11DRV_XWStoDS(physDev, deltas[idx]); xoff = offset * cosEsc; yoff = offset * -sinEsc; @@ -1361,7 +1361,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag if(extents.bottom < cur.y - entry->gis[glyphs[idx]].y + entry->gis[glyphs[idx]].height) extents.bottom = cur.y - entry->gis[glyphs[idx]].y + entry->gis[glyphs[idx]].height; if(deltas) { - offset += INTERNAL_XWSTODS(dc, deltas[idx]); + offset += X11DRV_XWStoDS(physDev, deltas[idx]); cur.x = offset * cosEsc; cur.y = offset * -sinEsc; } else { @@ -1438,7 +1438,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag &entry->gis[glyphs[idx]], dc->textColor); if(deltas) { - offset += INTERNAL_XWSTODS(dc, deltas[idx]); + offset += X11DRV_XWStoDS(physDev, deltas[idx]); xoff = offset * cosEsc; yoff = offset * -sinEsc; } else { diff --git a/include/gdi.h b/include/gdi.h index 6f11508be2c..66b8f238520 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -175,34 +175,6 @@ static inline INT WINE_UNUSED GDI_ROUND(FLOAT val) return (int)floor(val + 0.5); } - /* World -> Device size conversion */ - -/* Performs a world-to-viewport transformation on the specified width (which - * is in integer format). - */ -static inline INT WINE_UNUSED INTERNAL_XWSTODS(DC *dc, INT width) -{ - FLOAT floatWidth; - - /* Perform operation with floating point */ - floatWidth = (FLOAT)width * dc->xformWorld2Vport.eM11; - /* Round to integers */ - return GDI_ROUND(floatWidth); -} - -/* Performs a world-to-viewport transformation on the specified size (which - * is in integer format). - */ -static inline INT WINE_UNUSED INTERNAL_YWSTODS(DC *dc, INT height) -{ - FLOAT floatHeight; - - /* Perform operation with floating point */ - floatHeight = (FLOAT)height * dc->xformWorld2Vport.eM22; - /* Round to integers */ - return GDI_ROUND(floatHeight); -} - /* GDI local heap */ extern void *GDI_GetObjPtr( HGDIOBJ, WORD );