Commit 5ee1599d authored by Alexandre Julliard's avatar Alexandre Julliard

Replaced LPTODP/DPTOLP macros by calls to LPtoDP/DPtoLP (with the help

of Huw Davies).
parent 3a99d8ba
......@@ -36,10 +36,12 @@ WIN16DRV_LineTo( PHYSDEV dev, INT x, INT y )
DC *dc = physDev->dc;
POINT16 points[2];
points[0].x = physDev->org.x + XLPTODP( dc, dc->CursPosX );
points[0].y = physDev->org.y + YLPTODP( dc, dc->CursPosY );
points[1].x = physDev->org.x + XLPTODP( dc, x );
points[1].y = physDev->org.y + YLPTODP( dc, y );
points[0].x = dc->CursPosX;
points[0].y = dc->CursPosY;
points[1].x = x;
points[1].y = y;
LPtoDP16( physDev->hdc, points, 2 );
bRet = PRTDRV_Output(physDev->segptrPDEVICE,
OS_POLYLINE, 2, points,
physDev->PenInfo,
......@@ -63,15 +65,15 @@ WIN16DRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
BOOL bRet = 0;
POINT16 points[2];
TRACE("In WIN16DRV_Rectangle, x %d y %d DCOrgX %ld y %ld\n",
left, top, physDev->org.x, physDev->org.y);
TRACE("In WIN16DRV_Rectangle, x %d y %d\n", left, top );
TRACE("In WIN16DRV_Rectangle, VPortOrgX %d y %d\n",
dc->vportOrgX, dc->vportOrgY);
points[0].x = XLPTODP(dc, left);
points[0].y = YLPTODP(dc, top);
points[0].x = left;
points[0].y = top;
points[1].x = right;
points[1].y = bottom;
LPtoDP16( physDev->hdc, points, 2 );
points[1].x = XLPTODP(dc, right);
points[1].y = YLPTODP(dc, bottom);
bRet = PRTDRV_Output(physDev->segptrPDEVICE,
OS_RECTANGLE, 2, points,
physDev->PenInfo,
......@@ -104,9 +106,10 @@ WIN16DRV_Polygon(PHYSDEV dev, const POINT* pt, INT count )
for (i = 0; i < count - 1; i++)
{
points[i].x = XLPTODP( dc, pt[i].x );
points[i].y = YLPTODP( dc, pt[i].y );
points[i].x = pt[i].x;
points[i].y = pt[i].y;
}
LPtoDP16( physDev->hdc, points, count-1 );
points[count-1].x = points[0].x;
points[count-1].y = points[0].y;
bRet = PRTDRV_Output(physDev->segptrPDEVICE,
......@@ -138,9 +141,10 @@ WIN16DRV_Polyline(PHYSDEV dev, const POINT* pt, INT count )
for (i = 0; i < count; i++)
{
points[i].x = XLPTODP( dc, pt[i].x );
points[i].y = YLPTODP( dc, pt[i].y );
points[i].x = pt[i].x;
points[i].y = pt[i].y;
}
LPtoDP16( physDev->hdc, points, count );
bRet = PRTDRV_Output(physDev->segptrPDEVICE,
OS_POLYLINE, count, points,
physDev->PenInfo,
......@@ -163,14 +167,14 @@ WIN16DRV_Ellipse(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
BOOL bRet = 0;
POINT16 points[2];
TRACE("In WIN16DRV_Ellipse, x %d y %d DCOrgX %ld y %ld\n",
left, top, physDev->org.x, physDev->org.y);
TRACE("In WIN16DRV_Ellipse, x %d y %d\n", left, top );
TRACE("In WIN16DRV_Ellipse, VPortOrgX %d y %d\n", dc->vportOrgX, dc->vportOrgY);
points[0].x = XLPTODP(dc, left);
points[0].y = YLPTODP(dc, top);
points[1].x = XLPTODP(dc, right);
points[1].y = YLPTODP(dc, bottom);
points[0].x = left;
points[0].y = top;
points[1].x = right;
points[1].y = bottom;
LPtoDP16( physDev->hdc, points, 2 );
bRet = PRTDRV_Output(physDev->segptrPDEVICE,
OS_ELLIPSE, 2, points,
......
......@@ -258,7 +258,6 @@ BOOL WIN16DRV_CreateDC( DC *dc, PHYSDEV *pdev, LPCSTR driver, LPCSTR device, LPC
*pdev = (PHYSDEV)physDev;
physDev->hdc = dc->hSelf;
physDev->dc = dc;
physDev->org.x = physDev->org.y = 0;
pLPD = LoadPrinterDriver(driver);
if (pLPD == NULL)
......
......@@ -43,6 +43,7 @@ BOOL WIN16DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
RECT16 *lpOpaqueRect = NULL;
WORD wOptions = 0;
DWORD len;
POINT pt;
INT16 width;
char *str;
DWORD dwRet;
......@@ -77,8 +78,11 @@ BOOL WIN16DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
y = dc->CursPosY;
}
x = XLPTODP( dc, x );
y = YLPTODP( dc, y );
pt.x = x;
pt.y = y;
LPtoDP( physDev->hdc, &pt, 1 );
x = pt.x;
y = pt.y;
dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE, 0, 0,
NULL, str, -len, physDev->FontInfo,
......@@ -91,12 +95,22 @@ BOOL WIN16DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) {
case TA_LEFT:
if (dc->textAlign & TA_UPDATECP)
dc->CursPosX = XDPTOLP( dc, x + width );
{
pt.x = x + width;
pt.y = y;
DPtoLP( physDev->hdc, &pt, 1 );
dc->CursPosX = pt.x;
}
break;
case TA_RIGHT:
x -= width;
if (dc->textAlign & TA_UPDATECP)
dc->CursPosX = XDPTOLP( dc, x );
if (dc->textAlign & TA_UPDATECP)
{
pt.x = x;
pt.y = y;
DPtoLP( physDev->hdc, &pt, 1 );
dc->CursPosX = pt.x;
}
break;
case TA_CENTER:
x -= width / 2;
......@@ -123,12 +137,3 @@ BOOL WIN16DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
HeapFree( GetProcessHeap(), 0, str );
return bRet;
}
......@@ -207,7 +207,6 @@ typedef struct
LPLOGPEN16 PenInfo; /* Current pen realized by printer driver */
HDC hdc;
DC *dc;
POINT org; /* Device origin */
DeviceCaps DevCaps; /* Device caps */
} WIN16DRV_PDEVICE;
......
......@@ -148,8 +148,13 @@ static BOOL PSDRV_Text(PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags, LPCWSTR
TRACE("textAlign = %x\n", align);
switch(align & (TA_LEFT | TA_CENTER | TA_RIGHT) ) {
case TA_LEFT:
if(align & TA_UPDATECP) {
dc->CursPosX = INTERNAL_XDPTOWP(dc, x + sz.cx, y);
if(align & TA_UPDATECP)
{
POINT pt;
pt.x = x + sz.cx;
pt.y = y;
DPtoLP( physDev->hdc, &pt, 1 );
dc->CursPosX = pt.x;
}
break;
......@@ -159,8 +164,13 @@ static BOOL PSDRV_Text(PSDRV_PDEVICE *physDev, INT x, INT y, UINT flags, LPCWSTR
case TA_RIGHT:
x -= sz.cx;
if(align & TA_UPDATECP) {
dc->CursPosX = INTERNAL_XDPTOWP(dc, x, y);
if(align & TA_UPDATECP)
{
POINT pt;
pt.x = x;
pt.y = y;
DPtoLP( physDev->hdc, &pt, 1 );
dc->CursPosX = pt.x;
}
break;
}
......
......@@ -58,8 +58,8 @@ BOOL16 WINAPI DPtoLP16( HDC16 hdc, LPPOINT16 points, INT16 count )
while (count--)
{
points->x = XDPTOLP( dc, points->x );
points->y = YDPTOLP( dc, points->y );
points->x = MulDiv( points->x - dc->vportOrgX, dc->wndExtX, dc->vportExtX ) + dc->wndOrgX;
points->y = MulDiv( points->y - dc->vportOrgY, dc->wndExtY, dc->vportExtY ) + dc->wndOrgY;
points++;
}
GDI_ReleaseObj( hdc );
......@@ -75,11 +75,20 @@ BOOL WINAPI DPtoLP( HDC hdc, LPPOINT points, INT count )
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
while (count--)
if (dc->vport2WorldValid)
{
if (!INTERNAL_DPTOLP( dc, points ))
break;
points++;
while (count--)
{
FLOAT x = points->x;
FLOAT y = points->y;
points->x = floor( x * dc->xformVport2World.eM11 +
y * dc->xformVport2World.eM21 +
dc->xformVport2World.eDx + 0.5 );
points->y = floor( x * dc->xformVport2World.eM12 +
y * dc->xformVport2World.eM22 +
dc->xformVport2World.eDy + 0.5 );
points++;
}
}
GDI_ReleaseObj( hdc );
return (count < 0);
......@@ -96,8 +105,8 @@ BOOL16 WINAPI LPtoDP16( HDC16 hdc, LPPOINT16 points, INT16 count )
while (count--)
{
points->x = XLPTODP( dc, points->x );
points->y = YLPTODP( dc, points->y );
points->x = MulDiv( points->x - dc->wndOrgX, dc->vportExtX, dc->wndExtX ) + dc->vportOrgX;
points->y = MulDiv( points->y - dc->wndOrgY, dc->vportExtY, dc->wndExtY ) + dc->vportOrgY;
points++;
}
GDI_ReleaseObj( hdc );
......@@ -115,7 +124,14 @@ BOOL WINAPI LPtoDP( HDC hdc, LPPOINT points, INT count )
while (count--)
{
INTERNAL_LPTODP( dc, points );
FLOAT x = points->x;
FLOAT y = points->y;
points->x = floor( x * dc->xformWorld2Vport.eM11 +
y * dc->xformWorld2Vport.eM21 +
dc->xformWorld2Vport.eDx + 0.5 );
points->y = floor( x * dc->xformWorld2Vport.eM12 +
y * dc->xformWorld2Vport.eM22 +
dc->xformWorld2Vport.eDy + 0.5 );
points++;
}
GDI_ReleaseObj( hdc );
......
......@@ -81,6 +81,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdi);
#define GROW_FACTOR_NUMER 2 /* Numerator of grow factor for the array */
#define GROW_FACTOR_DENOM 1 /* Denominator of grow factor */
/* A floating point version of the POINT structure */
typedef struct tagFLOAT_POINT
{
FLOAT x, y;
} FLOAT_POINT;
static BOOL PATH_PathToRegion(GdiPath *pPath, INT nPolyFillMode,
HRGN *pHrgn);
......@@ -94,6 +100,23 @@ static void PATH_NormalizePoint(FLOAT_POINT corners[], const FLOAT_POINT
*pPoint, double *pX, double *pY);
static BOOL PATH_CheckCorners(DC *dc, POINT corners[], INT x1, INT y1, INT x2, INT y2);
/* Performs a world-to-viewport transformation on the specified point (which
* is in floating point format).
*/
static inline void WINE_UNUSED INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
{
FLOAT x, y;
/* Perform the transformation */
x = point->x;
y = point->y;
point->x = x * dc->xformWorld2Vport.eM11 +
y * dc->xformWorld2Vport.eM21 +
dc->xformWorld2Vport.eDx;
point->y = x * dc->xformWorld2Vport.eM12 +
y * dc->xformWorld2Vport.eM22 +
dc->xformWorld2Vport.eDy;
}
/***********************************************************************
* BeginPath (GDI.512)
......
......@@ -1224,6 +1224,7 @@ static BOOL BITBLT_InternalStretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT
const BYTE *opcode;
Pixmap pixmaps[3] = { 0, 0, 0 }; /* pixmaps for DST, SRC, TMP */
GC tmpGC = 0;
POINT pts[2];
DC *dcSrc = physDevSrc ? physDevSrc->dc : NULL;
DC *dcDst = physDevDst->dc;
......@@ -1244,12 +1245,15 @@ static BOOL BITBLT_InternalStretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT
/* Map the coordinates to device coords */
xDst = XLPTODP( dcDst, xDst );
yDst = YLPTODP( dcDst, yDst );
/* Here we have to round to integers, not truncate */
widthDst = MulDiv(widthDst, dcDst->vportExtX, dcDst->wndExtX);
heightDst = MulDiv(heightDst, dcDst->vportExtY, dcDst->wndExtY);
pts[0].x = xDst;
pts[0].y = yDst;
pts[1].x = xDst + widthDst;
pts[1].y = yDst + heightDst;
LPtoDP(physDevDst->hdc, pts, 2);
xDst = pts[0].x;
yDst = pts[0].y;
widthDst = pts[1].x - pts[0].x;
heightDst = pts[1].y - pts[0].y;
TRACE(" vportdst=%d,%d-%d,%d wnddst=%d,%d-%d,%d\n",
dcDst->vportOrgX, dcDst->vportOrgY,
......@@ -1262,10 +1266,16 @@ static BOOL BITBLT_InternalStretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT
if (useSrc)
{
xSrc = XLPTODP( dcSrc, xSrc );
ySrc = YLPTODP( dcSrc, ySrc );
widthSrc = widthSrc * dcSrc->vportExtX / dcSrc->wndExtX;
heightSrc = heightSrc * dcSrc->vportExtY / dcSrc->wndExtY;
pts[0].x = xSrc;
pts[0].y = ySrc;
pts[1].x = xSrc + widthSrc;
pts[1].y = ySrc + heightSrc;
LPtoDP(physDevSrc->hdc, pts, 2);
xSrc = pts[0].x;
ySrc = pts[0].y;
widthSrc = pts[1].x - pts[0].x;
heightSrc = pts[1].y - pts[0].y;
fStretch = (widthSrc != widthDst) || (heightSrc != heightDst);
TRACE(" vportsrc=%d,%d-%d,%d wndsrc=%d,%d-%d,%d\n",
dcSrc->vportOrgX, dcSrc->vportOrgY,
......@@ -1553,13 +1563,26 @@ BOOL X11DRV_BitBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst,
if ((sSrc == DIB_Status_AppMod) && (rop == SRCCOPY) &&
(dcSrc->bitsPerPixel == dcDst->bitsPerPixel))
{
POINT pts[2];
/* do everything ourselves; map coordinates */
xSrc = XLPTODP( dcSrc, xSrc );
ySrc = YLPTODP( dcSrc, ySrc );
xDst = XLPTODP( dcDst, xDst );
yDst = YLPTODP( dcDst, yDst );
width = MulDiv(width, dcDst->vportExtX, dcDst->wndExtX);
height = MulDiv(height, dcDst->vportExtY, dcDst->wndExtY);
pts[0].x = xSrc;
pts[0].y = ySrc;
pts[1].x = xSrc + width;
pts[1].y = ySrc + height;
LPtoDP(physDevSrc->hdc, pts, 2);
width = pts[1].x - pts[0].x;
height = pts[1].y - pts[0].y;
xSrc = pts[0].x;
ySrc = pts[0].y;
pts[0].x = xDst;
pts[0].y = yDst;
LPtoDP(physDevDst->hdc, pts, 1);
xDst = pts[0].x;
yDst = pts[0].y;
/* Perform basic clipping */
if (!BITBLT_GetVisRectangles( dcDst, xDst, yDst, width, height,
......
......@@ -4737,6 +4737,7 @@ INT X11DRV_SetDIBitsToDevice( X11DRV_PDEVICE *physDev, INT xDest, INT yDest, DWO
DWORD width, oldcy = cy;
INT result;
int height, tmpheight;
POINT pt;
DC *dc = physDev->dc;
if (DIB_GetBitmapInfo( &info->bmiHeader, &width, &height,
......@@ -4753,6 +4754,10 @@ INT X11DRV_SetDIBitsToDevice( X11DRV_PDEVICE *physDev, INT xDest, INT yDest, DWO
if (xSrc + cx >= width) cx = width - xSrc;
if (!cx || !cy) return 0;
pt.x = xDest;
pt.y = yDest;
LPtoDP(physDev->hdc, &pt, 1);
X11DRV_SetupGCForText( physDev ); /* To have the correct colors */
TSXSetFunction(gdi_display, physDev->gc, X11DRV_XROPfunction[dc->ROPmode-1]);
......@@ -4796,9 +4801,8 @@ INT X11DRV_SetDIBitsToDevice( X11DRV_PDEVICE *physDev, INT xDest, INT yDest, DWO
descr.xSrc = xSrc;
descr.ySrc = tmpheight >= 0 ? lines-(ySrc-startscan)-cy+(oldcy-cy)
: ySrc - startscan;
descr.xDest = physDev->org.x + XLPTODP( dc, xDest );
descr.yDest = physDev->org.y + YLPTODP( dc, yDest ) +
(tmpheight >= 0 ? oldcy-cy : 0);
descr.xDest = physDev->org.x + pt.x;
descr.yDest = physDev->org.y + pt.y + (tmpheight >= 0 ? oldcy-cy : 0);
descr.width = cx;
descr.height = cy;
descr.useShm = FALSE;
......
......@@ -339,26 +339,26 @@ X11DRV_DrawArc( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
INT width, oldwidth, oldendcap;
double start_angle, end_angle;
XPoint points[4];
DC *dc = physDev->dc;
BOOL update = FALSE;
left = XLPTODP( dc, left );
top = YLPTODP( dc, top );
right = XLPTODP( dc, right );
bottom = YLPTODP( dc, bottom );
xstart = XLPTODP( dc, xstart );
ystart = YLPTODP( dc, ystart );
xend = XLPTODP( dc, xend );
yend = YLPTODP( dc, yend );
if (right < left) { INT tmp = right; right = left; left = tmp; }
if (bottom < top) { INT tmp = bottom; bottom = top; top = tmp; }
if ((left == right) || (top == bottom)
||(lines && ((right-left==1)||(bottom-top==1)))) return TRUE;
if( dc->ArcDirection == AD_CLOCKWISE )
{ INT tmp = xstart; xstart = xend; xend = tmp;
tmp = ystart; ystart = yend; yend = tmp; }
POINT start, end;
RECT rc;
SetRect(&rc, left, top, right, bottom);
start.x = xstart;
start.y = ystart;
end.x = xend;
end.y = yend;
LPtoDP(physDev->hdc, (POINT*)&rc, 2);
LPtoDP(physDev->hdc, &start, 1);
LPtoDP(physDev->hdc, &end, 1);
if (rc.right < rc.left) { INT tmp = rc.right; rc.right = rc.left; rc.left = tmp; }
if (rc.bottom < rc.top) { INT tmp = rc.bottom; rc.bottom = rc.top; rc.top = tmp; }
if ((rc.left == rc.right) || (rc.top == rc.bottom)
||(lines && ((rc.right-rc.left==1)||(rc.bottom-rc.top==1)))) return TRUE;
if (GetArcDirection( physDev->hdc ) == AD_CLOCKWISE)
{ POINT tmp = start; start = end; end = tmp; }
oldwidth = width = physDev->pen.width;
oldendcap = physDev->pen.endcap;
......@@ -367,24 +367,24 @@ X11DRV_DrawArc( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
if ((physDev->pen.style == PS_INSIDEFRAME))
{
if (2*width > (right-left)) width=(right-left + 1)/2;
if (2*width > (bottom-top)) width=(bottom-top + 1)/2;
left += width / 2;
right -= (width - 1) / 2;
top += width / 2;
bottom -= (width - 1) / 2;
if (2*width > (rc.right-rc.left)) width=(rc.right-rc.left + 1)/2;
if (2*width > (rc.bottom-rc.top)) width=(rc.bottom-rc.top + 1)/2;
rc.left += width / 2;
rc.right -= (width - 1) / 2;
rc.top += width / 2;
rc.bottom -= (width - 1) / 2;
}
if(width == 0) width = 1; /* more accurate */
physDev->pen.width = width;
physDev->pen.endcap = PS_ENDCAP_SQUARE;
xcenter = (right + left) / 2;
ycenter = (bottom + top) / 2;
start_angle = atan2( (double)(ycenter-ystart)*(right-left),
(double)(xstart-xcenter)*(bottom-top) );
end_angle = atan2( (double)(ycenter-yend)*(right-left),
(double)(xend-xcenter)*(bottom-top) );
if ((xstart==xend)&&(ystart==yend))
xcenter = (rc.right + rc.left) / 2;
ycenter = (rc.bottom + rc.top) / 2;
start_angle = atan2( (double)(ycenter-start.y)*(rc.right-rc.left),
(double)(start.x-xcenter)*(rc.bottom-rc.top) );
end_angle = atan2( (double)(ycenter-end.y)*(rc.right-rc.left),
(double)(end.x-xcenter)*(rc.bottom-rc.top) );
if ((start.x==end.x)&&(start.y==end.y))
{ /* A lazy program delivers xstart=xend=ystart=yend=0) */
start_angle = 0;
end_angle = 2* PI;
......@@ -407,8 +407,8 @@ X11DRV_DrawArc( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
if ((lines > 0) && X11DRV_SetupGCForBrush( physDev )) {
TSXSetArcMode( gdi_display, physDev->gc, (lines==1) ? ArcChord : ArcPieSlice);
TSXFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
right-left-1, bottom-top-1, istart_angle, idiff_angle );
physDev->org.x + rc.left, physDev->org.y + rc.top,
rc.right-rc.left-1, rc.bottom-rc.top-1, istart_angle, idiff_angle );
update = TRUE;
}
......@@ -416,21 +416,21 @@ X11DRV_DrawArc( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
if (X11DRV_SetupGCForPen( physDev )){
TSXDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
right-left-1, bottom-top-1, istart_angle, idiff_angle );
physDev->org.x + rc.left, physDev->org.y + rc.top,
rc.right-rc.left-1, rc.bottom-rc.top-1, istart_angle, idiff_angle );
if (lines) {
/* use the truncated values */
start_angle=(double)istart_angle*PI/64./180.;
end_angle=(double)(istart_angle+idiff_angle)*PI/64./180.;
/* calculate the endpoints and round correctly */
points[0].x = (int) floor(physDev->org.x + (right+left)/2.0 +
cos(start_angle) * (right-left-width*2+2) / 2. + 0.5);
points[0].y = (int) floor(physDev->org.y + (top+bottom)/2.0 -
sin(start_angle) * (bottom-top-width*2+2) / 2. + 0.5);
points[1].x = (int) floor(physDev->org.x + (right+left)/2.0 +
cos(end_angle) * (right-left-width*2+2) / 2. + 0.5);
points[1].y = (int) floor(physDev->org.y + (top+bottom)/2.0 -
sin(end_angle) * (bottom-top-width*2+2) / 2. + 0.5);
points[0].x = (int) floor(physDev->org.x + (rc.right+rc.left)/2.0 +
cos(start_angle) * (rc.right-rc.left-width*2+2) / 2. + 0.5);
points[0].y = (int) floor(physDev->org.y + (rc.top+rc.bottom)/2.0 -
sin(start_angle) * (rc.bottom-rc.top-width*2+2) / 2. + 0.5);
points[1].x = (int) floor(physDev->org.x + (rc.right+rc.left)/2.0 +
cos(end_angle) * (rc.right-rc.left-width*2+2) / 2. + 0.5);
points[1].y = (int) floor(physDev->org.y + (rc.top+rc.bottom)/2.0 -
sin(end_angle) * (rc.bottom-rc.top-width*2+2) / 2. + 0.5);
/* OK, this stuff is optimized for Xfree86
* which is probably the server most used by
......@@ -448,7 +448,7 @@ X11DRV_DrawArc( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
points[2] = points[1];
dx1=points[1].x-points[0].x;
dy1=points[1].y-points[0].y;
if(((top-bottom) | -2) == -2)
if(((rc.top-rc.bottom) | -2) == -2)
if(dy1>0) points[1].y--;
if(dx1<0) {
if (((-dx1)*64)<=ABS(dy1)*37) points[0].x--;
......@@ -456,15 +456,15 @@ X11DRV_DrawArc( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
if( dy1<0 && ((dx1*9)) < (dy1*16)) points[0].y--;
} else {
if(dy1 < 0) points[0].y--;
if(((right-left) | -2) == -2) points[1].x--;
if(((rc.right-rc.left) | -2) == -2) points[1].x--;
}
dx1=points[3].x-points[2].x;
dy1=points[3].y-points[2].y;
if(((top-bottom) | -2 ) == -2)
if(((rc.top-rc.bottom) | -2 ) == -2)
if(dy1 < 0) points[2].y--;
if( dx1<0){
if( dy1>0) points[3].y--;
if(((right-left) | -2) == -2 ) points[2].x--;
if(((rc.right-rc.left) | -2) == -2 ) points[2].x--;
}else {
points[3].y--;
if( dx1 * 64 < dy1 * -37 ) points[3].x--;
......@@ -528,17 +528,16 @@ BOOL
X11DRV_Ellipse( X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom )
{
INT width, oldwidth;
DC *dc = physDev->dc;
BOOL update = FALSE;
RECT rc;
SetRect(&rc, left, top, right, bottom);
LPtoDP(physDev->hdc, (POINT*)&rc, 2);
left = XLPTODP( dc, left );
top = YLPTODP( dc, top );
right = XLPTODP( dc, right );
bottom = YLPTODP( dc, bottom );
if ((left == right) || (top == bottom)) return TRUE;
if ((rc.left == rc.right) || (rc.top == rc.bottom)) return TRUE;
if (right < left) { INT tmp = right; right = left; left = tmp; }
if (bottom < top) { INT tmp = bottom; bottom = top; top = tmp; }
if (rc.right < rc.left) { INT tmp = rc.right; rc.right = rc.left; rc.left = tmp; }
if (rc.bottom < rc.top) { INT tmp = rc.bottom; rc.bottom = rc.top; rc.top = tmp; }
oldwidth = width = physDev->pen.width;
if (!width) width = 1;
......@@ -546,12 +545,12 @@ X11DRV_Ellipse( X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT botto
if ((physDev->pen.style == PS_INSIDEFRAME))
{
if (2*width > (right-left)) width=(right-left + 1)/2;
if (2*width > (bottom-top)) width=(bottom-top + 1)/2;
left += width / 2;
right -= (width - 1) / 2;
top += width / 2;
bottom -= (width - 1) / 2;
if (2*width > (rc.right-rc.left)) width=(rc.right-rc.left + 1)/2;
if (2*width > (rc.bottom-rc.top)) width=(rc.bottom-rc.top + 1)/2;
rc.left += width / 2;
rc.right -= (width - 1) / 2;
rc.top += width / 2;
rc.bottom -= (width - 1) / 2;
}
if(width == 0) width = 1; /* more accurate */
physDev->pen.width = width;
......@@ -562,15 +561,15 @@ X11DRV_Ellipse( X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT botto
if (X11DRV_SetupGCForBrush( physDev ))
{
TSXFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
right-left-1, bottom-top-1, 0, 360*64 );
physDev->org.x + rc.left, physDev->org.y + rc.top,
rc.right-rc.left-1, rc.bottom-rc.top-1, 0, 360*64 );
update = TRUE;
}
if (X11DRV_SetupGCForPen( physDev ))
{
TSXDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
right-left-1, bottom-top-1, 0, 360*64 );
physDev->org.x + rc.left, physDev->org.y + rc.top,
rc.right-rc.left-1, rc.bottom-rc.top-1, 0, 360*64 );
update = TRUE;
}
......@@ -589,21 +588,18 @@ BOOL
X11DRV_Rectangle(X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT bottom)
{
INT width, oldwidth, oldjoinstyle;
DC *dc = physDev->dc;
BOOL update = FALSE;
RECT rc;
TRACE("(%d %d %d %d)\n",
left, top, right, bottom);
TRACE("(%d %d %d %d)\n", left, top, right, bottom);
left = INTERNAL_XWPTODP( dc, left, top );
top = INTERNAL_YWPTODP( dc, left, top );
right = INTERNAL_XWPTODP( dc, right, bottom );
bottom = INTERNAL_YWPTODP( dc, right, bottom );
SetRect(&rc, left, top, right, bottom);
LPtoDP(physDev->hdc, (POINT*)&rc, 2);
if ((left == right) || (top == bottom)) return TRUE;
if ((rc.left == rc.right) || (rc.top == rc.bottom)) return TRUE;
if (right < left) { INT tmp = right; right = left; left = tmp; }
if (bottom < top) { INT tmp = bottom; bottom = top; top = tmp; }
if (rc.right < rc.left) { INT tmp = rc.right; rc.right = rc.left; rc.left = tmp; }
if (rc.bottom < rc.top) { INT tmp = rc.bottom; rc.bottom = rc.top; rc.top = tmp; }
oldwidth = width = physDev->pen.width;
if (!width) width = 1;
......@@ -611,12 +607,12 @@ X11DRV_Rectangle(X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT bott
if ((physDev->pen.style == PS_INSIDEFRAME))
{
if (2*width > (right-left)) width=(right-left + 1)/2;
if (2*width > (bottom-top)) width=(bottom-top + 1)/2;
left += width / 2;
right -= (width - 1) / 2;
top += width / 2;
bottom -= (width - 1) / 2;
if (2*width > (rc.right-rc.left)) width=(rc.right-rc.left + 1)/2;
if (2*width > (rc.bottom-rc.top)) width=(rc.bottom-rc.top + 1)/2;
rc.left += width / 2;
rc.right -= (width - 1) / 2;
rc.top += width / 2;
rc.bottom -= (width - 1) / 2;
}
if(width == 1) width = 0;
physDev->pen.width = width;
......@@ -627,20 +623,22 @@ X11DRV_Rectangle(X11DRV_PDEVICE *physDev, INT left, INT top, INT right, INT bott
/* Update the pixmap from the DIB section */
X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
if ((right > left + width) && (bottom > top + width))
if ((rc.right > rc.left + width) && (rc.bottom > rc.top + width))
{
if (X11DRV_SetupGCForBrush( physDev ))
{
TSXFillRectangle( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left + (width + 1) / 2,
physDev->org.y + top + (width + 1) / 2,
right-left-width-1, bottom-top-width-1);
physDev->org.x + rc.left + (width + 1) / 2,
physDev->org.y + rc.top + (width + 1) / 2,
rc.right-rc.left-width-1, rc.bottom-rc.top-width-1);
update = TRUE;
}
}
if (X11DRV_SetupGCForPen( physDev ))
{
TSXDrawRectangle( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
right-left-1, bottom-top-1 );
physDev->org.x + rc.left, physDev->org.y + rc.top,
rc.right-rc.left-1, rc.bottom-rc.top-1 );
update = TRUE;
}
......@@ -660,29 +658,32 @@ X11DRV_RoundRect( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
{
INT width, oldwidth, oldendcap;
DC *dc = physDev->dc;
BOOL update = FALSE;
RECT rc;
POINT pts[2];
TRACE("(%d %d %d %d %d %d\n",
left, top, right, bottom, ell_width, ell_height);
left = XLPTODP( dc, left );
top = YLPTODP( dc, top );
right = XLPTODP( dc, right );
bottom = YLPTODP( dc, bottom );
SetRect(&rc, left, top, right, bottom);
LPtoDP(physDev->hdc, (POINT*)&rc, 2);
if ((left == right) || (top == bottom))
if ((rc.left == rc.right) || (rc.top == rc.bottom))
return TRUE;
/* Make sure ell_width and ell_height are >= 1 otherwise XDrawArc gets
called with width/height < 0 */
ell_width = max(abs( ell_width * dc->vportExtX / dc->wndExtX ), 1);
ell_height = max(abs( ell_height * dc->vportExtY / dc->wndExtY ), 1);
pts[0].x = pts[0].y = 0;
pts[1].x = ell_width;
pts[1].y = ell_height;
LPtoDP(physDev->hdc, pts, 2);
ell_width = max(abs( pts[1].x - pts[0].x ), 1);
ell_height = max(abs( pts[1].y - pts[0].y ), 1);
/* Fix the coordinates */
if (right < left) { INT tmp = right; right = left; left = tmp; }
if (bottom < top) { INT tmp = bottom; bottom = top; top = tmp; }
if (rc.right < rc.left) { INT tmp = rc.right; rc.right = rc.left; rc.left = tmp; }
if (rc.bottom < rc.top) { INT tmp = rc.bottom; rc.bottom = rc.top; rc.top = tmp; }
oldwidth = width = physDev->pen.width;
oldendcap = physDev->pen.endcap;
......@@ -691,12 +692,12 @@ X11DRV_RoundRect( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
if ((physDev->pen.style == PS_INSIDEFRAME))
{
if (2*width > (right-left)) width=(right-left + 1)/2;
if (2*width > (bottom-top)) width=(bottom-top + 1)/2;
left += width / 2;
right -= (width - 1) / 2;
top += width / 2;
bottom -= (width - 1) / 2;
if (2*width > (rc.right-rc.left)) width=(rc.right-rc.left + 1)/2;
if (2*width > (rc.bottom-rc.top)) width=(rc.bottom-rc.top + 1)/2;
rc.left += width / 2;
rc.right -= (width - 1) / 2;
rc.top += width / 2;
rc.bottom -= (width - 1) / 2;
}
if(width == 0) width = 1;
physDev->pen.width = width;
......@@ -708,66 +709,66 @@ X11DRV_RoundRect( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
wine_tsx11_lock();
if (X11DRV_SetupGCForBrush( physDev ))
{
if (ell_width > (right-left) )
if (ell_height > (bottom-top) )
if (ell_width > (rc.right-rc.left) )
if (ell_height > (rc.bottom-rc.top) )
XFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
right - left - 1, bottom - top - 1,
physDev->org.x + rc.left, physDev->org.y + rc.top,
rc.right - rc.left - 1, rc.bottom - rc.top - 1,
0, 360 * 64 );
else{
XFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
right - left - 1, ell_height, 0, 180 * 64 );
physDev->org.x + rc.left, physDev->org.y + rc.top,
rc.right - rc.left - 1, ell_height, 0, 180 * 64 );
XFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left,
physDev->org.y + bottom - ell_height - 1,
right - left - 1, ell_height, 180 * 64,
physDev->org.x + rc.left,
physDev->org.y + rc.bottom - ell_height - 1,
rc.right - rc.left - 1, ell_height, 180 * 64,
180 * 64 );
}
else if (ell_height > (bottom-top) ){
else if (ell_height > (rc.bottom-rc.top) ){
XFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
ell_width, bottom - top - 1, 90 * 64, 180 * 64 );
physDev->org.x + rc.left, physDev->org.y + rc.top,
ell_width, rc.bottom - rc.top - 1, 90 * 64, 180 * 64 );
XFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + right - ell_width -1, physDev->org.y + top,
ell_width, bottom - top - 1, 270 * 64, 180 * 64 );
physDev->org.x + rc.right - ell_width - 1, physDev->org.y + rc.top,
ell_width, rc.bottom - rc.top - 1, 270 * 64, 180 * 64 );
}else{
XFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
physDev->org.x + rc.left, physDev->org.y + rc.top,
ell_width, ell_height, 90 * 64, 90 * 64 );
XFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left,
physDev->org.y + bottom - ell_height - 1,
physDev->org.x + rc.left,
physDev->org.y + rc.bottom - ell_height - 1,
ell_width, ell_height, 180 * 64, 90 * 64 );
XFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + right - ell_width - 1,
physDev->org.y + bottom - ell_height - 1,
physDev->org.x + rc.right - ell_width - 1,
physDev->org.y + rc.bottom - ell_height - 1,
ell_width, ell_height, 270 * 64, 90 * 64 );
XFillArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + right - ell_width - 1,
physDev->org.y + top,
physDev->org.x + rc.right - ell_width - 1,
physDev->org.y + rc.top,
ell_width, ell_height, 0, 90 * 64 );
}
if (ell_width < right - left)
if (ell_width < rc.right - rc.left)
{
XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left + (ell_width + 1) / 2,
physDev->org.y + top + 1,
right - left - ell_width - 1,
physDev->org.x + rc.left + (ell_width + 1) / 2,
physDev->org.y + rc.top + 1,
rc.right - rc.left - ell_width - 1,
(ell_height + 1) / 2 - 1);
XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left + (ell_width + 1) / 2,
physDev->org.y + bottom - (ell_height) / 2 - 1,
right - left - ell_width - 1,
physDev->org.x + rc.left + (ell_width + 1) / 2,
physDev->org.y + rc.bottom - (ell_height) / 2 - 1,
rc.right - rc.left - ell_width - 1,
(ell_height) / 2 );
}
if (ell_height < bottom - top)
if (ell_height < rc.bottom - rc.top)
{
XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left + 1,
physDev->org.y + top + (ell_height + 1) / 2,
right - left - 2,
bottom - top - ell_height - 1);
physDev->org.x + rc.left + 1,
physDev->org.y + rc.top + (ell_height + 1) / 2,
rc.right - rc.left - 2,
rc.bottom - rc.top - ell_height - 1);
}
update = TRUE;
}
......@@ -782,68 +783,68 @@ X11DRV_RoundRect( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
*/
if (X11DRV_SetupGCForPen( physDev ))
{
if (ell_width > (right-left) )
if (ell_height > (bottom-top) )
if (ell_width > (rc.right-rc.left) )
if (ell_height > (rc.bottom-rc.top) )
XDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
right - left - 1, bottom -top - 1, 0 , 360 * 64 );
physDev->org.x + rc.left, physDev->org.y + rc.top,
rc.right - rc.left - 1, rc.bottom - rc.top - 1, 0 , 360 * 64 );
else{
XDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
right - left - 1, ell_height - 1, 0 , 180 * 64 );
physDev->org.x + rc.left, physDev->org.y + rc.top,
rc.right - rc.left - 1, ell_height - 1, 0 , 180 * 64 );
XDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left,
physDev->org.y + bottom - ell_height,
right - left - 1, ell_height - 1, 180 * 64 , 180 * 64 );
physDev->org.x + rc.left,
physDev->org.y + rc.bottom - ell_height,
rc.right - rc.left - 1, ell_height - 1, 180 * 64 , 180 * 64 );
}
else if (ell_height > (bottom-top) ){
else if (ell_height > (rc.bottom-rc.top) ){
XDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
ell_width - 1 , bottom - top - 1, 90 * 64 , 180 * 64 );
physDev->org.x + rc.left, physDev->org.y + rc.top,
ell_width - 1 , rc.bottom - rc.top - 1, 90 * 64 , 180 * 64 );
XDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + right - ell_width,
physDev->org.y + top,
ell_width - 1 , bottom - top - 1, 270 * 64 , 180 * 64 );
physDev->org.x + rc.right - ell_width,
physDev->org.y + rc.top,
ell_width - 1 , rc.bottom - rc.top - 1, 270 * 64 , 180 * 64 );
}else{
XDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + top,
physDev->org.x + rc.left, physDev->org.y + rc.top,
ell_width - 1, ell_height - 1, 90 * 64, 90 * 64 );
XDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left, physDev->org.y + bottom - ell_height,
physDev->org.x + rc.left, physDev->org.y + rc.bottom - ell_height,
ell_width - 1, ell_height - 1, 180 * 64, 90 * 64 );
XDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + right - ell_width,
physDev->org.y + bottom - ell_height,
physDev->org.x + rc.right - ell_width,
physDev->org.y + rc.bottom - ell_height,
ell_width - 1, ell_height - 1, 270 * 64, 90 * 64 );
XDrawArc( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + right - ell_width, physDev->org.y + top,
physDev->org.x + rc.right - ell_width, physDev->org.y + rc.top,
ell_width - 1, ell_height - 1, 0, 90 * 64 );
}
if (ell_width < right - left)
if (ell_width < rc.right - rc.left)
{
XDrawLine( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left + ell_width / 2,
physDev->org.y + top,
physDev->org.x + right - (ell_width+1) / 2,
physDev->org.y + top);
physDev->org.x + rc.left + ell_width / 2,
physDev->org.y + rc.top,
physDev->org.x + rc.right - (ell_width+1) / 2,
physDev->org.y + rc.top);
XDrawLine( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left + ell_width / 2 ,
physDev->org.y + bottom - 1,
physDev->org.x + right - (ell_width+1)/ 2,
physDev->org.y + bottom - 1);
physDev->org.x + rc.left + ell_width / 2 ,
physDev->org.y + rc.bottom - 1,
physDev->org.x + rc.right - (ell_width+1)/ 2,
physDev->org.y + rc.bottom - 1);
}
if (ell_height < bottom - top)
if (ell_height < rc.bottom - rc.top)
{
XDrawLine( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + right - 1,
physDev->org.y + top + ell_height / 2,
physDev->org.x + right - 1,
physDev->org.y + bottom - (ell_height+1) / 2);
physDev->org.x + rc.right - 1,
physDev->org.y + rc.top + ell_height / 2,
physDev->org.x + rc.right - 1,
physDev->org.y + rc.bottom - (ell_height+1) / 2);
XDrawLine( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + left,
physDev->org.y + top + ell_height / 2,
physDev->org.x + left,
physDev->org.y + bottom - (ell_height+1) / 2);
physDev->org.x + rc.left,
physDev->org.y + rc.top + ell_height / 2,
physDev->org.x + rc.left,
physDev->org.y + rc.bottom - (ell_height+1) / 2);
}
update = TRUE;
}
......@@ -975,7 +976,6 @@ X11DRV_Polyline( X11DRV_PDEVICE *physDev, const POINT* pt, INT count )
INT oldwidth;
register int i;
XPoint *points;
DC *dc = physDev->dc;
if((oldwidth = physDev->pen.width) == 0) physDev->pen.width = 1;
......@@ -986,8 +986,10 @@ X11DRV_Polyline( X11DRV_PDEVICE *physDev, const POINT* pt, INT count )
}
for (i = 0; i < count; i++)
{
points[i].x = physDev->org.x + INTERNAL_XWPTODP( dc, pt[i].x, pt[i].y );
points[i].y = physDev->org.y + INTERNAL_YWPTODP( dc, pt[i].x, pt[i].y );
POINT tmp = pt[i];
LPtoDP(physDev->hdc, &tmp, 1);
points[i].x = physDev->org.x + tmp.x;
points[i].y = physDev->org.y + tmp.y;
}
if (X11DRV_SetupGCForPen ( physDev ))
......@@ -1016,7 +1018,6 @@ X11DRV_Polygon( X11DRV_PDEVICE *physDev, const POINT* pt, INT count )
{
register int i;
XPoint *points;
DC *dc = physDev->dc;
BOOL update = FALSE;
if (!(points = HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint) * (count+1) )))
......@@ -1026,8 +1027,10 @@ X11DRV_Polygon( X11DRV_PDEVICE *physDev, const POINT* pt, INT count )
}
for (i = 0; i < count; i++)
{
points[i].x = physDev->org.x + INTERNAL_XWPTODP( dc, pt[i].x, pt[i].y );
points[i].y = physDev->org.y + INTERNAL_YWPTODP( dc, pt[i].x, pt[i].y );
POINT tmp = pt[i];
LPtoDP(physDev->hdc, &tmp, 1);
points[i].x = physDev->org.x + tmp.x;
points[i].y = physDev->org.y + tmp.y;
}
points[count] = points[0];
......@@ -1062,7 +1065,6 @@ BOOL
X11DRV_PolyPolygon( X11DRV_PDEVICE *physDev, const POINT* pt, const INT* counts, UINT polygons)
{
HRGN hrgn;
DC *dc = physDev->dc;
/* FIXME: The points should be converted to device coords before */
/* creating the region. */
......@@ -1091,8 +1093,10 @@ X11DRV_PolyPolygon( X11DRV_PDEVICE *physDev, const POINT* pt, const INT* counts,
{
for (j = 0; j < counts[i]; j++)
{
points[j].x = physDev->org.x + INTERNAL_XWPTODP( dc, pt->x, pt->y );
points[j].y = physDev->org.y + INTERNAL_YWPTODP( dc, pt->x, pt->y );
POINT tmp = *pt;
LPtoDP(physDev->hdc, &tmp, 1);
points[j].x = physDev->org.x + tmp.x;
points[j].y = physDev->org.y + tmp.y;
pt++;
}
points[j] = points[0];
......@@ -1115,8 +1119,6 @@ X11DRV_PolyPolygon( X11DRV_PDEVICE *physDev, const POINT* pt, const INT* counts,
BOOL
X11DRV_PolyPolyline( X11DRV_PDEVICE *physDev, const POINT* pt, const DWORD* counts, DWORD polylines )
{
DC *dc = physDev->dc;
if (X11DRV_SetupGCForPen ( physDev ))
{
int i, j, max = 0;
......@@ -1135,8 +1137,10 @@ X11DRV_PolyPolyline( X11DRV_PDEVICE *physDev, const POINT* pt, const DWORD* coun
{
for (j = 0; j < counts[i]; j++)
{
points[j].x = physDev->org.x + INTERNAL_XWPTODP( dc, pt->x, pt->y );
points[j].y = physDev->org.y + INTERNAL_YWPTODP( dc, pt->x, pt->y );
POINT tmp = *pt;
LPtoDP(physDev->hdc, &tmp, 1);
points[j].x = physDev->org.x + tmp.x;
points[j].y = physDev->org.y + tmp.y;
pt++;
}
TSXDrawLines( gdi_display, physDev->drawable, physDev->gc,
......@@ -1234,7 +1238,7 @@ X11DRV_ExtFloodFill( X11DRV_PDEVICE *physDev, INT x, INT y, COLORREF color,
TRACE("X11DRV_ExtFloodFill %d,%d %06lx %d\n", x, y, color, fillType );
if (!PtVisible( dc->hSelf, x, y )) return FALSE;
if (!PtVisible( physDev->hdc, x, y )) return FALSE;
if (GetRgnBox( dc->hGCClipRgn, &rect ) == ERROR) return FALSE;
if (!(image = TSXGetImage( gdi_display, physDev->drawable,
......@@ -1246,6 +1250,10 @@ X11DRV_ExtFloodFill( X11DRV_PDEVICE *physDev, INT x, INT y, COLORREF color,
if (X11DRV_SetupGCForBrush( physDev ))
{
POINT pt;
pt.x = x;
pt.y = y;
LPtoDP(physDev->hdc, &pt, 1);
/* Update the pixmap from the DIB section */
X11DRV_LockDIBSection(physDev, DIB_Status_GdiMod, FALSE);
......@@ -1253,8 +1261,8 @@ X11DRV_ExtFloodFill( X11DRV_PDEVICE *physDev, INT x, INT y, COLORREF color,
wine_tsx11_lock();
XSetFunction( gdi_display, physDev->gc, GXcopy );
X11DRV_InternalFloodFill(image, physDev,
XLPTODP(dc,x) - rect.left,
YLPTODP(dc,y) - rect.top,
physDev->org.x + pt.x - rect.left,
physDev->org.y + pt.y - rect.top,
rect.left, rect.top,
X11DRV_PALETTE_ToPhysical( physDev, color ),
fillType );
......
......@@ -58,6 +58,7 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
XChar2b *str2b = NULL;
BOOL dibUpdateFlag = FALSE;
BOOL result = TRUE;
POINT pt;
DC *dc = physDev->dc;
if(dc->gdiFont)
......@@ -105,24 +106,26 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
return FALSE;
if (!X11DRV_GetTextExtentPoint( physDev, wstr, count, &sz ))
return FALSE;
rect.left = INTERNAL_XWPTODP( dc, x, y );
rect.right = INTERNAL_XWPTODP( dc, x+sz.cx, y+sz.cy );
rect.top = INTERNAL_YWPTODP( dc, x, y );
rect.bottom = INTERNAL_YWPTODP( dc, x+sz.cx, y+sz.cy );
rect.left = x;
rect.right = x + sz.cx;
rect.top = y;
rect.bottom = y + sz.cy;
}
else
{
rect.left = INTERNAL_XWPTODP( dc, lprect->left, lprect->top );
rect.right = INTERNAL_XWPTODP( dc, lprect->right, lprect->bottom );
rect.top = INTERNAL_YWPTODP( dc, lprect->left, lprect->top );
rect.bottom = INTERNAL_YWPTODP( dc, lprect->right, lprect->bottom );
rect = *lprect;
}
LPtoDP(physDev->hdc, (POINT*)&rect, 2);
if (rect.right < rect.left) SWAP_INT( rect.left, rect.right );
if (rect.bottom < rect.top) SWAP_INT( rect.top, rect.bottom );
}
x = INTERNAL_XWPTODP( dc, x, y );
y = INTERNAL_YWPTODP( dc, x, y );
pt.x = x;
pt.y = y;
LPtoDP(physDev->hdc, &pt, 1);
x = pt.x;
y = pt.y;
TRACE("\treal coord: x=%i, y=%i, rect=(%d,%d - %d,%d)\n",
x, y, rect.left, rect.top, rect.right, rect.bottom);
......@@ -168,16 +171,22 @@ X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
{
case TA_LEFT:
if (dc->textAlign & TA_UPDATECP) {
dc->CursPosX = INTERNAL_XDPTOWP( dc, x + xwidth, y - ywidth );
dc->CursPosY = INTERNAL_YDPTOWP( dc, x + xwidth, y - ywidth );
pt.x = x + xwidth;
pt.y = y - ywidth;
DPtoLP(physDev->hdc, &pt, 1);
dc->CursPosX = pt.x;
dc->CursPosY = pt.y;
}
break;
case TA_RIGHT:
x -= xwidth;
y += ywidth;
if (dc->textAlign & TA_UPDATECP) {
dc->CursPosX = INTERNAL_XDPTOWP( dc, x, y );
dc->CursPosY = INTERNAL_YDPTOWP( dc, x, y );
pt.x = x;
pt.y = y;
DPtoLP(physDev->hdc, &pt, 1);
dc->CursPosX = pt.x;
dc->CursPosY = pt.y;
}
break;
case TA_CENTER:
......
......@@ -290,14 +290,6 @@ typedef struct tagDC_FUNCS
#define METAFILE_MEMORY 1
#define METAFILE_DISK 2
/* Device <-> logical coords conversion */
/* A floating point version of the POINT structure */
typedef struct tagFLOAT_POINT
{
FLOAT x, y;
} FLOAT_POINT;
/* Rounds a floating point number to integer. The world-to-viewport
* transformation process is done in floating point internally. This function
* is then used to round these coordinates to integer values.
......@@ -307,163 +299,6 @@ static inline INT WINE_UNUSED GDI_ROUND(FLOAT val)
return (int)floor(val + 0.5);
}
/* Performs a viewport-to-world transformation on the specified point (which
* is in floating point format). Returns TRUE if successful, else FALSE.
*/
static inline BOOL WINE_UNUSED INTERNAL_DPTOLP_FLOAT(DC *dc, FLOAT_POINT *point)
{
FLOAT x, y;
/* Check that the viewport-to-world transformation is valid */
if (!dc->vport2WorldValid)
return FALSE;
/* Perform the transformation */
x = point->x;
y = point->y;
point->x = x * dc->xformVport2World.eM11 +
y * dc->xformVport2World.eM21 +
dc->xformVport2World.eDx;
point->y = x * dc->xformVport2World.eM12 +
y * dc->xformVport2World.eM22 +
dc->xformVport2World.eDy;
return TRUE;
}
/* Performs a viewport-to-world transformation on the specified point (which
* is in integer format). Returns TRUE if successful, else FALSE.
*/
static inline BOOL WINE_UNUSED INTERNAL_DPTOLP(DC *dc, LPPOINT point)
{
FLOAT_POINT floatPoint;
/* Perform operation with floating point */
floatPoint.x=(FLOAT)point->x;
floatPoint.y=(FLOAT)point->y;
if (!INTERNAL_DPTOLP_FLOAT(dc, &floatPoint))
return FALSE;
/* Round to integers */
point->x = GDI_ROUND(floatPoint.x);
point->y = GDI_ROUND(floatPoint.y);
return TRUE;
}
/* Performs a world-to-viewport transformation on the specified point (which
* is in floating point format).
*/
static inline void WINE_UNUSED INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
{
FLOAT x, y;
/* Perform the transformation */
x = point->x;
y = point->y;
point->x = x * dc->xformWorld2Vport.eM11 +
y * dc->xformWorld2Vport.eM21 +
dc->xformWorld2Vport.eDx;
point->y = x * dc->xformWorld2Vport.eM12 +
y * dc->xformWorld2Vport.eM22 +
dc->xformWorld2Vport.eDy;
}
/* Performs a world-to-viewport transformation on the specified point (which
* is in integer format).
*/
static inline void WINE_UNUSED INTERNAL_LPTODP(DC *dc, LPPOINT point)
{
FLOAT_POINT floatPoint;
/* Perform operation with floating point */
floatPoint.x=(FLOAT)point->x;
floatPoint.y=(FLOAT)point->y;
INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
/* Round to integers */
point->x = GDI_ROUND(floatPoint.x);
point->y = GDI_ROUND(floatPoint.y);
}
/* Performs a world-to-viewport transformation on the specified point (which
* is in integer format).
*/
static inline INT WINE_UNUSED INTERNAL_XWPTODP(DC *dc, INT x, INT y)
{
FLOAT_POINT floatPoint;
/* Perform operation with floating point */
floatPoint.x=(FLOAT)x;
floatPoint.y=(FLOAT)y;
INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
/* Round to integers */
return GDI_ROUND(floatPoint.x);
}
/* Performs a world-to-viewport transformation on the specified point (which
* is in integer format).
*/
static inline INT WINE_UNUSED INTERNAL_YWPTODP(DC *dc, INT x, INT y)
{
FLOAT_POINT floatPoint;
/* Perform operation with floating point */
floatPoint.x=(FLOAT)x;
floatPoint.y=(FLOAT)y;
INTERNAL_LPTODP_FLOAT(dc, &floatPoint);
/* Round to integers */
return GDI_ROUND(floatPoint.y);
}
/* Performs a viewport-to-world transformation on the specified point (which
* is in integer format).
*/
static inline INT WINE_UNUSED INTERNAL_XDPTOWP(DC *dc, INT x, INT y)
{
FLOAT_POINT floatPoint;
/* Perform operation with floating point */
floatPoint.x=(FLOAT)x;
floatPoint.y=(FLOAT)y;
INTERNAL_DPTOLP_FLOAT(dc, &floatPoint);
/* Round to integers */
return GDI_ROUND(floatPoint.x);
}
/* Performs a viewport-to-world transformation on the specified point (which
* is in integer format).
*/
static inline INT WINE_UNUSED INTERNAL_YDPTOWP(DC *dc, INT x, INT y)
{
FLOAT_POINT floatPoint;
/* Perform operation with floating point */
floatPoint.x=(FLOAT)x;
floatPoint.y=(FLOAT)y;
INTERNAL_DPTOLP_FLOAT(dc, &floatPoint);
/* Round to integers */
return GDI_ROUND(floatPoint.y);
}
#define XDPTOLP(dc,x) \
(MulDiv(((x)-(dc)->vportOrgX), (dc)->wndExtX, (dc)->vportExtX) + (dc)->wndOrgX)
#define YDPTOLP(dc,y) \
(MulDiv(((y)-(dc)->vportOrgY), (dc)->wndExtY, (dc)->vportExtY) + (dc)->wndOrgY)
#define XLPTODP(dc,x) \
(MulDiv(((x)-(dc)->wndOrgX), (dc)->vportExtX, (dc)->wndExtX) + (dc)->vportOrgX)
#define YLPTODP(dc,y) \
(MulDiv(((y)-(dc)->wndOrgY), (dc)->vportExtY, (dc)->wndExtY) + (dc)->vportOrgY)
/* World -> Device size conversion */
/* Performs a world-to-viewport transformation on the specified width (which
......
......@@ -228,12 +228,14 @@ INT WINAPI ExcludeClipRect( HDC hdc, INT left, INT top,
ret = dc->funcs->pExcludeClipRect( dc->physDev, left, top, right, bottom );
else
{
left = XLPTODP( dc, left );
right = XLPTODP( dc, right );
top = YLPTODP( dc, top );
bottom = YLPTODP( dc, bottom );
if (!(newRgn = CreateRectRgn( left, top, right, bottom ))) ret = ERROR;
RECT rect;
rect.left = left;
rect.top = top;
rect.right = right;
rect.bottom = bottom;
LPtoDP( hdc, (POINT*)&rect, 2 );
if (!(newRgn = CreateRectRgn( rect.left, rect.top, rect.right, rect.bottom ))) ret = ERROR;
else
{
if (!dc->hClipRgn)
......@@ -271,27 +273,30 @@ INT WINAPI IntersectClipRect( HDC hdc, INT left, INT top,
DC *dc = DC_GetDCUpdate( hdc );
if (!dc) return ERROR;
TRACE("%04x %dx%d,%dx%d\n", hdc, left, top, right, bottom );
TRACE("%04x %d,%d - %d,%d\n", hdc, left, top, right, bottom );
if(dc->funcs->pIntersectClipRect)
ret = dc->funcs->pIntersectClipRect( dc->physDev, left, top, right, bottom );
else
{
left = XLPTODP( dc, left );
right = XLPTODP( dc, right );
top = YLPTODP( dc, top );
bottom = YLPTODP( dc, bottom );
RECT rect;
rect.left = left;
rect.top = top;
rect.right = right;
rect.bottom = bottom;
LPtoDP( hdc, (POINT*)&rect, 2 );
if (!dc->hClipRgn)
{
dc->hClipRgn = CreateRectRgn( left, top, right, bottom );
dc->hClipRgn = CreateRectRgn( rect.left, rect.top, rect.right, rect.bottom );
ret = SIMPLEREGION;
}
else
{
HRGN newRgn;
if (!(newRgn = CreateRectRgn( left, top, right, bottom ))) ret = ERROR;
if (!(newRgn = CreateRectRgn( rect.left, rect.top, rect.right, rect.bottom))) ret = ERROR;
else
{
ret = CombineRgn( dc->hClipRgn, dc->hClipRgn, newRgn, RGN_AND );
......@@ -313,17 +318,19 @@ INT16 WINAPI ExcludeVisRect16( HDC16 hdc, INT16 left, INT16 top,
{
HRGN tempRgn;
INT16 ret;
RECT rect;
DC * dc = DC_GetDCUpdate( hdc );
if (!dc) return ERROR;
left = XLPTODP( dc, left );
right = XLPTODP( dc, right );
top = YLPTODP( dc, top );
bottom = YLPTODP( dc, bottom );
rect.left = left;
rect.top = top;
rect.right = right;
rect.bottom = bottom;
LPtoDP( hdc, (POINT*)&rect, 2 );
TRACE("%04x %dx%d,%dx%d\n", hdc, left, top, right, bottom );
TRACE("%04x %d,%d - %d,%d\n", hdc, rect.left, rect.top, rect.right, rect.bottom );
if (!(tempRgn = CreateRectRgn( left, top, right, bottom ))) ret = ERROR;
if (!(tempRgn = CreateRectRgn( rect.left, rect.top, rect.right, rect.bottom ))) ret = ERROR;
else
{
ret = CombineRgn( dc->hVisRgn, dc->hVisRgn, tempRgn, RGN_DIFF );
......@@ -343,17 +350,19 @@ INT16 WINAPI IntersectVisRect16( HDC16 hdc, INT16 left, INT16 top,
{
HRGN tempRgn;
INT16 ret;
RECT rect;
DC * dc = DC_GetDCUpdate( hdc );
if (!dc) return ERROR;
left = XLPTODP( dc, left );
right = XLPTODP( dc, right );
top = YLPTODP( dc, top );
bottom = YLPTODP( dc, bottom );
rect.left = left;
rect.top = top;
rect.right = right;
rect.bottom = bottom;
LPtoDP( hdc, (POINT*)&rect, 2 );
TRACE("%04x %dx%d,%dx%d\n", hdc, left, top, right, bottom );
TRACE("%04x %d,%d - %d,%d\n", hdc, rect.left, rect.top, rect.right, rect.bottom );
if (!(tempRgn = CreateRectRgn( left, top, right, bottom ))) ret = ERROR;
if (!(tempRgn = CreateRectRgn( rect.left, rect.top, rect.right, rect.bottom ))) ret = ERROR;
else
{
ret = CombineRgn( dc->hVisRgn, dc->hVisRgn, tempRgn, RGN_AND );
......@@ -386,7 +395,12 @@ BOOL WINAPI PtVisible( HDC hdc, INT x, INT y )
if (!dc) return FALSE;
if (dc->hGCClipRgn)
{
ret = PtInRegion( dc->hGCClipRgn, XLPTODP(dc,x), YLPTODP(dc,y) );
POINT pt;
pt.x = x;
pt.y = y;
LPtoDP( hdc, &pt, 1 );
ret = PtInRegion( dc->hGCClipRgn, pt.x, pt.y );
}
GDI_ReleaseObj( hdc );
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment