Author: tkreuzer
Date: Thu Mar 26 06:41:57 2009
New Revision: 40246
URL:
http://svn.reactos.org/svn/reactos?rev=40246&view=rev
Log:
Hack cleanup: IntGdiBrushXlate is a dirty ros hack, it is needed due to the fact that we
handle brushes totally wrong. Replace it with a static function IntUpdateBrushXlate and
move it to dcobjs.c.
Modified:
trunk/reactos/subsystems/win32/win32k/include/intgdi.h
trunk/reactos/subsystems/win32/win32k/objects/brush.c
trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c
Modified: trunk/reactos/subsystems/win32/win32k/include/intgdi.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/intgdi.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/intgdi.h [iso-8859-1] Thu Mar 26
06:41:57 2009
@@ -7,9 +7,6 @@
extern HDC hSystemBM;
extern HSEMAPHORE hsemDriverMgmt;
-
-XLATEOBJ* FASTCALL
-IntGdiCreateBrushXlate(PDC Dc, BRUSH *BrushObj, BOOLEAN *Failed);
XLATEOBJ*
FASTCALL
Modified: trunk/reactos/subsystems/win32/win32k/objects/brush.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/brush.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/brush.c [iso-8859-1] Thu Mar 26 06:41:57
2009
@@ -112,58 +112,6 @@
/* FIXME */
return sizeof(LOGBRUSH);
-}
-
-
-XLATEOBJ* FASTCALL
-IntGdiCreateBrushXlate(PDC Dc, BRUSH *pbrush, BOOLEAN *Failed)
-{
- XLATEOBJ *Result = NULL;
- SURFACE * psurf;
- HPALETTE hPalette = NULL;
-
- psurf = SURFACE_LockSurface(Dc->rosdc.hBitmap);
- if (psurf)
- {
- hPalette = psurf->hDIBPalette;
- SURFACE_UnlockSurface(psurf);
- }
- if (!hPalette) hPalette = pPrimarySurface->DevInfo.hpalDefault;
-
- if (pbrush->flAttrs & GDIBRUSH_IS_NULL)
- {
- Result = NULL;
- *Failed = FALSE;
- }
- else if (pbrush->flAttrs & GDIBRUSH_IS_SOLID)
- {
- Result = IntEngCreateXlate(0, PAL_RGB, hPalette, NULL);
- *Failed = FALSE;
- }
- else
- {
- SURFACE *Pattern = SURFACE_LockSurface(pbrush->hbmPattern);
- if (Pattern == NULL)
- return NULL;
-
- /* Special case: 1bpp pattern */
- if (Pattern->SurfObj.iBitmapFormat == BMF_1BPP)
- {
- PDC_ATTR pdcattr = Dc->pdcattr;
-
- if (Dc->rosdc.bitsPerPixel != 1)
- Result = IntEngCreateSrcMonoXlate(hPalette, pdcattr->crBackgroundClr,
pbrush->BrushAttr.lbColor);
- }
- else if (pbrush->flAttrs & GDIBRUSH_IS_DIB)
- {
- Result = IntEngCreateXlate(0, 0, hPalette, Pattern->hDIBPalette);
- }
-
- SURFACE_UnlockSurface(Pattern);
- *Failed = FALSE;
- }
-
- return Result;
}
/**
Modified: trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c [iso-8859-1] Thu Mar 26
06:41:57 2009
@@ -10,6 +10,60 @@
#define NDEBUG
#include <debug.h>
+
+// HACK!
+static
+BOOLEAN
+IntUpdateBrushXlate(PDC pdc, XLATEOBJ **ppxlo, BRUSH *pbrush)
+{
+ SURFACE * psurf;
+ XLATEOBJ *pxlo = NULL;
+ HPALETTE hPalette = NULL;
+
+ psurf = SURFACE_LockSurface(pdc->rosdc.hBitmap);
+ if (psurf)
+ {
+ hPalette = psurf->hDIBPalette;
+ SURFACE_UnlockSurface(psurf);
+ }
+ 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
@@ -102,8 +156,8 @@
EBRUSHOBJ_vSetSolidBrushColor(&pdc->eboLine, iSolidColor);
}
- /* Clear flag */
- pdcattr->ulDirty_ &= ~DIRTY_LINE;
+ /* Clear flags */
+ pdcattr->ulDirty_ &= ~(DIRTY_LINE | DC_PEN_DIRTY);
}
VOID
@@ -202,8 +256,7 @@
PDC_ATTR pdcattr;
HBRUSH hOrgBrush;
PBRUSH pbrush;
- XLATEOBJ *XlateObj;
- BOOLEAN bFailed;
+ BOOLEAN bSuccess;
if (pDC == NULL || hBrush == NULL) return NULL;
@@ -216,23 +269,17 @@
return NULL;
}
- DC_vSelectFillBrush(pDC, pbrush);
-
- XlateObj = IntGdiCreateBrushXlate(pDC, pbrush, &bFailed);
- BRUSH_UnlockBrush(pbrush);
- if(bFailed)
- {
- return NULL;
- }
-
hOrgBrush = pdcattr->hbrush;
pdcattr->hbrush = hBrush;
- if (pDC->rosdc.XlateBrush != NULL)
- {
- EngDeleteXlate(pDC->rosdc.XlateBrush);
- }
- pDC->rosdc.XlateBrush = XlateObj;
+ DC_vSelectFillBrush(pDC, pbrush);
+
+ bSuccess = IntUpdateBrushXlate(pDC, &pDC->rosdc.XlateBrush, pbrush);
+ BRUSH_UnlockBrush(pbrush);
+ if(!bSuccess)
+ {
+ return NULL;
+ }
pdcattr->ulDirty_ &= ~DC_BRUSH_DIRTY;
@@ -248,8 +295,7 @@
PDC_ATTR pdcattr;
HPEN hOrgPen = NULL;
PBRUSH pbrushPen;
- XLATEOBJ *XlateObj;
- BOOLEAN bFailed;
+ BOOLEAN bSuccess;
if (pDC == NULL || hPen == NULL) return NULL;
@@ -261,26 +307,20 @@
return NULL;
}
- DC_vSelectLineBrush(pDC, pbrushPen);
-
- XlateObj = IntGdiCreateBrushXlate(pDC, pbrushPen, &bFailed);
- PEN_UnlockPen(pbrushPen);
- if (bFailed)
- {
- SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
- return NULL;
- }
-
hOrgPen = pdcattr->hpen;
pdcattr->hpen = hPen;
- if (pDC->rosdc.XlatePen != NULL)
- {
- EngDeleteXlate(pDC->rosdc.XlatePen);
- }
+ 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;
-
- pDC->rosdc.XlatePen = XlateObj;
return hOrgPen;
}
@@ -354,7 +394,6 @@
HBITMAP hOrgBmp;
PSURFACE psurfBmp, psurfOld;
HRGN hVisRgn;
- BOOLEAN bFailed;
PBRUSH pbrush;
if (hDC == NULL || hBmp == NULL) return NULL;
@@ -420,22 +459,14 @@
pbrush = BRUSH_LockBrush(pdcattr->hbrush);
if (pbrush)
{
- if (pDC->rosdc.XlateBrush)
- {
- EngDeleteXlate(pDC->rosdc.XlateBrush);
- }
- pDC->rosdc.XlateBrush = IntGdiCreateBrushXlate(pDC, pbrush, &bFailed);
+ IntUpdateBrushXlate(pDC, &pDC->rosdc.XlateBrush, pbrush);
BRUSH_UnlockBrush(pbrush);
}
pbrush = PEN_LockPen(pdcattr->hpen);
if (pbrush)
{
- if (pDC->rosdc.XlatePen)
- {
- EngDeleteXlate(pDC->rosdc.XlatePen);
- }
- pDC->rosdc.XlatePen = IntGdiCreateBrushXlate(pDC, pbrush, &bFailed);
+ IntUpdateBrushXlate(pDC, &pDC->rosdc.XlatePen, pbrush);
PEN_UnlockPen(pbrush);
}