gdiplus: Add a software implementation of hatch brushes.
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 @@ { 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 @@ 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 @@ switch (brush->bt) { case BrushTypeSolidColor: + case BrushTypeHatchFill: return 1; default: return 0; @@ -512,6 +513,32 @@ 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; }