Get rid of the global INTERNAL_[XY]WSTODS macros.

This commit is contained in:
Alexandre Julliard 2004-01-15 06:19:35 +00:00
parent 003465415f
commit 7342390852
13 changed files with 108 additions and 64 deletions

View File

@ -1182,6 +1182,7 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont)
GdiFont ret; GdiFont ret;
Face *face; Face *face;
Family *family = NULL; Family *family = NULL;
INT height;
BOOL bd, it; BOOL bd, it;
LOGFONTW lf; LOGFONTW lf;
CHARSETINFO csi; CHARSETINFO csi;
@ -1341,10 +1342,9 @@ not_found:
TRACE("Chosen: %s %s\n", debugstr_w(family->FamilyName), TRACE("Chosen: %s %s\n", debugstr_w(family->FamilyName),
debugstr_w(face->StyleName)); debugstr_w(face->StyleName));
height = GDI_ROUND( (FLOAT)lf.lfHeight * dc->xformWorld2Vport.eM22 );
ret->ft_face = OpenFontFile(ret, face->file, face->face_index, ret->ft_face = OpenFontFile(ret, face->file, face->face_index,
lf.lfHeight < 0 ? lf.lfHeight < 0 ? -abs(height) : abs(height));
-abs(INTERNAL_YWSTODS(dc,lf.lfHeight)) :
abs(INTERNAL_YWSTODS(dc, lf.lfHeight)));
if (!ret->ft_face) if (!ret->ft_face)
{ {
free_font( ret ); free_font( ret );

View File

@ -139,7 +139,7 @@ BOOL PSDRV_SelectDownloadFont(PSDRV_PDEVICE *physDev)
physDev->font.fontloc = Download; physDev->font.fontloc = Download;
physDev->font.fontinfo.Download = is_font_downloaded(physDev, ps_name); physDev->font.fontinfo.Download = is_font_downloaded(physDev, ps_name);
physDev->font.size = INTERNAL_YWSTODS(physDev->dc, /* ppem */ physDev->font.size = PSDRV_YWStoDS(physDev, /* ppem */
potm->otmTextMetrics.tmAscent + potm->otmTextMetrics.tmAscent +
potm->otmTextMetrics.tmDescent - potm->otmTextMetrics.tmDescent -
potm->otmTextMetrics.tmInternalLeading); potm->otmTextMetrics.tmInternalLeading);

View File

@ -35,6 +35,40 @@
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); 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 * PSDRV_DrawLine
*/ */

View File

@ -41,7 +41,7 @@ HPEN PSDRV_SelectPen( PSDRV_PDEVICE *physDev, HPEN hpen )
TRACE("hpen = %p colour = %08lx\n", hpen, logpen.lopnColor); 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) if(physDev->pen.width < 0)
physDev->pen.width = -physDev->pen.width; physDev->pen.width = -physDev->pen.width;

View File

@ -395,6 +395,9 @@ extern void PSDRV_FreeAFMList( FONTFAMILY *head );
extern BOOL WINAPI PSDRV_Init(HINSTANCE hinst, DWORD reason, LPVOID reserved); 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_Brush(PSDRV_PDEVICE *physDev, BOOL EO);
extern BOOL PSDRV_SetFont( PSDRV_PDEVICE *physDev ); extern BOOL PSDRV_SetFont( PSDRV_PDEVICE *physDev );
extern BOOL PSDRV_SetPen( PSDRV_PDEVICE *physDev ); extern BOOL PSDRV_SetPen( PSDRV_PDEVICE *physDev );

View File

@ -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 = tmpsz.cx; /* sz.cy remains untouched */
} }
sz.cx = INTERNAL_XWSTODS(dc, sz.cx); sz.cx = PSDRV_XWStoDS(physDev, sz.cx);
sz.cy = INTERNAL_YWSTODS(dc, sz.cy); sz.cy = PSDRV_YWStoDS(physDev, sz.cy);
GetTextMetricsW(physDev->hdc, &tm); GetTextMetricsW(physDev->hdc, &tm);
ascent = INTERNAL_YWSTODS(dc, tm.tmAscent); ascent = PSDRV_YWStoDS(physDev, tm.tmAscent);
descent = INTERNAL_YWSTODS(dc, tm.tmDescent); descent = PSDRV_YWStoDS(physDev, tm.tmDescent);
TRACE("textAlign = %x\n", align); TRACE("textAlign = %x\n", align);
switch(align & (TA_LEFT | TA_CENTER | TA_RIGHT) ) { 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); PSDRV_WriteBuiltinGlyphShow(physDev, str + i, 1);
dx += deltas[i] * cos_theta; dx += deltas[i] * cos_theta;
dy -= deltas[i] * sin_theta; dy -= deltas[i] * sin_theta;
PSDRV_WriteMoveTo(physDev, x + INTERNAL_XWSTODS(dc, dx), PSDRV_WriteMoveTo(physDev, x + PSDRV_XWStoDS(physDev, dx),
y + INTERNAL_YWSTODS(dc, dy)); y + PSDRV_YWStoDS(physDev, dy));
} }
if(physDev->font.fontloc == Download) if(physDev->font.fontloc == Download)
PSDRV_WriteDownloadGlyphShow(physDev, glyphs + i, 1); PSDRV_WriteDownloadGlyphShow(physDev, glyphs + i, 1);

View File

@ -293,6 +293,40 @@ BOOL X11DRV_SetupGCForText( X11DRV_PDEVICE *physDev )
return FALSE; 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 * X11DRV_LineTo
*/ */

View File

@ -37,7 +37,6 @@ static const char PEN_alternate[] = { 1,1 };
HPEN X11DRV_SelectPen( X11DRV_PDEVICE *physDev, HPEN hpen ) HPEN X11DRV_SelectPen( X11DRV_PDEVICE *physDev, HPEN hpen )
{ {
LOGPEN logpen; LOGPEN logpen;
DC *dc = physDev->dc;
if (!GetObjectA( hpen, sizeof(logpen), &logpen )) return 0; 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.endcap = logpen.lopnStyle & PS_ENDCAP_MASK;
physDev->pen.linejoin = logpen.lopnStyle & PS_JOIN_MASK; physDev->pen.linejoin = logpen.lopnStyle & PS_JOIN_MASK;
physDev->pen.width = GDI_ROUND((FLOAT)logpen.lopnWidth.x * physDev->pen.width = X11DRV_XWStoDS( physDev, logpen.lopnWidth.x );
dc->xformWorld2Vport.eM11);
if (physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width; if (physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width;
if (physDev->pen.width == 1) physDev->pen.width = 0; /* Faster */ if (physDev->pen.width == 1) physDev->pen.width = 0; /* Faster */
if (hpen == GetStockObject( DC_PEN )) if (hpen == GetStockObject( DC_PEN ))
logpen.lopnColor = dc->dcPenColor; logpen.lopnColor = GetDCPenColor( physDev->hdc );
physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, logpen.lopnColor ); physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, logpen.lopnColor );
switch(logpen.lopnStyle & PS_STYLE_MASK) switch(logpen.lopnStyle & PS_STYLE_MASK)
{ {

View File

@ -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 */ if (lpDx) /* have explicit character cell x offsets in logical coordinates */
{ {
for (i = width = 0; i < count; i++) width += lpDx[i]; for (i = width = 0; i < count; i++) width += lpDx[i];
width = INTERNAL_XWSTODS(dc, width); width = X11DRV_XWStoDS(physDev, width);
} }
else else
{ {
@ -158,7 +158,7 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
result = FALSE; result = FALSE;
goto END; goto END;
} }
width = INTERNAL_XWSTODS(dc, sz.cx); width = X11DRV_XWStoDS(physDev, sz.cx);
} }
ascent = pfo->lpX11Trans ? pfo->lpX11Trans->ascent : font->ascent; ascent = pfo->lpX11Trans ? pfo->lpX11Trans->ascent : font->ascent;
descent = pfo->lpX11Trans ? pfo->lpX11Trans->descent : font->descent; 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); x_i, y_i, &str2b[i], 1);
if (lpDx) if (lpDx)
{ {
offset += INTERNAL_XWSTODS(dc, lpDx[i]); offset += X11DRV_XWStoDS(physDev, lpDx[i]);
} }
else else
{ {

View File

@ -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_SetupGCForBrush( X11DRV_PDEVICE *physDev );
extern BOOL X11DRV_SetupGCForPen( X11DRV_PDEVICE *physDev ); extern BOOL X11DRV_SetupGCForPen( X11DRV_PDEVICE *physDev );
extern BOOL X11DRV_SetupGCForText( 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[]; extern const int X11DRV_XROPfunction[];

View File

@ -3287,14 +3287,15 @@ HFONT X11DRV_SelectFont( X11DRV_PDEVICE *physDev, HFONT hfont )
/* FIXME - check that the other drivers do this correctly */ /* FIXME - check that the other drivers do this correctly */
if (lf.lfWidth) 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) if (lf.lfWidth == 0)
lf.lfWidth = 1; /* Minimum width */ lf.lfWidth = 1; /* Minimum width */
} }
if (lf.lfHeight) 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) if (lf.lfHeight == 0)
lf.lfHeight = MIN_FONT_SIZE; lf.lfHeight = MIN_FONT_SIZE;
} }

View File

@ -1070,14 +1070,14 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
} }
width = sz.cx; width = sz.cx;
} }
width = INTERNAL_XWSTODS(dc, width); width = X11DRV_XWStoDS(physDev, width);
xwidth = width * cosEsc; xwidth = width * cosEsc;
ywidth = width * sinEsc; ywidth = width * sinEsc;
GetTextMetricsW(hdc, &tm); GetTextMetricsW(hdc, &tm);
tm.tmAscent = INTERNAL_YWSTODS(dc, tm.tmAscent); tm.tmAscent = X11DRV_YWStoDS(physDev, tm.tmAscent);
tm.tmDescent = INTERNAL_YWSTODS(dc, tm.tmDescent); tm.tmDescent = X11DRV_YWStoDS(physDev, tm.tmDescent);
switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) { switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) {
case TA_LEFT: case TA_LEFT:
if (dc->textAlign & TA_UPDATECP) { 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, 0, 0, physDev->org.x + x + xoff,
physDev->org.y + y + yoff, physDev->org.y + y + yoff,
glyphs + idx, 1); glyphs + idx, 1);
offset += INTERNAL_XWSTODS(dc, deltas[idx]); offset += X11DRV_XWStoDS(physDev, deltas[idx]);
xoff = offset * cosEsc; xoff = offset * cosEsc;
yoff = offset * -sinEsc; 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 ); XSetForeground( gdi_display, physDev->gc, physDev->textPixel );
if (lf.lfUnderline) { if (lf.lfUnderline) {
linePos = INTERNAL_YWSTODS(dc, otm->otmsUnderscorePosition); linePos = X11DRV_YWStoDS(physDev, otm->otmsUnderscorePosition);
lineWidth = INTERNAL_YWSTODS(dc, otm->otmsUnderscoreSize); lineWidth = X11DRV_YWStoDS(physDev, otm->otmsUnderscoreSize);
XSetLineAttributes( gdi_display, physDev->gc, lineWidth, XSetLineAttributes( gdi_display, physDev->gc, lineWidth,
LineSolid, CapProjecting, JoinBevel ); LineSolid, CapProjecting, JoinBevel );
@ -1286,8 +1286,8 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
} }
if (lf.lfStrikeOut) { if (lf.lfStrikeOut) {
linePos = INTERNAL_YWSTODS(dc, otm->otmsStrikeoutPosition); linePos = X11DRV_YWStoDS(physDev, otm->otmsStrikeoutPosition);
lineWidth = INTERNAL_YWSTODS(dc, otm->otmsStrikeoutSize); lineWidth = X11DRV_YWStoDS(physDev, otm->otmsStrikeoutSize);
XSetLineAttributes( gdi_display, physDev->gc, lineWidth, XSetLineAttributes( gdi_display, physDev->gc, lineWidth,
LineSolid, CapProjecting, JoinBevel ); 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->bitmaps[glyphs[idx]],
&entry->gis[glyphs[idx]]); &entry->gis[glyphs[idx]]);
if(deltas) { if(deltas) {
offset += INTERNAL_XWSTODS(dc, deltas[idx]); offset += X11DRV_XWStoDS(physDev, deltas[idx]);
xoff = offset * cosEsc; xoff = offset * cosEsc;
yoff = offset * -sinEsc; 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->bitmaps[glyphs[idx]],
&entry->gis[glyphs[idx]]); &entry->gis[glyphs[idx]]);
if(deltas) { if(deltas) {
offset += INTERNAL_XWSTODS(dc, deltas[idx]); offset += X11DRV_XWStoDS(physDev, deltas[idx]);
xoff = offset * cosEsc; xoff = offset * cosEsc;
yoff = offset * -sinEsc; 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) 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; extents.bottom = cur.y - entry->gis[glyphs[idx]].y + entry->gis[glyphs[idx]].height;
if(deltas) { if(deltas) {
offset += INTERNAL_XWSTODS(dc, deltas[idx]); offset += X11DRV_XWStoDS(physDev, deltas[idx]);
cur.x = offset * cosEsc; cur.x = offset * cosEsc;
cur.y = offset * -sinEsc; cur.y = offset * -sinEsc;
} else { } else {
@ -1438,7 +1438,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
&entry->gis[glyphs[idx]], &entry->gis[glyphs[idx]],
dc->textColor); dc->textColor);
if(deltas) { if(deltas) {
offset += INTERNAL_XWSTODS(dc, deltas[idx]); offset += X11DRV_XWStoDS(physDev, deltas[idx]);
xoff = offset * cosEsc; xoff = offset * cosEsc;
yoff = offset * -sinEsc; yoff = offset * -sinEsc;
} else { } else {

View File

@ -175,34 +175,6 @@ static inline INT WINE_UNUSED GDI_ROUND(FLOAT val)
return (int)floor(val + 0.5); 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 */ /* GDI local heap */
extern void *GDI_GetObjPtr( HGDIOBJ, WORD ); extern void *GDI_GetObjPtr( HGDIOBJ, WORD );