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