gdiplus: Add a software implementation of hatch brushes.

oldstable
Vincent Povirk 2011-01-21 13:44:04 -06:00 committed by Alexandre Julliard
parent 60cd477342
commit b7e664bc5c
3 changed files with 40 additions and 0 deletions

View File

@ -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.@]
*/

View File

@ -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);

View File

@ -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;
}