Converted to the new debug interface, using script written by Patrik
[wine] / graphics / win16drv / graphics.c
1 /*
2  * Windows 16 bit device driver graphics functions
3  *
4  * Copyright 1997 John Harvey
5  */
6
7 #include <stdio.h>
8 #include "heap.h"
9 #include "win16drv.h"
10 #include "debugtools.h"
11
12 DEFAULT_DEBUG_CHANNEL(win16drv)
13
14 /**********************************************************************
15  *           WIN16DRV_MoveToEx
16  */
17 BOOL
18 WIN16DRV_MoveToEx(DC *dc,INT x,INT y,LPPOINT pt) 
19 {
20     if (pt)
21     {
22         pt->x = dc->w.CursPosX;
23         pt->y = dc->w.CursPosY;
24     }
25     dc->w.CursPosX = x;
26     dc->w.CursPosY = y;
27     return TRUE;
28 }
29
30 /***********************************************************************
31  *           WIN16DRV_LineTo
32  */
33 BOOL
34 WIN16DRV_LineTo( DC *dc, INT x, INT y )
35 {
36     BOOL bRet ;
37     WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
38     POINT16 points[2];
39     points[0].x = dc->w.DCOrgX + XLPTODP( dc, dc->w.CursPosX );
40     points[0].y = dc->w.DCOrgY + YLPTODP( dc, dc->w.CursPosY );
41     points[1].x = dc->w.DCOrgX + XLPTODP( dc, x );
42     points[1].y = dc->w.DCOrgY + YLPTODP( dc, y );
43     bRet = PRTDRV_Output(physDev->segptrPDEVICE,
44                          OS_POLYLINE, 2, points, 
45                          physDev->PenInfo,
46                          NULL,
47                          win16drv_SegPtr_DrawMode, dc->w.hClipRgn);
48
49     dc->w.CursPosX = x;
50     dc->w.CursPosY = y;
51     return TRUE;
52 }
53
54
55 /***********************************************************************
56  *           WIN16DRV_Rectangle
57  */
58 BOOL
59 WIN16DRV_Rectangle(DC *dc, INT left, INT top, INT right, INT bottom)
60 {
61     WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
62     BOOL bRet = 0;
63     POINT16 points[2];
64
65     TRACE("In WIN16DRV_Rectangle, x %d y %d DCOrgX %d y %d\n",
66            left, top, dc->w.DCOrgX, dc->w.DCOrgY);
67     TRACE("In WIN16DRV_Rectangle, VPortOrgX %d y %d\n",
68            dc->vportOrgX, dc->vportOrgY);
69     points[0].x = XLPTODP(dc, left);
70     points[0].y = YLPTODP(dc, top);
71
72     points[1].x = XLPTODP(dc, right);
73     points[1].y = YLPTODP(dc, bottom);
74     bRet = PRTDRV_Output(physDev->segptrPDEVICE,
75                            OS_RECTANGLE, 2, points, 
76                            physDev->PenInfo,
77                            physDev->BrushInfo,
78                            win16drv_SegPtr_DrawMode, dc->w.hClipRgn);
79     return bRet;
80 }
81
82
83
84
85 /***********************************************************************
86  *           WIN16DRV_Polygon
87  */
88 BOOL
89 WIN16DRV_Polygon(DC *dc, const POINT* pt, INT count )
90 {
91     WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
92     BOOL bRet = 0;
93     LPPOINT16 points;
94     int i;
95
96     if(count < 2) return TRUE;
97     if(pt[0].x != pt[count-1].x || pt[0].y != pt[count-1].y)
98         count++; /* Ensure polygon is closed */
99
100     points = HEAP_xalloc( GetProcessHeap(), 0, count * sizeof(POINT16) );
101     for (i = 0; i < count - 1; i++)
102     {
103       points[i].x = XLPTODP( dc, pt[i].x );
104       points[i].y = YLPTODP( dc, pt[i].y );
105     }
106     points[count-1].x = points[0].x;
107     points[count-1].y = points[0].y;
108     bRet = PRTDRV_Output(physDev->segptrPDEVICE,
109                          OS_WINDPOLYGON, count, points, 
110                          physDev->PenInfo,
111                          physDev->BrushInfo,
112                          win16drv_SegPtr_DrawMode, dc->w.hClipRgn);
113     HeapFree( GetProcessHeap(), 0, points );
114     return bRet;
115 }
116
117
118 /***********************************************************************
119  *           WIN16DRV_Polyline
120  */
121 BOOL
122 WIN16DRV_Polyline(DC *dc, const POINT* pt, INT count )
123 {
124     WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
125     BOOL bRet = 0;
126     LPPOINT16 points;
127     int i;
128
129     if(count < 2) return TRUE;
130
131     points = HEAP_xalloc( GetProcessHeap(), 0, count * sizeof(POINT16) );
132     for (i = 0; i < count; i++)
133     {
134       points[i].x = XLPTODP( dc, pt[i].x );
135       points[i].y = YLPTODP( dc, pt[i].y );
136     }
137     bRet = PRTDRV_Output(physDev->segptrPDEVICE,
138                          OS_POLYLINE, count, points, 
139                          physDev->PenInfo,
140                          NULL,
141                          win16drv_SegPtr_DrawMode, dc->w.hClipRgn);
142     HeapFree( GetProcessHeap(), 0, points );
143     return bRet;
144 }
145
146
147
148 /***********************************************************************
149  *           WIN16DRV_Ellipse
150  */
151 BOOL
152 WIN16DRV_Ellipse(DC *dc, INT left, INT top, INT right, INT bottom)
153 {
154     WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
155     BOOL bRet = 0;
156     POINT16 points[2];
157     TRACE("In WIN16DRV_Ellipse, x %d y %d DCOrgX %d y %d\n",
158            left, top, dc->w.DCOrgX, dc->w.DCOrgY);
159     TRACE("In WIN16DRV_Ellipse, VPortOrgX %d y %d\n",
160            dc->vportOrgX, dc->vportOrgY);
161     points[0].x = XLPTODP(dc, left);
162     points[0].y = YLPTODP(dc, top);
163
164     points[1].x = XLPTODP(dc, right);
165     points[1].y = YLPTODP(dc, bottom);
166
167     bRet = PRTDRV_Output(physDev->segptrPDEVICE,
168                          OS_ELLIPSE, 2, points, 
169                          physDev->PenInfo,
170                          physDev->BrushInfo,
171                          win16drv_SegPtr_DrawMode, dc->w.hClipRgn);
172     return bRet;
173 }
174
175
176
177
178
179
180
181