forked from Mirrors/wine-wine
gdiplus: Handle rendering origin during hatch fill.
Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Esme Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>feature/deterministic
parent
03cefac99b
commit
da91507491
|
@ -127,7 +127,7 @@ static void init_hatch_palette(ARGB *hatch_palette, ARGB fore_color, ARGB back_c
|
||||||
hatch_palette[3] = fore_color;
|
hatch_palette[3] = fore_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HBITMAP create_hatch_bitmap(const GpHatch *hatch)
|
static HBITMAP create_hatch_bitmap(const GpHatch *hatch, INT origin_x, INT origin_y)
|
||||||
{
|
{
|
||||||
HBITMAP hbmp;
|
HBITMAP hbmp;
|
||||||
BITMAPINFOHEADER bmih;
|
BITMAPINFOHEADER bmih;
|
||||||
|
@ -159,7 +159,9 @@ static HBITMAP create_hatch_bitmap(const GpHatch *hatch)
|
||||||
* degree of shading needed. */
|
* degree of shading needed. */
|
||||||
for (y = 0; y < 8; y++)
|
for (y = 0; y < 8; y++)
|
||||||
{
|
{
|
||||||
unsigned int row = 0x101 * hatch_data[y];
|
const int hy = (((y + origin_y) % 8) + 8) % 8;
|
||||||
|
const int hx = ((origin_x % 8) + 8) % 8;
|
||||||
|
unsigned int row = (0x10101 * hatch_data[hy]) >> hx;
|
||||||
|
|
||||||
for (x = 0; x < 8; x++, row >>= 1)
|
for (x = 0; x < 8; x++, row >>= 1)
|
||||||
{
|
{
|
||||||
|
@ -184,7 +186,7 @@ static HBITMAP create_hatch_bitmap(const GpHatch *hatch)
|
||||||
return hbmp;
|
return hbmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GpStatus create_gdi_logbrush(const GpBrush *brush, LOGBRUSH *lb)
|
static GpStatus create_gdi_logbrush(const GpBrush *brush, LOGBRUSH *lb, INT origin_x, INT origin_y)
|
||||||
{
|
{
|
||||||
switch (brush->bt)
|
switch (brush->bt)
|
||||||
{
|
{
|
||||||
|
@ -202,7 +204,7 @@ static GpStatus create_gdi_logbrush(const GpBrush *brush, LOGBRUSH *lb)
|
||||||
const GpHatch *hatch = (const GpHatch *)brush;
|
const GpHatch *hatch = (const GpHatch *)brush;
|
||||||
HBITMAP hbmp;
|
HBITMAP hbmp;
|
||||||
|
|
||||||
hbmp = create_hatch_bitmap(hatch);
|
hbmp = create_hatch_bitmap(hatch, origin_x, origin_y);
|
||||||
if (!hbmp) return OutOfMemory;
|
if (!hbmp) return OutOfMemory;
|
||||||
|
|
||||||
lb->lbStyle = BS_PATTERN;
|
lb->lbStyle = BS_PATTERN;
|
||||||
|
@ -231,12 +233,12 @@ static GpStatus free_gdi_logbrush(LOGBRUSH *lb)
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HBRUSH create_gdi_brush(const GpBrush *brush)
|
static HBRUSH create_gdi_brush(const GpBrush *brush, INT origin_x, INT origin_y)
|
||||||
{
|
{
|
||||||
LOGBRUSH lb;
|
LOGBRUSH lb;
|
||||||
HBRUSH gdibrush;
|
HBRUSH gdibrush;
|
||||||
|
|
||||||
if (create_gdi_logbrush(brush, &lb) != Ok) return 0;
|
if (create_gdi_logbrush(brush, &lb, origin_x, origin_y) != Ok) return 0;
|
||||||
|
|
||||||
gdibrush = CreateBrushIndirect(&lb);
|
gdibrush = CreateBrushIndirect(&lb);
|
||||||
free_gdi_logbrush(&lb);
|
free_gdi_logbrush(&lb);
|
||||||
|
@ -293,14 +295,14 @@ static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
|
||||||
}
|
}
|
||||||
TRACE("\n and the pen style is %x\n", pen->style);
|
TRACE("\n and the pen style is %x\n", pen->style);
|
||||||
|
|
||||||
create_gdi_logbrush(pen->brush, &lb);
|
create_gdi_logbrush(pen->brush, &lb, graphics->origin_x, graphics->origin_y);
|
||||||
gdipen = ExtCreatePen(pen->style, gdip_round(width), &lb,
|
gdipen = ExtCreatePen(pen->style, gdip_round(width), &lb,
|
||||||
numdashes, dash_array);
|
numdashes, dash_array);
|
||||||
free_gdi_logbrush(&lb);
|
free_gdi_logbrush(&lb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
create_gdi_logbrush(pen->brush, &lb);
|
create_gdi_logbrush(pen->brush, &lb, graphics->origin_x, graphics->origin_y);
|
||||||
gdipen = ExtCreatePen(pen->style, gdip_round(width), &lb, 0, NULL);
|
gdipen = ExtCreatePen(pen->style, gdip_round(width), &lb, 0, NULL);
|
||||||
free_gdi_logbrush(&lb);
|
free_gdi_logbrush(&lb);
|
||||||
}
|
}
|
||||||
|
@ -1134,7 +1136,7 @@ static GpStatus brush_fill_path(GpGraphics *graphics, GpBrush *brush)
|
||||||
{
|
{
|
||||||
HBRUSH gdibrush, old_brush;
|
HBRUSH gdibrush, old_brush;
|
||||||
|
|
||||||
gdibrush = create_gdi_brush(brush);
|
gdibrush = create_gdi_brush(brush, graphics->origin_x, graphics->origin_y);
|
||||||
if (!gdibrush)
|
if (!gdibrush)
|
||||||
{
|
{
|
||||||
status = OutOfMemory;
|
status = OutOfMemory;
|
||||||
|
@ -1196,9 +1198,9 @@ static GpStatus brush_fill_pixels(GpGraphics *graphics, GpBrush *brush,
|
||||||
/* See create_hatch_bitmap for an explanation of how index is derived. */
|
/* See create_hatch_bitmap for an explanation of how index is derived. */
|
||||||
for (y = 0; y < fill_area->Height; y++, argb_pixels += cdwStride)
|
for (y = 0; y < fill_area->Height; y++, argb_pixels += cdwStride)
|
||||||
{
|
{
|
||||||
/* FIXME: Account for the rendering origin */
|
const int hy = (7 - ((y + fill_area->Y - graphics->origin_y) % 8)) % 8;
|
||||||
const int hy = 7 - ((y + fill_area->Y) % 8);
|
const int hx = ((graphics->origin_x % 8) + 8) % 8;
|
||||||
const unsigned int row = 0x101 * hatch_data[hy];
|
const unsigned int row = (0x10101 * hatch_data[hy]) >> hx;
|
||||||
|
|
||||||
for (x = 0; x < fill_area->Width; x++)
|
for (x = 0; x < fill_area->Width; x++)
|
||||||
{
|
{
|
||||||
|
@ -6193,13 +6195,8 @@ GpStatus WINGDIPAPI GdipSetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipSetRenderingOrigin(GpGraphics *graphics, INT x, INT y)
|
GpStatus WINGDIPAPI GdipSetRenderingOrigin(GpGraphics *graphics, INT x, INT y)
|
||||||
{
|
{
|
||||||
static int calls;
|
|
||||||
|
|
||||||
TRACE("(%p,%i,%i)\n", graphics, x, y);
|
TRACE("(%p,%i,%i)\n", graphics, x, y);
|
||||||
|
|
||||||
if (!(calls++))
|
|
||||||
FIXME("value is unused in rendering\n");
|
|
||||||
|
|
||||||
if (!graphics)
|
if (!graphics)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
|
|
|
@ -1852,13 +1852,10 @@ static void test_renderingOrigin(void)
|
||||||
match_image = FALSE;
|
match_image = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
todo_wine
|
|
||||||
{
|
|
||||||
ok(match_hdc, "Hatch brush rendered incorrectly on hdc with rendering origin (%d, %d).\n",
|
ok(match_hdc, "Hatch brush rendered incorrectly on hdc with rendering origin (%d, %d).\n",
|
||||||
tests[i][0], tests[i][1]);
|
tests[i][0], tests[i][1]);
|
||||||
ok(match_image, "Hatch brush rendered incorrectly on image with rendering origin (%d, %d).\n",
|
ok(match_image, "Hatch brush rendered incorrectly on image with rendering origin (%d, %d).\n",
|
||||||
tests[i][0], tests[i][1]);
|
tests[i][0], tests[i][1]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GdipDeleteBrush((GpBrush *)brush);
|
GdipDeleteBrush((GpBrush *)brush);
|
||||||
|
|
Loading…
Reference in New Issue