secur32: Don't try to use ntlm_auth --use-cred-cache.
[wine] / dlls / d3dx9_36 / font.c
1 /*
2  * Copyright (C) 2008 Tony Wasserka
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  *
18  */
19
20 #include "config.h"
21 #include "wine/port.h"
22
23 #include "wine/debug.h"
24 #include "wine/unicode.h"
25 #include "d3dx9_36_private.h"
26
27 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
28
29 static HRESULT WINAPI ID3DXFontImpl_QueryInterface(LPD3DXFONT iface, REFIID riid, LPVOID *object)
30 {
31     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
32
33     TRACE("(%p): QueryInterface from %s\n", This, debugstr_guid(riid));
34     if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ID3DXFont)) {
35         IUnknown_AddRef(iface);
36         *object=This;
37         return S_OK;
38     }
39     WARN("(%p)->(%s, %p): not found\n", iface, debugstr_guid(riid), *object);
40     return E_NOINTERFACE;
41 }
42
43 static ULONG WINAPI ID3DXFontImpl_AddRef(LPD3DXFONT iface)
44 {
45     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
46     ULONG ref=InterlockedIncrement(&This->ref);
47     TRACE("(%p): AddRef from %d\n", This, ref-1);
48     return ref;
49 }
50
51 static ULONG WINAPI ID3DXFontImpl_Release(LPD3DXFONT iface)
52 {
53     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
54     ULONG ref=InterlockedDecrement(&This->ref);
55     TRACE("(%p): ReleaseRef to %d\n", This, ref);
56
57     if(ref==0) {
58         HeapFree(GetProcessHeap(), 0, This);
59     }
60     return ref;
61 }
62
63 static HRESULT WINAPI ID3DXFontImpl_GetDevice(LPD3DXFONT iface, LPDIRECT3DDEVICE9 *device)
64 {
65     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
66     FIXME("(%p): stub\n", This);
67     return D3D_OK;
68 }
69
70 static HRESULT WINAPI ID3DXFontImpl_GetDescA(LPD3DXFONT iface, D3DXFONT_DESCA *desc)
71 {
72     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
73     FIXME("(%p): stub\n", This);
74     return D3D_OK;
75 }
76
77 static HRESULT WINAPI ID3DXFontImpl_GetDescW(LPD3DXFONT iface, D3DXFONT_DESCW *desc)
78 {
79     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
80     FIXME("(%p): stub\n", This);
81     return D3D_OK;
82 }
83
84 static BOOL WINAPI ID3DXFontImpl_GetTextMetricsA(LPD3DXFONT iface, TEXTMETRICA *metrics)
85 {
86     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
87     FIXME("(%p): stub\n", This);
88     return FALSE;
89 }
90
91 static BOOL WINAPI ID3DXFontImpl_GetTextMetricsW(LPD3DXFONT iface, TEXTMETRICW *metrics)
92 {
93     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
94     FIXME("(%p): stub\n", This);
95     return FALSE;
96 }
97
98 static HDC WINAPI ID3DXFontImpl_GetDC(LPD3DXFONT iface)
99 {
100     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
101     FIXME("(%p): stub\n", This);
102     return NULL;
103 }
104
105 static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(LPD3DXFONT iface, UINT glyph, LPDIRECT3DTEXTURE9 *texture, RECT *blackbox, POINT *cellinc)
106 {
107     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
108     FIXME("(%p): stub\n", This);
109     return D3D_OK;
110 }
111
112 static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(LPD3DXFONT iface, UINT first, UINT last)
113 {
114     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
115     FIXME("(%p): stub\n", This);
116     return D3D_OK;
117 }
118
119 static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(LPD3DXFONT iface, UINT first, UINT last)
120 {
121     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
122     FIXME("(%p): stub\n", This);
123     return D3D_OK;
124 }
125
126 static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(LPD3DXFONT iface, LPCSTR string, INT count)
127 {
128     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
129     FIXME("(%p): stub\n", This);
130     return D3D_OK;
131 }
132
133 static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(LPD3DXFONT iface, LPCWSTR string, INT count)
134 {
135     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
136     FIXME("(%p): stub\n", This);
137     return D3D_OK;
138 }
139
140 static INT WINAPI ID3DXFontImpl_DrawTextA(LPD3DXFONT iface, LPD3DXSPRITE sprite, LPCSTR string, INT count, LPRECT rect, DWORD format, D3DCOLOR color)
141 {
142     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
143     FIXME("(%p): stub\n", This);
144     return 1;
145 }
146
147 static INT WINAPI ID3DXFontImpl_DrawTextW(LPD3DXFONT iface, LPD3DXSPRITE sprite, LPCWSTR string, INT count, LPRECT rect, DWORD format, D3DCOLOR color)
148 {
149     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
150     FIXME("(%p): stub\n", This);
151     return 1;
152 }
153
154 static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(LPD3DXFONT iface)
155 {
156     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
157     FIXME("(%p): stub\n", This);
158     return D3D_OK;
159 }
160
161 static HRESULT WINAPI ID3DXFontImpl_OnResetDevice(LPD3DXFONT iface)
162 {
163     ID3DXFontImpl *This=(ID3DXFontImpl*)iface;
164     FIXME("(%p): stub\n", This);
165     return D3D_OK;
166 }
167
168 static const ID3DXFontVtbl D3DXFont_Vtbl =
169 {
170     /*** IUnknown methods ***/
171     ID3DXFontImpl_QueryInterface,
172     ID3DXFontImpl_AddRef,
173     ID3DXFontImpl_Release,
174     /*** ID3DXFont methods ***/
175     ID3DXFontImpl_GetDevice,
176     ID3DXFontImpl_GetDescA,
177     ID3DXFontImpl_GetDescW,
178     ID3DXFontImpl_GetTextMetricsA,
179     ID3DXFontImpl_GetTextMetricsW,
180     ID3DXFontImpl_GetDC,
181     ID3DXFontImpl_GetGlyphData,
182     ID3DXFontImpl_PreloadCharacters,
183     ID3DXFontImpl_PreloadGlyphs,
184     ID3DXFontImpl_PreloadTextA,
185     ID3DXFontImpl_PreloadTextW,
186     ID3DXFontImpl_DrawTextA,
187     ID3DXFontImpl_DrawTextW,
188     ID3DXFontImpl_OnLostDevice,
189     ID3DXFontImpl_OnResetDevice
190 };
191
192 HRESULT WINAPI D3DXCreateFontA(LPDIRECT3DDEVICE9 device, INT height, UINT width, UINT weight, UINT miplevels, BOOL italic, DWORD charset,
193                                DWORD precision, DWORD quality, DWORD pitchandfamily, LPCSTR facename, LPD3DXFONT *font)
194 {
195     D3DXFONT_DESCA desc;
196
197     if(!facename) return D3DXERR_INVALIDDATA;
198
199     desc.Height=height;
200     desc.Width=width;
201     desc.Weight=weight;
202     desc.MipLevels=miplevels;
203     desc.Italic=italic;
204     desc.CharSet=charset;
205     desc.OutputPrecision=precision;
206     desc.Quality=quality;
207     desc.PitchAndFamily=pitchandfamily;
208     lstrcpyA(desc.FaceName, facename);
209
210     return D3DXCreateFontIndirectA(device, &desc, font);
211 }
212
213 HRESULT WINAPI D3DXCreateFontW(LPDIRECT3DDEVICE9 device, INT height, UINT width, UINT weight, UINT miplevels, BOOL italic, DWORD charset,
214                                DWORD precision, DWORD quality, DWORD pitchandfamily, LPCWSTR facename, LPD3DXFONT *font)
215 {
216     D3DXFONT_DESCW desc;
217
218     if(!facename) return D3DXERR_INVALIDDATA;
219
220     desc.Height=height;
221     desc.Width=width;
222     desc.Weight=weight;
223     desc.MipLevels=miplevels;
224     desc.Italic=italic;
225     desc.CharSet=charset;
226     desc.OutputPrecision=precision;
227     desc.Quality=quality;
228     desc.PitchAndFamily=pitchandfamily;
229     strcpyW(desc.FaceName, facename);
230
231     return D3DXCreateFontIndirectW(device, &desc, font);
232 }
233
234 /***********************************************************************
235  *           D3DXCreateFontIndirectA    (D3DX9_36.@)
236  */
237 HRESULT WINAPI D3DXCreateFontIndirectA(LPDIRECT3DDEVICE9 device, CONST D3DXFONT_DESCA *desc, LPD3DXFONT *font)
238 {
239     D3DXFONT_DESCW widedesc;
240
241     if(!desc) return D3DERR_INVALIDCALL;
242     if(!desc->FaceName) return D3DERR_INVALIDCALL;
243
244     /* Copy everything but the last structure member. This requires the
245        two D3DXFONT_DESC structures to be equal until the FaceName member */
246     memcpy(&widedesc, desc, FIELD_OFFSET(D3DXFONT_DESCA, FaceName));
247     MultiByteToWideChar(CP_ACP, 0, desc->FaceName, -1,
248                         widedesc.FaceName, sizeof(widedesc.FaceName)/sizeof(WCHAR));
249     return D3DXCreateFontIndirectW(device, &widedesc, font);
250 }
251
252 /***********************************************************************
253  *           D3DXCreateFontIndirectW    (D3DX9_36.@)
254  */
255 HRESULT WINAPI D3DXCreateFontIndirectW(LPDIRECT3DDEVICE9 device, CONST D3DXFONT_DESCW *desc, LPD3DXFONT *font)
256 {
257     ID3DXFontImpl *object;
258
259     FIXME("stub\n");
260
261     if(!desc) return D3DERR_INVALIDCALL;
262
263     object=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXFontImpl));
264     if(object==NULL) {
265         *font=NULL;
266         return E_OUTOFMEMORY;
267     }
268     object->lpVtbl=&D3DXFont_Vtbl;
269     object->ref=1;
270
271     *font=(LPD3DXFONT)object;
272
273     return D3D_OK;
274 }