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

View file

@ -3450,7 +3450,7 @@ typedef struct _RGNDATAHEADER {
typedef struct _RGNDATA { typedef struct _RGNDATA {
RGNDATAHEADER rdh; RGNDATAHEADER rdh;
char Buffer[1]; char* Buffer;
} RGNDATA, *PRGNDATA, *LPRGNDATA; } RGNDATA, *PRGNDATA, *LPRGNDATA;
typedef struct tagSCROLLINFO { typedef struct tagSCROLLINFO {

View file

@ -1,6 +1,9 @@
#ifndef _WIN32K_CLIPRGN_H #ifndef _WIN32K_CLIPRGN_H
#define _WIN32K_CLIPRGN_H #define _WIN32K_CLIPRGN_H
HRGN WINAPI SaveVisRgn(HDC hdc);
INT WINAPI SelectVisRgn(HDC hdc, HRGN hrgn);
int int
STDCALL STDCALL
W32kExcludeClipRect ( 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 typedef struct tagFLOAT_POINT
{ {
FLOAT x, y; FLOAT x, y;
@ -33,6 +40,7 @@ static inline void INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
/* Performs a viewport-to-world transformation on the specified point (which /* Performs a viewport-to-world transformation on the specified point (which
* is in integer format). Returns TRUE if successful, else FALSE. * is in integer format). Returns TRUE if successful, else FALSE.
*/ */
#if 0
static inline BOOL INTERNAL_DPTOLP(DC *dc, LPPOINT point) static inline BOOL INTERNAL_DPTOLP(DC *dc, LPPOINT point)
{ {
FLOAT_POINT floatPoint; FLOAT_POINT floatPoint;
@ -67,6 +75,10 @@ static inline void INTERNAL_LPTODP(DC *dc, LPPOINT point)
point->y = GDI_ROUND(floatPoint.y); point->y = GDI_ROUND(floatPoint.y);
} }
#endif
#define MulDiv( x, y, z ) EngMulDiv( x, y, z )
#define XDPTOLP(dc,x) \ #define XDPTOLP(dc,x) \
(MulDiv(((x)-(dc)->vportOrgX), (dc)->wndExtX, (dc)->vportExtX) + (dc)->wndOrgX) (MulDiv(((x)-(dc)->vportOrgX), (dc)->wndExtX, (dc)->vportExtX) + (dc)->wndOrgX)
#define YDPTOLP(dc,y) \ #define YDPTOLP(dc,y) \
@ -86,3 +98,5 @@ static inline void INTERNAL_LPTODP(DC *dc, LPPOINT point)
MulDiv((x), (dc)->vportExtX, (dc)->wndExtX) MulDiv((x), (dc)->vportExtX, (dc)->wndExtX)
#define YLSTODS(dc,y) \ #define YLSTODS(dc,y) \
MulDiv((y), (dc)->vportExtY, (dc)->wndExtY) MulDiv((y), (dc)->vportExtY, (dc)->wndExtY)
#endif

View file

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

View file

@ -18,6 +18,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <windows.h>
double atan (double __x); double atan (double __x);
double atan2 (double __y, double __x); double atan2 (double __y, double __x);
@ -207,3 +208,50 @@ double tan (double __x)
return __value; 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -23,6 +23,7 @@
#include <user32/wininternal.h> #include <user32/wininternal.h>
#include <include/rect.h> #include <include/rect.h>
#include <win32k/coord.h> #include <win32k/coord.h>
#include <win32k/region.h>
#define NDEBUG #define NDEBUG
@ -173,11 +174,11 @@ PaintRedrawWindow(HWND hWnd, const RECT* UpdateRect, HRGN UpdateRgn,
{ {
if (Window->UpdateRegion != NULL) if (Window->UpdateRegion != NULL)
{ {
hRgn = W32kCropRgn(0, UpdateRgn, NULL, &Pt); hRgn = REGION_CropRgn(0, UpdateRgn, NULL, &Pt);
} }
else else
{ {
Window->UpdateRegion = W32kCropRgn(0, UpdateRgn, &Rect, &Pt); Window->UpdateRegion = REGION_CropRgn(0, UpdateRgn, &Rect, &Pt);
} }
} }
else if (UpdateRect != NULL) else if (UpdateRect != NULL)
@ -329,7 +330,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT; Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
if (Window->UpdateRegion > (HANDLE)1) if (Window->UpdateRegion > (HANDLE)1)
{ {
hRgnRet = W32kCropRgn(hRgn, Window->UpdateRegion, NULL, NULL); hRgnRet = REGION_CropRgn(hRgn, Window->UpdateRegion, NULL, NULL);
} }
else else
{ {
@ -355,7 +356,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
Rect.right != ClientRect.right || Rect.right != ClientRect.right) Rect.right != ClientRect.right || Rect.right != ClientRect.right)
{ {
hClip = Window->UpdateRegion; hClip = Window->UpdateRegion;
Window->UpdateRegion = W32kCropRgn(hRgn, hClip, Window->UpdateRegion = REGION_CropRgn(hRgn, hClip,
&Rect, NULL); &Rect, NULL);
if (Flags & UNC_REGION) if (Flags & UNC_REGION)
{ {
@ -365,7 +366,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
if (Flags & UNC_CHECK) if (Flags & UNC_CHECK)
{ {
W32kGetBoxRgn(Window->UpdateRegion, &UpdateRegionBox); W32kGetRgnBox(Window->UpdateRegion, &UpdateRegionBox);
if (W32kIsEmptyRect(&UpdateRegionBox)) if (W32kIsEmptyRect(&UpdateRegionBox))
{ {
W32kDeleteObject(Window->UpdateRegion); W32kDeleteObject(Window->UpdateRegion);
@ -377,7 +378,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
if (!hClip && Window->UpdateRegion && Flags & UNC_REGION) if (!hClip && Window->UpdateRegion && Flags & UNC_REGION)
{ {
hRgnRet = W32kCropRgn(hRgn, Window->UpdateRegion, NULL, hRgnRet = REGION_CropRgn(hRgn, Window->UpdateRegion, NULL,
NULL); NULL);
} }
} }
@ -398,7 +399,7 @@ PaintUpdateNCRegion(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
{ {
if (Window->UpdateRegion > (HANDLE)1 && Flags & UNC_REGION) 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) else if (Window->UpdateRegion == (HANDLE)1 && Flags & UNC_UPDATE)
{ {

View file

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

View file

@ -1,7 +1,7 @@
/* /*
* GDIOBJ.C - GDI object manipulation routines * 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)); Obj = (PGDIOBJ)((PCHAR)handleEntry->pObject + sizeof(GDIOBJHDR));
switch( handleEntry->wMagic ){ switch( handleEntry->wMagic ){
case GO_REGION_MAGIC: case GO_REGION_MAGIC:
bRet = RGNDATA_InternalDelete( (PRGNDATA) Obj );
break;
case GO_PEN_MAGIC: case GO_PEN_MAGIC:
case GO_PALETTE_MAGIC: case GO_PALETTE_MAGIC:
case GO_BITMAP_MAGIC: case GO_BITMAP_MAGIC:
@ -290,6 +291,7 @@ BOOL GDIOBJ_UnlockObj( HGDIOBJ hObj, WORD Magic )
if( objectHeader->dwCount == 0x80000000 ){ if( objectHeader->dwCount == 0x80000000 ){
//delayed object release //delayed object release
objectHeader->dwCount = 0;
ExReleaseFastMutex(&RefCountHandling); ExReleaseFastMutex(&RefCountHandling);
DPRINT("GDIOBJ_UnlockObj: delayed delete\n"); DPRINT("GDIOBJ_UnlockObj: delayed delete\n");
return GDIOBJ_FreeObj( hObj, Magic ); return GDIOBJ_FreeObj( hObj, Magic );
@ -439,31 +441,6 @@ HGDIOBJ STDCALL W32kGetStockObject(INT Object)
BOOL STDCALL W32kDeleteObject(HGDIOBJ hObject) 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 ); 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(EngMapModule)
STUB(EngMarkBandingSurface) STUB(EngMarkBandingSurface)
STUB(EngMovePointer) STUB(EngMovePointer)
STUB(EngMulDiv)
STUB(EngMultiByteToUnicodeN) STUB(EngMultiByteToUnicodeN)
STUB(EngMultiByteToWideChar) STUB(EngMultiByteToWideChar)
STUB(EngProbeForRead) STUB(EngProbeForRead)