Simple temporary implementation of EngRealizeBrush. Not tested, not used yet.
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 29 Mar 2009 01:43:09 +0000 (01:43 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 29 Mar 2009 01:43:09 +0000 (01:43 +0000)
svn path=/trunk/; revision=40278

reactos/subsystems/win32/win32k/eng/engbrush.c
reactos/subsystems/win32/win32k/include/brush.h

index 9e354c8..0029d83 100644 (file)
@@ -27,8 +27,48 @@ EngRealizeBrush(
     XLATEOBJ *pxlo,
     ULONG    iHatch)
 {
-    UNIMPLEMENTED;
-    return FALSE;
+    EBRUSHOBJ *pebo;
+    HBITMAP hbmpRealize;
+    SURFOBJ *psoRealize;
+    POINTL ptlSrc = {0, 0};
+    RECTL rclDest;
+    ULONG lWidth;
+
+    rclDest = (RECTL){0, 0, psoPattern->sizlBitmap.cx, psoPattern->sizlBitmap.cy};
+
+    /* Calculate width in bytes of the realized brush */
+    lWidth = DIB_GetDIBWidthBytes(psoPattern->sizlBitmap.cx,
+                                  BitsPerFormat(psoDst->iBitmapFormat));
+
+    /* Allocate a bitmap */
+    hbmpRealize = EngCreateBitmap(psoPattern->sizlBitmap,
+                                  lWidth,
+                                  psoDst->iBitmapFormat,
+                                  BMF_NOZEROINIT,
+                                  NULL);
+    if (!hbmpRealize)
+    {
+        return FALSE;
+    }
+
+    /* Lock the bitmap */
+    psoRealize = EngLockSurface(hbmpRealize);
+    if (!psoRealize)
+    {
+        EngDeleteSurface(hbmpRealize);
+        return FALSE;
+    }
+
+    /* Copy the bits to the new format bitmap */
+    EngCopyBits(psoRealize, psoPattern, NULL, pxlo, &rclDest, &ptlSrc);
+
+    /* Unlock the bitmap again */
+    EngUnlockSurface(psoRealize);
+
+    pebo = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject);
+    pebo->pengbrush = (PVOID)hbmpRealize;
+
+    return TRUE;
 }
 
 VOID
@@ -61,6 +101,7 @@ EBRUSHOBJ_vInit(EBRUSHOBJ *pebo, PBRUSH pbrush, XLATEOBJ *pxlo)
 //        EBRUSHOBJ_bRealizeBrush(pebo);
     }
 
+//    pebo->psurfTrg = psurfTrg;
     pebo->BrushObject.pvRbrush = pbrush->ulRealization;
     pebo->BrushObject.flColorType = 0;
     pebo->pbrush = pbrush;
@@ -91,7 +132,7 @@ EBRUSHOBJ_bRealizeBrush(EBRUSHOBJ *pebo)
     psurfTrg = pebo->psurfTrg; // FIXME: all EBRUSHOBJs need a surface
     ppdev = (PPDEVOBJ)psurfTrg->SurfObj.hdev; // FIXME: all SURFACEs need a PDEV
 
-    pfnRealzizeBrush = ppdev->DriverFunctions.RealizeBrush;
+    pfnRealzizeBrush = NULL;//ppdev->DriverFunctions.RealizeBrush;
     if (!pfnRealzizeBrush)
     {
         pfnRealzizeBrush = EngRealizeBrush;
index e6c3545..ccf994a 100644 (file)
@@ -14,7 +14,6 @@
  * DON'T MODIFY THIS STRUCTURE UNLESS REALLY NEEDED AND EVEN THEN ASK ON
  * A MAILING LIST FIRST.
  */
-
 typedef struct _BRUSH
 {
   /* Header for all gdi objects in the handle table.
@@ -50,7 +49,7 @@ typedef struct _EBRUSHOBJ
 
     COLORREF    crRealize;
     ULONG       ulRGBColor;
-    DWORD       pengbrush;
+    PVOID       pengbrush;
     ULONG       ulSurfPalTime;
     ULONG       ulDCPalTime;
     COLORREF    crCurrentText;