From 69d04cfc3485ad1d2f627a591d2719e990b2a36c Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 8 Jul 2009 21:53:35 +0000 Subject: [PATCH] Get rid of the DCs XlateBrush and XlatePen. The resulting code isn't any better yet, but this step is needed for the upcoming xlateobj rewrite. svn path=/trunk/; revision=41820 --- reactos/subsystems/win32/win32k/eng/xlate.c | 49 +++++++++++ reactos/subsystems/win32/win32k/include/dc.h | 2 - .../subsystems/win32/win32k/include/inteng.h | 3 + .../subsystems/win32/win32k/objects/bitblt.c | 6 +- .../subsystems/win32/win32k/objects/dclife.c | 6 +- .../subsystems/win32/win32k/objects/dcobjs.c | 84 ++++--------------- 6 files changed, 72 insertions(+), 78 deletions(-) diff --git a/reactos/subsystems/win32/win32k/eng/xlate.c b/reactos/subsystems/win32/win32k/eng/xlate.c index c5914edf606..7dd66d74ed8 100644 --- a/reactos/subsystems/win32/win32k/eng/xlate.c +++ b/reactos/subsystems/win32/win32k/eng/xlate.c @@ -671,4 +671,53 @@ XLATEOBJ_cGetPalette(XLATEOBJ *XlateObj, ULONG PalOutType, ULONG cPal, return 0; } +// HACK! +XLATEOBJ* +IntCreateBrushXlate(PDC pdc, BRUSH *pbrush) +{ + SURFACE * psurf; + XLATEOBJ *pxlo = NULL; + HPALETTE hPalette = NULL; + + psurf = pdc->dclevel.pSurface; + if (psurf) + { + hPalette = psurf->hDIBPalette; + } + if (!hPalette) hPalette = pPrimarySurface->DevInfo.hpalDefault; + + if (pbrush->flAttrs & GDIBRUSH_IS_NULL) + { + pxlo = NULL; + } + else if (pbrush->flAttrs & GDIBRUSH_IS_SOLID) + { + pxlo = IntEngCreateXlate(0, PAL_RGB, hPalette, NULL); + } + else + { + SURFACE *psurfPattern = SURFACE_LockSurface(pbrush->hbmPattern); + if (psurfPattern == NULL) + return FALSE; + + /* Special case: 1bpp pattern */ + if (psurfPattern->SurfObj.iBitmapFormat == BMF_1BPP) + { + if (pdc->rosdc.bitsPerPixel != 1) + pxlo = IntEngCreateSrcMonoXlate(hPalette, + pdc->pdcattr->crBackgroundClr, + pbrush->BrushAttr.lbColor); + } + else if (pbrush->flAttrs & GDIBRUSH_IS_DIB) + { + pxlo = IntEngCreateXlate(0, 0, hPalette, psurfPattern->hDIBPalette); + } + + SURFACE_UnlockSurface(psurfPattern); + } + + return pxlo; +} + + /* EOF */ diff --git a/reactos/subsystems/win32/win32k/include/dc.h b/reactos/subsystems/win32/win32k/include/dc.h index a85bcf784a0..1bda87a2cae 100644 --- a/reactos/subsystems/win32/win32k/include/dc.h +++ b/reactos/subsystems/win32/win32k/include/dc.h @@ -21,8 +21,6 @@ typedef struct _ROS_DC_INFO BYTE bitsPerPixel; CLIPOBJ *CombinedClip; - XLATEOBJ *XlateBrush; - XLATEOBJ *XlatePen; UNICODE_STRING DriverName; diff --git a/reactos/subsystems/win32/win32k/include/inteng.h b/reactos/subsystems/win32/win32k/include/inteng.h index 164cc06a5d4..f31f94e9f45 100644 --- a/reactos/subsystems/win32/win32k/include/inteng.h +++ b/reactos/subsystems/win32/win32k/include/inteng.h @@ -107,6 +107,9 @@ IntEngCreateSrcMonoXlate(HPALETTE PaletteDest, ULONG Color0, ULONG Color1); +XLATEOBJ* +IntCreateBrushXlate(PDC pdc, BRUSH *pbrush); + HPALETTE FASTCALL IntEngGetXlatePalette(XLATEOBJ *XlateObj, ULONG Palette); diff --git a/reactos/subsystems/win32/win32k/objects/bitblt.c b/reactos/subsystems/win32/win32k/objects/bitblt.c index d3bd319c70a..db91e471b76 100644 --- a/reactos/subsystems/win32/win32k/objects/bitblt.c +++ b/reactos/subsystems/win32/win32k/objects/bitblt.c @@ -941,6 +941,7 @@ IntPatBlt( EBRUSHOBJ eboFill; POINTL BrushOrigin; BOOL ret; + XLATEOBJ *pxlo; ASSERT(pbrush); @@ -988,7 +989,8 @@ IntPatBlt( BrushOrigin.x = pbrush->ptOrigin.x + pdc->ptlDCOrig.x; BrushOrigin.y = pbrush->ptOrigin.y + pdc->ptlDCOrig.y; - EBRUSHOBJ_vInit(&eboFill, pbrush, pdc->rosdc.XlateBrush); + pxlo = IntCreateBrushXlate(pdc, pbrush); + EBRUSHOBJ_vInit(&eboFill, pbrush, pxlo); ret = IntEngBitBlt( &psurf->SurfObj, @@ -1003,6 +1005,8 @@ IntPatBlt( &BrushOrigin, ROP3_TO_ROP4(dwRop)); + EngDeleteXlate(pxlo); + return ret; } diff --git a/reactos/subsystems/win32/win32k/objects/dclife.c b/reactos/subsystems/win32/win32k/objects/dclife.c index 97d86561c94..b11062107b6 100644 --- a/reactos/subsystems/win32/win32k/objects/dclife.c +++ b/reactos/subsystems/win32/win32k/objects/dclife.c @@ -500,10 +500,6 @@ IntGdiDeleteDC(HDC hDC, BOOL Force) NtGdiSelectBrush (DCHandle, STOCK_WHITE_BRUSH); NtGdiSelectFont (DCHandle, STOCK_SYSTEM_FONT); DC_LockDC (DCHandle); NtGdiSelectXxx does not recognize stock objects yet */ - if (DCToDelete->rosdc.XlateBrush != NULL) - EngDeleteXlate(DCToDelete->rosdc.XlateBrush); - if (DCToDelete->rosdc.XlatePen != NULL) - EngDeleteXlate(DCToDelete->rosdc.XlatePen); } if (DCToDelete->rosdc.hClipRgn) { @@ -719,7 +715,7 @@ NewNtGdiDeleteObjectApp(HANDLE DCHandle) return GreDeleteObject((HGDIOBJ) DCHandle); default: - return FALSE; + return FALSE; } } return (DCHandle != NULL); diff --git a/reactos/subsystems/win32/win32k/objects/dcobjs.c b/reactos/subsystems/win32/win32k/objects/dcobjs.c index ec45654ade2..ffe7ebb19c3 100644 --- a/reactos/subsystems/win32/win32k/objects/dcobjs.c +++ b/reactos/subsystems/win32/win32k/objects/dcobjs.c @@ -1,4 +1,4 @@ -/* +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * PURPOSE: Functions for creation and destruction of DCs @@ -11,60 +11,6 @@ #define NDEBUG #include -// HACK! -static -BOOLEAN -IntUpdateBrushXlate(PDC pdc, XLATEOBJ **ppxlo, BRUSH *pbrush) -{ - SURFACE * psurf; - XLATEOBJ *pxlo = NULL; - HPALETTE hPalette = NULL; - - psurf = pdc->dclevel.pSurface; - if (psurf) - { - hPalette = psurf->hDIBPalette; - } - if (!hPalette) hPalette = pPrimarySurface->DevInfo.hpalDefault; - - if (pbrush->flAttrs & GDIBRUSH_IS_NULL) - { - pxlo = NULL; - } - else if (pbrush->flAttrs & GDIBRUSH_IS_SOLID) - { - pxlo = IntEngCreateXlate(0, PAL_RGB, hPalette, NULL); - } - else - { - SURFACE *psurfPattern = SURFACE_LockSurface(pbrush->hbmPattern); - if (psurfPattern == NULL) - return FALSE; - - /* Special case: 1bpp pattern */ - if (psurfPattern->SurfObj.iBitmapFormat == BMF_1BPP) - { - if (pdc->rosdc.bitsPerPixel != 1) - pxlo = IntEngCreateSrcMonoXlate(hPalette, - pdc->pdcattr->crBackgroundClr, - pbrush->BrushAttr.lbColor); - } - else if (pbrush->flAttrs & GDIBRUSH_IS_DIB) - { - pxlo = IntEngCreateXlate(0, 0, hPalette, psurfPattern->hDIBPalette); - } - - SURFACE_UnlockSurface(psurfPattern); - } - - if (*ppxlo != NULL) - EngDeleteXlate(*ppxlo); - - *ppxlo = pxlo; - return TRUE; -} - - VOID FASTCALL DC_vUpdateFillBrush(PDC pdc) @@ -94,28 +40,27 @@ DC_vUpdateFillBrush(PDC pdc) } } + /* ROS HACK, should use surf xlate */ + pxlo = IntCreateBrushXlate(pdc, pdc->dclevel.pbrFill); + /* Check if the EBRUSHOBJ needs update */ if (pdcattr->ulDirty_ & DIRTY_FILL) { pbrFill = pdc->dclevel.pbrFill; - /* ROS HACK, should use surf xlate */ - IntUpdateBrushXlate(pdc, &pdc->rosdc.XlateBrush, pbrFill); - /* Update eboFill, realizing it, if needed */ - EBRUSHOBJ_vUpdate(&pdc->eboFill, pbrFill, pdc->rosdc.XlateBrush); + EBRUSHOBJ_vUpdate(&pdc->eboFill, pbrFill, pxlo); } /* Check for DC brush */ if (pdcattr->hbrush == StockObjects[DC_BRUSH]) { - /* ROS HACK, should use surf xlate */ - pxlo = pdc->rosdc.XlateBrush; - /* Update the eboFill's solid color */ EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboFill, pdcattr->crPenClr, pxlo); } + EngDeleteXlate(pxlo); + /* Clear flags */ pdcattr->ulDirty_ &= ~(DIRTY_FILL | DC_BRUSH_DIRTY); } @@ -149,28 +94,27 @@ DC_vUpdateLineBrush(PDC pdc) } } + /* ROS HACK, should use surf xlate */ + pxlo = IntCreateBrushXlate(pdc, pdc->dclevel.pbrFill); + /* Check if the EBRUSHOBJ needs update */ if (pdcattr->ulDirty_ & DIRTY_LINE) { pbrLine = pdc->dclevel.pbrLine; - /* ROS HACK, should use surf xlate */ - IntUpdateBrushXlate(pdc, &pdc->rosdc.XlatePen, pbrLine); - /* Update eboLine, realizing it, if needed */ - EBRUSHOBJ_vUpdate(&pdc->eboLine, pbrLine, pdc->rosdc.XlatePen); + EBRUSHOBJ_vUpdate(&pdc->eboLine, pbrLine, pxlo); } /* Check for DC pen */ if (pdcattr->hpen == StockObjects[DC_PEN]) { - /* ROS HACK, should use surf xlate */ - pxlo = pdc->rosdc.XlatePen; - /* Update the eboLine's solid color */ EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboLine, pdcattr->crPenClr, pxlo); } + EngDeleteXlate(pxlo); + /* Clear flags */ pdcattr->ulDirty_ &= ~(DIRTY_LINE | DC_PEN_DIRTY); } @@ -434,7 +378,7 @@ NtGdiSelectClipPath( BOOL success = FALSE; PDC_ATTR pdcattr; PDC pdc; - + pdc = DC_LockDc(hDC); if (!pdc) {