gdi32: Add support for solid diagonal lines.

This commit is contained in:
Huw Davies 2011-04-13 13:42:06 +01:00 committed by Alexandre Julliard
parent cd39f0cd6b
commit 626ab3a9d9
2 changed files with 34 additions and 4 deletions

View File

@ -106,6 +106,19 @@ static inline BOOL pt_in_rect( const RECT *rect, POINT pt )
(pt.y >= rect->top) && (pt.y < rect->bottom));
}
static void WINAPI solid_pen_line_callback(INT x, INT y, LPARAM lparam)
{
dibdrv_physdev *pdev = (dibdrv_physdev *)lparam;
RECT rect;
rect.left = x;
rect.right = x + 1;
rect.top = y;
rect.bottom = y + 1;
pdev->dib.funcs->solid_rects(&pdev->dib, 1, &rect, pdev->pen_and, pdev->pen_xor);
return;
}
static BOOL solid_pen_line(dibdrv_physdev *pdev, POINT *start, POINT *end)
{
RECT rc;
@ -124,17 +137,20 @@ static BOOL solid_pen_line(dibdrv_physdev *pdev, POINT *start, POINT *end)
order_end_points(&rc.left, &rc.right);
rc.bottom++;
pdev->dib.funcs->solid_rects(&pdev->dib, 1, &rc, pdev->pen_and, pdev->pen_xor);
return TRUE;
}
else if(rc.left == rc.right)
{
order_end_points(&rc.top, &rc.bottom);
rc.right++;
pdev->dib.funcs->solid_rects(&pdev->dib, 1, &rc, pdev->pen_and, pdev->pen_xor);
return TRUE;
}
return FALSE;
else
{
/* FIXME: Optimize by moving Bresenham algorithm to the primitive functions,
or at least cache adjacent points in the callback */
LineDDA(start->x, start->y, end->x, end->y, solid_pen_line_callback, (LPARAM)pdev);
}
return TRUE;
}
/***********************************************************************

View File

@ -20,6 +20,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <math.h>
#include "windef.h"
#include "winbase.h"
@ -76,6 +77,7 @@ static const char *sha1_graphics_a8r8g8b8[] =
{
"a3cadd34d95d3d5cc23344f69aab1c2e55935fcf",
"2426172d9e8fec27d9228088f382ef3c93717da9",
"9e8f27ca952cdba01dbf25d07c34e86a7820c012",
"17b2c177bdce5e94433574a928bda5c94a8cdfa5",
NULL
};
@ -174,6 +176,18 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh
compare_hash(bmi, bits, sha1, "h and v solid lines");
memset(bits, 0xcc, dib_size);
SetROP2(hdc, R2_COPYPEN);
for(i = 0; i < 16; i++)
{
double s = sin(M_PI * i / 8.0);
double c = cos(M_PI * i / 8.0);
MoveToEx(hdc, 200.5 + 10 * c, 200.5 + 10 * s, NULL);
LineTo(hdc, 200.5 + 100 * c, 200.5 + 100 * s);
}
compare_hash(bmi, bits, sha1, "diagonal solid lines");
memset(bits, 0xcc, dib_size);
solid_brush = CreateSolidBrush(RGB(0x33, 0xaa, 0xff));
orig_brush = SelectObject(hdc, solid_brush);