Huw Davies : gdi32: Add support for solid diagonal lines.

Alexandre Julliard julliard at winehq.org
Wed Apr 13 10:49:30 CDT 2011


Module: wine
Branch: master
Commit: 626ab3a9d943c03c37df49d60986afb1799e2116
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=626ab3a9d943c03c37df49d60986afb1799e2116

Author: Huw Davies <huw at codeweavers.com>
Date:   Wed Apr 13 13:42:06 2011 +0100

gdi32: Add support for solid diagonal lines.

---

 dlls/gdi32/dibdrv/objects.c |   24 ++++++++++++++++++++----
 dlls/gdi32/tests/dib.c      |   14 ++++++++++++++
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/dlls/gdi32/dibdrv/objects.c b/dlls/gdi32/dibdrv/objects.c
index 4ebeee1..1ad2f30 100644
--- a/dlls/gdi32/dibdrv/objects.c
+++ b/dlls/gdi32/dibdrv/objects.c
@@ -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;
 }
 
 /***********************************************************************
diff --git a/dlls/gdi32/tests/dib.c b/dlls/gdi32/tests/dib.c
index d89a6fa..a6a1156 100644
--- a/dlls/gdi32/tests/dib.c
+++ b/dlls/gdi32/tests/dib.c
@@ -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);
 




More information about the wine-cvs mailing list