Added GetRegionData gdi function. Added region test. Fixed some bugs.

svn path=/trunk/; revision=3285
This commit is contained in:
Eugene Ingerman 2002-07-22 07:55:49 +00:00
parent 1aa76f94bd
commit 2bda045a8e
11 changed files with 396 additions and 333 deletions

View file

@ -11,7 +11,7 @@ void __stdcall Background (HDC Desktop)
{
HPEN Pen;
int x, y;
Pen = CreatePen(PS_SOLID, 1, RGB(64, 64, 128));
SelectObject (Desktop, Pen);
@ -30,8 +30,7 @@ void __stdcall Background (HDC Desktop)
}
}
int main (void)
{
void gditest( void ){
HDC Desktop, MyDC, DC24;
HPEN RedPen, GreenPen, BluePen, WhitePen;
HBITMAP MyBitmap, DIB24;
@ -39,14 +38,12 @@ int main (void)
BITMAPINFOHEADER BitInf;
BITMAPINFO BitPalInf;
printf("Entering GDITest..\n");
GdiDllInitialize (NULL, DLL_PROCESS_ATTACH, NULL);
// Set up a DC called Desktop that accesses DISPLAY
Desktop = CreateDCA("DISPLAY", NULL, NULL, NULL);
if (Desktop == NULL)
return 1;
if (Desktop == NULL){
printf("Can't create desktop\n");
return;
}
// Background
Background (Desktop);
@ -128,5 +125,161 @@ int main (void)
// Free up everything
DeleteDC(Desktop);
DeleteDC(MyDC);
}
void DumpRgnData( HRGN hRgn )
{
int size, ret, i;
LPRGNDATA rgnData;
size = GetRegionData( hRgn, 0, NULL );
if( size == 0 ){
printf("GetRegionData returned 0\n");
return;
}
rgnData = (LPRGNDATA) malloc( size );
ret = GetRegionData( hRgn, size, rgnData );
if( ret == 0 ){
printf("GetRegionData( hRgn, size, rgnData ) returned 0\n");
return;
}
printf("Bounds: left=%d top=%d right=%d bottom=%d, count: %d, type: %i\n\n",
rgnData->rdh.rcBound.left, rgnData->rdh.rcBound.top, rgnData->rdh.rcBound.right, rgnData->rdh.rcBound.bottom,
rgnData->rdh.nCount, rgnData->rdh.iType);
printf("Rects:\t i \t left \t top \t right \t bottom\n");
for ( i = 0; i < rgnData->rdh.nCount; i++ ) {
PRECT pr = (PRECT) rgnData->Buffer + i;
printf("\t %d \t %d \t %d \t %d \t %d\n", i, pr->left, pr->top, pr->right, pr->bottom );
}
printf("\n");
}
void rgntest( void )
{
HRGN hRgn1, hRgn2, hRgn3;
RECT Rect;
int i;
hRgn1 = CreateRectRgn( 1, 1, 100, 100 );
if( hRgn1 == NULL ) {
printf("Failed at hRgn1 = CreateRectRgn( 1, 1, 100, 100 )\n");
return;
}
i = GetRgnBox( hRgn1, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("GetRgnBox( hRgn1, &Rect ): i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn1 );
hRgn2 = CreateRectRgn( 51, 51, 150, 150 );
if( hRgn2 == NULL ) {
printf("Failed at hRgn2 = CreateRectRgn( 51, 51, 150, 150 )\n");
return;
}
i = GetRgnBox( hRgn2, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn2, &Rect )\n");
return;
}
printf("GetRgnBox( hRgn2, &Rect ): i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn2 );
if( EqualRgn( hRgn1, hRgn2 ) == TRUE ){
printf("\t hRgn1, hRgn2 are equal\n");
}
else{
printf("\t hRgn1, hRgn2 are NOT equal\n\n");
}
i = OffsetRgn(hRgn1,50,50);
if( i==ERROR ){
printf("Failed OffsetRgn(hRgn1,50,50)\n");
return;
}
i = GetRgnBox( hRgn1, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After offset\nGetRgnBox( hRgn1, &Rect ): i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
if( EqualRgn( hRgn1, hRgn2 ) == TRUE ){
printf("\t hRgn1, hRgn2 are equal after offset\n");
}
else{
printf("\t hRgn1, hRgn2 are NOT equal after offset!\n\n");
}
i = SetRectRgn(hRgn1, 10, 10, 110, 110 );
if( i==0 ){
printf("Failed SetRectRgn(hRgn1... )\n");
return;
}
i = GetRgnBox( hRgn1, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("after SetRectRgn(hRgn1, 10, 10, 110, 110 ):\n i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
hRgn3 = CreateRectRgn( 1, 1, 1, 1);
i = CombineRgn( hRgn3, hRgn1, hRgn2, RGN_AND );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn3, hRgn1, hRgn2, RGN_AND ). LastError: %d\n", GetLastError);
return;
}
if( GetRgnBox( hRgn3, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn3, hRgn1, hRgn2, RGN_AND ): \nGetRgnBox( hRgn3, &Rect ): CR_i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn3 );
/*
i = CombineRgn( hRgn3, hRgn1, hRgn2, RGN_OR );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn3, hRgn1, hRgn2, RGN_OR ). LastError: %d\n", GetLastError);
return;
}
if( GetRgnBox( hRgn3, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn3, hRgn1, hRgn2, RGN_OR ): \nGetRgnBox( hRgn3, &Rect ): CR_i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn3 );
*/
DeleteObject( hRgn1 );
DeleteObject( hRgn2 );
DeleteObject( hRgn3 );
printf("region test finished\n");
}
int main (int argc, char* argv[])
{
printf("Entering GDITest..\n");
printf("use gditest for older tests\n");
printf("use gditest 1 for region test\n");
GdiDllInitialize (NULL, DLL_PROCESS_ATTACH, NULL);
if( argc < 2 )
gditest();
else {
if( !strncmp( argv[1], "1", 1 ) ) {
rgntest();
}
}
return 0;
}

View file

@ -153,6 +153,7 @@ W32kGetROP2 1
#W32kGetRandomRgn ?
W32kGetRasterizerCaps 2
W32kGetRelAbs 1
W32kGetRegionData 3
W32kGetRgnBox 2
W32kGetStockObject 1
W32kGetStretchBltMode 1
@ -533,4 +534,4 @@ NtUserWin32PoolAllocationStats 6
NtUserWindowFromPoint 2
NtUserYieldTask 0
# ReactOS only system calls
NtUserAcquireOrReleaseInputOwnership 1
NtUserAcquireOrReleaseInputOwnership 1

View file

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

View file

@ -4,12 +4,19 @@
#include <win32k/gdiobj.h>
//Internal region data. Can't use RGNDATA structure because buffer is allocated statically
typedef struct _ROSRGNDATA {
RGNDATAHEADER rdh;
char* Buffer;
} ROSRGNDATA, *PROSRGNDATA, *LPROSRGNDATA;
#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_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, GO_REGION_MAGIC))
#define RGNDATA_UnlockRgn(hRgn) GDIOBJ_UnlockObj((HGDIOBJ)hRgn, GO_REGION_MAGIC)
HRGN RGNDATA_AllocRgn(INT n);
BOOL RGNDATA_InternalDelete( PRGNDATA Obj );
BOOL RGNDATA_InternalDelete( PROSRGNDATA Obj );
/* User entry points */
HRGN STDCALL
@ -75,7 +82,7 @@ HRGN
STDCALL
W32kExtCreateRegion(CONST PXFORM Xform,
DWORD Count,
CONST PRGNDATA RgnData);
CONST PROSRGNDATA RgnData);
BOOL
STDCALL
@ -131,5 +138,10 @@ W32kSetRectRgn(HRGN hRgn,
INT RightRect,
INT BottomRect);
DWORD
STDCALL
W32kGetRegionData(HRGN hrgn,
DWORD count,
LPRGNDATA rgndata);
#endif

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.19 2001/08/21 20:13:06 chorns Exp $
# $Id: makefile,v 1.20 2002/07/22 07:55:48 ei Exp $
PATH_TO_TOP = ../..
@ -22,7 +22,7 @@ MAIN_OBJECTS = main/dllmain.o
MISC_OBJECTS = misc/stubs.o misc/stubsa.o misc/stubsw.o misc/win32k.o
OBJECTS_OBJECTS = objects/dc.o objects/line.o objects/pen.o objects/bitblt.o objects/text.o
OBJECTS_OBJECTS = objects/dc.o objects/line.o objects/pen.o objects/bitblt.o objects/text.o objects/region.o
OBJECTS = $(MAIN_OBJECTS) $(MISC_OBJECTS) $(OBJECTS_OBJECTS)

View file

@ -1,4 +1,4 @@
/* $Id: stubs.c,v 1.6 2001/08/02 20:20:17 phreak Exp $
/* $Id: stubs.c,v 1.7 2002/07/22 07:55:48 ei Exp $
*
* reactos/lib/gdi32/misc/stubs.c
*
@ -105,21 +105,6 @@ CloseMetaFile(
int
STDCALL
CombineRgn(
HRGN a0,
HRGN a1,
HRGN a2,
int a3
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
HBRUSH
STDCALL
CreateBrushIndirect(
@ -210,75 +195,6 @@ CreatePalette(
HRGN
STDCALL
CreatePolyPolygonRgn(
CONST POINT *a0,
CONST INT *a1,
int a2,
int a3
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
HBRUSH
STDCALL
CreatePatternBrush(
HBITMAP a0
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
HRGN
STDCALL
CreateRectRgn(
int a0,
int a1,
int a2,
int a3
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
HRGN
STDCALL
CreateRectRgnIndirect(
CONST RECT *a0
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
HRGN
STDCALL
CreateRoundRectRgn(
int a0,
int a1,
int a2,
int a3,
int a4,
int a5
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
HBRUSH
STDCALL
@ -303,18 +219,6 @@ DeleteMetaFile(
BOOL
STDCALL
DeleteObject(
HGDIOBJ a0
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
int
STDCALL
DescribePixelFormat(
@ -376,19 +280,6 @@ EnumObjects(
BOOL
STDCALL
EqualRgn(
HRGN a0,
HRGN a1
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
int
STDCALL
Escape(
@ -827,33 +718,6 @@ GetRasterizerCaps(
DWORD
STDCALL
GetRegionData(
HRGN a0,
DWORD a1,
LPRGNDATA a2
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
int
STDCALL
GetRgnBox(
HRGN a0,
LPRECT a1
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
HGDIOBJ
STDCALL
GetStockObject(
@ -1103,21 +967,6 @@ OffsetClipRgn(
}
int
STDCALL
OffsetRgn(
HRGN a0,
int a1,
int a2
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
BOOL
STDCALL
PatBlt(
@ -1411,10 +1260,10 @@ SetBoundsRect(
DWORD
STDCALL
DWORD
STDCALL
SetMapperFlags(
HDC a0,
HDC a0,
DWORD a1
)
{
@ -1423,11 +1272,11 @@ SetMapperFlags(
}
int
STDCALL
int
STDCALL
SetGraphicsMode(
HDC hdc,
HDC hdc,
int iMode
)
{
@ -1436,11 +1285,11 @@ SetGraphicsMode(
}
HMETAFILE
STDCALL
HMETAFILE
STDCALL
SetMetaFileBitsEx(
UINT a0,
UINT a0,
CONST BYTE *a1
)
{
@ -1449,13 +1298,13 @@ SetMetaFileBitsEx(
}
UINT
STDCALL
UINT
STDCALL
SetPaletteEntries(
HPALETTE a0,
UINT a1,
UINT a2,
HPALETTE a0,
UINT a1,
UINT a2,
CONST PALETTEENTRY *a3
)
{
@ -1464,13 +1313,13 @@ SetPaletteEntries(
}
BOOL
STDCALL
BOOL
STDCALL
SetPixelV(
HDC a0,
int a1,
int a2,
int a1,
int a2,
COLORREF a3
)
{
@ -1479,12 +1328,12 @@ SetPixelV(
}
BOOL
STDCALL
BOOL
STDCALL
SetPixelFormat(
HDC a0,
int a1,
HDC a0,
int a1,
CONST PIXELFORMATDESCRIPTOR *a2
)
{
@ -1493,11 +1342,11 @@ SetPixelFormat(
}
int
STDCALL
int
STDCALL
SetPolyFillMode(
HDC a0,
HDC a0,
int a1
)
{
@ -1506,20 +1355,20 @@ SetPolyFillMode(
}
BOOL
STDCALL
BOOL
STDCALL
StretchBlt(
HDC a0,
int a1,
int a2,
int a3,
int a4,
HDC a5,
int a6,
int a7,
int a8,
int a9,
HDC a0,
int a1,
int a2,
int a3,
int a4,
HDC a5,
int a6,
int a7,
int a8,
int a9,
DWORD a10
)
{
@ -1528,27 +1377,11 @@ StretchBlt(
}
BOOL
STDCALL
SetRectRgn(
HRGN a0,
int a1,
int a2,
int a3,
int a4
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
int
STDCALL
int
STDCALL
SetROP2(
HDC a0,
HDC a0,
int a1
)
{
@ -1557,11 +1390,11 @@ SetROP2(
}
int
STDCALL
int
STDCALL
SetStretchBltMode(
HDC a0,
HDC a0,
int a1
)
{
@ -1570,11 +1403,11 @@ SetStretchBltMode(
}
UINT
STDCALL
UINT
STDCALL
SetSystemPaletteUse(
HDC a0,
HDC a0,
UINT a1
)
{
@ -1583,11 +1416,11 @@ SetSystemPaletteUse(
}
int
STDCALL
int
STDCALL
SetTextCharacterExtra(
HDC a0,
HDC a0,
int a1
)
{
@ -1596,11 +1429,11 @@ SetTextCharacterExtra(
}
UINT
STDCALL
UINT
STDCALL
SetTextAlign(
HDC a0,
HDC a0,
UINT a1
)
{
@ -1609,9 +1442,9 @@ SetTextAlign(
}
BOOL
STDCALL
BOOL
STDCALL
SetTextJustification(
HDC a0,
int a1,
@ -1623,9 +1456,9 @@ SetTextJustification(
}
BOOL
STDCALL
BOOL
STDCALL
UpdateColors(
HDC hdc
)
@ -1635,13 +1468,13 @@ UpdateColors(
}
BOOL
STDCALL
BOOL
STDCALL
PlayMetaFileRecord(
HDC a0,
LPHANDLETABLE a1,
LPMETARECORD a2,
HDC a0,
LPHANDLETABLE a1,
LPMETARECORD a2,
UINT a3
)
{
@ -1650,13 +1483,13 @@ PlayMetaFileRecord(
}
BOOL
STDCALL
BOOL
STDCALL
EnumMetaFile(
HDC a0,
HMETAFILE a1,
ENUMMETAFILEPROC a2,
HDC a0,
HMETAFILE a1,
ENUMMETAFILEPROC a2,
LPARAM a3
)
{
@ -1665,9 +1498,9 @@ EnumMetaFile(
}
HENHMETAFILE
STDCALL
HENHMETAFILE
STDCALL
CloseEnhMetaFile(
HDC hdc
)
@ -1677,9 +1510,9 @@ CloseEnhMetaFile(
}
BOOL
STDCALL
BOOL
STDCALL
DeleteEnhMetaFile(
HENHMETAFILE a0
)
@ -1689,9 +1522,9 @@ DeleteEnhMetaFile(
}
BOOL
STDCALL
BOOL
STDCALL
EnumEnhMetaFile(
HDC a0,
HENHMETAFILE a1,

View file

@ -118,10 +118,10 @@ SelectObject(
return W32kSelectObject(hDC, hGDIObj);
}
int
STDCALL
int
STDCALL
SetMapMode(
HDC a0,
HDC a0,
int a1
)
{
@ -151,3 +151,13 @@ SetWindowOrgEx(
{
return W32kSetWindowOrgEx( a0, a1, a2, a3 );
}
BOOL
STDCALL
DeleteObject(
HGDIOBJ a0
)
{
return W32kDeleteObject(a0);
}

View file

@ -13,7 +13,7 @@
HRGN WINAPI SaveVisRgn(HDC hdc)
{
HRGN copy;
PRGNDATA obj, copyObj;
PROSRGNDATA obj, copyObj;
PDC dc = DC_HandleToPtr(hdc);
if (!dc) return 0;

View file

@ -1,7 +1,7 @@
/*
* GDIOBJ.C - GDI object manipulation routines
*
* $Id: gdiobj.c,v 1.13 2002/07/18 21:59:18 ei Exp $
* $Id: gdiobj.c,v 1.14 2002/07/22 07:55:48 ei Exp $
*
*/
@ -14,7 +14,8 @@
#include <win32k/text.h>
#include <win32k/dc.h>
#include <win32k/bitmaps.h>
//#define NDEBUG
#include <win32k/region.h>
#define NDEBUG
#include <win32k/debug1.h>
// GDI stock objects
@ -132,7 +133,7 @@ GDIOBJ_iGetHandleEntryForIndex (WORD TableIndex)
{
//DPRINT("GDIOBJ_iGetHandleEntryForIndex: TableIndex: %d,\n handle: %x, ptr: %x\n", TableIndex, HandleTable->Handles [TableIndex], &(HandleTable->Handles [TableIndex]) );
//DPRINT("GIG: HandleTable: %x, Handles: %x, \n TableIndex: %x, pt: %x\n", HandleTable, HandleTable->Handles, TableIndex, ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex));
DPRINT("GIG: Hndl: %x, mag: %x\n", ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex), ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex)->wMagic);
//DPRINT("GIG: Hndl: %x, mag: %x\n", ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex), ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex)->wMagic);
return ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex);
}
@ -213,7 +214,7 @@ 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 );
bRet = RGNDATA_InternalDelete( (PROSRGNDATA) Obj );
break;
case GO_PEN_MAGIC:
case GO_PALETTE_MAGIC:

View file

@ -7,6 +7,7 @@
#include <win32k/line.h>
#include <win32k/path.h>
#include <win32k/pen.h>
#include <win32k/region.h>
// #define NDEBUG
#include <win32k/debug1.h>
@ -107,7 +108,7 @@ W32kLineTo(HDC hDC,
SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject(dc->Surface);
BOOL ret;
PPENOBJ pen;
PRGNDATA reg;
PROSRGNDATA reg;
if(!dc) return FALSE;
@ -115,7 +116,7 @@ W32kLineTo(HDC hDC,
ret = PATH_LineTo(hDC, XEnd, YEnd);
} else {
pen = (PPENOBJ) GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC);
reg = (PRGNDATA)GDIOBJ_LockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC);
reg = (PROSRGNDATA)GDIOBJ_LockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC);
ASSERT( pen );
// not yet implemented ASSERT( reg );

View file

@ -42,7 +42,7 @@
/*
* Check to see if there is enough memory in the present region.
*/
static inline int xmemcheck(RGNDATA *reg, LPRECT *rect, LPRECT *firstrect ) {
static inline int xmemcheck(ROSRGNDATA *reg, LPRECT *rect, LPRECT *firstrect ) {
if ( (reg->rdh.nCount+1)*sizeof( RECT ) >= reg->rdh.nRgnSize ) {
PRECT temp;
temp = ExAllocatePool( PagedPool, (2 * (reg->rdh.nRgnSize)));
@ -72,7 +72,7 @@ typedef struct _POINTBLOCK {
struct _POINTBLOCK *next;
} POINTBLOCK;
static BOOL REGION_CopyRegion(PRGNDATA dst, PRGNDATA src)
static BOOL REGION_CopyRegion(PROSRGNDATA dst, PROSRGNDATA src)
{
if(dst != src) // don't want to copy to itself
{
@ -100,7 +100,7 @@ static BOOL REGION_CopyRegion(PRGNDATA dst, PRGNDATA src)
return TRUE;
}
static void REGION_SetExtents (RGNDATA *pReg)
static void REGION_SetExtents (ROSRGNDATA *pReg)
{
RECT *pRect, *pRectEnd, *pExtents;
@ -143,7 +143,7 @@ static void REGION_SetExtents (RGNDATA *pReg)
/***********************************************************************
* REGION_CropAndOffsetRegion
*/
static BOOL REGION_CropAndOffsetRegion(const PPOINT off, const PRECT rect, PRGNDATA rgnSrc, PRGNDATA rgnDst)
static BOOL REGION_CropAndOffsetRegion(const PPOINT off, const PRECT rect, PROSRGNDATA rgnSrc, PROSRGNDATA rgnDst)
{
if(!rect) // just copy and offset
{
@ -166,7 +166,7 @@ static BOOL REGION_CropAndOffsetRegion(const PPOINT off, const PRECT rect, PRGND
INT i;
if(rgnDst != rgnSrc)
RtlCopyMemory(rgnDst, rgnSrc, sizeof(RGNDATA));
RtlCopyMemory(rgnDst, rgnSrc, sizeof(ROSRGNDATA));
if(off->x || off->y)
{
@ -307,14 +307,14 @@ empty:
*
* Returns: hDst if success, 0 otherwise.
*/
HRGN REGION_CropRgn(HRGN hDst, HRGN hSrc, const PRECT lpRect, const PPOINT lpPt)
HRGN REGION_CropRgn(HRGN hDst, HRGN hSrc, const PRECT lpRect, PPOINT lpPt)
{
PRGNDATA objSrc = RGNDATA_LockRgn(hSrc);
PROSRGNDATA objSrc = RGNDATA_LockRgn(hSrc);
HRGN hNewDst;
if(objSrc)
{
PRGNDATA rgnDst;
PROSRGNDATA rgnDst;
if(hDst)
{
@ -392,7 +392,7 @@ done:
*
*/
static INT REGION_Coalesce (
PRGNDATA pReg, /* Region to coalesce */
PROSRGNDATA pReg, /* Region to coalesce */
INT prevStart, /* Index of start of previous band */
INT curStart /* Index of start of current band */
) {
@ -536,9 +536,9 @@ static INT REGION_Coalesce (
*
*/
static void REGION_RegionOp(
RGNDATA *newReg, /* Place to store result */
RGNDATA *reg1, /* First region in operation */
RGNDATA *reg2, /* 2nd region in operation */
ROSRGNDATA *newReg, /* Place to store result */
ROSRGNDATA *reg1, /* First region in operation */
ROSRGNDATA *reg2, /* 2nd region in operation */
void (*overlapFunc)(), /* Function to call for over-lapping bands */
void (*nonOverlap1Func)(), /* Function to call for non-overlapping bands in region 1 */
void (*nonOverlap2Func)() /* Function to call for non-overlapping bands in region 2 */
@ -826,7 +826,7 @@ static void REGION_RegionOp(
* Rectangles may be added to the region.
*
*/
static void REGION_IntersectO(RGNDATA *pReg, RECT *r1, RECT *r1End,
static void REGION_IntersectO(ROSRGNDATA *pReg, RECT *r1, RECT *r1End,
RECT *r2, RECT *r2End, INT top, INT bottom)
{
@ -883,8 +883,8 @@ static void REGION_IntersectO(RGNDATA *pReg, RECT *r1, RECT *r1End,
/***********************************************************************
* REGION_IntersectRegion
*/
static void REGION_IntersectRegion(RGNDATA *newReg, RGNDATA *reg1,
RGNDATA *reg2)
static void REGION_IntersectRegion(ROSRGNDATA *newReg, ROSRGNDATA *reg1,
ROSRGNDATA *reg2)
{
/* check for trivial reject */
if ( (!(reg1->rdh.nCount)) || (!(reg2->rdh.nCount)) ||
@ -923,7 +923,7 @@ static void REGION_IntersectRegion(RGNDATA *newReg, RGNDATA *reg1,
* with the rectangles we're passed.
*
*/
static void REGION_UnionNonO (RGNDATA *pReg, RECT *r, RECT *rEnd,
static void REGION_UnionNonO (ROSRGNDATA *pReg, RECT *r, RECT *rEnd,
INT top, INT bottom)
{
RECT *pNextRect;
@ -958,7 +958,7 @@ static void REGION_UnionNonO (RGNDATA *pReg, RECT *r, RECT *rEnd,
* be changed.
*
*/
static void REGION_UnionO (RGNDATA *pReg, RECT *r1, RECT *r1End,
static void REGION_UnionO (ROSRGNDATA *pReg, RECT *r1, RECT *r1End,
RECT *r2, RECT *r2End, INT top, INT bottom)
{
RECT *pNextRect;
@ -1017,8 +1017,8 @@ static void REGION_UnionO (RGNDATA *pReg, RECT *r1, RECT *r1End,
/***********************************************************************
* REGION_UnionRegion
*/
static void REGION_UnionRegion(RGNDATA *newReg, RGNDATA *reg1,
RGNDATA *reg2)
static void REGION_UnionRegion(ROSRGNDATA *newReg, ROSRGNDATA *reg1,
ROSRGNDATA *reg2)
{
/* checks all the simple cases */
@ -1096,7 +1096,7 @@ static void REGION_UnionRegion(RGNDATA *newReg, RGNDATA *reg1,
* pReg may be affected.
*
*/
static void REGION_SubtractNonO1 (RGNDATA *pReg, RECT *r, RECT *rEnd,
static void REGION_SubtractNonO1 (ROSRGNDATA *pReg, RECT *r, RECT *rEnd,
INT top, INT bottom)
{
RECT *pNextRect;
@ -1131,7 +1131,7 @@ static void REGION_SubtractNonO1 (RGNDATA *pReg, RECT *r, RECT *rEnd,
* pReg may have rectangles added to it.
*
*/
static void REGION_SubtractO (RGNDATA *pReg, RECT *r1, RECT *r1End,
static void REGION_SubtractO (ROSRGNDATA *pReg, RECT *r1, RECT *r1End,
RECT *r2, RECT *r2End, INT top, INT bottom)
{
RECT *pNextRect;
@ -1259,8 +1259,8 @@ static void REGION_SubtractO (RGNDATA *pReg, RECT *r1, RECT *r1End,
* regD is overwritten.
*
*/
static void REGION_SubtractRegion(RGNDATA *regD, RGNDATA *regM,
RGNDATA *regS )
static void REGION_SubtractRegion(ROSRGNDATA *regD, ROSRGNDATA *regM,
ROSRGNDATA *regS )
{
/* check for trivial reject */
if ( (!(regM->rdh.nCount)) || (!(regS->rdh.nCount)) ||
@ -1286,11 +1286,11 @@ static void REGION_SubtractRegion(RGNDATA *regD, RGNDATA *regM,
/***********************************************************************
* REGION_XorRegion
*/
static void REGION_XorRegion(RGNDATA *dr, RGNDATA *sra,
RGNDATA *srb)
static void REGION_XorRegion(ROSRGNDATA *dr, ROSRGNDATA *sra,
ROSRGNDATA *srb)
{
HRGN htra, htrb;
RGNDATA *tra, *trb;
ROSRGNDATA *tra, *trb;
if ((! (htra = RGNDATA_AllocRgn(sra->rdh.nCount + 1))) ||
(! (htrb = RGNDATA_AllocRgn(srb->rdh.nCount + 1))))
@ -1326,9 +1326,9 @@ static void REGION_XorRegion(RGNDATA *dr, RGNDATA *sra,
* REGION_UnionRectWithRegion
* Adds a rectangle to a WINEREGION
*/
static void REGION_UnionRectWithRegion(const RECT *rect, RGNDATA *rgn)
static void REGION_UnionRectWithRegion(const RECT *rect, ROSRGNDATA *rgn)
{
RGNDATA region;
ROSRGNDATA region;
region.Buffer = (char*)(&(region.rdh.rcBound));
region.rdh.nCount = 1;
@ -1341,8 +1341,8 @@ static void REGION_UnionRectWithRegion(const RECT *rect, RGNDATA *rgn)
BOOL REGION_LPTODP(HDC hdc, HRGN hDest, HRGN hSrc)
{
RECT *pCurRect, *pEndRect;
PRGNDATA srcObj = NULL;
PRGNDATA destObj = NULL;
PROSRGNDATA srcObj = NULL;
PROSRGNDATA destObj = NULL;
DC * dc = DC_HandleToPtr(hdc);
RECT tmpRect;
@ -1361,9 +1361,9 @@ BOOL REGION_LPTODP(HDC hdc, HRGN hDest, HRGN hSrc)
goto done;
}
if(!( srcObj = (PRGNDATA) RGNDATA_LockRgn( hSrc ) ))
if(!( srcObj = (PROSRGNDATA) RGNDATA_LockRgn( hSrc ) ))
goto done;
if(!( destObj = (PRGNDATA) RGNDATA_LockRgn( hDest ) ))
if(!( destObj = (PROSRGNDATA) RGNDATA_LockRgn( hDest ) ))
{
RGNDATA_UnlockRgn( hSrc );
goto done;
@ -1399,17 +1399,17 @@ done:
HRGN RGNDATA_AllocRgn(INT n)
{
HRGN hReg;
PRGNDATA pReg;
PROSRGNDATA pReg;
BOOL bRet;
if((hReg = (HRGN)GDIOBJ_AllocObj(sizeof(RGNDATA), GO_REGION_MAGIC))){
if((hReg = (HRGN)GDIOBJ_AllocObj(sizeof(ROSRGNDATA), GO_REGION_MAGIC))){
if( (pReg = GDIOBJ_LockObj( hReg, GO_REGION_MAGIC )) ){
if ((pReg->Buffer = ExAllocatePool(PagedPool, n * sizeof(RECT)))){
EMPTY_REGION(pReg);
pReg->rdh.dwSize = sizeof(RGNDATAHEADER);
pReg->rdh.nCount = n;
pReg->rdh.nRgnSize = n*sizeof(RECT);
EMPTY_REGION(pReg);
bRet = GDIOBJ_UnlockObj( hReg, GO_REGION_MAGIC );
ASSERT(bRet);
@ -1424,7 +1424,7 @@ HRGN RGNDATA_AllocRgn(INT n)
return NULL;
}
BOOL RGNDATA_InternalDelete( PRGNDATA pRgn )
BOOL RGNDATA_InternalDelete( PROSRGNDATA pRgn )
{
ASSERT(pRgn);
if(pRgn->Buffer)
@ -1441,10 +1441,10 @@ W32kCombineRgn(HRGN hDest,
INT CombineMode)
{
INT result = ERROR;
PRGNDATA destRgn = RGNDATA_LockRgn(hDest);
PROSRGNDATA destRgn = RGNDATA_LockRgn(hDest);
if( destRgn ){
PRGNDATA src1Rgn = RGNDATA_LockRgn(hSrc1);
PROSRGNDATA src1Rgn = RGNDATA_LockRgn(hSrc1);
if( src1Rgn ){
if (CombineMode == RGN_COPY)
@ -1455,7 +1455,7 @@ W32kCombineRgn(HRGN hDest,
}
else
{
PRGNDATA src2Rgn = RGNDATA_LockRgn(hSrc2);
PROSRGNDATA src2Rgn = RGNDATA_LockRgn(hSrc2);
if( src2Rgn ){
switch (CombineMode)
{
@ -1530,7 +1530,7 @@ W32kCreateRectRgn(INT LeftRect,
INT BottomRect)
{
HRGN hRgn;
PRGNDATA pRgnData;
PROSRGNDATA pRgnData;
PRECT pRect;
// Allocate region data structure with space for 1 RECT
@ -1583,7 +1583,7 @@ STDCALL
W32kEqualRgn(HRGN hSrcRgn1,
HRGN hSrcRgn2)
{
PRGNDATA rgn1, rgn2;
PROSRGNDATA rgn1, rgn2;
PRECT tRect1, tRect2;
int i;
BOOL bRet = FALSE;
@ -1630,7 +1630,7 @@ HRGN
STDCALL
W32kExtCreateRegion(CONST PXFORM Xform,
DWORD Count,
CONST PRGNDATA RgnData)
CONST PROSRGNDATA RgnData)
{
HRGN hRgn;
@ -1668,7 +1668,7 @@ STDCALL
W32kGetRgnBox(HRGN hRgn,
LPRECT pRect)
{
PRGNDATA rgn = RGNDATA_LockRgn(hRgn);
PROSRGNDATA rgn = RGNDATA_LockRgn(hRgn);
DWORD ret;
if( rgn ){
@ -1702,16 +1702,21 @@ W32kOffsetRgn(HRGN hRgn,
INT XOffset,
INT YOffset)
{
PRGNDATA rgn = RGNDATA_LockRgn(hRgn);
PROSRGNDATA rgn = RGNDATA_LockRgn(hRgn);
INT ret;
if( !rgn )
DPRINT("W32kOffsetRgn: hRgn %d Xoffs %d Yoffs %d rgn %x\n", hRgn, XOffset, YOffset, rgn );
if( !rgn ){
DPRINT("W32kOffsetRgn: hRgn error\n");
return ERROR;
}
if(XOffset || YOffset) {
int nbox = rgn->rdh.nCount;
PRECT pbox = (PRECT)rgn->Buffer;
DPRINT("nbox %d, pbox %x\n", nbox, pbox);
if(nbox && pbox) {
while(nbox--) {
pbox->left += XOffset;
@ -1720,10 +1725,12 @@ W32kOffsetRgn(HRGN hRgn,
pbox->bottom += YOffset;
pbox++;
}
DPRINT("rgn->rdh.rcBound.left %d\n",rgn->rdh.rcBound.left);
rgn->rdh.rcBound.left += XOffset;
rgn->rdh.rcBound.right += XOffset;
rgn->rdh.rcBound.top += YOffset;
rgn->rdh.rcBound.bottom += YOffset;
DPRINT("after rgn->rdh.rcBound.left %d\n",rgn->rdh.rcBound.left);
}
}
ret = rgn->rdh.iType;
@ -1790,7 +1797,7 @@ W32kPtInRegion(HRGN hRgn,
INT X,
INT Y)
{
PRGNDATA rgn;
PROSRGNDATA rgn;
int i;
if( (rgn = RGNDATA_LockRgn(hRgn) ) )
@ -1813,7 +1820,7 @@ STDCALL
W32kRectInRegion(HRGN hRgn,
CONST LPRECT unsaferc)
{
PRGNDATA rgn;
PROSRGNDATA rgn;
PRECT pCurRect, pRectEnd;
PRECT rc;
BOOL bRet = FALSE;
@ -1851,7 +1858,7 @@ W32kSetRectRgn(HRGN hRgn,
INT RightRect,
INT BottomRect)
{
PRGNDATA rgn;
PROSRGNDATA rgn;
PRECT firstRect;
@ -1883,7 +1890,7 @@ HRGN STDCALL
W32kUnionRectWithRgn(HRGN hDest, const RECT* unsafeRect)
{
PRECT pRect;
PRGNDATA pRgn;
PROSRGNDATA pRgn;
if( !NT_SUCCESS( MmCopyFromCaller( pRect, unsafeRect, sizeof( RECT ) ) ) )
return NULL;
@ -1895,3 +1902,48 @@ W32kUnionRectWithRgn(HRGN hDest, const RECT* unsafeRect)
RGNDATA_UnlockRgn( hDest );
return hDest;
}
/***********************************************************************
* GetRegionData (GDI32.@)
*
* MSDN: GetRegionData, Return Values:
*
* "If the function succeeds and dwCount specifies an adequate number of bytes,
* the return value is always dwCount. If dwCount is too small or the function
* fails, the return value is 0. If lpRgnData is NULL, the return value is the
* required number of bytes.
*
* If the function fails, the return value is zero."
*/
DWORD STDCALL W32kGetRegionData(HRGN hrgn, DWORD count, LPRGNDATA rgndata)
{
DWORD size;
PROSRGNDATA obj = RGNDATA_LockRgn( hrgn );
if(!obj)
return 0;
size = obj->rdh.nCount * sizeof(RECT);
if(count < (size + sizeof(RGNDATAHEADER)) || rgndata == NULL)
{
RGNDATA_UnlockRgn( hrgn );
if (rgndata) /* buffer is too small, signal it by return 0 */
return 0;
else /* user requested buffer size with rgndata NULL */
return size + sizeof(RGNDATAHEADER);
}
//first we copy the header then we copy buffer
if( !NT_SUCCESS( MmCopyToCaller( rgndata, obj, sizeof( RGNDATAHEADER )))){
RGNDATA_UnlockRgn( hrgn );
return 0;
}
if( !NT_SUCCESS( MmCopyToCaller( (char*)rgndata+sizeof( RGNDATAHEADER ), obj->Buffer, size ))){
RGNDATA_UnlockRgn( hrgn );
return 0;
}
RGNDATA_UnlockRgn( hrgn );
return size + sizeof(RGNDATAHEADER);
}