Changed the GDI driver interface to pass an opaque PHYSDEV pointer
[wine/gsoc_dplay.git] / dlls / gdi / win16drv / graphics.c
blob7d9af8698f79588215cdcf3ab938095f9e6fb51d
1 /*
2 * Windows 16 bit device driver graphics functions
4 * Copyright 1997 John Harvey
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <stdio.h>
23 #include "win16drv/win16drv.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(win16drv);
28 /***********************************************************************
29 * WIN16DRV_LineTo
31 BOOL
32 WIN16DRV_LineTo( PHYSDEV dev, INT x, INT y )
34 BOOL bRet ;
35 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dev;
36 DC *dc = physDev->dc;
37 POINT16 points[2];
39 points[0].x = dc->DCOrgX + XLPTODP( dc, dc->CursPosX );
40 points[0].y = dc->DCOrgY + YLPTODP( dc, dc->CursPosY );
41 points[1].x = dc->DCOrgX + XLPTODP( dc, x );
42 points[1].y = dc->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->hClipRgn);
49 dc->CursPosX = x;
50 dc->CursPosY = y;
51 return TRUE;
55 /***********************************************************************
56 * WIN16DRV_Rectangle
58 BOOL
59 WIN16DRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
61 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dev;
62 DC *dc = physDev->dc;
63 BOOL bRet = 0;
64 POINT16 points[2];
66 TRACE("In WIN16DRV_Rectangle, x %d y %d DCOrgX %d y %d\n",
67 left, top, dc->DCOrgX, dc->DCOrgY);
68 TRACE("In WIN16DRV_Rectangle, VPortOrgX %d y %d\n",
69 dc->vportOrgX, dc->vportOrgY);
70 points[0].x = XLPTODP(dc, left);
71 points[0].y = YLPTODP(dc, top);
73 points[1].x = XLPTODP(dc, right);
74 points[1].y = YLPTODP(dc, bottom);
75 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
76 OS_RECTANGLE, 2, points,
77 physDev->PenInfo,
78 physDev->BrushInfo,
79 win16drv_SegPtr_DrawMode, dc->hClipRgn);
80 return bRet;
86 /***********************************************************************
87 * WIN16DRV_Polygon
89 BOOL
90 WIN16DRV_Polygon(PHYSDEV dev, const POINT* pt, INT count )
92 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dev;
93 DC *dc = physDev->dc;
94 BOOL bRet = 0;
95 LPPOINT16 points;
96 int i;
98 if(count < 2) return TRUE;
99 if(pt[0].x != pt[count-1].x || pt[0].y != pt[count-1].y)
100 count++; /* Ensure polygon is closed */
102 points = HeapAlloc( GetProcessHeap(), 0, count * sizeof(POINT16) );
103 if(points == NULL) return FALSE;
105 for (i = 0; i < count - 1; i++)
107 points[i].x = XLPTODP( dc, pt[i].x );
108 points[i].y = YLPTODP( dc, pt[i].y );
110 points[count-1].x = points[0].x;
111 points[count-1].y = points[0].y;
112 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
113 OS_WINDPOLYGON, count, points,
114 physDev->PenInfo,
115 physDev->BrushInfo,
116 win16drv_SegPtr_DrawMode, dc->hClipRgn);
117 HeapFree( GetProcessHeap(), 0, points );
118 return bRet;
122 /***********************************************************************
123 * WIN16DRV_Polyline
125 BOOL
126 WIN16DRV_Polyline(PHYSDEV dev, const POINT* pt, INT count )
128 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dev;
129 DC *dc = physDev->dc;
130 BOOL bRet = 0;
131 LPPOINT16 points;
132 int i;
134 if(count < 2) return TRUE;
136 points = HeapAlloc( GetProcessHeap(), 0, count * sizeof(POINT16) );
137 if(points == NULL) return FALSE;
139 for (i = 0; i < count; i++)
141 points[i].x = XLPTODP( dc, pt[i].x );
142 points[i].y = YLPTODP( dc, pt[i].y );
144 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
145 OS_POLYLINE, count, points,
146 physDev->PenInfo,
147 NULL,
148 win16drv_SegPtr_DrawMode, dc->hClipRgn);
149 HeapFree( GetProcessHeap(), 0, points );
150 return bRet;
155 /***********************************************************************
156 * WIN16DRV_Ellipse
158 BOOL
159 WIN16DRV_Ellipse(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
161 WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dev;
162 DC *dc = physDev->dc;
163 BOOL bRet = 0;
164 POINT16 points[2];
166 TRACE("In WIN16DRV_Ellipse, x %d y %d DCOrgX %d y %d\n", left, top, dc->DCOrgX, dc->DCOrgY);
167 TRACE("In WIN16DRV_Ellipse, VPortOrgX %d y %d\n", dc->vportOrgX, dc->vportOrgY);
168 points[0].x = XLPTODP(dc, left);
169 points[0].y = YLPTODP(dc, top);
171 points[1].x = XLPTODP(dc, right);
172 points[1].y = YLPTODP(dc, bottom);
174 bRet = PRTDRV_Output(physDev->segptrPDEVICE,
175 OS_ELLIPSE, 2, points,
176 physDev->PenInfo,
177 physDev->BrushInfo,
178 win16drv_SegPtr_DrawMode, dc->hClipRgn);
179 return bRet;