Commit 62f824f7 authored by Alexandre Julliard's avatar Alexandre Julliard

Avoid calling the *Rect USER functions from inside GDI.

Moved a few USER functions to a more appropriate location.
parent fe08568a
...@@ -845,8 +845,14 @@ static void BITBLT_GetSrcAreaStretch( DC *dcSrc, DC *dcDst, ...@@ -845,8 +845,14 @@ static void BITBLT_GetSrcAreaStretch( DC *dcSrc, DC *dcDst,
if (widthDst < 0) xDst += widthDst; if (widthDst < 0) xDst += widthDst;
if (heightSrc < 0) ySrc += heightSrc; if (heightSrc < 0) ySrc += heightSrc;
if (heightDst < 0) yDst += heightDst; if (heightDst < 0) yDst += heightDst;
OffsetRect( &rectSrc, -xSrc, -ySrc ); rectSrc.left -= xSrc;
OffsetRect( &rectDst, -xDst, -yDst ); rectSrc.right -= xSrc;
rectSrc.top -= ySrc;
rectSrc.bottom -= ySrc;
rectDst.left -= xDst;
rectDst.right -= xDst;
rectDst.top -= yDst;
rectDst.bottom -= yDst;
/* FIXME: avoid BadMatch errors */ /* FIXME: avoid BadMatch errors */
imageSrc = XGetImage( display, physDevSrc->drawable, imageSrc = XGetImage( display, physDevSrc->drawable,
...@@ -1056,7 +1062,10 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, ...@@ -1056,7 +1062,10 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst,
/* Get the destination visible rectangle */ /* Get the destination visible rectangle */
SetRect( &rect, xDst, yDst, xDst + widthDst, yDst + heightDst ); rect.left = xDst;
rect.top = yDst;
rect.right = xDst + widthDst;
rect.bottom = yDst + heightDst;
if (widthDst < 0) SWAP_INT32( &rect.left, &rect.right ); if (widthDst < 0) SWAP_INT32( &rect.left, &rect.right );
if (heightDst < 0) SWAP_INT32( &rect.top, &rect.bottom ); if (heightDst < 0) SWAP_INT32( &rect.top, &rect.bottom );
GetRgnBox( dcDst->w.hGCClipRgn, &clipRect ); GetRgnBox( dcDst->w.hGCClipRgn, &clipRect );
...@@ -1065,7 +1074,10 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, ...@@ -1065,7 +1074,10 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst,
/* Get the source visible rectangle */ /* Get the source visible rectangle */
if (!dcSrc) return TRUE; if (!dcSrc) return TRUE;
SetRect( &rect, xSrc, ySrc, xSrc + widthSrc, ySrc + heightSrc ); rect.left = xSrc;
rect.top = ySrc;
rect.right = xSrc + widthSrc;
rect.bottom = ySrc + heightSrc;
if (widthSrc < 0) SWAP_INT32( &rect.left, &rect.right ); if (widthSrc < 0) SWAP_INT32( &rect.left, &rect.right );
if (heightSrc < 0) SWAP_INT32( &rect.top, &rect.bottom ); if (heightSrc < 0) SWAP_INT32( &rect.top, &rect.bottom );
/* Apparently the clipping and visible regions are only for output, /* Apparently the clipping and visible regions are only for output,
...@@ -1077,10 +1089,16 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, ...@@ -1077,10 +1089,16 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst,
if ((widthSrc == widthDst) && (heightSrc == heightDst)) /* no stretching */ if ((widthSrc == widthDst) && (heightSrc == heightDst)) /* no stretching */
{ {
OffsetRect( visRectSrc, xDst - xSrc, yDst - ySrc ); visRectSrc->left += xDst - xSrc;
visRectSrc->right += xDst - xSrc;
visRectSrc->top += yDst - ySrc;
visRectSrc->bottom += yDst - ySrc;
if (!IntersectRect( &rect, visRectSrc, visRectDst )) return FALSE; if (!IntersectRect( &rect, visRectSrc, visRectDst )) return FALSE;
*visRectSrc = *visRectDst = rect; *visRectSrc = *visRectDst = rect;
OffsetRect( visRectSrc, xSrc - xDst, ySrc - yDst ); visRectSrc->left += xSrc - xDst;
visRectSrc->right += xSrc - xDst;
visRectSrc->top += ySrc - yDst;
visRectSrc->bottom += ySrc - yDst;
} }
else /* stretching */ else /* stretching */
{ {
...@@ -1091,7 +1109,12 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, ...@@ -1091,7 +1109,12 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst,
rect.bottom = yDst + ((visRectSrc->bottom - ySrc)*heightDst)/heightSrc; rect.bottom = yDst + ((visRectSrc->bottom - ySrc)*heightDst)/heightSrc;
if (rect.left > rect.right) SWAP_INT32( &rect.left, &rect.right ); if (rect.left > rect.right) SWAP_INT32( &rect.left, &rect.right );
if (rect.top > rect.bottom) SWAP_INT32( &rect.top, &rect.bottom ); if (rect.top > rect.bottom) SWAP_INT32( &rect.top, &rect.bottom );
InflateRect( &rect, 1, 1 ); /* Avoid rounding errors */
/* Avoid rounding errors */
rect.left--;
rect.top--;
rect.right++;
rect.bottom++;
if (!IntersectRect( visRectDst, &rect, visRectDst )) return FALSE; if (!IntersectRect( visRectDst, &rect, visRectDst )) return FALSE;
/* Map destination rectangle back to source coordinates */ /* Map destination rectangle back to source coordinates */
...@@ -1102,7 +1125,12 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, ...@@ -1102,7 +1125,12 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst,
rect.bottom = ySrc + ((visRectDst->bottom - yDst)*heightSrc)/heightDst; rect.bottom = ySrc + ((visRectDst->bottom - yDst)*heightSrc)/heightDst;
if (rect.left > rect.right) SWAP_INT32( &rect.left, &rect.right ); if (rect.left > rect.right) SWAP_INT32( &rect.left, &rect.right );
if (rect.top > rect.bottom) SWAP_INT32( &rect.top, &rect.bottom ); if (rect.top > rect.bottom) SWAP_INT32( &rect.top, &rect.bottom );
InflateRect( &rect, 1, 1 ); /* Avoid rounding errors */
/* Avoid rounding errors */
rect.left--;
rect.top--;
rect.right++;
rect.bottom++;
if (!IntersectRect( visRectSrc, &rect, visRectSrc )) return FALSE; if (!IntersectRect( visRectSrc, &rect, visRectSrc )) return FALSE;
} }
return TRUE; return TRUE;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "winnt.h" #include "winnt.h"
#include "callback.h"
#include "msdos.h" #include "msdos.h"
#include "file.h" #include "file.h"
#include "miscemu.h" #include "miscemu.h"
...@@ -357,11 +359,11 @@ void DOSVM_Wait( int read_pipe, HANDLE hObject ) ...@@ -357,11 +359,11 @@ void DOSVM_Wait( int read_pipe, HANDLE hObject )
do { do {
/* check for messages (waste time before the response check below) */ /* check for messages (waste time before the response check below) */
while (PeekMessageA(&msg,0,0,0,PM_REMOVE|PM_NOYIELD)) { while (Callout.PeekMessageA(&msg,0,0,0,PM_REMOVE|PM_NOYIELD)) {
/* got a message */ /* got a message */
DOSVM_ProcessMessage(lpDosTask,&msg); DOSVM_ProcessMessage(lpDosTask,&msg);
/* we don't need a TranslateMessage here */ /* we don't need a TranslateMessage here */
DispatchMessageA(&msg); Callout.DispatchMessageA(&msg);
got_msg = TRUE; got_msg = TRUE;
} }
if (read_pipe == -1) { if (read_pipe == -1) {
......
...@@ -21,7 +21,6 @@ C_SRCS = \ ...@@ -21,7 +21,6 @@ C_SRCS = \
port.c \ port.c \
printdrv.c \ printdrv.c \
registry.c \ registry.c \
spy.c \
system.c \ system.c \
toolhelp.c \ toolhelp.c \
tweak.c \ tweak.c \
......
...@@ -10,7 +10,6 @@ C_SRCS = \ ...@@ -10,7 +10,6 @@ C_SRCS = \
brush.c \ brush.c \
clipping.c \ clipping.c \
color.c \ color.c \
cursoricon.c \
dc.c \ dc.c \
dcvalues.c \ dcvalues.c \
dib.c \ dib.c \
......
...@@ -440,7 +440,10 @@ BOOL16 WINAPI RectVisible16( HDC16 hdc, const RECT16* rect ) ...@@ -440,7 +440,10 @@ BOOL16 WINAPI RectVisible16( HDC16 hdc, const RECT16* rect )
/* copy rectangle to avoid overwriting by LPtoDP */ /* copy rectangle to avoid overwriting by LPtoDP */
tmpRect = *rect; tmpRect = *rect;
LPtoDP16( hdc, (LPPOINT16)&tmpRect, 2 ); LPtoDP16( hdc, (LPPOINT16)&tmpRect, 2 );
OffsetRect16( &tmpRect, dc->w.DCOrgX, dc->w.DCOrgY ); tmpRect.left += dc->w.DCOrgX;
tmpRect.right += dc->w.DCOrgX;
tmpRect.top += dc->w.DCOrgY;
tmpRect.bottom += dc->w.DCOrgY;
return RectInRegion16( dc->w.hGCClipRgn, &tmpRect ); return RectInRegion16( dc->w.hGCClipRgn, &tmpRect );
} }
...@@ -465,7 +468,10 @@ INT16 WINAPI GetClipBox16( HDC16 hdc, LPRECT16 rect ) ...@@ -465,7 +468,10 @@ INT16 WINAPI GetClipBox16( HDC16 hdc, LPRECT16 rect )
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR; if (!dc) return ERROR;
ret = GetRgnBox16( dc->w.hGCClipRgn, rect ); ret = GetRgnBox16( dc->w.hGCClipRgn, rect );
OffsetRect16( rect, -dc->w.DCOrgX, -dc->w.DCOrgY ); rect->left -= dc->w.DCOrgX;
rect->right -= dc->w.DCOrgX;
rect->top -= dc->w.DCOrgY;
rect->bottom -= dc->w.DCOrgY;
DPtoLP16( hdc, (LPPOINT16)rect, 2 ); DPtoLP16( hdc, (LPPOINT16)rect, 2 );
TRACE("%d,%d-%d,%d\n", rect->left,rect->top,rect->right,rect->bottom ); TRACE("%d,%d-%d,%d\n", rect->left,rect->top,rect->right,rect->bottom );
return ret; return ret;
...@@ -481,7 +487,10 @@ INT WINAPI GetClipBox( HDC hdc, LPRECT rect ) ...@@ -481,7 +487,10 @@ INT WINAPI GetClipBox( HDC hdc, LPRECT rect )
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR; if (!dc) return ERROR;
ret = GetRgnBox( dc->w.hGCClipRgn, rect ); ret = GetRgnBox( dc->w.hGCClipRgn, rect );
OffsetRect( rect, -dc->w.DCOrgX, -dc->w.DCOrgY ); rect->left -= dc->w.DCOrgX;
rect->right -= dc->w.DCOrgX;
rect->top -= dc->w.DCOrgY;
rect->bottom -= dc->w.DCOrgY;
DPtoLP( hdc, (LPPOINT)rect, 2 ); DPtoLP( hdc, (LPPOINT)rect, 2 );
return ret; return ret;
} }
......
...@@ -1037,17 +1037,26 @@ BOOL WINAPI EqualRgn( HRGN hrgn1, HRGN hrgn2 ) ...@@ -1037,17 +1037,26 @@ BOOL WINAPI EqualRgn( HRGN hrgn1, HRGN hrgn2 )
{ {
int i; int i;
if ( obj1->rgn->numRects != obj2->rgn->numRects ) goto done;
if ( obj1->rgn->numRects == 0 )
{
ret = TRUE; ret = TRUE;
if ( obj1->rgn->numRects != obj2->rgn->numRects ) ret = FALSE; goto done;
else if ( obj1->rgn->numRects == 0 ) ret = TRUE;
else if ( !EqualRect(&obj1->rgn->extents, &obj2->rgn->extents) )
ret = FALSE;
else for( i = 0; i < obj1->rgn->numRects; i++ ) {
if (!EqualRect(obj1->rgn->rects + i, obj2->rgn->rects + i)) {
ret = FALSE;
break;
} }
if (obj1->rgn->extents.left != obj2->rgn->extents.left) goto done;
if (obj1->rgn->extents.right != obj2->rgn->extents.right) goto done;
if (obj1->rgn->extents.top != obj2->rgn->extents.top) goto done;
if (obj1->rgn->extents.bottom != obj2->rgn->extents.bottom) goto done;
for( i = 0; i < obj1->rgn->numRects; i++ )
{
if (obj1->rgn->rects[i].left != obj2->rgn->rects[i].left) goto done;
if (obj1->rgn->rects[i].right != obj2->rgn->rects[i].right) goto done;
if (obj1->rgn->rects[i].top != obj2->rgn->rects[i].top) goto done;
if (obj1->rgn->rects[i].bottom != obj2->rgn->rects[i].bottom) goto done;
} }
ret = TRUE;
done:
GDI_HEAP_UNLOCK(hrgn2); GDI_HEAP_UNLOCK(hrgn2);
} }
GDI_HEAP_UNLOCK(hrgn1); GDI_HEAP_UNLOCK(hrgn1);
...@@ -1067,7 +1076,7 @@ static void REGION_UnionRectWithRegion(const RECT *rect, WINEREGION *rgn) ...@@ -1067,7 +1076,7 @@ static void REGION_UnionRectWithRegion(const RECT *rect, WINEREGION *rgn)
region.numRects = 1; region.numRects = 1;
region.size = 1; region.size = 1;
region.type = SIMPLEREGION; region.type = SIMPLEREGION;
CopyRect(&(region.extents), rect); region.extents = *rect;
REGION_UnionRegion(rgn, rgn, &region); REGION_UnionRegion(rgn, rgn, &region);
return; return;
} }
...@@ -2964,7 +2973,10 @@ static BOOL REGION_CropAndOffsetRegion(const POINT* off, const RECT *rect, WINER ...@@ -2964,7 +2973,10 @@ static BOOL REGION_CropAndOffsetRegion(const POINT* off, const RECT *rect, WINER
xrect[i].top = rgnSrc->rects[i].top + off->y; xrect[i].top = rgnSrc->rects[i].top + off->y;
xrect[i].bottom = rgnSrc->rects[i].bottom + off->y; xrect[i].bottom = rgnSrc->rects[i].bottom + off->y;
} }
OffsetRect( &rgnDst->extents, off->x, off->y ); rgnDst->extents.left += off->x;
rgnDst->extents.right += off->x;
rgnDst->extents.top += off->y;
rgnDst->extents.bottom += off->y;
} }
else else
memcpy( xrect, rgnSrc->rects, rgnDst->numRects * sizeof(RECT)); memcpy( xrect, rgnSrc->rects, rgnDst->numRects * sizeof(RECT));
...@@ -2972,7 +2984,9 @@ static BOOL REGION_CropAndOffsetRegion(const POINT* off, const RECT *rect, WINER ...@@ -2972,7 +2984,9 @@ static BOOL REGION_CropAndOffsetRegion(const POINT* off, const RECT *rect, WINER
} else } else
return FALSE; return FALSE;
} }
else if( IsRectEmpty(rect) || !EXTENTCHECK(rect, &rgnSrc->extents) ) else if ((rect->left >= rect->right) ||
(rect->top >= rect->bottom) ||
!EXTENTCHECK(rect, &rgnSrc->extents))
{ {
empty: empty:
if( !rgnDst->rects ) if( !rgnDst->rects )
......
...@@ -453,7 +453,6 @@ static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb, ...@@ -453,7 +453,6 @@ static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb,
HDC memdc = CreateCompatibleDC(hdc); HDC memdc = CreateCompatibleDC(hdc);
int slen = len; int slen = len;
BOOL retval = TRUE; BOOL retval = TRUE;
RECT r;
COLORREF fg, bg; COLORREF fg, bg;
if(!hdc) return FALSE; if(!hdc) return FALSE;
...@@ -481,13 +480,11 @@ static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb, ...@@ -481,13 +480,11 @@ static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb,
if(cy == 0) cy = s.cy; if(cy == 0) cy = s.cy;
} }
r.left = r.top = 0;
r.right = cx;
r.bottom = cy;
hbm = CreateBitmap(cx, cy, 1, 1, NULL); hbm = CreateBitmap(cx, cy, 1, 1, NULL);
hbmsave = (HBITMAP)SelectObject(memdc, hbm); hbmsave = (HBITMAP)SelectObject(memdc, hbm);
FillRect(memdc, &r, (HBRUSH)GetStockObject(BLACK_BRUSH)); hbsave = SelectObject( memdc, GetStockObject(BLACK_BRUSH) );
PatBlt( memdc, 0, 0, cx, cy, PATCOPY );
SelectObject( memdc, hbsave );
SetTextColor(memdc, RGB(255, 255, 255)); SetTextColor(memdc, RGB(255, 255, 255));
SetBkColor(memdc, RGB(0, 0, 0)); SetBkColor(memdc, RGB(0, 0, 0));
hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT)); hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
...@@ -630,7 +627,10 @@ LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr, ...@@ -630,7 +627,10 @@ LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr,
if (fDisplayText) if (fDisplayText)
{ {
RECT r; RECT r;
SetRect( &r, x, y, tabPos, y+HIWORD(extent) ); r.left = x;
r.top = y;
r.right = tabPos;
r.bottom = y + HIWORD(extent);
ExtTextOutA( hdc, x, y, ExtTextOutA( hdc, x, y,
GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0, GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
&r, lpstr, i, NULL ); &r, lpstr, i, NULL );
......
...@@ -9,6 +9,7 @@ C_SRCS = \ ...@@ -9,6 +9,7 @@ C_SRCS = \
caret.c \ caret.c \
class.c \ class.c \
clipboard.c \ clipboard.c \
cursoricon.c \
dce.c \ dce.c \
defdlg.c \ defdlg.c \
defwnd.c \ defwnd.c \
...@@ -29,8 +30,10 @@ C_SRCS = \ ...@@ -29,8 +30,10 @@ C_SRCS = \
queue.c \ queue.c \
rect.c \ rect.c \
scroll.c \ scroll.c \
spy.c \
syscolor.c \ syscolor.c \
sysmetrics.c \ sysmetrics.c \
sysparams.c \
timer.c \ timer.c \
user.c \ user.c \
win.c \ win.c \
......
...@@ -2493,23 +2493,6 @@ WORD WINAPI RegisterWindowMessageW( LPCWSTR str ) ...@@ -2493,23 +2493,6 @@ WORD WINAPI RegisterWindowMessageW( LPCWSTR str )
/*********************************************************************** /***********************************************************************
* GetTickCount (USER.13) (KERNEL32.299) System Time
* Returns the number of milliseconds, modulo 2^32, since the start
* of the current session.
*
* CONFORMANCE
*
* ECMA-234, Win32
*/
DWORD WINAPI GetTickCount(void)
{
struct timeval t;
gettimeofday( &t, NULL );
return ((t.tv_sec * 1000) + (t.tv_usec / 1000)) - MSG_WineStartTicks;
}
/***********************************************************************
* GetCurrentTime16 (USER.15) * GetCurrentTime16 (USER.15)
* *
* (effectively identical to GetTickCount) * (effectively identical to GetTickCount)
......
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