Rewrote gdi (Engxxx) objects.

svn path=/trunk/; revision=3313
This commit is contained in:
Eugene Ingerman 2002-08-04 09:55:11 +00:00
parent 94706d121d
commit 7325b379e2
14 changed files with 193 additions and 152 deletions

View file

@ -14,48 +14,6 @@
#include "clip.h"
#include <include/object.h>
// FIXME: Complex clipping doesn't work
CLIPOBJ *EngCreateClipRegion(ULONG NumRects, RECTL Rects[],
ULONG Mode, ULONG Options)
{
HCLIP NewClip;
CLIPOBJ *ClipObj;
CLIPGDI *ClipGDI;
ClipObj = EngAllocMem(FL_ZERO_MEMORY, sizeof(CLIPOBJ), 0);
ClipGDI = EngAllocMem(FL_ZERO_MEMORY, sizeof(CLIPGDI), 0);
NewClip = CreateGDIHandle(ClipGDI, ClipObj);
ClipGDI->NumRegionRects = NumRects;
ClipGDI->RegionRects = Rects;
ClipObj->iMode = Mode;
ClipObj->fjOptions = Options;
ClipObj->iDComplexity = DC_TRIVIAL;
if(NumRects == 1)
{
ClipObj->iFComplexity = FC_RECT;
ClipObj->iDComplexity = DC_RECT;
// FIXME: Is this correct??
ClipObj->rclBounds = Rects[0];
} else
{
ClipObj->iDComplexity = DC_COMPLEX;
if(NumRects <= 4)
{
ClipObj->iFComplexity = FC_RECT4;
} else
{
ClipObj->iFComplexity = FC_COMPLEX;
}
}
return ClipObj;
}
VOID EngDeleteClipRegion(CLIPOBJ *ClipObj)
{
HCLIP HClip = AccessHandleFromUserObject(ClipObj);
@ -66,23 +24,6 @@ VOID EngDeleteClipRegion(CLIPOBJ *ClipObj)
FreeGDIHandle(HClip);
}
VOID EngIntersectClipRegion(CLIPOBJ *ClipObj, ULONG NumRects, RECTL *IntersectRects)
{
CLIPGDI *ClipGDI = (CLIPGDI*)AccessInternalObjectFromUserObject(ClipObj);
ClipGDI->NumIntersectRects = NumRects;
ClipGDI->IntersectRects = IntersectRects;
if(NumRects == 1)
{
ClipObj->iDComplexity = DC_RECT;
ClipObj->rclBounds = IntersectRects[0];
} else
{
ClipObj->iDComplexity = DC_COMPLEX;
ClipGDI->IntersectRects = IntersectRects;
}
}
CLIPOBJ * STDCALL
EngCreateClip(VOID)

View file

@ -11,57 +11,96 @@
#include <ddk/winddi.h>
#include "handle.h"
// FIXME: Total rewrite..
// Place User and GDI objects in ONE object with the user items shown first
// See ..\objects\gdiobj
// To switch between user and gdi objects, just -\+ the size of all the user items
//#define NDEBUG
#include <win32k/debug1.h>
ULONG CreateGDIHandle(PVOID InternalObject, PVOID UserObject)
ULONG CreateGDIHandle(ULONG InternalSize, ULONG UserSize)
{
ULONG NewHandle = HandleCounter++;
ULONG size;
PENGOBJ pObj;
int i;
GDIHandles[NewHandle].InternalObject = InternalObject;
GDIHandles[NewHandle].UserObject = UserObject;
size = sizeof( ENGOBJ ) + InternalSize + UserSize;
pObj = EngAllocMem( FL_ZERO_MEMORY, size, 0 );
return NewHandle;
if( !pObj )
return 0;
pObj->InternalSize = InternalSize;
pObj->UserSize = UserSize;
for( i=1; i < MAX_GDI_HANDLES; i++ ){
if( GDIHandles[ i ].pEngObj == NULL ){
pObj->hObj = i;
GDIHandles[ i ].pEngObj = pObj;
DPRINT("CreateGDIHandle: obj: %x, handle: %d, usersize: %d\n", pObj, i, UserSize );
return i;
}
}
DPRINT("CreateGDIHandle: Out of available handles!!!\n");
EngFreeMem( pObj );
return 0;
}
VOID FreeGDIHandle(ULONG Handle)
{
GDIHandles[Handle].InternalObject = NULL;
GDIHandles[Handle].UserObject = NULL;
if( Handle == 0 || Handle >= MAX_GDI_HANDLES ){
DPRINT("FreeGDIHandle: invalid handle!!!!\n");
return;
}
DPRINT("FreeGDIHandle: handle: %d\n", Handle);
EngFreeMem( GDIHandles[Handle].pEngObj );
GDIHandles[Handle].pEngObj = NULL;
}
PVOID AccessInternalObject(ULONG Handle)
{
return GDIHandles[Handle].InternalObject;
PENGOBJ pEngObj;
if( Handle == 0 || Handle >= MAX_GDI_HANDLES ){
DPRINT("AccessInternalObject: invalid handle: %d!!!!\n", Handle);
return NULL;
}
pEngObj = GDIHandles[Handle].pEngObj;
return (PVOID)((PCHAR)pEngObj + sizeof( ENGOBJ ) + pEngObj->UserSize);
}
PVOID AccessUserObject(ULONG Handle)
{
return GDIHandles[Handle].UserObject;
}
PENGOBJ pEngObj;
PVOID AccessInternalObjectFromUserObject(PVOID UserObject)
{
ULONG i;
for(i=0; i<MAX_GDI_HANDLES; i++)
{
if(GDIHandles[i].UserObject == UserObject) return GDIHandles[i].InternalObject;
if( Handle == 0 || Handle >= MAX_GDI_HANDLES ){
DPRINT("AccessUserObject: invalid handle: %d!!!!\n", Handle);
return NULL;
}
return NULL;
pEngObj = GDIHandles[Handle].pEngObj;
return (PVOID)( (PCHAR)pEngObj + sizeof( ENGOBJ ) );
}
ULONG AccessHandleFromUserObject(PVOID UserObject)
{
ULONG i;
PENGOBJ pEngObj;
ULONG Handle;
for(i=0; i<MAX_GDI_HANDLES; i++)
{
if(GDIHandles[i].UserObject == UserObject) return i;
if( !UserObject )
return INVALID_HANDLE;
pEngObj = (PENGOBJ)((PCHAR) UserObject - sizeof( ENGOBJ ));
Handle = pEngObj->hObj;
if( Handle == 0 || Handle >= MAX_GDI_HANDLES ){
DPRINT("AccessHandleFromUserObject: inv handle: %d, obj: %x!!!!\n", Handle, pEngObj);
return INVALID_HANDLE;
}
return INVALID_HANDLE;
return Handle;
}
PVOID AccessInternalObjectFromUserObject(PVOID UserObject)
{
return AccessInternalObject( AccessHandleFromUserObject( UserObject ) );
}

View file

@ -7,17 +7,21 @@
* REVISION HISTORY:
* 29/8/1999: Created
*/
#ifndef __ENG_HANDLE_H
#define __ENG_HANDLE_H
#include "objects.h"
#include <include/object.h>
typedef struct _GDI_HANDLE {
ULONG Handle;
PVOID InternalObject;
PVOID UserObject;
PENGOBJ pEngObj;
} GDI_HANDLE, *PGDI_HANDLE;
#define INVALID_HANDLE 0
#define MAX_GDI_HANDLES 4096
GDI_HANDLE GDIHandles[MAX_GDI_HANDLES];
ULONG HandleCounter = 1;
#define ValidEngHandle( x ) (!( (x) == INVALID_HANDLE ))
#endif

View file

@ -7,14 +7,40 @@
* REVISION HISTORY:
* 21/8/1999: Created
*/
#ifndef __ENG_OBJECTS_H
#define __ENG_OBJECTS_H
#include <freetype/freetype.h>
typedef struct _BRUSHGDI {
/* Structure of internal gdi objects that win32k manages for ddi engine:
|---------------------------------|
| EngObj |
|---------------------------------|
| Public part |
| accessed from engine |
|---------------------------------|
| Private part |
| managed by gdi |
|_________________________________|
---------------------------------------------------------------------------*/
typedef struct _ENGOBJ {
ULONG hObj;
ULONG InternalSize;
ULONG UserSize;
}ENGOBJ, *PENGOBJ;
typedef struct _BRUSHGDI {
ENGOBJ Header;
BRUSHOBJ BrushObj;
} BRUSHGDI;
typedef struct _CLIPGDI {
ENGOBJ Header;
CLIPOBJ ClipObj;
ULONG NumRegionRects;
ULONG NumIntersectRects;
RECTL *RegionRects;
@ -24,6 +50,7 @@ typedef struct _CLIPGDI {
ENUMRECTS EnumRects;
} CLIPGDI, *PCLIPGDI;
/*ei What is this for? */
typedef struct _DRVFUNCTIONSGDI {
HDEV hdev;
DRVFN Functions[INDEX_LAST];
@ -34,12 +61,18 @@ typedef struct _FLOATGDI {
} FLOATGDI;
typedef struct _FONTGDI {
ENGOBJ Header;
FONTOBJ FontObj;
LPCWSTR Filename;
FT_Face face;
TEXTMETRIC TextMetric;
} FONTGDI, *PFONTGDI;
typedef struct _PALGDI {
ENGOBJ Header;
PALOBJ PalObj;
ULONG Mode; // PAL_INDEXED, PAL_BITFIELDS, PAL_RGB, PAL_BGR
ULONG NumColors;
ULONG *IndexedColors;
@ -49,11 +82,14 @@ typedef struct _PALGDI {
} PALGDI, *PPALGDI;
typedef struct _PATHGDI {
ENGOBJ Header;
PATHOBJ PathObj;
} PATHGDI;
/*ei Fixme! Fix STROBJ */
typedef struct _STRGDI {
ENGOBJ Header;
//STROBJ StrObj;
} STRGDI;
typedef BOOL STDCALL (*PFN_BitBlt)(PSURFOBJ, PSURFOBJ, PSURFOBJ, PCLIPOBJ,
@ -100,6 +136,9 @@ typedef HBITMAP STDCALL (*PFN_CreateDeviceBitmap)(DHPDEV, SIZEL, ULONG);
typedef BOOL STDCALL (*PFN_SetPalette)(DHPDEV, PALOBJ*, ULONG, ULONG, ULONG);
typedef struct _SURFGDI {
ENGOBJ Header;
SURFOBJ SurfObj;
INT BitsPerPixel;
PFN_BitBlt BitBlt;
@ -121,10 +160,13 @@ typedef struct _SURFGDI {
} SURFGDI, *PSURFGDI;
typedef struct _XFORMGDI {
ENGOBJ Header;
/* XFORMOBJ has no public members */
} XFORMGDI;
typedef struct _XLATEGDI {
ENGOBJ Header;
XLATEOBJ XlateObj;
HPALETTE DestPal;
HPALETTE SourcePal;
@ -145,3 +187,5 @@ typedef struct _XLATEGDI {
#define MAX_GDI_SURFS 255
#define MAX_GDI_XFORMS 255
#define MAX_GDI_XLATES 255
#endif //__ENG_OBJECTS_H

View file

@ -10,7 +10,10 @@
#include <ddk/winddi.h>
#include <include/object.h>
#include "objects.h"
#include "handle.h"
//#define NDEBUG
#include <win32k/debug1.h>
HPALETTE STDCALL
EngCreatePalette(ULONG Mode,
@ -21,13 +24,14 @@ EngCreatePalette(ULONG Mode,
ULONG Blue)
{
HPALETTE NewPalette;
PALOBJ *PalObj;
PALGDI *PalGDI;
PalObj = EngAllocMem(FL_ZERO_MEMORY, sizeof(PALOBJ), 0);
PalGDI = EngAllocMem(FL_ZERO_MEMORY, sizeof(PALGDI), 0);
NewPalette = (HPALETTE)CreateGDIHandle(sizeof(PALGDI), sizeof(PALOBJ));
if( !ValidEngHandle( NewPalette ) )
return 0;
NewPalette = (HPALETTE)CreateGDIHandle(PalGDI, PalObj);
PalGDI = (PALGDI*) AccessInternalObject( NewPalette );
ASSERT( PalGDI );
PalGDI->Mode = Mode;
@ -55,16 +59,7 @@ EngCreatePalette(ULONG Mode,
BOOL STDCALL
EngDeletePalette(IN HPALETTE Palette)
{
PALOBJ *PalObj;
PALGDI *PalGDI;
PalGDI = (PALGDI*)AccessInternalObject((ULONG)Palette);
PalObj = (PALOBJ*)AccessUserObject((ULONG)Palette);
EngFreeMem(PalGDI);
EngFreeMem(PalObj);
FreeGDIHandle((ULONG)Palette);
return TRUE;
}

View file

@ -17,7 +17,10 @@
#include <include/dib.h>
#include <include/object.h>
#include <include/paint.h>
#include "objects.h"
#include "handle.h"
//#define NDEBUG
#include <win32k/debug1.h>
INT BitsPerFormat(ULONG Format)
{
@ -92,10 +95,15 @@ EngCreateBitmap(IN SIZEL Size,
SURFOBJ *SurfObj;
SURFGDI *SurfGDI;
SurfObj = EngAllocMem(FL_ZERO_MEMORY, sizeof(SURFOBJ), 0);
SurfGDI = EngAllocMem(FL_ZERO_MEMORY, sizeof(SURFGDI), 0);
NewBitmap = (PVOID)CreateGDIHandle(SurfGDI, SurfObj);
NewBitmap = (PVOID)CreateGDIHandle(sizeof(SURFGDI), sizeof(SURFOBJ));
if( !ValidEngHandle( NewBitmap ) )
return 0;
SurfObj = (SURFOBJ*) AccessUserObject( NewBitmap );
SurfGDI = (SURFGDI*) AccessInternalObject( NewBitmap );
ASSERT( SurfObj );
ASSERT( SurfGDI );
InitializeHooks(SurfGDI);
@ -141,10 +149,14 @@ EngCreateDeviceSurface(IN DHSURF dhsurf,
SURFOBJ *SurfObj;
SURFGDI *SurfGDI;
SurfObj = EngAllocMem(FL_ZERO_MEMORY, sizeof(SURFOBJ), 0);
SurfGDI = EngAllocMem(FL_ZERO_MEMORY, sizeof(SURFGDI), 0);
NewSurface = (HSURF)CreateGDIHandle(sizeof( SURFGDI ), sizeof( SURFOBJ ));
if( !ValidEngHandle( NewSurface ) )
return 0;
NewSurface = (HSURF)CreateGDIHandle(SurfGDI, SurfObj);
SurfObj = (SURFOBJ*) AccessUserObject( NewSurface );
SurfGDI = (SURFGDI*) AccessInternalObject( NewSurface );
ASSERT( SurfObj );
ASSERT( SurfGDI );
InitializeHooks(SurfGDI);
@ -212,16 +224,7 @@ EngAssociateSurface(IN HSURF Surface,
BOOL STDCALL
EngDeleteSurface(IN HSURF Surface)
{
SURFOBJ *SurfObj;
SURFGDI *SurfGDI;
SurfGDI = (SURFGDI*)AccessInternalObject((ULONG)Surface);
SurfObj = (SURFOBJ*)AccessUserObject((ULONG)Surface);
EngFreeMem(SurfGDI);
EngFreeMem(SurfObj);
FreeGDIHandle((ULONG)Surface);
return TRUE;
}

View file

@ -15,7 +15,10 @@
#include <ddk/ntddvid.h>
#include <include/object.h>
#include "objects.h"
#include "handle.h"
//#define NDEBUG
#include <win32k/debug1.h>
ULONG CCMLastSourceColor = 0, CCMLastColorMatch = 0;
@ -106,10 +109,14 @@ XLATEOBJ *EngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
PALGDI *SourcePalGDI, *DestPalGDI;
ULONG IndexedColors;
XlateObj = EngAllocMem(FL_ZERO_MEMORY, sizeof(XLATEOBJ), 0);
XlateGDI = EngAllocMem(FL_ZERO_MEMORY, sizeof(XLATEGDI), 0);
NewXlate = (HPALETTE)CreateGDIHandle(sizeof( XLATEGDI ), sizeof( XLATEOBJ ));
if( !ValidEngHandle( NewXlate ) )
return NULL;
NewXlate = (HPALETTE)CreateGDIHandle(XlateGDI, XlateObj);
XlateObj = (XLATEOBJ*) AccessUserObject( NewXlate );
XlateGDI = (XLATEGDI*) AccessInternalObject( NewXlate );
ASSERT( XlateObj );
ASSERT( XlateGDI );
if(SourcePalType == PAL_INDEXED)
SourcePalGDI = (PALGDI*)AccessInternalObject((ULONG)PaletteSource);
@ -202,8 +209,6 @@ VOID EngDeleteXlate(XLATEOBJ *XlateObj)
EngFreeMem(XlateGDI->translationTable);
}
EngFreeMem(XlateGDI);
EngFreeMem(XlateObj);
FreeGDIHandle((ULONG)HXlate);
}

View file

@ -101,13 +101,15 @@ VOID
ObmDestroyHandleTable(
PUSER_HANDLE_TABLE HandleTable);
PVOID AccessInternalObjectFromUserObject(PVOID UserObject);
PVOID AccessUserObject(ULONG Handle);
ULONG CreateGDIHandle(PVOID InternalObject, PVOID UserObject);
ULONG CreateGDIHandle(ULONG InternalSize, ULONG UserSize);
VOID FreeGDIHandle(ULONG Handle);
ULONG AccessHandleFromUserObject(PVOID UserObject);
PVOID AccessUserObject(ULONG Handle);
PVOID AccessInternalObject(ULONG Handle);
PVOID AccessInternalObjectFromUserObject(PVOID UserObject);
ULONG AccessHandleFromUserObject(PVOID UserObject);
#endif /* __WIN32K_OBJECT_H */
/* EOF */

View file

@ -3,7 +3,7 @@
#include <stdlib.h>
#include <win32k/bitmaps.h>
//#include <win32k/debug.h>
#include "../eng/objects.h"
#include "../eng/handle.h"
//#define NDEBUG
#include <win32k/debug1.h>

View file

@ -6,7 +6,7 @@
#include <ddk/winddi.h>
#include <win32k/dc.h>
#include <win32k/color.h>
#include "../eng/objects.h"
#include "../eng/handle.h"
// #define NDEBUG
#include <win32k/debug1.h>

View file

@ -1,4 +1,4 @@
/* $Id: dc.c,v 1.32 2002/07/13 21:37:26 ei Exp $
/* $Id: dc.c,v 1.33 2002/08/04 09:55:11 ei Exp $
*
* DC.C - Device context functions
*
@ -17,7 +17,7 @@
#include <win32k/gdiobj.h>
#include <win32k/pen.h>
#include <win32k/text.h>
#include "../eng/objects.h"
#include "../eng/handle.h"
//#define NDEBUG
#include <win32k/debug1.h>
@ -943,11 +943,12 @@ HGDIOBJ STDCALL W32kSelectObject(HDC hDC, HGDIOBJ hGDIObj)
// setup mem dc for drawing into bitmap
pb = BITMAPOBJ_HandleToPtr (hGDIObj);
surfobj = ExAllocatePool(PagedPool, sizeof(SURFOBJ));
surfgdi = ExAllocatePool(PagedPool, sizeof(SURFGDI));
dc->w.hBitmap = CreateGDIHandle(sizeof( SURFGDI ), sizeof( SURFOBJ )); // Assign the DC's bitmap
surfobj = (PSURFOBJ) AccessUserObject( dc->w.hBitmap );
surfgdi = (PSURFGDI) AccessInternalObject( dc->w.hBitmap );
BitmapToSurf(hDC, surfgdi, surfobj, pb); // Put the bitmap in a surface
dc->w.hBitmap = CreateGDIHandle(surfgdi, surfobj); // Assign the DC's bitmap
dc->Surface = dc->w.hBitmap;
// if we're working with a DIB, get the palette [fixme: only create if the selected palette is null]

View file

@ -4,7 +4,7 @@
#include <win32k/bitmaps.h>
#include <win32k/debug.h>
#include <debug.h>
#include "../eng/objects.h"
#include "../eng/handle.h"
#include <ntos/minmax.h>
VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap);
@ -96,9 +96,10 @@ INT STDCALL W32kSetDIBits(HDC hDC,
lpRGB = &bmi->bmiColors[0];
// Create a temporary surface for the destination bitmap
DestSurf = ExAllocatePool(PagedPool, sizeof(SURFOBJ));
DestGDI = ExAllocatePool(PagedPool, sizeof(SURFGDI));
DestBitmap = (HBITMAP)CreateGDIHandle(DestGDI, DestSurf);
DestBitmap = (HBITMAP)CreateGDIHandle(sizeof(SURFGDI), sizeof(SURFOBJ));
DestSurf = (PSURFOBJ) AccessUserObject( DestBitmap );
DestGDI = (PSURFGDI) AccessInternalObject( DestBitmap );
BitmapToSurf(hDC, DestGDI, DestSurf, bitmap);

View file

@ -804,7 +804,13 @@ static void REGION_RegionOp(
ASSERT( newReg->Buffer );
}
}
ExFreePool( oldRects );
if( newReg->rdh.nCount == 0 )
newReg->rdh.iType = NULLREGION;
else
newReg->rdh.iType = (newReg->rdh.nCount > 1)? COMPLEXREGION : SIMPLEREGION;
ExFreePool( oldRects );
return;
}
@ -1540,7 +1546,7 @@ W32kCreateRectRgn(INT LeftRect,
ASSERT(pRect);
// Fill in the region data header
pRgnData->rdh.iType = RDH_RECTANGLES;
pRgnData->rdh.iType = SIMPLEREGION;
W32kSetRect(&(pRgnData->rdh.rcBound), LeftRect, TopRect, RightRect, BottomRect);
// use W32kCopyRect when implemented

View file

@ -8,7 +8,7 @@
#include <win32k/kapi.h>
#include <freetype/freetype.h>
#include "../eng/objects.h"
#include "../eng/handle.h"
// #define NDEBUG
#include <win32k/debug1.h>
@ -61,9 +61,9 @@ W32kAddFontResource(LPCWSTR Filename)
UNICODE_STRING StringU;
IO_STATUS_BLOCK Iosb;
FontObj = EngAllocMem(FL_ZERO_MEMORY, sizeof(FONTOBJ), 0);
FontGDI = EngAllocMem(FL_ZERO_MEMORY, sizeof(FONTGDI), 0);
NewFont = (HFONT)CreateGDIHandle(FontGDI, FontObj);
NewFont = (HFONT)CreateGDIHandle(sizeof( FONTGDI ), sizeof( FONTOBJ ));
FontObj = (PFONTOBJ) AccessUserObject( NewFont );
FontGDI = (PFONTGDI) AccessInternalObject( NewFont );
RtlCreateUnicodeString(&uFileName, (LPWSTR)Filename);