From 189fc82964b69a6b7cccffe74a58b84806529645 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 1 Apr 2009 01:49:18 +0000 Subject: [PATCH] win32k brush update: - fix EBRUSHOBJ_vSetSolidBrushColor - Initialize text and background brush in DC_AllocDC - Update the DCs EBRUSHOBJs on demand - Use the DCs EBRUSHOBJs for drawing where appropriate This makes things faster and finally adds support for DC_BRUSH and DC_PEN svn path=/trunk/; revision=40306 --- .../subsystems/win32/win32k/eng/engbrush.c | 14 +- .../subsystems/win32/win32k/include/brush.h | 2 +- reactos/subsystems/win32/win32k/include/dc.h | 4 + reactos/subsystems/win32/win32k/objects/arc.c | 10 +- .../subsystems/win32/win32k/objects/bitblt.c | 78 ++++------- .../subsystems/win32/win32k/objects/dclife.c | 15 ++- .../subsystems/win32/win32k/objects/dcobjs.c | 125 +++++++----------- .../subsystems/win32/win32k/objects/dcutil.c | 23 ++-- .../subsystems/win32/win32k/objects/drawing.c | 8 +- .../win32/win32k/objects/fillshap.c | 112 +++++----------- .../win32/win32k/objects/freetype.c | 78 ++--------- .../subsystems/win32/win32k/objects/line.c | 49 +++---- .../subsystems/win32/win32k/objects/region.c | 10 +- 13 files changed, 192 insertions(+), 336 deletions(-) diff --git a/reactos/subsystems/win32/win32k/eng/engbrush.c b/reactos/subsystems/win32/win32k/eng/engbrush.c index 0029d834725..21799f0e408 100644 --- a/reactos/subsystems/win32/win32k/eng/engbrush.c +++ b/reactos/subsystems/win32/win32k/eng/engbrush.c @@ -111,11 +111,21 @@ EBRUSHOBJ_vInit(EBRUSHOBJ *pebo, PBRUSH pbrush, XLATEOBJ *pxlo) VOID FASTCALL -EBRUSHOBJ_vSetSolidBrushColor(EBRUSHOBJ *pebo, ULONG iSolidColor) +EBRUSHOBJ_vSetSolidBrushColor(EBRUSHOBJ *pebo, COLORREF crColor, XLATEOBJ *pxlo) { + ULONG iSolidColor; + /* Never use with non-solid brushes */ ASSERT(pebo->flattrs & GDIBRUSH_IS_SOLID); + /* Set the RGB color */ + pebo->crRealize = crColor; + pebo->ulRGBColor = crColor; + + /* Translate the brush color to the target format */ + iSolidColor = XLATEOBJ_iXlate(pxlo, crColor); + pebo->BrushObject.iSolidColor = iSolidColor; + pebo->BrushObject.iSolidColor = iSolidColor; } @@ -169,7 +179,7 @@ EBRUSHOBJ_vUnrealizeBrush(EBRUSHOBJ *pebo) /* Check if it's a GDI realisation */ if (pebo->pengbrush) { - + EngDeleteSurface(pebo->pengbrush); } else if (pebo->BrushObject.pvRbrush) { diff --git a/reactos/subsystems/win32/win32k/include/brush.h b/reactos/subsystems/win32/win32k/include/brush.h index ccf994af713..f96fd7bf691 100644 --- a/reactos/subsystems/win32/win32k/include/brush.h +++ b/reactos/subsystems/win32/win32k/include/brush.h @@ -110,7 +110,7 @@ EBRUSHOBJ_vInit(EBRUSHOBJ *BrushInst, PBRUSH BrushObj, XLATEOBJ *XlateObj); VOID FASTCALL -EBRUSHOBJ_vSetSolidBrushColor(EBRUSHOBJ *pebo, ULONG iSolidColor); +EBRUSHOBJ_vSetSolidBrushColor(EBRUSHOBJ *pebo, COLORREF crColor, XLATEOBJ *pxlo); VOID FASTCALL diff --git a/reactos/subsystems/win32/win32k/include/dc.h b/reactos/subsystems/win32/win32k/include/dc.h index 59016abd6fd..6b04d84178b 100644 --- a/reactos/subsystems/win32/win32k/include/dc.h +++ b/reactos/subsystems/win32/win32k/include/dc.h @@ -246,6 +246,10 @@ VOID FASTCALL DC_UpdateXforms(PDC dc); BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest); VOID FASTCALL DC_vUpdateViewportExt(PDC pdc); VOID FASTCALL DC_vCopyState(PDC pdcSrc, PDC pdcDst); +VOID FASTCALL DC_vUpdateFillBrush(PDC pdc); +VOID FASTCALL DC_vUpdateLineBrush(PDC pdc); +VOID FASTCALL DC_vUpdateTextBrush(PDC pdc); +VOID FASTCALL DC_vUpdateBackgroundBrush(PDC pdc); BOOL FASTCALL DCU_SyncDcAttrtoUser(PDC); BOOL FASTCALL DCU_SynchDcAttrtoUser(HDC); diff --git a/reactos/subsystems/win32/win32k/objects/arc.c b/reactos/subsystems/win32/win32k/objects/arc.c index d2590ea7d2d..c18fc1560e0 100644 --- a/reactos/subsystems/win32/win32k/objects/arc.c +++ b/reactos/subsystems/win32/win32k/objects/arc.c @@ -165,8 +165,6 @@ IntArc( DC *dc, return FALSE; } - EBRUSHOBJ_vInit(&dc->eboLine, pbrushPen, dc->rosdc.XlatePen); - if (arctype == GdiTypePie) { PUTLINE(CenterX, CenterY, SfCx + CenterX, SfCy + CenterY, dc->eboLine); @@ -222,11 +220,11 @@ IntGdiArcInternal( pdcattr = dc->pdcattr; - if (pdcattr->ulDirty_ & DC_BRUSH_DIRTY) - IntGdiSelectBrush(dc,pdcattr->hbrush); + if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)) + DC_vUpdateFillBrush(dc); - if (pdcattr->ulDirty_ & DC_PEN_DIRTY) - IntGdiSelectPen(dc,pdcattr->hpen); + if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY)) + DC_vUpdateLineBrush(dc); if (arctype == GdiTypeArcTo) { diff --git a/reactos/subsystems/win32/win32k/objects/bitblt.c b/reactos/subsystems/win32/win32k/objects/bitblt.c index 4a6076f6a4f..ff9c09122fa 100644 --- a/reactos/subsystems/win32/win32k/objects/bitblt.c +++ b/reactos/subsystems/win32/win32k/objects/bitblt.c @@ -192,10 +192,7 @@ NtGdiBitBlt( POINTL SourcePoint, BrushOrigin; BOOL Status = FALSE; XLATEOBJ *XlateObj = NULL; - PBRUSH pbrush = NULL; - EBRUSHOBJ BrushInst; BOOL UsesSource = ROP3_USES_SOURCE(ROP); - BOOL UsesPattern = ROP3_USES_PATTERN(ROP); DCDest = DC_LockDc(hDCDest); if (NULL == DCDest) @@ -237,8 +234,8 @@ NtGdiBitBlt( pdcattr = DCDest->pdcattr; - if (pdcattr->ulDirty_ & DC_BRUSH_DIRTY) - IntGdiSelectBrush(DCDest,pdcattr->hbrush); + if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)) + DC_vUpdateFillBrush(DCDest); /* Offset the destination and source by the origin of their DCs. */ XDest += DCDest->ptlDCOrig.x; @@ -283,18 +280,6 @@ NtGdiBitBlt( } } - if (UsesPattern) - { - pbrush = BRUSH_LockBrush(pdcattr->hbrush); - if (NULL == pbrush) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - goto cleanup; - } - BrushOrigin = *((PPOINTL)&pbrush->ptOrigin); - EBRUSHOBJ_vInit(&BrushInst, pbrush, DCDest->rosdc.XlateBrush); - } - /* Create the XLATEOBJ. */ if (UsesSource) { @@ -310,11 +295,17 @@ NtGdiBitBlt( } /* Perform the bitblt operation */ - Status = IntEngBitBlt(&BitmapDest->SurfObj, BitmapSrc ? &BitmapSrc->SurfObj : NULL, NULL, - DCDest->rosdc.CombinedClip, XlateObj, &DestRect, - &SourcePoint, NULL, - pbrush ? &BrushInst.BrushObject : NULL, - &BrushOrigin, ROP3_TO_ROP4(ROP)); + Status = IntEngBitBlt(&BitmapDest->SurfObj, + BitmapSrc ? &BitmapSrc->SurfObj : NULL, + NULL, + DCDest->rosdc.CombinedClip, + XlateObj, + &DestRect, + &SourcePoint, + NULL, + &DCDest->eboFill.BrushObject, + &DCDest->dclevel.pbrFill->ptOrigin, + ROP3_TO_ROP4(ROP)); cleanup: if (UsesSource && XlateObj != NULL) @@ -328,10 +319,6 @@ cleanup: { SURFACE_UnlockSurface(BitmapSrc); } - if (pbrush != NULL) - { - BRUSH_UnlockBrush(pbrush); - } if (UsesSource && hDCSrc != hDCDest) { DC_UnlockDc(DCSrc); @@ -756,10 +743,7 @@ NtGdiStretchBlt( BOOL Status = FALSE; XLATEOBJ *XlateObj = NULL; POINTL BrushOrigin; - PBRUSH pbrush = NULL; - EBRUSHOBJ BrushInst; BOOL UsesSource = ROP3_USES_SOURCE(ROP); - BOOL UsesPattern = ROP3_USES_PATTERN(ROP); if (0 == WidthDest || 0 == HeightDest || 0 == WidthSrc || 0 == HeightSrc) { @@ -808,8 +792,8 @@ NtGdiStretchBlt( pdcattr = DCDest->pdcattr; - if (pdcattr->ulDirty_ & DC_BRUSH_DIRTY) - IntGdiSelectBrush(DCDest,pdcattr->hbrush); + if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)) + DC_vUpdateFillBrush(DCDest); /* Offset the destination and source by the origin of their DCs. */ XOriginDest += DCDest->ptlDCOrig.x; @@ -865,38 +849,28 @@ NtGdiStretchBlt( } } - if (UsesPattern) - { - pbrush = BRUSH_LockBrush(pdcattr->hbrush); - if (NULL == pbrush) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - goto failed; - } - BrushOrigin = *((PPOINTL)&pbrush->ptOrigin); - EBRUSHOBJ_vInit(&BrushInst, pbrush, DCDest->rosdc.XlateBrush); - } - /* Offset the brush */ BrushOrigin.x += DCDest->ptlDCOrig.x; BrushOrigin.y += DCDest->ptlDCOrig.y; /* Perform the bitblt operation */ - Status = IntEngStretchBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj, - NULL, DCDest->rosdc.CombinedClip, XlateObj, - &DestRect, &SourceRect, NULL, - pbrush ? &BrushInst.BrushObject : NULL, - &BrushOrigin, ROP3_TO_ROP4(ROP)); + Status = IntEngStretchBlt(&BitmapDest->SurfObj, + &BitmapSrc->SurfObj, + NULL, + DCDest->rosdc.CombinedClip, + XlateObj, + &DestRect, + &SourceRect, + NULL, + &DCDest->eboFill.BrushObject, + &BrushOrigin, + ROP3_TO_ROP4(ROP)); failed: if (XlateObj) { EngDeleteXlate(XlateObj); } - if (pbrush) - { - BRUSH_UnlockBrush(pbrush); - } if (BitmapSrc && DCSrc->rosdc.hBitmap != DCDest->rosdc.hBitmap) { SURFACE_UnlockSurface(BitmapSrc); diff --git a/reactos/subsystems/win32/win32k/objects/dclife.c b/reactos/subsystems/win32/win32k/objects/dclife.c index a107ace2f10..a5933916a11 100644 --- a/reactos/subsystems/win32/win32k/objects/dclife.c +++ b/reactos/subsystems/win32/win32k/objects/dclife.c @@ -22,6 +22,7 @@ DC_AllocDC(PUNICODE_STRING Driver) HDC hDC; PWSTR Buf = NULL; XFORM xformTemplate; + PBRUSH pbrush; if (Driver != NULL) { @@ -104,8 +105,16 @@ DC_AllocDC(PUNICODE_STRING Driver) /* Create the default pen / line brush */ pdcattr->hpen = NtGdiGetStockObject(BLACK_PEN); NewDC->dclevel.pbrLine = PEN_ShareLockPen(pdcattr->hpen); - EBRUSHOBJ_vInit(&NewDC->eboLine, NewDC->dclevel.pbrFill, NULL); + EBRUSHOBJ_vInit(&NewDC->eboLine, NewDC->dclevel.pbrLine, NULL); + /* Create the default text brush */ + pbrush = BRUSH_ShareLockBrush(NtGdiGetStockObject(BLACK_BRUSH)); + EBRUSHOBJ_vInit(&NewDC->eboText, pbrush, NULL); + pdcattr->ulDirty_ |= DIRTY_TEXT; + + /* Create the default background brush */ + pbrush = BRUSH_ShareLockBrush(NtGdiGetStockObject(WHITE_BRUSH)); + EBRUSHOBJ_vInit(&NewDC->eboBackground, pbrush, NULL); pdcattr->hlfntNew = NtGdiGetStockObject(SYSTEM_FONT); TextIntRealizeFont(pdcattr->hlfntNew,NULL); @@ -149,6 +158,10 @@ DC_Cleanup(PVOID ObjectBody) DC_vSelectFillBrush(pDC, NULL); DC_vSelectLineBrush(pDC, NULL); + /* Dereference default brushes */ + BRUSH_ShareUnlockBrush(pDC->eboText.pbrush); + BRUSH_ShareUnlockBrush(pDC->eboBackground.pbrush); + return TRUE; } diff --git a/reactos/subsystems/win32/win32k/objects/dcobjs.c b/reactos/subsystems/win32/win32k/objects/dcobjs.c index 18473d62d2e..52a6b8c1c7b 100644 --- a/reactos/subsystems/win32/win32k/objects/dcobjs.c +++ b/reactos/subsystems/win32/win32k/objects/dcobjs.c @@ -73,7 +73,6 @@ DC_vUpdateFillBrush(PDC pdc) PDC_ATTR pdcattr = pdc->pdcattr; PBRUSH pbrFill; XLATEOBJ *pxlo = NULL; - ULONG iSolidColor; /* Check if the brush handle has changed */ if (pdcattr->hbrush != pdc->dclevel.pbrFill->BaseObject.hHmgr) @@ -96,9 +95,6 @@ DC_vUpdateFillBrush(PDC pdc) { /* Invalid brush handle, restore old one */ pdcattr->hbrush = pdc->dclevel.pbrFill->BaseObject.hHmgr; - - /* ROS HACK, should use surf xlate */ - IntUpdateBrushXlate(pdc, &pdc->rosdc.XlateBrush, pdc->dclevel.pbrFill); } } @@ -108,11 +104,8 @@ DC_vUpdateFillBrush(PDC pdc) /* Check for DC brush */ if (pdcattr->hbrush == StockObjects[DC_BRUSH]) { - /* Translate the color to the target format */ - iSolidColor = XLATEOBJ_iXlate(pxlo, pdcattr->crPenClr); - /* Update the eboFill's solid color */ - EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboFill, iSolidColor); + EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboFill, pdcattr->crPenClr, pxlo); } /* Clear flags */ @@ -126,16 +119,12 @@ DC_vUpdateLineBrush(PDC pdc) PDC_ATTR pdcattr = pdc->pdcattr; PBRUSH pbrLine; XLATEOBJ *pxlo; - ULONG iSolidColor; - - /* ROS HACK, should use surf xlate */ - pxlo = pdc->rosdc.XlatePen; /* Check if the pen handle has changed */ if (pdcattr->hpen != pdc->dclevel.pbrLine->BaseObject.hHmgr) { /* Try to lock the new pen */ - pbrLine = BRUSH_ShareLockBrush(pdcattr->hpen); + pbrLine = PEN_ShareLockPen(pdcattr->hpen); if (pbrLine) { /* Unlock old brush, set new brush */ @@ -152,9 +141,6 @@ DC_vUpdateLineBrush(PDC pdc) { /* Invalid pen handle, restore old one */ pdcattr->hpen = pdc->dclevel.pbrLine->BaseObject.hHmgr; - - /* ROS HACK, should use surf xlate */ - IntUpdateBrushXlate(pdc, &pdc->rosdc.XlatePen, pdc->dclevel.pbrLine); } } @@ -164,11 +150,8 @@ DC_vUpdateLineBrush(PDC pdc) /* Check for DC pen */ if (pdcattr->hpen == StockObjects[DC_PEN]) { - /* Translate the color to the target format */ - iSolidColor = XLATEOBJ_iXlate(pxlo, pdcattr->crPenClr); - /* Update the eboLine's solid color */ - EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboLine, iSolidColor); + EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboLine, pdcattr->crPenClr, pxlo); } /* Clear flags */ @@ -180,17 +163,27 @@ FASTCALL DC_vUpdateTextBrush(PDC pdc) { PDC_ATTR pdcattr = pdc->pdcattr; - XLATEOBJ *pxlo; - ULONG iSolidColor; + XLATEOBJ *pxlo = NULL; + SURFACE *psurf; + HPALETTE hpal; - /* ROS HACK, should use surf xlate */ - pxlo = pdc->rosdc.XlatePen; - - /* Translate the color to the target format */ - iSolidColor = XLATEOBJ_iXlate(pxlo, pdcattr->crForegroundClr); +// psurf = pdc->dclevel.pSurface; + psurf = SURFACE_LockSurface(pdc->rosdc.hBitmap); + if (psurf) + { + hpal = psurf->hDIBPalette; + if (!hpal) hpal = pPrimarySurface->DevInfo.hpalDefault; + pxlo = IntEngCreateXlate(0, PAL_RGB, hpal, NULL); + SURFACE_UnlockSurface(psurf); + } /* Update the eboText's solid color */ - EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboText, iSolidColor); + EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboText, pdcattr->crForegroundClr, pxlo); + + if (pxlo) + { + EngDeleteXlate(pxlo); + } /* Clear flag */ pdcattr->ulDirty_ &= ~DIRTY_TEXT; @@ -201,17 +194,27 @@ FASTCALL DC_vUpdateBackgroundBrush(PDC pdc) { PDC_ATTR pdcattr = pdc->pdcattr; - XLATEOBJ *pxlo; - ULONG iSolidColor; + XLATEOBJ *pxlo = NULL; + SURFACE *psurf; + HPALETTE hpal; - /* ROS HACK, should use surf xlate */ - pxlo = pdc->rosdc.XlatePen; - - /* Translate the color to the target format */ - iSolidColor = XLATEOBJ_iXlate(pxlo, pdcattr->crBackgroundClr); +// psurf = pdc->dclevel.pSurface; + psurf = SURFACE_LockSurface(pdc->rosdc.hBitmap); + if (psurf) + { + hpal = psurf->hDIBPalette; + if (!hpal) hpal = pPrimarySurface->DevInfo.hpalDefault; + pxlo = IntEngCreateXlate(0, PAL_RGB, hpal, NULL); + SURFACE_UnlockSurface(psurf); + } /* Update the eboBackground's solid color */ - EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboBackground, iSolidColor); + EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboBackground, pdcattr->crBackgroundClr, pxlo); + + if (pxlo) + { + EngDeleteXlate(pxlo); + } /* Clear flag */ pdcattr->ulDirty_ &= ~DIRTY_BACKGROUND; @@ -270,33 +273,15 @@ IntGdiSelectBrush( { PDC_ATTR pdcattr; HBRUSH hOrgBrush; - PBRUSH pbrush; - BOOLEAN bSuccess; if (pDC == NULL || hBrush == NULL) return NULL; pdcattr = pDC->pdcattr; - pbrush = BRUSH_LockBrush(hBrush); - if (pbrush == NULL) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return NULL; - } - hOrgBrush = pdcattr->hbrush; pdcattr->hbrush = hBrush; - DC_vSelectFillBrush(pDC, pbrush); - - bSuccess = IntUpdateBrushXlate(pDC, &pDC->rosdc.XlateBrush, pbrush); - BRUSH_UnlockBrush(pbrush); - if(!bSuccess) - { - return NULL; - } - - pdcattr->ulDirty_ &= ~DC_BRUSH_DIRTY; + DC_vUpdateFillBrush(pDC); return hOrgBrush; } @@ -309,33 +294,15 @@ IntGdiSelectPen( { PDC_ATTR pdcattr; HPEN hOrgPen = NULL; - PBRUSH pbrushPen; - BOOLEAN bSuccess; if (pDC == NULL || hPen == NULL) return NULL; pdcattr = pDC->pdcattr; - pbrushPen = PEN_LockPen(hPen); - if (pbrushPen == NULL) - { - return NULL; - } - hOrgPen = pdcattr->hpen; pdcattr->hpen = hPen; - DC_vSelectLineBrush(pDC, pbrushPen); - - bSuccess = IntUpdateBrushXlate(pDC, &pDC->rosdc.XlatePen, pbrushPen); - PEN_UnlockPen(pbrushPen); - if (!bSuccess) - { - SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); - return NULL; - } - - pdcattr->ulDirty_ &= ~DC_PEN_DIRTY; + DC_vUpdateLineBrush(pDC); return hOrgPen; } @@ -361,7 +328,10 @@ NtGdiSelectBrush( return NULL; } - hOrgBrush = IntGdiSelectBrush(pDC,hBrush); +// hOrgBrush = IntGdiSelectBrush(pDC,hBrush); + hOrgBrush = pDC->pdcattr->hbrush; + pDC->pdcattr->hbrush = hBrush; + DC_vUpdateFillBrush(pDC); DC_UnlockDc(pDC); @@ -388,7 +358,10 @@ NtGdiSelectPen( return NULL; } - hOrgPen = IntGdiSelectPen(pDC, hPen); +// hOrgPen = IntGdiSelectPen(pDC, hPen); + hOrgPen = pDC->pdcattr->hpen; + pDC->pdcattr->hpen = hPen; + DC_vUpdateLineBrush(pDC); DC_UnlockDc(pDC); diff --git a/reactos/subsystems/win32/win32k/objects/dcutil.c b/reactos/subsystems/win32/win32k/objects/dcutil.c index 0a31a7725e1..9721af3147f 100644 --- a/reactos/subsystems/win32/win32k/objects/dcutil.c +++ b/reactos/subsystems/win32/win32k/objects/dcutil.c @@ -75,25 +75,26 @@ FASTCALL IntGdiSetTextColor(HDC hDC, COLORREF color) { - COLORREF oldColor; - PDC dc = DC_LockDc(hDC); + COLORREF crOldColor; + PDC pdc; PDC_ATTR pdcattr; - HBRUSH hBrush; - if (!dc) + pdc = DC_LockDc(hDC); + if (!pdc) { SetLastWin32Error(ERROR_INVALID_HANDLE); return CLR_INVALID; } - pdcattr = dc->pdcattr; + pdcattr = pdc->pdcattr; - oldColor = pdcattr->crForegroundClr; + // What about ulForegroundClr, like in gdi32? + crOldColor = pdcattr->crForegroundClr; pdcattr->crForegroundClr = color; - hBrush = pdcattr->hbrush; - pdcattr->ulDirty_ &= ~(DIRTY_TEXT|DIRTY_LINE|DIRTY_FILL); - DC_UnlockDc(dc); - NtGdiSelectBrush(hDC, hBrush); - return oldColor; + DC_vUpdateTextBrush(pdc); + + DC_UnlockDc(pdc); + + return crOldColor; } VOID diff --git a/reactos/subsystems/win32/win32k/objects/drawing.c b/reactos/subsystems/win32/win32k/objects/drawing.c index 83b34b4dbdf..1f63e21ff12 100755 --- a/reactos/subsystems/win32/win32k/objects/drawing.c +++ b/reactos/subsystems/win32/win32k/objects/drawing.c @@ -1192,7 +1192,6 @@ IntFillRect( DC *dc, DWORD ROP = PATCOPY; RECTL DestRect; SURFACE *psurf; - EBRUSHOBJ eboFill; POINTL BrushOrigin; BOOL Ret = TRUE; PDC_ATTR pdcattr; @@ -1236,11 +1235,6 @@ IntFillRect( DC *dc, else ROP = PATCOPY; - if (Pen) - EBRUSHOBJ_vInit(&eboFill, pbrush, dc->rosdc.XlatePen); - else - EBRUSHOBJ_vInit(&eboFill, pbrush, dc->rosdc.XlateBrush); - Ret = IntEngBitBlt( &psurf->SurfObj, NULL, @@ -1250,7 +1244,7 @@ IntFillRect( DC *dc, &DestRect, NULL, NULL, - &eboFill.BrushObject, // use pDC->eboFill + Pen ? &dc->eboLine.BrushObject : &dc->eboFill.BrushObject, &BrushOrigin, ROP3_TO_ROP4(ROP)); } diff --git a/reactos/subsystems/win32/win32k/objects/fillshap.c b/reactos/subsystems/win32/win32k/objects/fillshap.c index 15af40a5162..b53b1946842 100644 --- a/reactos/subsystems/win32/win32k/objects/fillshap.c +++ b/reactos/subsystems/win32/win32k/objects/fillshap.c @@ -36,8 +36,7 @@ IntGdiPolygon(PDC dc, int Count) { SURFACE *psurf; - PBRUSH pbrushLine, pbrushFill; - EBRUSHOBJ eboLine, eboFill; + PBRUSH pbrLine, pbrFill; BOOL ret = FALSE; // default to failure RECTL DestRect; int CurrentPoint; @@ -95,32 +94,32 @@ IntGdiPolygon(PDC dc, IntGdiSelectPen(dc,pdcattr->hpen); /* Special locking order to avoid lock-ups */ - pbrushFill = BRUSH_LockBrush(pdcattr->hbrush); - pbrushLine = PEN_LockPen(pdcattr->hpen); + pbrFill = dc->dclevel.pbrFill; + pbrLine = dc->dclevel.pbrLine; psurf = SURFACE_LockSurface(dc->rosdc.hBitmap); /* FIXME - psurf can be NULL!!!! don't assert but handle this case gracefully! */ ASSERT(psurf); - /* Now fill the polygon with the current brush. */ - if (pbrushFill && !(pbrushFill->flAttrs & GDIBRUSH_IS_NULL)) + /* Now fill the polygon with the current fill brush. */ + if (!(pbrFill->flAttrs & GDIBRUSH_IS_NULL)) { - BrushOrigin = *((PPOINTL)&pbrushFill->ptOrigin); + BrushOrigin = *((PPOINTL)&pbrFill->ptOrigin); BrushOrigin.x += dc->ptlDCOrig.x; BrushOrigin.y += dc->ptlDCOrig.y; - EBRUSHOBJ_vInit(&eboFill, pbrushFill, dc->rosdc.XlateBrush); - ret = IntFillPolygon (dc, psurf, &eboFill.BrushObject, Points, Count, - DestRect, &BrushOrigin); + ret = IntFillPolygon (dc, + psurf, + &dc->eboFill.BrushObject, + Points, + Count, + DestRect, + &BrushOrigin); } - if (pbrushFill) - BRUSH_UnlockBrush(pbrushFill); // Draw the Polygon Edges with the current pen ( if not a NULL pen ) - if (pbrushLine && !(pbrushLine->flAttrs & GDIBRUSH_IS_NULL)) + if (!(pbrLine->flAttrs & GDIBRUSH_IS_NULL)) { int i; - EBRUSHOBJ_vInit(&eboLine, pbrushLine, dc->rosdc.XlatePen); - for (i = 0; i < Count-1; i++) { @@ -130,7 +129,7 @@ IntGdiPolygon(PDC dc, ret = IntEngLineTo(&psurf->SurfObj, dc->rosdc.CombinedClip, - &eboLine.BrushObject, + &dc->eboLine.BrushObject, Points[i].x, /* From */ Points[i].y, Points[i+1].x, /* To */ @@ -144,7 +143,7 @@ IntGdiPolygon(PDC dc, { ret = IntEngLineTo(&psurf->SurfObj, dc->rosdc.CombinedClip, - &eboLine.BrushObject, + &dc->eboLine.BrushObject, Points[Count-1].x, /* From */ Points[Count-1].y, Points[0].x, /* To */ @@ -153,8 +152,6 @@ IntGdiPolygon(PDC dc, ROP2_TO_MIX(pdcattr->jROP2)); /* MIX */ } } - if (pbrushLine) - PEN_UnlockPen(pbrushLine); } SURFACE_UnlockSurface(psurf); @@ -522,8 +519,7 @@ IntRectangle(PDC dc, int BottomRect) { SURFACE *psurf = NULL; - PBRUSH pbrushLine = NULL, pbrushFill = NULL; - EBRUSHOBJ eboLine, eboFill; + PBRUSH pbrLine, pbrFill; BOOL ret = FALSE; // default to failure RECTL DestRect; MIX Mix; @@ -578,10 +574,9 @@ IntRectangle(PDC dc, if (pdcattr->ulDirty_ & DC_PEN_DIRTY) IntGdiSelectPen(dc,pdcattr->hpen); - /* Special locking order to avoid lock-ups! */ - pbrushFill = BRUSH_LockBrush(pdcattr->hbrush); - pbrushLine = PEN_LockPen(pdcattr->hpen); - if (!pbrushLine) + pbrFill = dc->dclevel.pbrFill; + pbrLine = dc->dclevel.pbrLine; + if (!pbrLine) { ret = FALSE; goto cleanup; @@ -593,14 +588,13 @@ IntRectangle(PDC dc, goto cleanup; } - if ( pbrushFill ) + if (pbrFill) { - if (!(pbrushFill->flAttrs & GDIBRUSH_IS_NULL)) + if (!(pbrFill->flAttrs & GDIBRUSH_IS_NULL)) { - BrushOrigin = *((PPOINTL)&pbrushFill->ptOrigin); + BrushOrigin = *((PPOINTL)&pbrFill->ptOrigin); BrushOrigin.x += dc->ptlDCOrig.x; BrushOrigin.y += dc->ptlDCOrig.y; - EBRUSHOBJ_vInit(&eboFill, pbrushFill, dc->rosdc.XlateBrush); ret = IntEngBitBlt(&psurf->SurfObj, NULL, NULL, @@ -609,57 +603,49 @@ IntRectangle(PDC dc, &DestRect, NULL, NULL, - &eboFill.BrushObject, + &dc->eboFill.BrushObject, &BrushOrigin, ROP3_TO_ROP4(PATCOPY)); } } - EBRUSHOBJ_vInit(&eboLine, pbrushLine, dc->rosdc.XlatePen); - // Draw the rectangle with the current pen ret = TRUE; // change default to success - if (!(pbrushLine->flAttrs & GDIBRUSH_IS_NULL)) + if (!(pbrLine->flAttrs & GDIBRUSH_IS_NULL)) { Mix = ROP2_TO_MIX(pdcattr->jROP2); ret = ret && IntEngLineTo(&psurf->SurfObj, dc->rosdc.CombinedClip, - &eboLine.BrushObject, + &dc->eboLine.BrushObject, DestRect.left, DestRect.top, DestRect.right, DestRect.top, &DestRect, // Bounding rectangle Mix); ret = ret && IntEngLineTo(&psurf->SurfObj, dc->rosdc.CombinedClip, - &eboLine.BrushObject, + &dc->eboLine.BrushObject, DestRect.right, DestRect.top, DestRect.right, DestRect.bottom, &DestRect, // Bounding rectangle Mix); ret = ret && IntEngLineTo(&psurf->SurfObj, dc->rosdc.CombinedClip, - &eboLine.BrushObject, + &dc->eboLine.BrushObject, DestRect.right, DestRect.bottom, DestRect.left, DestRect.bottom, &DestRect, // Bounding rectangle Mix); ret = ret && IntEngLineTo(&psurf->SurfObj, dc->rosdc.CombinedClip, - &eboLine.BrushObject, + &dc->eboLine.BrushObject, DestRect.left, DestRect.bottom, DestRect.left, DestRect.top, &DestRect, // Bounding rectangle Mix); } cleanup: - if (pbrushFill) - BRUSH_UnlockBrush(pbrushFill); - - if (pbrushLine) - PEN_UnlockPen(pbrushLine); - if (psurf) SURFACE_UnlockSurface(psurf); @@ -1086,12 +1072,10 @@ NtGdiExtFloodFill( PDC dc; PDC_ATTR pdcattr; SURFACE *psurf = NULL; - PBRUSH pbrushFill = NULL; - EBRUSHOBJ eboFill; + PBRUSH pbrFill = NULL; BOOL Ret = FALSE; RECTL DestRect; POINTL Pt; - POINTL BrushOrigin; DPRINT1("FIXME: NtGdiExtFloodFill is UNIMPLEMENTED\n"); @@ -1110,11 +1094,11 @@ NtGdiExtFloodFill( pdcattr = dc->pdcattr; - if (pdcattr->ulDirty_ & DC_PEN_DIRTY) - IntGdiSelectPen(dc,pdcattr->hpen); + if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)) + DC_vUpdateFillBrush(dc); - if (pdcattr->ulDirty_ & DC_BRUSH_DIRTY) - IntGdiSelectBrush(dc,pdcattr->hbrush); + if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY)) + DC_vUpdateLineBrush(dc); Pt.x = XStart; Pt.y = YStart; @@ -1126,8 +1110,8 @@ NtGdiExtFloodFill( else goto cleanup; - pbrushFill = BRUSH_LockBrush(pdcattr->hbrush); - if (!pbrushFill) + pbrFill = dc->dclevel.pbrFill; + if (!pbrFill) { Ret = FALSE; goto cleanup; @@ -1139,31 +1123,7 @@ NtGdiExtFloodFill( goto cleanup; } - if ( pbrushFill && (FillType == FLOODFILLBORDER)) - { - if (!(pbrushFill->flAttrs & GDIBRUSH_IS_NULL)) - { - pbrushFill->BrushAttr.lbColor = Color; - BrushOrigin = *((PPOINTL)&pbrushFill->ptOrigin); - BrushOrigin.x += dc->ptlDCOrig.x; - BrushOrigin.y += dc->ptlDCOrig.y; - EBRUSHOBJ_vInit(&eboFill, pbrushFill, dc->rosdc.XlateBrush); - Ret = IntEngBitBlt(&psurf->SurfObj, NULL, NULL, - dc->rosdc.CombinedClip, NULL, - &DestRect, NULL, NULL, - &eboFill.BrushObject, - &BrushOrigin, - ROP3_TO_ROP4(PATCOPY)); - } - } - else - { - } - cleanup: - if (pbrushFill) - BRUSH_UnlockBrush(pbrushFill); - if (psurf) SURFACE_UnlockSurface(psurf); diff --git a/reactos/subsystems/win32/win32k/objects/freetype.c b/reactos/subsystems/win32/win32k/objects/freetype.c index 8b565d10c91..f867386a5e6 100644 --- a/reactos/subsystems/win32/win32k/objects/freetype.c +++ b/reactos/subsystems/win32/win32k/objects/freetype.c @@ -3128,12 +3128,6 @@ GreExtTextOutW( FT_Bool use_kerning; RECTL DestRect, MaskRect; POINTL SourcePoint, BrushOrigin; - HBRUSH hbrushText = NULL; - PBRUSH pbrushText = NULL; - EBRUSHOBJ eboText; - HBRUSH hbrushBackGnd = NULL; - PBRUSH pbrushBackGnd = NULL; - EBRUSHOBJ eboBackGnd; HBITMAP HSourceGlyph; SURFOBJ *SourceGlyphSurf; SIZEL bitSize; @@ -3142,9 +3136,7 @@ GreExtTextOutW( FONTOBJ *FontObj; PFONTGDI FontGDI; PTEXTOBJ TextObj = NULL; - PPALGDI PalDestGDI; XLATEOBJ *XlateObj=NULL, *XlateObj2=NULL; - ULONG Mode; FT_Render_Mode RenderMode; BOOLEAN Render; POINT Start; @@ -3169,6 +3161,15 @@ GreExtTextOutW( pdcattr = dc->pdcattr; + if (pdcattr->ulDirty_ & DIRTY_TEXT) + DC_vUpdateTextBrush(dc); + + if ((fuOptions & ETO_OPAQUE) || pdcattr->jBkMode == OPAQUE) + { + if (pdcattr->ulDirty_ & DIRTY_BACKGROUND) + DC_vUpdateBackgroundBrush(dc); + } + /* Check if String is valid */ if ((Count > 0xFFFF) || (Count > 0 && String == NULL)) { @@ -3202,7 +3203,6 @@ GreExtTextOutW( goto fail; } SurfObj = &psurf->SurfObj; - ASSERT(SurfObj); Start.x = XStart; Start.y = YStart; @@ -3214,45 +3214,12 @@ GreExtTextOutW( /* Create the brushes */ hDestPalette = psurf->hDIBPalette; if (!hDestPalette) hDestPalette = pPrimarySurface->DevInfo.hpalDefault; - PalDestGDI = PALETTE_LockPalette(hDestPalette); - if ( !PalDestGDI ) - Mode = PAL_RGB; - else - { - Mode = PalDestGDI->Mode; - PALETTE_UnlockPalette(PalDestGDI); - } - XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, hDestPalette, NULL); + XlateObj = (XLATEOBJ*)IntEngCreateXlate(0, PAL_RGB, hDestPalette, NULL); if ( !XlateObj ) { goto fail; } - hbrushText = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, pdcattr->crForegroundClr), 0); - if ( !hbrushText ) - { - goto fail; - } - pbrushText = BRUSH_LockBrush(hbrushText); - if ( !pbrushText ) - { - goto fail; - } - EBRUSHOBJ_vInit(&eboText, pbrushText, NULL); - if ((fuOptions & ETO_OPAQUE) || pdcattr->jBkMode == OPAQUE) - { - hbrushBackGnd = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, pdcattr->crBackgroundClr), 0); - if ( !hbrushBackGnd ) - { - goto fail; - } - pbrushBackGnd = BRUSH_LockBrush(hbrushBackGnd); - if ( !pbrushBackGnd ) - { - goto fail; - } - EBRUSHOBJ_vInit(&eboBackGnd, pbrushBackGnd, NULL); - } - XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, hDestPalette); + XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, 0, NULL, hDestPalette); if ( !XlateObj2 ) { goto fail; @@ -3281,7 +3248,7 @@ GreExtTextOutW( &DestRect, &SourcePoint, &SourcePoint, - &eboBackGnd.BrushObject, + &dc->eboBackground.BrushObject, &BrushOrigin, ROP3_TO_ROP4(PATCOPY)); fuOptions &= ~ETO_OPAQUE; @@ -3527,7 +3494,7 @@ GreExtTextOutW( &DestRect, &SourcePoint, &SourcePoint, - &eboBackGnd.BrushObject, + &dc->eboBackground.BrushObject, &BrushOrigin, ROP3_TO_ROP4(PATCOPY)); BackgroundLeft = DestRect.right; @@ -3599,7 +3566,7 @@ GreExtTextOutW( &DestRect, &SourcePoint, (PPOINTL)&MaskRect, - &eboText.BrushObject, + &dc->eboText.BrushObject, &BrushOrigin); EngUnlockSurface(SourceGlyphSurf); @@ -3638,13 +3605,6 @@ GreExtTextOutW( SURFACE_UnlockSurface(psurf); if (TextObj != NULL) TEXTOBJ_UnlockText(TextObj); - if (hbrushBackGnd != NULL) - { - BRUSH_UnlockBrush(pbrushBackGnd); - GreDeleteObject(hbrushBackGnd); - } - BRUSH_UnlockBrush(pbrushText); - GreDeleteObject(hbrushText); good: DC_UnlockDc( dc ); @@ -3659,16 +3619,6 @@ fail: TEXTOBJ_UnlockText(TextObj); if (psurf != NULL) SURFACE_UnlockSurface(psurf); - if (hbrushBackGnd != NULL) - { - BRUSH_UnlockBrush(pbrushBackGnd); - GreDeleteObject(hbrushBackGnd); - } - if (hbrushText != NULL) - { - BRUSH_UnlockBrush(pbrushText); - GreDeleteObject(hbrushText); - } DC_UnlockDc(dc); return FALSE; diff --git a/reactos/subsystems/win32/win32k/objects/line.c b/reactos/subsystems/win32/win32k/objects/line.c index e70998d760c..a7feceef4ca 100644 --- a/reactos/subsystems/win32/win32k/objects/line.c +++ b/reactos/subsystems/win32/win32k/objects/line.c @@ -89,13 +89,11 @@ IntGdiLineTo(DC *dc, { SURFACE *psurf; BOOL Ret = TRUE; - PBRUSH pbrushLine; - EBRUSHOBJ eboLine; + PBRUSH pbrLine; RECTL Bounds; POINT Points[2]; PDC_ATTR pdcattr = dc->pdcattr; - if (PATH_IsPathOpen(dc->dclevel)) { Ret = PATH_LineTo(dc, XEnd, YEnd); @@ -112,11 +110,8 @@ IntGdiLineTo(DC *dc, } else { - if (pdcattr->ulDirty_ & DC_BRUSH_DIRTY) - IntGdiSelectBrush(dc,pdcattr->hbrush); - - if (pdcattr->ulDirty_ & DC_PEN_DIRTY) - IntGdiSelectPen(dc,pdcattr->hpen); + if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY)) + DC_vUpdateLineBrush(dc); psurf = SURFACE_LockSurface( dc->rosdc.hBitmap ); if (NULL == psurf) @@ -144,20 +139,14 @@ IntGdiLineTo(DC *dc, Bounds.bottom = max(Points[0].y, Points[1].y); /* get BRUSH from current pen. */ - pbrushLine = PEN_LockPen( pdcattr->hpen ); - if (!pbrushLine) - { - /* default to BLACK_PEN */ - pbrushLine = PEN_LockPen(NtGdiGetStockObject(BLACK_PEN)); - ASSERT(pbrushLine); - } + pbrLine = dc->dclevel.pbrLine; + ASSERT(pbrLine); - if (!(pbrushLine->flAttrs & GDIBRUSH_IS_NULL)) + if (!(pbrLine->flAttrs & GDIBRUSH_IS_NULL)) { - EBRUSHOBJ_vInit(&eboLine, pbrushLine, dc->rosdc.XlatePen); Ret = IntEngLineTo(&psurf->SurfObj, dc->rosdc.CombinedClip, - &eboLine.BrushObject, + &dc->eboLine.BrushObject, Points[0].x, Points[0].y, Points[1].x, Points[1].y, &Bounds, @@ -165,7 +154,6 @@ IntGdiLineTo(DC *dc, } SURFACE_UnlockSurface(psurf); - PEN_UnlockPen( pbrushLine ); } if (Ret) @@ -251,8 +239,7 @@ IntGdiPolyline(DC *dc, int Count) { SURFACE *psurf; - BRUSH *pbrushLine; - EBRUSHOBJ eboLine; + BRUSH *pbrLine; LPPOINT Points; BOOL Ret = TRUE; LONG i; @@ -261,18 +248,17 @@ IntGdiPolyline(DC *dc, if (PATH_IsPathOpen(dc->dclevel)) return PATH_Polyline(dc, pt, Count); - if (pdcattr->ulDirty_ & DC_BRUSH_DIRTY) - IntGdiSelectBrush(dc,pdcattr->hbrush); + if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)) + DC_vUpdateFillBrush(dc); - if (pdcattr->ulDirty_ & DC_PEN_DIRTY) - IntGdiSelectPen(dc,pdcattr->hpen); + if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY)) + DC_vUpdateLineBrush(dc); /* Get BRUSHOBJ from current pen. */ - pbrushLine = PEN_LockPen(pdcattr->hpen); - /* FIXME - pbrushLine can be NULL! Don't assert here! */ - ASSERT(pbrushLine); + pbrLine = dc->dclevel.pbrLine; + ASSERT(pbrLine); - if (!(pbrushLine->flAttrs & GDIBRUSH_IS_NULL)) + if (!(pbrLine->flAttrs & GDIBRUSH_IS_NULL)) { Points = EngAllocMem(0, Count * sizeof(POINT), TAG_COORD); if (Points != NULL) @@ -292,10 +278,9 @@ IntGdiPolyline(DC *dc, Points[i].y += dc->ptlDCOrig.y; } - EBRUSHOBJ_vInit(&eboLine, pbrushLine, dc->rosdc.XlatePen); Ret = IntEngPolyline(&psurf->SurfObj, dc->rosdc.CombinedClip, - &eboLine.BrushObject, + &dc->eboLine.BrushObject, Points, Count, ROP2_TO_MIX(pdcattr->jROP2)); @@ -309,8 +294,6 @@ IntGdiPolyline(DC *dc, } } - PEN_UnlockPen(pbrushLine); - return Ret; } diff --git a/reactos/subsystems/win32/win32k/objects/region.c b/reactos/subsystems/win32/win32k/objects/region.c index 343592c171a..c90c9c64eb8 100644 --- a/reactos/subsystems/win32/win32k/objects/region.c +++ b/reactos/subsystems/win32/win32k/objects/region.c @@ -2903,8 +2903,6 @@ IntGdiPaintRgn( PROSRGNDATA visrgn; CLIPOBJ* ClipRegion; BOOL bRet = FALSE; - PBRUSH pbrush; - EBRUSHOBJ eboFill; POINTL BrushOrigin; SURFACE *psurf; PDC_ATTR pdcattr; @@ -2912,6 +2910,8 @@ IntGdiPaintRgn( if (!dc) return FALSE; pdcattr = dc->pdcattr; + ASSERT(!(pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))); + if (!(tmpVisRgn = NtGdiCreateRectRgn(0, 0, 0, 0))) return FALSE; // Transform region into device co-ords @@ -2935,9 +2935,6 @@ IntGdiPaintRgn( visrgn->Buffer, &visrgn->rdh.rcBound ); ASSERT(ClipRegion); - pbrush = BRUSH_LockBrush(pdcattr->hbrush); - ASSERT(pbrush); - EBRUSHOBJ_vInit(&eboFill, pbrush, dc->rosdc.XlateBrush); BrushOrigin.x = pdcattr->ptlBrushOrigin.x; BrushOrigin.y = pdcattr->ptlBrushOrigin.y; @@ -2946,12 +2943,11 @@ IntGdiPaintRgn( bRet = IntEngPaint(&psurf->SurfObj, ClipRegion, - &eboFill.BrushObject, + &dc->eboFill.BrushObject, &BrushOrigin, 0xFFFF);//FIXME:don't know what to put here SURFACE_UnlockSurface(psurf); - BRUSH_UnlockBrush(pbrush); REGION_UnlockRgn(visrgn); GreDeleteObject(tmpVisRgn);