Author: tkreuzer Date: Wed Apr 1 05:49:18 2009 New Revision: 40306
URL: http://svn.reactos.org/svn/reactos?rev=40306&view=rev Log: 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
Modified: trunk/reactos/subsystems/win32/win32k/eng/engbrush.c trunk/reactos/subsystems/win32/win32k/include/brush.h trunk/reactos/subsystems/win32/win32k/include/dc.h trunk/reactos/subsystems/win32/win32k/objects/arc.c trunk/reactos/subsystems/win32/win32k/objects/bitblt.c trunk/reactos/subsystems/win32/win32k/objects/dclife.c trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c trunk/reactos/subsystems/win32/win32k/objects/dcutil.c trunk/reactos/subsystems/win32/win32k/objects/drawing.c trunk/reactos/subsystems/win32/win32k/objects/fillshap.c trunk/reactos/subsystems/win32/win32k/objects/freetype.c trunk/reactos/subsystems/win32/win32k/objects/line.c trunk/reactos/subsystems/win32/win32k/objects/region.c
Modified: trunk/reactos/subsystems/win32/win32k/eng/engbrush.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/engbrush.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/eng/engbrush.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -111,10 +111,20 @@
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 @@ /* Check if it's a GDI realisation */ if (pebo->pengbrush) { - + EngDeleteSurface(pebo->pengbrush); } else if (pebo->BrushObject.pvRbrush) {
Modified: trunk/reactos/subsystems/win32/win32k/include/brush.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/brush.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/brush.h [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -110,7 +110,7 @@
VOID FASTCALL -EBRUSHOBJ_vSetSolidBrushColor(EBRUSHOBJ *pebo, ULONG iSolidColor); +EBRUSHOBJ_vSetSolidBrushColor(EBRUSHOBJ *pebo, COLORREF crColor, XLATEOBJ *pxlo);
VOID FASTCALL
Modified: trunk/reactos/subsystems/win32/win32k/include/dc.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -246,6 +246,10 @@ 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);
Modified: trunk/reactos/subsystems/win32/win32k/objects/arc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/arc.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/arc.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -165,8 +165,6 @@ 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 @@
pdcattr = dc->pdcattr;
- if (pdcattr->ulDirty_ & DC_BRUSH_DIRTY) - IntGdiSelectBrush(dc,pdcattr->hbrush); - - if (pdcattr->ulDirty_ & DC_PEN_DIRTY) - IntGdiSelectPen(dc,pdcattr->hpen); + if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)) + DC_vUpdateFillBrush(dc); + + if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY)) + DC_vUpdateLineBrush(dc);
if (arctype == GdiTypeArcTo) {
Modified: trunk/reactos/subsystems/win32/win32k/objects/bitblt.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/bitblt.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/bitblt.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -192,10 +192,7 @@ 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 @@
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 @@ } }
- 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 @@ }
/* 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) @@ -327,10 +318,6 @@ if (BitmapSrc != NULL && BitmapSrc != BitmapDest) { SURFACE_UnlockSurface(BitmapSrc); - } - if (pbrush != NULL) - { - BRUSH_UnlockBrush(pbrush); } if (UsesSource && hDCSrc != hDCDest) { @@ -756,10 +743,7 @@ 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 @@
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,37 +849,27 @@ } }
- 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) {
Modified: trunk/reactos/subsystems/win32/win32k/objects/dclife.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dclife.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dclife.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -22,6 +22,7 @@ HDC hDC; PWSTR Buf = NULL; XFORM xformTemplate; + PBRUSH pbrush;
if (Driver != NULL) { @@ -104,8 +105,16 @@ /* 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); @@ -148,6 +157,10 @@ DC_vSelectSurface(pDC, NULL); DC_vSelectFillBrush(pDC, NULL); DC_vSelectLineBrush(pDC, NULL); + + /* Dereference default brushes */ + BRUSH_ShareUnlockBrush(pDC->eboText.pbrush); + BRUSH_ShareUnlockBrush(pDC->eboBackground.pbrush);
return TRUE; }
Modified: trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -73,7 +73,6 @@ 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 @@ { /* 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 @@ /* 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 @@ 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 @@ { /* 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 @@ /* 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 @@ DC_vUpdateTextBrush(PDC pdc) { PDC_ATTR pdcattr = pdc->pdcattr; - XLATEOBJ *pxlo; - ULONG iSolidColor; - - /* ROS HACK, should use surf xlate */ - pxlo = pdc->rosdc.XlatePen; - - /* Translate the color to the target format */ - iSolidColor = XLATEOBJ_iXlate(pxlo, pdcattr->crForegroundClr); + XLATEOBJ *pxlo = NULL; + SURFACE *psurf; + HPALETTE hpal; + +// 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 @@ DC_vUpdateBackgroundBrush(PDC pdc) { PDC_ATTR pdcattr = pdc->pdcattr; - XLATEOBJ *pxlo; - ULONG iSolidColor; - - /* ROS HACK, should use surf xlate */ - pxlo = pdc->rosdc.XlatePen; - - /* Translate the color to the target format */ - iSolidColor = XLATEOBJ_iXlate(pxlo, pdcattr->crBackgroundClr); + XLATEOBJ *pxlo = NULL; + SURFACE *psurf; + HPALETTE hpal; + +// 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 @@ { 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 @@ { 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 @@ 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 @@ return NULL; }
- hOrgPen = IntGdiSelectPen(pDC, hPen); +// hOrgPen = IntGdiSelectPen(pDC, hPen); + hOrgPen = pDC->pdcattr->hpen; + pDC->pdcattr->hpen = hPen; + DC_vUpdateLineBrush(pDC);
DC_UnlockDc(pDC);
Modified: trunk/reactos/subsystems/win32/win32k/objects/dcutil.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dcutil.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dcutil.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -75,25 +75,26 @@ IntGdiSetTextColor(HDC hDC, COLORREF color) { - COLORREF oldColor; - PDC dc = DC_LockDc(hDC); - PDC_ATTR pdcattr; - HBRUSH hBrush; - - if (!dc) + COLORREF crOldColor; + PDC pdc; + PDC_ATTR pdcattr; + + pdc = DC_LockDc(hDC); + if (!pdc) { SetLastWin32Error(ERROR_INVALID_HANDLE); return CLR_INVALID; } - pdcattr = dc->pdcattr; - - oldColor = pdcattr->crForegroundClr; + pdcattr = pdc->pdcattr; + + // 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
Modified: trunk/reactos/subsystems/win32/win32k/objects/drawing.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/drawing.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/drawing.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -1192,7 +1192,6 @@ DWORD ROP = PATCOPY; RECTL DestRect; SURFACE *psurf; - EBRUSHOBJ eboFill; POINTL BrushOrigin; BOOL Ret = TRUE; PDC_ATTR pdcattr; @@ -1236,11 +1235,6 @@ 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 @@ &DestRect, NULL, NULL, - &eboFill.BrushObject, // use pDC->eboFill + Pen ? &dc->eboLine.BrushObject : &dc->eboFill.BrushObject, &BrushOrigin, ROP3_TO_ROP4(ROP)); }
Modified: trunk/reactos/subsystems/win32/win32k/objects/fillshap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -36,8 +36,7 @@ int Count) { SURFACE *psurf; - PBRUSH pbrushLine, pbrushFill; - EBRUSHOBJ eboLine, eboFill; + PBRUSH pbrLine, pbrFill; BOOL ret = FALSE; // default to failure RECTL DestRect; int CurrentPoint; @@ -95,31 +94,31 @@ 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 @@
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 @@ { 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 @@ ROP2_TO_MIX(pdcattr->jROP2)); /* MIX */ } } - if (pbrushLine) - PEN_UnlockPen(pbrushLine); } SURFACE_UnlockSurface(psurf);
@@ -522,8 +519,7 @@ 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 @@ 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 @@ goto cleanup; }
- if ( pbrushFill ) - { - if (!(pbrushFill->flAttrs & GDIBRUSH_IS_NULL)) + if (pbrFill) + { + 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 @@ &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 @@ 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 @@
pdcattr = dc->pdcattr;
- if (pdcattr->ulDirty_ & DC_PEN_DIRTY) - IntGdiSelectPen(dc,pdcattr->hpen); - - if (pdcattr->ulDirty_ & DC_BRUSH_DIRTY) - IntGdiSelectBrush(dc,pdcattr->hbrush); + if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)) + DC_vUpdateFillBrush(dc); + + if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY)) + DC_vUpdateLineBrush(dc);
Pt.x = XStart; Pt.y = YStart; @@ -1126,8 +1110,8 @@ else goto cleanup;
- pbrushFill = BRUSH_LockBrush(pdcattr->hbrush); - if (!pbrushFill) + pbrFill = dc->dclevel.pbrFill; + if (!pbrFill) { Ret = FALSE; goto cleanup; @@ -1139,31 +1123,7 @@ 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);
Modified: trunk/reactos/subsystems/win32/win32k/objects/freetype.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/freetype.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/freetype.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -3128,12 +3128,6 @@ 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 @@ FONTOBJ *FontObj; PFONTGDI FontGDI; PTEXTOBJ TextObj = NULL; - PPALGDI PalDestGDI; XLATEOBJ *XlateObj=NULL, *XlateObj2=NULL; - ULONG Mode; FT_Render_Mode RenderMode; BOOLEAN Render; POINT Start; @@ -3168,6 +3160,15 @@ }
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 @@ goto fail; } SurfObj = &psurf->SurfObj; - ASSERT(SurfObj);
Start.x = XStart; Start.y = YStart; @@ -3214,45 +3214,12 @@ /* 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 @@ &DestRect, &SourcePoint, &SourcePoint, - &eboBackGnd.BrushObject, + &dc->eboBackground.BrushObject, &BrushOrigin, ROP3_TO_ROP4(PATCOPY)); fuOptions &= ~ETO_OPAQUE; @@ -3527,7 +3494,7 @@ &DestRect, &SourcePoint, &SourcePoint, - &eboBackGnd.BrushObject, + &dc->eboBackground.BrushObject, &BrushOrigin, ROP3_TO_ROP4(PATCOPY)); BackgroundLeft = DestRect.right; @@ -3599,7 +3566,7 @@ &DestRect, &SourcePoint, (PPOINTL)&MaskRect, - &eboText.BrushObject, + &dc->eboText.BrushObject, &BrushOrigin);
EngUnlockSurface(SourceGlyphSurf); @@ -3638,13 +3605,6 @@ 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 @@ 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;
Modified: trunk/reactos/subsystems/win32/win32k/objects/line.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/line.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/line.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -89,12 +89,10 @@ { 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)) { @@ -112,11 +110,8 @@ } 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 @@ 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); - } - - if (!(pbrushLine->flAttrs & GDIBRUSH_IS_NULL)) - { - EBRUSHOBJ_vInit(&eboLine, pbrushLine, dc->rosdc.XlatePen); + pbrLine = dc->dclevel.pbrLine; + ASSERT(pbrLine); + + if (!(pbrLine->flAttrs & GDIBRUSH_IS_NULL)) + { 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 @@ }
SURFACE_UnlockSurface(psurf); - PEN_UnlockPen( pbrushLine ); }
if (Ret) @@ -251,8 +239,7 @@ int Count) { SURFACE *psurf; - BRUSH *pbrushLine; - EBRUSHOBJ eboLine; + BRUSH *pbrLine; LPPOINT Points; BOOL Ret = TRUE; LONG i; @@ -261,18 +248,17 @@ if (PATH_IsPathOpen(dc->dclevel)) return PATH_Polyline(dc, pt, Count);
- if (pdcattr->ulDirty_ & DC_BRUSH_DIRTY) - IntGdiSelectBrush(dc,pdcattr->hbrush); - - if (pdcattr->ulDirty_ & DC_PEN_DIRTY) - IntGdiSelectPen(dc,pdcattr->hpen); + if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)) + DC_vUpdateFillBrush(dc); + + 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); - - if (!(pbrushLine->flAttrs & GDIBRUSH_IS_NULL)) + pbrLine = dc->dclevel.pbrLine; + ASSERT(pbrLine); + + if (!(pbrLine->flAttrs & GDIBRUSH_IS_NULL)) { Points = EngAllocMem(0, Count * sizeof(POINT), TAG_COORD); if (Points != NULL) @@ -292,10 +278,9 @@ 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)); @@ -308,8 +293,6 @@ Ret = FALSE; } } - - PEN_UnlockPen(pbrushLine);
return Ret; }
Modified: trunk/reactos/subsystems/win32/win32k/objects/region.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/region.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/region.c [iso-8859-1] Wed Apr 1 05:49:18 2009 @@ -2903,14 +2903,14 @@ PROSRGNDATA visrgn; CLIPOBJ* ClipRegion; BOOL bRet = FALSE; - PBRUSH pbrush; - EBRUSHOBJ eboFill; POINTL BrushOrigin; SURFACE *psurf; PDC_ATTR pdcattr;
if (!dc) return FALSE; pdcattr = dc->pdcattr; + + ASSERT(!(pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY)));
if (!(tmpVisRgn = NtGdiCreateRectRgn(0, 0, 0, 0))) return FALSE;
@@ -2935,9 +2935,6 @@ 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 @@
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);