Commit b7e664bc authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Add a software implementation of hatch brushes.

parent 60cd4773
......@@ -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.@]
*/
......
......@@ -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);
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment