Author: tkreuzer Date: Mon Apr 23 21:22:12 2012 New Revision: 56401
URL: http://svn.reactos.org/svn/reactos?rev=56401&view=rev Log: [GDI32/WIN32K] Fix some regressions from previous commit
Modified: trunk/reactos/win32ss/gdi/gdi32/objects/coord.c trunk/reactos/win32ss/gdi/gdi32/objects/dc.c
Modified: trunk/reactos/win32ss/gdi/gdi32/objects/coord.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/objects/c... ============================================================================== --- trunk/reactos/win32ss/gdi/gdi32/objects/coord.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/gdi32/objects/coord.c [iso-8859-1] Mon Apr 23 21:22:12 2012 @@ -479,7 +479,8 @@ int nYExtent, LPSIZE lpSize) { - PDC_ATTR Dc_Attr; + PDC_ATTR pdcattr; + #if 0 if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) { @@ -500,39 +501,44 @@ } } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + pdcattr = GdiGetDcAttr(hdc); + if (!pdcattr) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + }
if (lpSize) { - lpSize->cx = Dc_Attr->szlWindowExt.cx; - lpSize->cy = Dc_Attr->szlWindowExt.cy; - if (Dc_Attr->dwLayout & LAYOUT_RTL) lpSize->cx = -lpSize->cx; - } - - if (Dc_Attr->dwLayout & LAYOUT_RTL) + lpSize->cx = pdcattr->szlWindowExt.cx; + lpSize->cy = pdcattr->szlWindowExt.cy; + if (pdcattr->dwLayout & LAYOUT_RTL) lpSize->cx = -lpSize->cx; + } + + if (pdcattr->dwLayout & LAYOUT_RTL) { NtGdiMirrorWindowOrg(hdc); - Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); - } - else if ((Dc_Attr->iMapMode == MM_ISOTROPIC) || (Dc_Attr->iMapMode == MM_ANISOTROPIC)) - { - if ((Dc_Attr->szlWindowExt.cx == nXExtent) && (Dc_Attr->szlWindowExt.cy == nYExtent)) + pdcattr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); + } + else if ((pdcattr->iMapMode == MM_ISOTROPIC) || (pdcattr->iMapMode == MM_ANISOTROPIC)) + { + if ((pdcattr->szlWindowExt.cx == nXExtent) && (pdcattr->szlWindowExt.cy == nYExtent)) return TRUE;
if ((!nXExtent) || (!nYExtent)) return FALSE;
if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) { - if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) + if (pdcattr->ulDirty_ & DC_FONTTEXT_DIRTY) { NtGdiFlush(); // Sync up Dc_Attr from Kernel space. - Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); - } - } - Dc_Attr->szlWindowExt.cx = nXExtent; - Dc_Attr->szlWindowExt.cy = nYExtent; - if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); - Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); + pdcattr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); + } + } + pdcattr->szlWindowExt.cx = nXExtent; + pdcattr->szlWindowExt.cy = nYExtent; + if (pdcattr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); + pdcattr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); } return TRUE; // Return TRUE. }
Modified: trunk/reactos/win32ss/gdi/gdi32/objects/dc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/objects/d... ============================================================================== --- trunk/reactos/win32ss/gdi/gdi32/objects/dc.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/gdi32/objects/dc.c [iso-8859-1] Mon Apr 23 21:22:12 2012 @@ -909,9 +909,6 @@ SetLastError(ERROR_INVALID_PARAMETER); return cbResult;
- case GDI_OBJECT_TYPE_METADC: - return 0; - case GDI_OBJECT_TYPE_DC: case GDI_OBJECT_TYPE_REGION: case GDI_OBJECT_TYPE_EMF: @@ -1011,25 +1008,30 @@ COLORREF WINAPI SetDCPenColor( - HDC hdc, - COLORREF crColor -) -{ - PDC_ATTR Dc_Attr; - COLORREF OldColor = CLR_INVALID; - - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (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; - } - } + _In_ HDC hdc, + _In_ COLORREF crColor) +{ + PDC_ATTR pdcattr; + COLORREF OldColor; + + /* Get the dc attribute */ + pdcattr = GdiGetDcAttr(hdc); + if (!pdcattr) + { + SetLastError(ERROR_INVALID_PARAMETER); + return CLR_INVALID; + } + + /* Get old color and store the new */ + OldColor = (COLORREF)pdcattr->ulPenClr; + pdcattr->ulPenClr = (ULONG)crColor; + + if (pdcattr->crPenClr != crColor) + { + pdcattr->ulDirty_ |= DIRTY_LINE; + pdcattr->crPenClr = crColor; + } + return OldColor; }
@@ -1438,129 +1440,135 @@ INT WINAPI SetMapMode( - HDC hdc, - INT Mode -) + _In_ HDC hdc, + _In_ INT iMode) +{ + PDC_ATTR pdcattr; + + pdcattr = GdiGetDcAttr(hdc); + if (!pdcattr) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + +#if 0 + if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetMapMode(hdc, iMode); + else + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } +#endif + // Force change if Isotropic is set for recompute. + if ((iMode != pdcattr->iMapMode) || (iMode == MM_ISOTROPIC)) + { + pdcattr->ulDirty_ &= ~SLOW_WIDTHS; + return GetAndSetDCDWord( hdc, GdiGetSetMapMode, iMode, 0, 0, 0 ); + } + return pdcattr->iMapMode; +} + +/* + * @implemented + * + */ +int +WINAPI +GetStretchBltMode(HDC hdc) { PDC_ATTR Dc_Attr; if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + return Dc_Attr->lStretchBltMode; +} + +/* + * @implemented + */ +int +WINAPI +SetStretchBltMode(HDC hdc, int iStretchMode) +{ + INT oSMode; + PDC_ATTR Dc_Attr; #if 0 - if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetMapMode(hdc, Mode); + if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) + { + if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) + return MFDRV_SetStretchBltMode( hdc, iStretchMode); else { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } + PLDC pLDC = GdiGetLDC(hdc); + if ( !pLDC ) + { + SetLastError(ERROR_INVALID_HANDLE); + return 0; + } + if (pLDC->iType == LDC_EMFLDC) + { + return EMFDRV_SetStretchBltMode( hdc, iStretchMode); + } + } + } #endif - // Force change if Isotropic is set for recompute. - if ((Mode != Dc_Attr->iMapMode) || (Mode == MM_ISOTROPIC)) - { - Dc_Attr->ulDirty_ &= ~SLOW_WIDTHS; - return GetAndSetDCDWord( hdc, GdiGetSetMapMode, Mode, 0, 0, 0 ); - } - return Dc_Attr->iMapMode; - } - - /* - * @implemented - * - */ - int - WINAPI - GetStretchBltMode(HDC hdc) - { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - return Dc_Attr->lStretchBltMode; - } - - /* - * @implemented - */ - int - WINAPI - SetStretchBltMode(HDC hdc, int iStretchMode) - { - INT oSMode; - PDC_ATTR Dc_Attr; -#if 0 - if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) - { - if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC) - return MFDRV_SetStretchBltMode( hdc, iStretchMode); - else - { - PLDC pLDC = GdiGetLDC(hdc); - if ( !pLDC ) - { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - if (pLDC->iType == LDC_EMFLDC) - { - return EMFDRV_SetStretchBltMode( hdc, iStretchMode); - } - } - } -#endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; - - oSMode = Dc_Attr->lStretchBltMode; - Dc_Attr->lStretchBltMode = iStretchMode; - - // Wine returns an error here. We set the default. - if ((iStretchMode <= 0) || (iStretchMode > MAXSTRETCHBLTMODE)) iStretchMode = WHITEONBLACK; - - Dc_Attr->jStretchBltMode = iStretchMode; - - return oSMode; - } - - /* - * @implemented - */ - HFONT - WINAPI - GetHFONT(HDC hdc) - { - PDC_ATTR Dc_Attr; - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return NULL; - return Dc_Attr->hlfntNew; - } - - - /* - * @implemented - * - */ - HGDIOBJ - WINAPI - SelectObject(HDC hDC, - HGDIOBJ hGdiObj) - { - PDC_ATTR pDc_Attr; - HGDIOBJ hOldObj = NULL; - UINT uType; - - if(!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) - { - SetLastError(ERROR_INVALID_HANDLE); - return NULL; - } - - hGdiObj = GdiFixUpHandle(hGdiObj); - if (!GdiIsHandleValid(hGdiObj)) - { - return NULL; - } - - uType = GDI_HANDLE_GET_TYPE(hGdiObj); - - switch (uType) - { + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return 0; + + oSMode = Dc_Attr->lStretchBltMode; + Dc_Attr->lStretchBltMode = iStretchMode; + + // Wine returns an error here. We set the default. + if ((iStretchMode <= 0) || (iStretchMode > MAXSTRETCHBLTMODE)) iStretchMode = WHITEONBLACK; + + Dc_Attr->jStretchBltMode = iStretchMode; + + return oSMode; +} + +/* + * @implemented + */ +HFONT +WINAPI +GetHFONT(HDC hdc) +{ + PDC_ATTR Dc_Attr; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return NULL; + return Dc_Attr->hlfntNew; +} + + +/* + * @implemented + * + */ +HGDIOBJ +WINAPI +SelectObject(HDC hDC, + HGDIOBJ hGdiObj) +{ + PDC_ATTR pDc_Attr; + HGDIOBJ hOldObj = NULL; + UINT uType; + + if(!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr)) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + + hGdiObj = GdiFixUpHandle(hGdiObj); + if (!GdiIsHandleValid(hGdiObj)) + { + return NULL; + } + + uType = GDI_HANDLE_GET_TYPE(hGdiObj); + + switch (uType) + { case GDI_OBJECT_TYPE_REGION: return (HGDIOBJ)ExtSelectClipRgn(hDC, hGdiObj, RGN_COPY);
@@ -1618,10 +1626,10 @@ return NULL;
case GDI_OBJECT_TYPE_PALETTE: + SetLastError(ERROR_INVALID_FUNCTION); default: - SetLastError(ERROR_INVALID_FUNCTION); return NULL; - } - - return NULL; - } + } + + return NULL; +}