DIB Engine: Fork DDB-DIB behaviour
[wine/hacks.git] / dlls / winedib.drv / dc.c
blobc8e3b91ad97187be97a2b53693fdcc42f5ca9426
1 /*
2 * DIB driver initialization functions
4 * Copyright 2009 Massimo Del Fedele
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include "dibdrv.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(dibdrv);
28 /**********************************************************************
29 * DIBDRV_CreateDC
31 BOOL DIBDRV_CreateDC( HDC hdc, DIBDRVPHYSDEV **pdev, LPCWSTR driver, LPCWSTR device,
32 LPCWSTR output, const DEVMODEW* initData )
34 DIBDRVPHYSDEV *physDev;
35 PHYSDEV X11PhysDev;
37 TRACE("hdc:%p, pdev:%p, driver:%s, device:%s, output:%s, initData:%p\n",
38 hdc, pdev, debugstr_w(driver), debugstr_w(device), debugstr_w(output), initData);
40 /* allocates physical device */
41 physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DIBDRVPHYSDEV) );
42 if (!physDev)
43 return FALSE;
45 /* creates X11 physical device */
46 if(!_DIBDRV_GetDisplayDriver()->pCreateDC(hdc, &X11PhysDev, driver, device, output, initData))
48 HeapFree(GetProcessHeap(), 0, physDev);
49 return FALSE;
52 /* sets X11 Device pointer in DIB Engine device */
53 physDev->X11PhysDev = X11PhysDev;
55 /* stock bitmap selected on DC creation */
56 physDev->hbitmap = GetStockObject(DEFAULT_BITMAP);
58 /* no DIB selected into DC on creation */
59 physDev->hasDIB = FALSE;
61 /* sets the result value and returns */
62 *pdev = physDev;
64 return TRUE;
67 /**********************************************************************
68 * DIBDRV_DeleteDC
70 BOOL DIBDRV_DeleteDC( DIBDRVPHYSDEV *physDev )
72 BOOL res;
74 TRACE("physDev:%p\n", physDev);
76 /* frees X11 device */
77 res = _DIBDRV_GetDisplayDriver()->pDeleteDC(physDev->X11PhysDev);
78 physDev->X11PhysDev = NULL;
80 /* frees DIB Engine device */
81 HeapFree(GetProcessHeap(), 0, physDev);
83 ONCE(FIXME("stub\n"));
84 return res;
87 /**********************************************************************
88 * DIBDRV_ExtEscape
90 INT DIBDRV_ExtEscape( DIBDRVPHYSDEV *physDev, INT escape, INT in_count, LPCVOID in_data,
91 INT out_count, LPVOID out_data )
93 INT res;
95 TRACE("physDev:%p, escape:%d, in_count:%d, in_data:%p, out_count:%d, out_data:%p\n",
96 physDev, escape, in_count, in_data, out_count, out_data);
98 if(physDev->hasDIB)
100 /* DIB section selected in, use DIB Engine */
101 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
102 res = _DIBDRV_GetDisplayDriver()->pExtEscape(physDev->X11PhysDev, escape, in_count, in_data, out_count, out_data);
104 else
106 /* DDB selected in, use X11 driver */
107 res = _DIBDRV_GetDisplayDriver()->pExtEscape(physDev->X11PhysDev, escape, in_count, in_data, out_count, out_data);
109 return res;
112 /***********************************************************************
113 * DIBDRV_GetDeviceCaps
115 INT DIBDRV_GetDeviceCaps( DIBDRVPHYSDEV *physDev, INT cap )
117 INT res;
119 TRACE("physDev:%p, cap:%d\n", physDev, cap);
121 if(physDev->hasDIB)
123 /* DIB section selected in, use DIB Engine */
124 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
125 res = _DIBDRV_GetDisplayDriver()->pGetDeviceCaps(physDev->X11PhysDev, cap);
127 else
129 /* DDB selected in, use X11 driver */
130 res = _DIBDRV_GetDisplayDriver()->pGetDeviceCaps(physDev->X11PhysDev, cap);
132 return res;