diff --git a/reactos/win32ss/gdi/ntgdi/brush.c b/reactos/win32ss/gdi/ntgdi/brush.c index 33ce56b10f9..fa08cab99c8 100644 --- a/reactos/win32ss/gdi/ntgdi/brush.c +++ b/reactos/win32ss/gdi/ntgdi/brush.c @@ -484,60 +484,5 @@ NtGdiCreateSolidBrush(COLORREF Color, return IntGdiCreateSolidBrush(Color); } -/** - * \name NtGdiSetBrushOrg - * - * \brief Sets the brush origin that GDI assigns to - * the next brush an application selects into the specified device context. - * - * @implemented - */ -BOOL -APIENTRY -NtGdiSetBrushOrg(HDC hDC, INT XOrg, INT YOrg, LPPOINT Point) -{ - PDC dc; - PDC_ATTR pdcattr; - - dc = DC_LockDc(hDC); - if (dc == NULL) - { - EngSetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - pdcattr = dc->pdcattr; - - if (Point != NULL) - { - NTSTATUS Status = STATUS_SUCCESS; - POINT SafePoint; - SafePoint.x = pdcattr->ptlBrushOrigin.x; - SafePoint.y = pdcattr->ptlBrushOrigin.y; - _SEH2_TRY - { - ProbeForWrite(Point, sizeof(POINT), 1); - *Point = SafePoint; - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END; - - if (!NT_SUCCESS(Status)) - { - DC_UnlockDc(dc); - SetLastNtError(Status); - return FALSE; - } - } - - pdcattr->ptlBrushOrigin.x = XOrg; - pdcattr->ptlBrushOrigin.y = YOrg; - IntptlBrushOrigin(dc, XOrg, YOrg ); - DC_UnlockDc(dc); - - return TRUE; -} /* EOF */ diff --git a/reactos/win32ss/gdi/ntgdi/coord.c b/reactos/win32ss/gdi/ntgdi/coord.c index f8f1697d9de..d3a1a661782 100644 --- a/reactos/win32ss/gdi/ntgdi/coord.c +++ b/reactos/win32ss/gdi/ntgdi/coord.c @@ -1205,17 +1205,6 @@ NtGdiSetVirtualResolution( return TRUE; } -PPOINTL -FASTCALL -IntptlBrushOrigin(PDC pdc, LONG x, LONG y ) -{ - pdc->dclevel.ptlBrushOrigin.x = x; - pdc->dclevel.ptlBrushOrigin.y = y; - pdc->ptlFillOrigin.x = pdc->dclevel.ptlBrushOrigin.x + pdc->ptlDCOrig.x; - pdc->ptlFillOrigin.y = pdc->dclevel.ptlBrushOrigin.y + pdc->ptlDCOrig.y; - return &pdc->dclevel.ptlBrushOrigin; -} - static VOID FASTCALL DC_vGetAspectRatioFilter(PDC pDC, LPSIZE AspectRatio) diff --git a/reactos/win32ss/gdi/ntgdi/coord.h b/reactos/win32ss/gdi/ntgdi/coord.h index b0887644fc6..adf8626bb18 100644 --- a/reactos/win32ss/gdi/ntgdi/coord.h +++ b/reactos/win32ss/gdi/ntgdi/coord.h @@ -159,4 +159,4 @@ GreModifyWorldTransform( VOID FASTCALL IntMirrorWindowOrg(PDC); void FASTCALL IntFixIsotropicMapping(PDC); LONG FASTCALL IntCalcFillOrigin(PDC); -PPOINTL FASTCALL IntptlBrushOrigin(PDC pdc,LONG,LONG); + diff --git a/reactos/win32ss/gdi/ntgdi/dc.h b/reactos/win32ss/gdi/ntgdi/dc.h index 737bd32daba..97bd42e39dd 100644 --- a/reactos/win32ss/gdi/ntgdi/dc.h +++ b/reactos/win32ss/gdi/ntgdi/dc.h @@ -189,6 +189,9 @@ VOID FASTCALL IntvGetDeviceCaps(PPDEVOBJ, PDEVCAPS); BOOL FASTCALL IntSetDefaultRegion(PDC); BOOL NTAPI GreSetDCOwner(HDC hdc, ULONG ulOwner); +VOID +NTAPI +DC_vSetBrushOrigin(PDC pdc, LONG x, LONG y); FORCEINLINE PDC diff --git a/reactos/win32ss/gdi/ntgdi/dcobjs.c b/reactos/win32ss/gdi/ntgdi/dcobjs.c index 737cd671d96..d7699eca8a7 100644 --- a/reactos/win32ss/gdi/ntgdi/dcobjs.c +++ b/reactos/win32ss/gdi/ntgdi/dcobjs.c @@ -138,6 +138,71 @@ DC_vUpdateBackgroundBrush(PDC pdc) pdcattr->ulDirty_ &= ~DIRTY_BACKGROUND; } +VOID +NTAPI +DC_vSetBrushOrigin(PDC pdc, LONG x, LONG y) +{ + /* Set the brush origin */ + pdc->dclevel.ptlBrushOrigin.x = x; + pdc->dclevel.ptlBrushOrigin.y = y; + + /* Set the fill origin */ + pdc->ptlFillOrigin.x = x + pdc->ptlDCOrig.x; + pdc->ptlFillOrigin.y = y + pdc->ptlDCOrig.y; +} + +/** + * \name NtGdiSetBrushOrg + * + * \brief Sets the brush origin that GDI uses when drawing with pattern + * brushes. The brush origin is relative to the DC origin. + * + * @implemented + */ +BOOL +APIENTRY +NtGdiSetBrushOrg( + _In_ HDC hdc, + _In_ INT x, + _In_ INT y, + _Out_opt_ LPPOINT pptOut) +{ + PDC pdc; + + /* Lock the DC */ + pdc = DC_LockDc(hdc); + if (pdc == NULL) + { + EngSetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + /* Check if the old origin was requested */ + if (pptOut != NULL) + { + /* Enter SEH for buffer transfer */ + _SEH2_TRY + { + /* Probe and copy the old origin */ + ProbeForWrite(pptOut, sizeof(POINT), 1); + *pptOut = pdc->pdcattr->ptlBrushOrigin; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + DC_UnlockDc(pdc); + _SEH2_YIELD(return FALSE); + } + _SEH2_END; + } + + /* Call the internal function */ + DC_vSetBrushOrigin(pdc, x, y); + + /* Unlock the DC and return success */ + DC_UnlockDc(pdc); + return TRUE; +} + HPALETTE NTAPI GdiSelectPalette( diff --git a/reactos/win32ss/gdi/ntgdi/gdibatch.c b/reactos/win32ss/gdi/ntgdi/gdibatch.c index 4c380e69e71..ae365aa670d 100644 --- a/reactos/win32ss/gdi/ntgdi/gdibatch.c +++ b/reactos/win32ss/gdi/ntgdi/gdibatch.c @@ -109,7 +109,7 @@ GdiFlushUserBatch(PDC dc, PGDIBATCHHDR pHdr) if (!dc) break; pgSBO = (PGDIBSSETBRHORG) pHdr; pdcattr->ptlBrushOrigin = pgSBO->ptlBrushOrigin; - IntptlBrushOrigin(dc, pgSBO->ptlBrushOrigin.x, pgSBO->ptlBrushOrigin.y); + DC_vSetBrushOrigin(dc, pgSBO->ptlBrushOrigin.x, pgSBO->ptlBrushOrigin.y); break; } case GdiBCExtSelClipRgn: