Author: jimtabor
Date: Thu Nov 15 01:53:19 2007
New Revision: 30448
URL:
http://svn.reactos.org/svn/reactos?rev=30448&view=rev
Log:
Removed code support for dcattr, it was over kill. Fix display locks, take resource from
GdiDevice. If pDc_Attr zero, use internal. Fix mass exit error when freeing already freed
handle.
Modified:
trunk/reactos/subsystems/win32/win32k/include/dc.h
trunk/reactos/subsystems/win32/win32k/objects/brush.c
trunk/reactos/subsystems/win32/win32k/objects/dc.c
trunk/reactos/subsystems/win32/win32k/objects/dcutil.c
trunk/reactos/subsystems/win32/win32k/objects/text.c
Modified: trunk/reactos/subsystems/win32/win32k/include/dc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/dc.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/dc.h Thu Nov 15 01:53:19 2007
@@ -86,19 +86,16 @@
HDC FASTCALL DC_GetNextDC (PDC pDC);
VOID FASTCALL DC_SetNextDC (PDC pDC, HDC hNextDC);
VOID FASTCALL DC_SetOwnership(HDC DC, PEPROCESS Owner);
-VOID FASTCALL DC_LockDisplay(PERESOURCE);
-VOID FASTCALL DC_UnlockDisplay(PERESOURCE);
+VOID FASTCALL DC_LockDisplay(HDC);
+VOID FASTCALL DC_UnlockDisplay(HDC);
VOID FASTCALL IntGdiCopyFromSaveState(PDC, PDC, HDC);
VOID FASTCALL IntGdiCopyToSaveState(PDC, PDC);
VOID FASTCALL DC_UpdateXforms(PDC dc);
BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest);
-BOOL FASTCALL DCU_UpdateUserXForms(PDC, ULONG);
BOOL FASTCALL DCU_SyncDcAttrtoUser(PDC, FLONG);
BOOL FASTCALL DCU_SynchDcAttrtoUser(HDC, FLONG);
-BOOL FASTCALL DCU_SyncDcAttrtoW32k(PDC, FLONG);
-BOOL FASTCALL DCU_SynchDcAttrtoW32k(HDC, FLONG);
VOID FASTCALL IntGetViewportExtEx(PDC dc, LPSIZE pt);
VOID FASTCALL IntGetViewportOrgEx(PDC dc, LPPOINT pt);
Modified: trunk/reactos/subsystems/win32/win32k/objects/brush.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/brush.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/brush.c Thu Nov 15 01:53:19 2007
@@ -589,6 +589,8 @@
NtGdiSetBrushOrg(HDC hDC, INT XOrg, INT YOrg, LPPOINT Point)
{
PDC dc = DC_LockDc(hDC);
+ PDC_ATTR Dc_Attr = dc->pDc_Attr;
+ if (!Dc_Attr) Dc_Attr = &dc->Dc_Attr;
if (dc == NULL)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
@@ -599,8 +601,8 @@
{
NTSTATUS Status = STATUS_SUCCESS;
POINT SafePoint;
- SafePoint.x = dc->Dc_Attr.ptlBrushOrigin.x;
- SafePoint.y = dc->Dc_Attr.ptlBrushOrigin.y;
+ SafePoint.x = Dc_Attr->ptlBrushOrigin.x;
+ SafePoint.y = Dc_Attr->ptlBrushOrigin.y;
_SEH_TRY
{
ProbeForWrite(Point,
@@ -621,36 +623,9 @@
return FALSE;
}
}
-
- dc->Dc_Attr.ptlBrushOrigin.x = XOrg;
- dc->Dc_Attr.ptlBrushOrigin.y = YOrg;
-
- if (dc->pDc_Attr)
- {
- PDC_ATTR Dc_Attr = dc->pDc_Attr;
- NTSTATUS Status = STATUS_SUCCESS;
- _SEH_TRY
- {
- ProbeForWrite(Dc_Attr,
- sizeof(DC_ATTR),
- 1);
- Dc_Attr->ptlBrushOrigin = dc->Dc_Attr.ptlBrushOrigin;
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
-
- if(!NT_SUCCESS(Status))
- {
- DC_UnlockDc(dc);
- SetLastNtError(Status);
- return FALSE;
- }
- }
+ Dc_Attr->ptlBrushOrigin.x = XOrg;
+ Dc_Attr->ptlBrushOrigin.y = YOrg;
DC_UnlockDc(dc);
-
return TRUE;
}
Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dc.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dc.c Thu Nov 15 01:53:19 2007
@@ -2528,7 +2528,6 @@
PDC pDC = DC_LockDc(DCToFree);
if (pDC->pDc_Attr == &pDC->Dc_Attr) return; // Internal DC object!
pDC->pDc_Attr = NULL;
-// pDC->pDc_Attr = &pDC->Dc_Attr; // Correct behavior.
DC_UnlockDc(pDC);
KeEnterCriticalRegion();
@@ -2556,10 +2555,18 @@
DC_FreeDC(HDC DCToFree)
{
DC_FreeDcAttr(DCToFree);
-
- if (!GDIOBJ_FreeObj(GdiHandleTable, DCToFree, GDI_OBJECT_TYPE_DC))
- {
- DPRINT("DC_FreeDC failed\n");
+ INT Index = GDI_HANDLE_GET_INDEX(DCToFree);
+ PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index];
+ if ((Entry->Type & ~GDI_ENTRY_REUSE_MASK) != 0 && Entry->KernelData
!= NULL)
+ {
+ if (!GDIOBJ_FreeObj(GdiHandleTable, DCToFree, GDI_OBJECT_TYPE_DC))
+ {
+ DPRINT1("DC_FreeDC failed\n");
+ }
+ }
+ else
+ {
+ DPRINT1("Attempted to Delete 0x%x currently being
destroyed!!!\n",DCToFree);
}
}
@@ -2655,21 +2662,31 @@
//
// Support multi display/device locks.
-// Here, it is PrimarySurface.hsemDevLock
-// or ((PGDIDEVICE)PDC->pPDev)->hsemDevLock
//
VOID
FASTCALL
-DC_LockDisplay(PERESOURCE Resource)
-{
+DC_LockDisplay(HDC hDC)
+{
+ PERESOURCE Resource;
+ PDC dc = DC_LockDc(hDC);
+ if (!dc) return;
+ Resource = ((PGDIDEVICE)dc->pPDev)->hsemDevLock;
+ DC_UnlockDc(dc);
+ if (!Resource) return;
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite( Resource , TRUE);
}
VOID
FASTCALL
-DC_UnlockDisplay(PERESOURCE Resource)
-{
+DC_UnlockDisplay(HDC hDC)
+{
+ PERESOURCE Resource;
+ PDC dc = DC_LockDc(hDC);
+ if (!dc) return;
+ Resource = ((PGDIDEVICE)dc->pPDev)->hsemDevLock;
+ DC_UnlockDc(dc);
+ if (!Resource) return;
ExReleaseResourceLite( Resource );
KeLeaveCriticalRegion();
}
Modified: trunk/reactos/subsystems/win32/win32k/objects/dcutil.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dcutil.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dcutil.c Thu Nov 15 01:53:19 2007
@@ -52,160 +52,19 @@
XForm2MatrixS( &Dc_Attr->mxWorldToPage, &dc->w.xformWorld2Wnd);
}
-static
-VOID
-CopyFromUserDcAttr(PDC dc, PDC_ATTR Dc_Attr, FLONG Dirty)
-{
- if ( (Dirty & DIRTY_FILL) || (Dc_Attr->ulDirty_ & DIRTY_FILL))
- {
- dc->Dc_Attr.ulBrushClr = Dc_Attr->ulBrushClr;
- dc->Dc_Attr.crBrushClr = Dc_Attr->crBrushClr;
- Dc_Attr->ulDirty_ &= ~DIRTY_FILL;
- }
- if ( Dirty & DIRTY_LINE || (Dc_Attr->ulDirty_ & DIRTY_LINE))
- {
- dc->Dc_Attr.crBackgroundClr = Dc_Attr->crBackgroundClr;
- dc->Dc_Attr.ulBackgroundClr = Dc_Attr->ulBackgroundClr;
- dc->Dc_Attr.ulPenClr = Dc_Attr->ulPenClr;
- dc->Dc_Attr.crPenClr = Dc_Attr->crPenClr;
- Dc_Attr->ulDirty_ &= ~DIRTY_LINE;
- }
- if ( Dirty & DIRTY_TEXT || (Dc_Attr->ulDirty_ & DIRTY_TEXT))
- {
- dc->Dc_Attr.crForegroundClr = Dc_Attr->crForegroundClr;
- dc->Dc_Attr.ulForegroundClr = Dc_Attr->ulForegroundClr;
- Dc_Attr->ulDirty_ &= ~DIRTY_TEXT;
- }
-
- if ( Dirty & (DC_MODE_DIRTY|DC_FONTTEXT_DIRTY) ||
- (Dc_Attr->ulDirty_ & (DC_MODE_DIRTY|DC_FONTTEXT_DIRTY)))
- {
- dc->Dc_Attr.jROP2 = Dc_Attr->jROP2;
- dc->Dc_Attr.iGraphicsMode = Dc_Attr->iGraphicsMode;
- dc->Dc_Attr.lFillMode = Dc_Attr->lFillMode;
- dc->Dc_Attr.flFontMapper = Dc_Attr->flFontMapper;
- dc->Dc_Attr.lBreakExtra = Dc_Attr->lBreakExtra;
- dc->Dc_Attr.cBreak = Dc_Attr->cBreak;
- }
-}
-
-static
-BOOL
-ReadWriteVMDcAttr(PDC dc, FLONG Dirty, BOOL Write)
-{
- BOOL Ret = FALSE;
- KeEnterCriticalRegion();
- {
- INT Index = GDI_HANDLE_GET_INDEX(dc->hHmgr);
- PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index];
- HANDLE ProcessId = (HANDLE)(((ULONG_PTR)(Entry->ProcessId)) & ~1);
- DC_ATTR lDc_AttrData;
-
- if(Entry->UserData)
- {
- NTSTATUS Status = ZwReadVirtualMemory ( ProcessId,
- &(Entry->UserData),
- &lDc_AttrData,
- sizeof(DC_ATTR),
- NULL );
- if (Write)
- {
- if (NT_SUCCESS(Status)) CopytoUserDcAttr(dc, &lDc_AttrData, Dirty);
- Ret = TRUE;
- }
- else
- {
- if (NT_SUCCESS(Status)) CopyFromUserDcAttr(dc, &lDc_AttrData, Dirty);
- Ret = TRUE;
- }
- if (Write)
- Status = ZwWriteVirtualMemory ( ProcessId,
- &(Entry->UserData),
- &lDc_AttrData,
- sizeof(DC_ATTR),
- NULL );
- if(!NT_SUCCESS(Status))
- {
- SetLastNtError(Status);
- Ret = FALSE;
- }
- }
- }
- KeLeaveCriticalRegion();
- return Ret;
-}
-
-
-BOOL
-FASTCALL
-DCU_UpdateUserXForms(PDC pDC, ULONG uMask)
-{
- PDC_ATTR DC_Attr = pDC->pDc_Attr;
-
- if (!uMask) return FALSE;
-
- if (!DC_Attr) return FALSE;
- else
- {
- NTSTATUS Status = STATUS_SUCCESS;
- KeEnterCriticalRegion();
- _SEH_TRY
- {
- ProbeForWrite(DC_Attr,
- sizeof(DC_ATTR),
- 1);
- if (uMask & WORLD_XFORM_CHANGED)
- XForm2MatrixS( &DC_Attr->mxWorldToDevice, &pDC->w.xformWorld2Vport);
-
- if (uMask & DEVICE_TO_WORLD_INVALID)
- XForm2MatrixS( &DC_Attr->mxDevicetoWorld, &pDC->w.xformVport2World);
-
- if (uMask & WORLD_TO_PAGE_IDENTITY)
- XForm2MatrixS( &DC_Attr->mxWorldToPage, &pDC->w.xformWorld2Wnd);
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- KeLeaveCriticalRegion();
- if(!NT_SUCCESS(Status))
- {
- SetLastNtError(Status);
- return FALSE;
- }
- }
- return TRUE;
-}
BOOL
FASTCALL
DCU_SyncDcAttrtoUser(PDC dc, FLONG Dirty)
{
- BOOL TryHarder = FALSE;
PDC_ATTR Dc_Attr = dc->pDc_Attr;
if (!Dirty) return FALSE;
+
+ if (Dc_Attr == ((PDC_ATTR)&dc->Dc_Attr)) return TRUE; // No need to copy self.
+
if (!Dc_Attr) return FALSE;
else
- {
- NTSTATUS Status = STATUS_SUCCESS;
- KeEnterCriticalRegion();
- _SEH_TRY
- {
- ProbeForWrite(Dc_Attr,
- sizeof(DC_ATTR),
- 1);
- CopytoUserDcAttr( dc, Dc_Attr, Dirty);
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- KeLeaveCriticalRegion();
- if(!NT_SUCCESS(Status)) TryHarder = TRUE;
- if (TryHarder) return ReadWriteVMDcAttr( dc, Dirty, TRUE);
- }
+ CopytoUserDcAttr( dc, Dc_Attr, Dirty);
return TRUE;
}
@@ -220,45 +79,4 @@
return Ret;
}
-BOOL
-FASTCALL
-DCU_SyncDcAttrtoW32k(PDC dc, FLONG Dirty)
-{
- BOOL TryHarder = FALSE;
- PDC_ATTR Dc_Attr = dc->pDc_Attr;
- if (!Dirty) return FALSE;
- if (!Dc_Attr) return FALSE;
- else
- {
- NTSTATUS Status = STATUS_SUCCESS;
- KeEnterCriticalRegion();
- _SEH_TRY
- {
- ProbeForRead(Dc_Attr,
- sizeof(DC_ATTR),
- 1);
- CopyFromUserDcAttr( dc, Dc_Attr, Dirty);
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- KeLeaveCriticalRegion();
- if(!NT_SUCCESS(Status)) TryHarder = TRUE;
- if (TryHarder) return ReadWriteVMDcAttr( dc, Dirty, FALSE);
- }
- return TRUE;
-}
-BOOL
-FASTCALL
-DCU_SynchDcAttrtoW32k(HDC hDC, FLONG Dirty)
-{
- PDC pDC = DC_LockDc ( hDC );
- if (!pDC) return FALSE;
- BOOL Ret = DCU_SyncDcAttrtoW32k(pDC, Dirty);
- DC_UnlockDc( pDC );
- return Ret;
-}
-
Modified: trunk/reactos/subsystems/win32/win32k/objects/text.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/text.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/text.c Thu Nov 15 01:53:19 2007
@@ -3348,34 +3348,15 @@
DWORD cscp = IntGdiGetCharSet(hDC);
// If here, update everything!
Dc = DC_LockDc(hDC);
+ PDC_ATTR Dc_Attr = Dc->pDc_Attr;
+ if (!Dc_Attr) Dc_Attr = &Dc->Dc_Attr;
if (!Dc)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return 0;
}
-
- Dc->Dc_Attr.iCS_CP = cscp;
- Dc->Dc_Attr.ulDirty_ &= ~DIRTY_CHARSET;
-
- if (Dc->pDc_Attr)
- {
- PDC_ATTR Dc_Attr = Dc->pDc_Attr;
- NTSTATUS Status = STATUS_SUCCESS;
- _SEH_TRY
- {
- ProbeForWrite(Dc_Attr,
- sizeof(DC_ATTR),
- 1);
- Dc_Attr->iCS_CP = cscp;
- Dc_Attr->ulDirty_ &= ~DIRTY_CHARSET;
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- if(!NT_SUCCESS(Status)) SetLastNtError(Status);
- }
+ Dc_Attr->iCS_CP = cscp;
+ Dc_Attr->ulDirty_ &= ~DIRTY_CHARSET;
DC_UnlockDc( Dc );
return cscp;
}