Author: jimtabor
Date: Mon Sep 3 07:43:21 2007
New Revision: 28797
URL:
http://svn.reactos.org/svn/reactos?rev=28797&view=rev
Log:
- Win32k: DC_ATTR: Moved to it.
- We need to decide how to optimize the syncing. CreateD/IC/CompatibleDC, GetDCState and
SelectObject use the sync in one form. This can become ugly. Some DC handles do not belong
to the current process. We need to reorder the mess in dc.c and clean it up.
- Gdi32: The only ones using it are GetCurrentObject and with out updates
Get/SetDCBrush/PenColor.
- Implemented an example of RealizePalette. Moved SetBk/TextColor into dc.c, don't use
them.
- Update gdi32.def.
Modified:
trunk/reactos/dll/win32/gdi32/gdi32.def
trunk/reactos/dll/win32/gdi32/misc/hacks.c
trunk/reactos/dll/win32/gdi32/objects/dc.c
trunk/reactos/dll/win32/gdi32/objects/palette.c
trunk/reactos/subsystems/win32/win32k/objects/dc.c
trunk/reactos/subsystems/win32/win32k/objects/dcutil.c
Modified: trunk/reactos/dll/win32/gdi32/gdi32.def
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/gdi32.def?…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/gdi32.def (original)
+++ trunk/reactos/dll/win32/gdi32/gdi32.def Mon Sep 3 07:43:21 2007
@@ -520,7 +520,7 @@
PtInRegion@12=NtGdiPtInRegion@12
PtVisible@12=NtGdiPtVisible@12
QueryFontAssocStatus@0
-RealizePalette@4=NtGdiRealizePalette@4
+RealizePalette@4
RectInRegion@8=NtGdiRectInRegion@8
RectVisible@8=NtGdiRectVisible@8
Rectangle@20
@@ -588,7 +588,7 @@
SetSystemPaletteUse@8
SetTextAlign@8=NtGdiSetTextAlign@8
SetTextCharacterExtra@8
-SetTextColor@8=NtGdiSetTextColor@8
+SetTextColor@8
SetTextJustification@12
SetViewportExtEx@16=NtGdiSetViewportExtEx@16
SetViewportOrgEx@16=NtGdiSetViewportOrgEx@16
Modified: trunk/reactos/dll/win32/gdi32/misc/hacks.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/misc/hacks…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/misc/hacks.c (original)
+++ trunk/reactos/dll/win32/gdi32/misc/hacks.c Mon Sep 3 07:43:21 2007
@@ -108,18 +108,6 @@
* @implemented
*
*/
-COLORREF
-STDCALL
-SetBkColor(HDC hdc,
- COLORREF crColor)
-{
- return NtGdiSetBkColor(hdc,crColor);
-}
-
-/*
- * @implemented
- *
- */
HGDIOBJ
STDCALL
SelectObject(HDC hdc,
Modified: trunk/reactos/dll/win32/gdi32/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/dc…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/dc.c (original)
+++ trunk/reactos/dll/win32/gdi32/objects/dc.c Mon Sep 3 07:43:21 2007
@@ -320,13 +320,13 @@
STDCALL
GetDCObject( HDC hDC, INT iType)
{
-#if 0
+//#if 0
if((iType == GDI_OBJECT_TYPE_BRUSH) ||
(iType == GDI_OBJECT_TYPE_EXTPEN)||
(iType == GDI_OBJECT_TYPE_PEN) ||
(iType == GDI_OBJECT_TYPE_COLORSPACE))
{
- HGDIOBJ hGO;
+ HGDIOBJ hGO = NULL;
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hDC, (PVOID) &Dc_Attr)) return NULL;
@@ -348,7 +348,7 @@
}
return hGO;
}
-#endif
+//#endif
return NtGdiGetDCObject( hDC, iType );
}
@@ -691,12 +691,12 @@
HDC hdc
)
{
-#if 0
+//#if 0
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return CLR_INVALID;
return (COLORREF) Dc_Attr->ulPenClr;
-#endif
+//#endif
return NtUserGetDCBrushColor(hdc);
}
@@ -709,12 +709,12 @@
HDC hdc
)
{
-#if 0
+//#if 0
PDC_ATTR Dc_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return CLR_INVALID;
return (COLORREF) Dc_Attr->ulPenClr;
-#endif
+//#endif
return NtUserGetDCPenColor(hdc);
}
@@ -728,7 +728,7 @@
COLORREF crColor
)
{
-#if 0
+//#if 0
PDC_ATTR Dc_Attr;
COLORREF OldColor = CLR_INVALID;
@@ -745,7 +745,7 @@
}
}
return OldColor;
-#endif
+//#endif
return NtUserSetDCBrushColor(hdc, crColor);
}
@@ -759,27 +759,122 @@
COLORREF crColor
)
{
+//#if 0
+ PDC_ATTR Dc_Attr;
+ COLORREF OldColor = CLR_INVALID;
+
+ if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return OldColor;
+ else
+ {
+ OldColor = (COLORREF) Dc_Attr->ulPenClr;
+ Dc_Attr->ulPenClr = (ULONG) crColor;
+
+ if ( Dc_Attr->crPenClr != crColor )
+ {
+ Dc_Attr->ulDirty_ |= DIRTY_LINE;
+ Dc_Attr->crPenClr = crColor;
+ }
+ }
+ return OldColor;
+//#endif
+ return NtUserSetDCPenColor(hdc, crColor);
+}
+
+/*
+ * @implemented
+ */
+COLORREF
+STDCALL
+SetTextColor(
+ HDC hdc,
+ COLORREF crColor
+)
+{
#if 0
PDC_ATTR Dc_Attr;
COLORREF OldColor = CLR_INVALID;
if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return OldColor;
- else
- {
- OldColor = (COLORREF) Dc_Attr->ulPenClr;
- Dc_Attr->ulPenClr = (ULONG) crColor;
-
- if ( Dc_Attr->crPenClr != crColor )
- {
- Dc_Attr->ulDirty_ |= DIRTY_LINE;
- Dc_Attr->crPenClr = crColor;
- }
+#if 0
+ if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)
+ {
+ if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC)
+ return MFDRV_SetTextColor( hDC, crColor );
+ else
+ {
+ PLDC pLDC = Dc_Attr->pvLDC;
+ if ( !pLDC )
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ if (pLDC->iType == LDC_EMFLDC)
+ {
+ if return EMFDRV_SetTextColor( hDC, crColor );
+ }
+ }
+ }
+#endif
+ OldColor = (COLORREF) Dc_Attr->ulForegroundClr;
+ Dc_Attr->ulForegroundClr = (ULONG) crColor;
+
+ if ( Dc_Attr->crForegroundClr != crColor )
+ {
+ Dc_Attr->ulDirty_ |= DIRTY_TEXT;
+ Dc_Attr->crForegroundClr = crColor;
}
return OldColor;
#endif
- return NtUserSetDCPenColor(hdc, crColor);
-}
-
+ return NtGdiSetTextColor(hdc, crColor);
+}
+
+/*
+ * @implemented
+ */
+COLORREF
+STDCALL
+SetBkColor(
+ HDC hdc,
+ COLORREF crColor
+)
+{
+#if 0
+ PDC_ATTR Dc_Attr;
+ COLORREF OldColor = CLR_INVALID;
+
+ if (!GdiGetHandleUserData((HGDIOBJ) hdc, (PVOID) &Dc_Attr)) return OldColor;
+#if 0
+ if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)
+ {
+ if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC)
+ return MFDRV_SetBkColor( hDC, crColor );
+ else
+ {
+ PLDC pLDC = Dc_Attr->pvLDC;
+ if ( !pLDC )
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+ if (pLDC->iType == LDC_EMFLDC)
+ {
+ if return EMFDRV_SetBkColor( hDC, crColor );
+ }
+ }
+ }
+#endif
+ OldColor = (COLORREF) Dc_Attr->ulBackgroundClr;
+ Dc_Attr->ulBackgroundClr = (ULONG) crColor;
+
+ if ( Dc_Attr->crBackgroundClr != crColor )
+ {
+ Dc_Attr->ulDirty_ |= DIRTY_LINE;
+ Dc_Attr->crBackgroundClr = crColor;
+ }
+ return OldColor;
+#endif
+ return NtGdiSetBkColor(hdc, crColor);
+}
/*
* @implemented
Modified: trunk/reactos/dll/win32/gdi32/objects/palette.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/pa…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/palette.c (original)
+++ trunk/reactos/dll/win32/gdi32/objects/palette.c Mon Sep 3 07:43:21 2007
@@ -66,6 +66,36 @@
/*
* @implemented
*/
+UINT
+WINAPI
+RealizePalette(HDC hDC) /* [in] Handle of device context */
+{
+#if 0
+// Handle something other than a normal dc object.
+ if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)
+ {
+ if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC)
+ return MFDRV_(hDC);
+ else
+ {
+ HPALETTE Pal = GetDCObject(hDC, GDI_OBJECT_TYPE_PALETTE);
+ PLDC pLDC = GdiGetLDC((HDC) Pal);
+ if ( !pLDC ) return FALSE;
+ if (pLDC->iType == LDC_EMFLDC) return EMFDRV_(Pal);
+ return FALSE;
+ }
+ }
+#endif
+// return UserRealizePalette(hDC);
+
+//HACK!!!!!
+ return NtGdiRealizePalette(hDC);
+}
+
+
+/*
+ * @implemented
+ */
UINT
WINAPI
SetDIBColorTable(HDC hDC,
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 Mon Sep 3 07:43:21 2007
@@ -252,6 +252,7 @@
NewDC->Dc_Attr.crBackgroundClr = OrigDC->Dc_Attr.crBackgroundClr;
NewDC->Dc_Attr.jBkMode = OrigDC->Dc_Attr.jBkMode;
NewDC->Dc_Attr.jROP2 = OrigDC->Dc_Attr.jROP2;
+
DC_UnlockDc(NewDC);
DC_UnlockDc(OrigDC);
if (NULL != DisplayDC)
@@ -264,6 +265,7 @@
NtGdiDeleteObject(hVisRgn);
DC_InitDC(hNewDC);
+ DCU_SynchDcAttrtoUser(hNewDC, -1);
return hNewDC;
}
@@ -933,9 +935,17 @@
NtGdiSetTextAlign(hNewDC, TA_TOP);
NtGdiSetBkColor(hNewDC, RGB(255, 255, 255));
NtGdiSetBkMode(hNewDC, OPAQUE);
+ DCU_SynchDcAttrtoUser(hNewDC, -1);
}
else
{
+ /* From MSDN2:
+ The CreateIC function creates an information context for the specified device.
+ The information context provides a fast way to get information about the
+ device without creating a device context (DC). However, GDI drawing functions
+ cannot accept a handle to an information context.
+ */
+ NewDC->DC_Type = DC_TYPE_INFO;
DC_UnlockDc( NewDC );
}
@@ -1360,6 +1370,7 @@
newdc->w.hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
NtGdiCombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY );
}
+ DCU_SyncDcAttrtoUser(newdc, -1);
DC_UnlockDc( newdc );
DC_UnlockDc( dc );
return hnewdc;
@@ -2101,6 +2112,7 @@
default:
break;
}
+ DCU_SyncDcAttrtoUser(dc, -1);
DC_UnlockDc( dc );
return objOrg;
}
@@ -2335,7 +2347,6 @@
PDC NewDC;
HDC hDC;
PWSTR Buf = NULL;
-// PDC_ATTR DC_Attr = NULL;
if (Driver != NULL)
{
@@ -2356,7 +2367,7 @@
}
return NULL;
}
-#if 0
+//#if 0
PVOID NewMem = NULL;
ULONG MemSize = sizeof(DC_ATTR); //PAGE_SIZE it will allocate that size
NTSTATUS Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
@@ -2382,16 +2393,15 @@
}
}
KeLeaveCriticalRegion();
-#endif
+//#endif
NewDC = DC_LockDc(hDC);
/* FIXME - Handle NewDC == NULL! */
-#if 0
+//#if 0
if(NewMem)
{
NewDC->pDc_Attr = NewMem; // Store pointer
- DC_Attr = NewMem;
- }
-#endif
+ }
+//#endif
if (Driver != NULL)
{
RtlCopyMemory(&NewDC->DriverName, Driver, sizeof(UNICODE_STRING));
@@ -2408,39 +2418,31 @@
NewDC->w.xformVport2World = NewDC->w.xformWorld2Wnd;
NewDC->w.vport2WorldValid = TRUE;
-// XForm2MatrixS( &DC_Attr->mxWorldToDevice, &NewDC->w.xformWorld2Vport);
-// XForm2MatrixS( &DC_Attr->mxDevicetoWorld, &NewDC->w.xformVport2World);
-// XForm2MatrixS( &DC_Attr->mxWorldToPage, &NewDC->w.xformWorld2Wnd);
-
// Setup syncing bits for the dcattr data packets.
-// NewDC->Dc_Attr.flXform = DEVICE_TO_PAGE_INVALID;
-// DC_Attr->flXform = NewDC->Dc_Attr.flXform;
-// NewDC->Dc_Attr.ulDirty_ = 0; // Server side
-// DC_Attr->ulDirty_ = 0; // Client side
+ NewDC->Dc_Attr.flXform = DEVICE_TO_PAGE_INVALID;
+
+ NewDC->Dc_Attr.ulDirty_ = 0; // Server side
NewDC->Dc_Attr.iMapMode = MM_TEXT;
-// DC_Attr->iMapMode = MM_TEXT;
NewDC->Dc_Attr.szlWindowExt.cx = 1; // Float to Int,,, WRONG!
NewDC->Dc_Attr.szlWindowExt.cy = 1;
NewDC->Dc_Attr.szlViewportExt.cx = 1;
NewDC->Dc_Attr.szlViewportExt.cy = 1;
-// DC_Attr->szlWindowExt.cx = 1;
-// DC_Attr->szlWindowExt.cy = 1;
-// DC_Attr->szlViewportExt.cx = 1;
-// DC_Attr->szlViewportExt.cy = 1;
-
NewDC->Dc_Attr.crForegroundClr = 0;
NewDC->Dc_Attr.ulForegroundClr = 0;
NewDC->Dc_Attr.ulBackgroundClr = 0xffffff;
NewDC->Dc_Attr.crBackgroundClr = 0xffffff;
-// DC_Attr->ulBackgroundClr = 0xffffff;
-// DC_Attr->crBackgroundClr = 0xffffff;
+
+ NewDC->Dc_Attr.ulPenClr = RGB( 0, 0, 0 );
+ NewDC->Dc_Attr.crPenClr = RGB( 0, 0, 0 );
+
+ NewDC->Dc_Attr.ulBrushClr = RGB( 255, 255, 255 ); // Do this way too.
+ NewDC->Dc_Attr.crBrushClr = RGB( 255, 255, 255 );
NewDC->Dc_Attr.hlfntNew = NtGdiGetStockObject(SYSTEM_FONT);
-// DC_Attr->hlfntNew = NewDC->Dc_Attr.hlfntNew; // It's a service to the
user.
TextIntRealizeFont(NewDC->Dc_Attr.hlfntNew);
NewDC->w.hPalette = NtGdiGetStockObject(DEFAULT_PALETTE);
@@ -2477,10 +2479,10 @@
*/
}
-VOID FASTCALL
-DC_FreeDC(HDC DCToFree)
-{
-#if 0
+VOID
+FASTCALL
+DC_FreeDcAttr(HDC DCToFree)
+{
KeEnterCriticalRegion();
{
INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)DCToFree);
@@ -2500,7 +2502,14 @@
}
}
KeLeaveCriticalRegion();
-#endif
+}
+
+VOID FASTCALL
+DC_FreeDC(HDC DCToFree)
+{
+//#if 0
+ DC_FreeDcAttr(DCToFree);
+//#endif
if (!GDIOBJ_FreeObj(GdiHandleTable, DCToFree, GDI_OBJECT_TYPE_DC))
{
DPRINT("DC_FreeDC failed\n");
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 Mon Sep 3 07:43:21 2007
@@ -8,7 +8,6 @@
VOID
CopytoUserDcAttr(PDC dc, PDC_ATTR Dc_Attr, FLONG Dirty)
{
-
Dc_Attr->hpen = dc->Dc_Attr.hpen;
Dc_Attr->hbrush = dc->Dc_Attr.hbrush;
Dc_Attr->hColorSpace = dc->Dc_Attr.hColorSpace;
@@ -67,9 +66,17 @@
}
if ( Dirty & DIRTY_LINE || (Dc_Attr->ulDirty_ & DIRTY_LINE))
{
- dc->Dc_Attr.ulPenClr = Dc_Attr->ulPenClr;
- dc->Dc_Attr.crPenClr = Dc_Attr->crPenClr;
+ 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;
}
}
@@ -133,6 +140,7 @@
else
{
NTSTATUS Status = STATUS_SUCCESS;
+ KeEnterCriticalRegion();
_SEH_TRY
{
ProbeForWrite(DC_Attr,
@@ -152,6 +160,7 @@
Status = _SEH_GetExceptionCode();
}
_SEH_END;
+ KeLeaveCriticalRegion();
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
@@ -173,6 +182,7 @@
else
{
NTSTATUS Status = STATUS_SUCCESS;
+ KeEnterCriticalRegion();
_SEH_TRY
{
ProbeForWrite(Dc_Attr,
@@ -185,14 +195,9 @@
Status = _SEH_GetExceptionCode();
}
_SEH_END;
- if(!NT_SUCCESS(Status))
- {
- TryHarder = TRUE;
- }
- if (TryHarder)
- {
- return ReadWriteVMDcAttr( dc, Dirty, TRUE);
- }
+ KeLeaveCriticalRegion();
+ if(!NT_SUCCESS(Status)) TryHarder = TRUE;
+ if (TryHarder) return ReadWriteVMDcAttr( dc, Dirty, TRUE);
}
return TRUE;
}
@@ -218,6 +223,7 @@
else
{
NTSTATUS Status = STATUS_SUCCESS;
+ KeEnterCriticalRegion();
_SEH_TRY
{
ProbeForRead(Dc_Attr,
@@ -230,14 +236,9 @@
Status = _SEH_GetExceptionCode();
}
_SEH_END;
- if(!NT_SUCCESS(Status))
- {
- TryHarder = TRUE;
- }
- if (TryHarder)
- {
- return ReadWriteVMDcAttr( dc, Dirty, FALSE);
- }
+ KeLeaveCriticalRegion();
+ if(!NT_SUCCESS(Status)) TryHarder = TRUE;
+ if (TryHarder) return ReadWriteVMDcAttr( dc, Dirty, FALSE);
}
return TRUE;
}