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;
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 );

View File

@ -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;

View File

@ -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
*/

View File

@ -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;

View File

@ -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 );

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 = 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);

View File

@ -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
*/

View File

@ -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)
{

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 */
{
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
{

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_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[];

View File

@ -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;
}

View File

@ -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 {

View File

@ -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 );