Implemented some of gdi region functions.

svn path=/trunk/; revision=3262
This commit is contained in:
Eugene Ingerman 2002-07-18 21:59:18 +00:00
parent 52102e72fc
commit 8d9c181908
10 changed files with 5139 additions and 3419 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,9 @@
#ifndef _WIN32K_CLIPRGN_H
#define _WIN32K_CLIPRGN_H
HRGN WINAPI SaveVisRgn(HDC hdc);
INT WINAPI SelectVisRgn(HDC hdc, HRGN hrgn);
int
STDCALL
W32kExcludeClipRect (

View file

@ -1,3 +1,10 @@
#ifndef __WIN32K_FLOAT_H
#define __WIN32K_FLOAT_H
#include <win32k/math.h>
#include <win32k/dc.h>
#include <freetype/freetype.h>
typedef struct tagFLOAT_POINT
{
FLOAT x, y;
@ -18,7 +25,7 @@ static inline INT GDI_ROUND(FLOAT val)
static inline void INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
{
FLOAT x, y;
/* Perform the transformation */
x = point->x;
y = point->y;
@ -33,16 +40,17 @@ static inline void INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
/* Performs a viewport-to-world transformation on the specified point (which
* is in integer format). Returns TRUE if successful, else FALSE.
*/
#if 0
static inline BOOL 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);
@ -56,17 +64,21 @@ static inline BOOL INTERNAL_DPTOLP(DC *dc, LPPOINT point)
static inline void 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);
}
#endif
#define MulDiv( x, y, z ) EngMulDiv( x, y, z )
#define XDPTOLP(dc,x) \
(MulDiv(((x)-(dc)->vportOrgX), (dc)->wndExtX, (dc)->vportExtX) + (dc)->wndOrgX)
#define YDPTOLP(dc,y) \
@ -86,3 +98,5 @@ static inline void INTERNAL_LPTODP(DC *dc, LPPOINT point)
MulDiv((x), (dc)->vportExtX, (dc)->wndExtX)
#define YLSTODS(dc,y) \
MulDiv((y), (dc)->vportExtY, (dc)->wndExtY)
#endif

View file

@ -2,32 +2,16 @@
#ifndef __WIN32K_REGION_H
#define __WIN32K_REGION_H
#include <structs.h>
#include <win32k/gdiobj.h>
/* Internal functions */
/*
#define RGNDATA_PtrToHandle(pRgn) \
((HRGN) GDIOBJ_PtrToHandle ((PGDIOBJ) pRgn, GO_REGION_MAGIC))
*/
#define RGNDATA_HandleToPtr(hRgn) \
((RGNDATA *) GDIOBJ_LockObj ((HGDIOBJ) hRgn, GO_REGION_MAGIC))
#define RGNDATA_FreeRgn(hRgn) GDIOBJ_FreeObj((HGDIOBJ)hRgn, GO_REGION_MAGIC)
#define RGNDATA_LockRgn(hRgn) ((PRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, GO_REGION_MAGIC))
#define RGNDATA_UnlockRgn(hRgn) GDIOBJ_UnlockObj((HGDIOBJ)hRgn, GO_REGION_MAGIC)
HRGN RGNDATA_AllocRgn(INT n);
/* call GDIOBJ_ReleaseObj when reference counting is added */
#define RGNDATA_Release(hRgn) {}
/* GDI logical region object */
typedef struct tagRGNOBJ
{
GDIOBJHDR header;
RGNDATA* rgn;
} RGNOBJ;
BOOL RGNDATA_InternalDelete( PRGNDATA Obj );
/* User entry points */
INT STDCALL
W32kGetBoxRgn(HRGN hRgn, PRECT Rect);
HRGN STDCALL
W32kCropRgn(HRGN hDest, HRGN hSrc, const RECT* Rect, const POINT* Point);
HRGN STDCALL
W32kUnionRectWithRgn(HRGN hDest, const RECT* Rect);

View file

@ -18,6 +18,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <windows.h>
double atan (double __x);
double atan2 (double __y, double __x);
@ -207,3 +208,50 @@ double tan (double __x)
return __value;
}
//FIXME! Is there a better algorithm. like FT_MulDiv
INT STDCALL EngMulDiv(
INT nMultiplicand,
INT nMultiplier,
INT nDivisor)
{
#if SIZEOF_LONG_LONG >= 8
long long ret;
if (!nDivisor) return -1;
/* We want to deal with a positive divisor to simplify the logic. */
if (nDivisor < 0)
{
nMultiplicand = - nMultiplicand;
nDivisor = -nDivisor;
}
/* If the result is positive, we "add" to round. else, we subtract to round. */
if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
ret = (((long long)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
else
ret = (((long long)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
if ((ret > 2147483647) || (ret < -2147483647)) return -1;
return ret;
#else
if (!nDivisor) return -1;
/* We want to deal with a positive divisor to simplify the logic. */
if (nDivisor < 0)
{
nMultiplicand = - nMultiplicand;
nDivisor = -nDivisor;
}
/* If the result is positive, we "add" to round. else, we subtract to round. */
if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
return ((nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
return ((nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
#endif
}

View file

@ -1,4 +1,4 @@
/* $Id: painting.c,v 1.1 2002/07/04 20:12:27 dwelch Exp $
/* $Id: painting.c,v 1.2 2002/07/18 21:59:18 ei Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -23,6 +23,7 @@
#include <user32/wininternal.h>
#include <include/rect.h>
#include <win32k/coord.h>
#include <win32k/region.h>
#define NDEBUG
@ -47,7 +48,7 @@ PaintDoPaint(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags, ULONG ExFlags)
BOOL bIcon = (Window->Style & WS_MINIMIZE) &&
NtUserGetClassLong(hWnd, GCL_HICON);
if (ExFlags & RDW_EX_DELAY_NCPAINT ||
if (ExFlags & RDW_EX_DELAY_NCPAINT ||
PaintHaveToDelayNCPaint(Window, 0))
{
ExFlags |= RDW_EX_DELAY_NCPAINT;
@ -66,12 +67,12 @@ PaintDoPaint(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags, ULONG ExFlags)
DCX_WINDOWPAINT | DCX_CACHE;
HRGN hRgnRet;
hRgnRet =
hRgnRet =
PaintUpdateNCRegion(Window,
hRgn,
UNC_REGION | UNC_CHECK |
((ExFlags & RDW_EX_TOPFRAME) ? UNC_ENTIRE : 0) |
((ExFlags & RDW_EX_DELAY_NCPAINT) ?
((ExFlags & RDW_EX_DELAY_NCPAINT) ?
UNC_DELAY_NCPAINT : 0));
if (hRgnRet != NULL)
{
@ -91,8 +92,8 @@ PaintDoPaint(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags, ULONG ExFlags)
}
if (hRgnRet)
{
W32kOffsetRgn(hRgnRet,
Window->WindowRect.left -
W32kOffsetRgn(hRgnRet,
Window->WindowRect.left -
Window->ClientRect.left,
Window->WindowRect.top -
Window->ClientRect.top);
@ -123,7 +124,7 @@ PaintDoPaint(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags, ULONG ExFlags)
}
VOID STATIC
PaintUpdateRgns(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags,
PaintUpdateRgns(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags,
BOOL First)
{
@ -173,11 +174,11 @@ PaintRedrawWindow(HWND hWnd, const RECT* UpdateRect, HRGN UpdateRgn,
{
if (Window->UpdateRegion != NULL)
{
hRgn = W32kCropRgn(0, UpdateRgn, NULL, &Pt);
hRgn = REGION_CropRgn(0, UpdateRgn, NULL, &Pt);
}
else
{
Window->UpdateRegion = W32kCropRgn(0, UpdateRgn, &Rect, &Pt);
Window->UpdateRegion = REGION_CropRgn(0, UpdateRgn, &Rect, &Pt);
}
}
else if (UpdateRect != NULL)
@ -282,7 +283,7 @@ PaintingFindWinToRepaint(HWND hWnd, PW32THREAD Thread)
return(hFoundWnd);
}
Status =
Status =
ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation->HandleTable,
hWnd,
otWindow,
@ -329,7 +330,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
if (Window->UpdateRegion > (HANDLE)1)
{
hRgnRet = W32kCropRgn(hRgn, Window->UpdateRegion, NULL, NULL);
hRgnRet = REGION_CropRgn(hRgn, Window->UpdateRegion, NULL, NULL);
}
else
{
@ -338,7 +339,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
return(hRgnRet);
}
if (Window->Flags & WINDOWOBJECT_NEED_NCPAINT &&
if (Window->Flags & WINDOWOBJECT_NEED_NCPAINT &&
!PaintHaveToDelayNCPaint(Window, Flags))
{
RECT UpdateRegionBox;
@ -355,7 +356,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
Rect.right != ClientRect.right || Rect.right != ClientRect.right)
{
hClip = Window->UpdateRegion;
Window->UpdateRegion = W32kCropRgn(hRgn, hClip,
Window->UpdateRegion = REGION_CropRgn(hRgn, hClip,
&Rect, NULL);
if (Flags & UNC_REGION)
{
@ -365,7 +366,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
if (Flags & UNC_CHECK)
{
W32kGetBoxRgn(Window->UpdateRegion, &UpdateRegionBox);
W32kGetRgnBox(Window->UpdateRegion, &UpdateRegionBox);
if (W32kIsEmptyRect(&UpdateRegionBox))
{
W32kDeleteObject(Window->UpdateRegion);
@ -377,7 +378,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
if (!hClip && Window->UpdateRegion && Flags & UNC_REGION)
{
hRgnRet = W32kCropRgn(hRgn, Window->UpdateRegion, NULL,
hRgnRet = REGION_CropRgn(hRgn, Window->UpdateRegion, NULL,
NULL);
}
}
@ -398,7 +399,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
{
if (Window->UpdateRegion > (HANDLE)1 && Flags & UNC_REGION)
{
hRgnRet = W32kCropRgn(hRgn, Window->UpdateRegion, NULL, NULL);
hRgnRet = REGION_CropRgn(hRgn, Window->UpdateRegion, NULL, NULL);
}
else if (Window->UpdateRegion == (HANDLE)1 && Flags & UNC_UPDATE)
{
@ -413,7 +414,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
if (hClip == NULL && Flags & UNC_ENTIRE)
{
if (RtlCompareMemory(&Window->WindowRect, &Window->ClientRect,
if (RtlCompareMemory(&Window->WindowRect, &Window->ClientRect,
sizeof(RECT)) == sizeof(RECT))
{
hClip = (HANDLE)1;
@ -459,7 +460,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* lPs)
RECT ClipRect;
NTSTATUS Status;
Status =
Status =
ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation->HandleTable,
hWnd,
otWindow,
@ -469,9 +470,9 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* lPs)
return(NULL);
}
IsIcon = Window->Style & WS_MINIMIZE &&
IsIcon = Window->Style & WS_MINIMIZE &&
NtUserGetClassLong(Window->Self, GCL_HICON);
Window->Flags &= ~WINDOWOBJECT_NEED_BEGINPAINT;
/* Send WM_NCPAINT */
@ -499,8 +500,8 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* lPs)
{
if (UpdateRegion != NULL)
{
W32kOffsetRgn(UpdateRegion,
Window->WindowRect.left -
W32kOffsetRgn(UpdateRegion,
Window->WindowRect.left -
Window->ClientRect.left,
Window->WindowRect.top -
Window->ClientRect.top);
@ -522,7 +523,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* lPs)
{
BOOLEAN Result;
Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBACKGRD;
Result = NtUserSendMessage(hWnd,
Result = NtUserSendMessage(hWnd,
IsIcon ? WM_ICONERASEBKGND : WM_ERASEBKGND,
(WPARAM)lPs->hdc,
0);

View file

@ -4,6 +4,7 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <win32k/dc.h>
#include <win32k/region.h>
#include <win32k/cliprgn.h>
// #define NDEBUG
@ -14,43 +15,39 @@ HRGN WINAPI SaveVisRgn(HDC hdc)
HRGN copy;
PRGNDATA obj, copyObj;
PDC dc = DC_HandleToPtr(hdc);
/*ei
if (!dc) return 0;
obj = RGNDATA_HandleToPtr(dc->w.hVisRgn);
obj = RGNDATA_LockRgn(dc->w.hVisRgn);
if(!(copy = CreateRectRgn(0, 0, 0, 0)))
if(!(copy = W32kCreateRectRgn(0, 0, 0, 0)))
{
GDI_ReleaseObj(dc->w.hVisRgn);
GDI_ReleaseObj(hdc);
RGNDATA_UnlockRgn(dc->w.hVisRgn);
DC_ReleasePtr(hdc);
return 0;
}
CombineRgn(copy, dc->w.hVisRgn, 0, RGN_COPY);
copyObj = RGNDATA_HandleToPtr(copy);
*/
W32kCombineRgn(copy, dc->w.hVisRgn, 0, RGN_COPY);
copyObj = RGNDATA_LockRgn(copy);
/* copyObj->header.hNext = obj->header.hNext;
header.hNext = copy; */
DC_ReleasePtr( hdc );
return copy;
}
INT16 WINAPI SelectVisRgn(HDC hdc, HRGN hrgn)
INT WINAPI SelectVisRgn(HDC hdc, HRGN hrgn)
{
return ERROR;
/*ei
int retval;
DC *dc;
if (!hrgn) return ERROR;
if (!(dc = DC_HandleToPtr(hdc))) return ERROR;
dc->flags &= ~DC_DIRTY;
dc->w.flags &= ~DC_DIRTY;
retval = CombineRgn(dc->hVisRgn, hrgn, 0, RGN_COPY);
CLIPPING_UpdateGCRegion(dc);
retval = W32kCombineRgn(dc->w.hVisRgn, hrgn, 0, RGN_COPY);
//ei CLIPPING_UpdateGCRegion(dc);
return retval;
*/
}
int STDCALL W32kExcludeClipRect(HDC hDC,

View file

@ -1,7 +1,7 @@
/*
* GDIOBJ.C - GDI object manipulation routines
*
* $Id: gdiobj.c,v 1.12 2002/07/13 21:37:27 ei Exp $
* $Id: gdiobj.c,v 1.13 2002/07/18 21:59:18 ei Exp $
*
*/
@ -213,7 +213,8 @@ BOOL GDIOBJ_FreeObj(HGDIOBJ hObj, WORD Magic)
Obj = (PGDIOBJ)((PCHAR)handleEntry->pObject + sizeof(GDIOBJHDR));
switch( handleEntry->wMagic ){
case GO_REGION_MAGIC:
bRet = RGNDATA_InternalDelete( (PRGNDATA) Obj );
break;
case GO_PEN_MAGIC:
case GO_PALETTE_MAGIC:
case GO_BITMAP_MAGIC:
@ -290,6 +291,7 @@ BOOL GDIOBJ_UnlockObj( HGDIOBJ hObj, WORD Magic )
if( objectHeader->dwCount == 0x80000000 ){
//delayed object release
objectHeader->dwCount = 0;
ExReleaseFastMutex(&RefCountHandling);
DPRINT("GDIOBJ_UnlockObj: delayed delete\n");
return GDIOBJ_FreeObj( hObj, Magic );
@ -439,31 +441,6 @@ HGDIOBJ STDCALL W32kGetStockObject(INT Object)
BOOL STDCALL W32kDeleteObject(HGDIOBJ hObject)
{
/* ei: Now this is handled in gdiobj.c
PGDIOBJ Obj;
PGDIOBJHDR ObjHdr;
WORD magic;
magic = GDIOBJ_GetHandleMagic (hObject);
Obj = GDIOBJ_HandleToPtr( hObject, GO_MAGIC_DONTCARE );
if( !Obj )
return FALSE;
ObjHdr = (PGDIOBJHDR)(((PCHAR)Obj) - sizeof (GDIOBJHDR));
switch( magic )
{
case GO_BITMAP_MAGIC: {
DPRINT( "Deleting bitmap\n" );
ExFreePool( ((PBITMAPOBJ)Obj)->bitmap.bmBits );
BITMAPOBJ_FreeBitmap( Obj );
break;
}
default: {
DPRINT( "W32kDeleteObject: Deleting object of unknown type %x\n", magic );
return FALSE;
}
}
return TRUE;
*/
return GDIOBJ_FreeObj( hObject, GO_MAGIC_DONTCARE );
}

File diff suppressed because it is too large Load diff

View file

@ -46,7 +46,6 @@ STUB(EngMapFontFile)
STUB(EngMapModule)
STUB(EngMarkBandingSurface)
STUB(EngMovePointer)
STUB(EngMulDiv)
STUB(EngMultiByteToUnicodeN)
STUB(EngMultiByteToWideChar)
STUB(EngProbeForRead)