Vincent Povirk : gdiplus: Add a software implementation of hatch brushes.

Alexandre Julliard julliard at winehq.org
Mon Jan 24 11:07:29 CST 2011


Module: wine
Branch: master
Commit: b7e664bc5c18d36aa8decbc97e6cecdfdabc4d57
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b7e664bc5c18d36aa8decbc97e6cecdfdabc4d57

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Fri Jan 21 13:44:04 2011 -0600

gdiplus: Add a software implementation of hatch brushes.

---

 dlls/gdiplus/brush.c           |   11 +++++++++++
 dlls/gdiplus/gdiplus_private.h |    2 ++
 dlls/gdiplus/graphics.c        |   27 +++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index 61ec6a3..480d0a3 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -219,6 +219,17 @@ static const char HatchBrushes[][8] = {
     { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
 };
 
+GpStatus get_hatch_data(HatchStyle hatchstyle, const char **result)
+{
+    if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
+    {
+        *result = HatchBrushes[hatchstyle];
+        return Ok;
+    }
+    else
+        return NotImplemented;
+}
+
 /******************************************************************************
  * GdipCreateHatchBrush [GDIPLUS.@]
  */
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index b78e459..7665714 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -65,6 +65,8 @@ extern GpStatus trace_path(GpGraphics *graphics, GpPath *path);
 typedef struct region_element region_element;
 extern void delete_element(region_element *element);
 
+extern GpStatus get_hatch_data(HatchStyle hatchstyle, const char **result);
+
 static inline INT roundr(REAL x)
 {
     return (INT) floorf(x + 0.5);
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 7759685..284847e 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -492,6 +492,7 @@ static INT brush_can_fill_pixels(GpBrush *brush)
     switch (brush->bt)
     {
     case BrushTypeSolidColor:
+    case BrushTypeHatchFill:
         return 1;
     default:
         return 0;
@@ -512,6 +513,32 @@ static GpStatus brush_fill_pixels(GpGraphics *graphics, GpBrush *brush,
                 argb_pixels[x + y*cdwStride] = fill->color;
         return Ok;
     }
+    case BrushTypeHatchFill:
+    {
+        int x, y;
+        GpHatch *fill = (GpHatch*)brush;
+        const char *hatch_data;
+
+        if (get_hatch_data(fill->hatchstyle, &hatch_data) != Ok)
+            return NotImplemented;
+
+        for (x=0; x<fill_area->Width; x++)
+            for (y=0; y<fill_area->Height; y++)
+            {
+                int hx, hy;
+
+                /* FIXME: Account for the rendering origin */
+                hx = (x + fill_area->X) % 8;
+                hy = (y + fill_area->Y) % 8;
+
+                if ((hatch_data[7-hy] & (0x80 >> hx)) != 0)
+                    argb_pixels[x + y*cdwStride] = fill->forecol;
+                else
+                    argb_pixels[x + y*cdwStride] = fill->backcol;
+            }
+
+        return Ok;
+    }
     default:
         return NotImplemented;
     }




More information about the wine-cvs mailing list