kernel32/tests: Don't test function directly when reporting GetLastError().
[wine] / dlls / winemac.drv / gdi.c
1 /*
2  * Mac graphics driver initialisation functions
3  *
4  * Copyright 1996 Alexandre Julliard
5  * Copyright 2011, 2012 Ken Thomases for CodeWeavers, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include "config.h"
23
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "wine/debug.h"
30 #include "wine/gdi_driver.h"
31 #include "winreg.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(macdrv);
34
35
36 typedef struct
37 {
38     struct gdi_physdev  dev;
39 } MACDRV_PDEVICE;
40
41 static inline MACDRV_PDEVICE *get_macdrv_dev(PHYSDEV dev)
42 {
43     return (MACDRV_PDEVICE*)dev;
44 }
45
46
47 static const struct gdi_dc_funcs macdrv_funcs;
48
49
50 static MACDRV_PDEVICE *create_mac_physdev(void)
51 {
52     MACDRV_PDEVICE *physDev;
53
54     if (!(physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev)))) return NULL;
55
56     return physDev;
57 }
58
59
60 /**********************************************************************
61  *              CreateDC (MACDRV.@)
62  */
63 static BOOL macdrv_CreateDC(PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device,
64                             LPCWSTR output, const DEVMODEW* initData)
65 {
66     MACDRV_PDEVICE *physDev = create_mac_physdev();
67
68     TRACE("pdev %p hdc %p driver %s device %s output %s initData %p\n", pdev,
69           (*pdev)->hdc, debugstr_w(driver),debugstr_w(device), debugstr_w(output),
70           initData);
71
72     if (!physDev) return FALSE;
73
74     push_dc_driver(pdev, &physDev->dev, &macdrv_funcs);
75     return TRUE;
76 }
77
78
79 /**********************************************************************
80  *              CreateCompatibleDC (MACDRV.@)
81  */
82 static BOOL macdrv_CreateCompatibleDC(PHYSDEV orig, PHYSDEV *pdev)
83 {
84     MACDRV_PDEVICE *physDev = create_mac_physdev();
85
86     TRACE("orig %p orig->hdc %p pdev %p pdev->hdc %p\n", orig, (orig ? orig->hdc : NULL), pdev,
87           ((pdev && *pdev) ? (*pdev)->hdc : NULL));
88
89     if (!physDev) return FALSE;
90
91     push_dc_driver(pdev, &physDev->dev, &macdrv_funcs);
92     return TRUE;
93 }
94
95
96 /**********************************************************************
97  *              DeleteDC (MACDRV.@)
98  */
99 static BOOL macdrv_DeleteDC(PHYSDEV dev)
100 {
101     MACDRV_PDEVICE *physDev = get_macdrv_dev(dev);
102
103     TRACE("hdc %p\n", dev->hdc);
104
105     HeapFree(GetProcessHeap(), 0, physDev);
106     return TRUE;
107 }
108
109
110 static const struct gdi_dc_funcs macdrv_funcs =
111 {
112     NULL,                                   /* pAbortDoc */
113     NULL,                                   /* pAbortPath */
114     NULL,                                   /* pAlphaBlend */
115     NULL,                                   /* pAngleArc */
116     NULL,                                   /* pArc */
117     NULL,                                   /* pArcTo */
118     NULL,                                   /* pBeginPath */
119     NULL,                                   /* pBlendImage */
120     NULL,                                   /* pChord */
121     NULL,                                   /* pCloseFigure */
122     macdrv_CreateCompatibleDC,              /* pCreateCompatibleDC */
123     macdrv_CreateDC,                        /* pCreateDC */
124     macdrv_DeleteDC,                        /* pDeleteDC */
125     NULL,                                   /* pDeleteObject */
126     NULL,                                   /* pDeviceCapabilities */
127     NULL,                                   /* pEllipse */
128     NULL,                                   /* pEndDoc */
129     NULL,                                   /* pEndPage */
130     NULL,                                   /* pEndPath */
131     NULL,                                   /* pEnumFonts */
132     NULL,                                   /* pEnumICMProfiles */
133     NULL,                                   /* pExcludeClipRect */
134     NULL,                                   /* pExtDeviceMode */
135     NULL,                                   /* pExtEscape */
136     NULL,                                   /* pExtFloodFill */
137     NULL,                                   /* pExtSelectClipRgn */
138     NULL,                                   /* pExtTextOut */
139     NULL,                                   /* pFillPath */
140     NULL,                                   /* pFillRgn */
141     NULL,                                   /* pFlattenPath */
142     NULL,                                   /* pFontIsLinked */
143     NULL,                                   /* pFrameRgn */
144     NULL,                                   /* pGdiComment */
145     NULL,                                   /* pGdiRealizationInfo */
146     NULL,                                   /* pGetBoundsRect */
147     NULL,                                   /* pGetCharABCWidths */
148     NULL,                                   /* pGetCharABCWidthsI */
149     NULL,                                   /* pGetCharWidth */
150     NULL,                                   /* pGetDeviceCaps */
151     NULL,                                   /* pGetDeviceGammaRamp */
152     NULL,                                   /* pGetFontData */
153     NULL,                                   /* pGetFontUnicodeRanges */
154     NULL,                                   /* pGetGlyphIndices */
155     NULL,                                   /* pGetGlyphOutline */
156     NULL,                                   /* pGetICMProfile */
157     NULL,                                   /* pGetImage */
158     NULL,                                   /* pGetKerningPairs */
159     NULL,                                   /* pGetNearestColor */
160     NULL,                                   /* pGetOutlineTextMetrics */
161     NULL,                                   /* pGetPixel */
162     NULL,                                   /* pGetSystemPaletteEntries */
163     NULL,                                   /* pGetTextCharsetInfo */
164     NULL,                                   /* pGetTextExtentExPoint */
165     NULL,                                   /* pGetTextExtentExPointI */
166     NULL,                                   /* pGetTextFace */
167     NULL,                                   /* pGetTextMetrics */
168     NULL,                                   /* pGradientFill */
169     NULL,                                   /* pIntersectClipRect */
170     NULL,                                   /* pInvertRgn */
171     NULL,                                   /* pLineTo */
172     NULL,                                   /* pModifyWorldTransform */
173     NULL,                                   /* pMoveTo */
174     NULL,                                   /* pOffsetClipRgn */
175     NULL,                                   /* pOffsetViewportOrg */
176     NULL,                                   /* pOffsetWindowOrg */
177     NULL,                                   /* pPaintRgn */
178     NULL,                                   /* pPatBlt */
179     NULL,                                   /* pPie */
180     NULL,                                   /* pPolyBezier */
181     NULL,                                   /* pPolyBezierTo */
182     NULL,                                   /* pPolyDraw */
183     NULL,                                   /* pPolyPolygon */
184     NULL,                                   /* pPolyPolyline */
185     NULL,                                   /* pPolygon */
186     NULL,                                   /* pPolyline */
187     NULL,                                   /* pPolylineTo */
188     NULL,                                   /* pPutImage */
189     NULL,                                   /* pRealizeDefaultPalette */
190     NULL,                                   /* pRealizePalette */
191     NULL,                                   /* pRectangle */
192     NULL,                                   /* pResetDC */
193     NULL,                                   /* pRestoreDC */
194     NULL,                                   /* pRoundRect */
195     NULL,                                   /* pSaveDC */
196     NULL,                                   /* pScaleViewportExt */
197     NULL,                                   /* pScaleWindowExt */
198     NULL,                                   /* pSelectBitmap */
199     NULL,                                   /* pSelectBrush */
200     NULL,                                   /* pSelectClipPath */
201     NULL,                                   /* pSelectFont */
202     NULL,                                   /* pSelectPalette */
203     NULL,                                   /* pSelectPen */
204     NULL,                                   /* pSetArcDirection */
205     NULL,                                   /* pSetBkColor */
206     NULL,                                   /* pSetBkMode */
207     NULL,                                   /* pSetBoundsRect */
208     NULL,                                   /* pSetDCBrushColor */
209     NULL,                                   /* pSetDCPenColor */
210     NULL,                                   /* pSetDIBitsToDevice */
211     NULL,                                   /* pSetDeviceClipping */
212     NULL,                                   /* pSetDeviceGammaRamp */
213     NULL,                                   /* pSetLayout */
214     NULL,                                   /* pSetMapMode */
215     NULL,                                   /* pSetMapperFlags */
216     NULL,                                   /* pSetPixel */
217     NULL,                                   /* pSetPolyFillMode */
218     NULL,                                   /* pSetROP2 */
219     NULL,                                   /* pSetRelAbs */
220     NULL,                                   /* pSetStretchBltMode */
221     NULL,                                   /* pSetTextAlign */
222     NULL,                                   /* pSetTextCharacterExtra */
223     NULL,                                   /* pSetTextColor */
224     NULL,                                   /* pSetTextJustification */
225     NULL,                                   /* pSetViewportExt */
226     NULL,                                   /* pSetViewportOrg */
227     NULL,                                   /* pSetWindowExt */
228     NULL,                                   /* pSetWindowOrg */
229     NULL,                                   /* pSetWorldTransform */
230     NULL,                                   /* pStartDoc */
231     NULL,                                   /* pStartPage */
232     NULL,                                   /* pStretchBlt */
233     NULL,                                   /* pStretchDIBits */
234     NULL,                                   /* pStrokeAndFillPath */
235     NULL,                                   /* pStrokePath */
236     NULL,                                   /* pUnrealizePalette */
237     NULL,                                   /* pWidenPath */
238     NULL,                                   /* wine_get_wgl_driver */
239     GDI_PRIORITY_GRAPHICS_DRV               /* priority */
240 };
241
242
243 /******************************************************************************
244  *              macdrv_get_gdi_driver
245  */
246 const struct gdi_dc_funcs * CDECL macdrv_get_gdi_driver(unsigned int version)
247 {
248     if (version != WINE_GDI_DRIVER_VERSION)
249     {
250         ERR("version mismatch, gdi32 wants %u but winemac has %u\n", version, WINE_GDI_DRIVER_VERSION);
251         return NULL;
252     }
253     return &macdrv_funcs;
254 }