2 * Copyright (C) 2008 Tony Wasserka
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.
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.
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
21 #include "wine/port.h"
23 #include "wine/debug.h"
24 #include "wine/unicode.h"
25 #include "d3dx9_36_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3dx
);
29 static HRESULT WINAPI
ID3DXFontImpl_QueryInterface(LPD3DXFONT iface
, REFIID riid
, LPVOID
*object
)
31 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
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
);
39 WARN("(%p)->(%s, %p): not found\n", iface
, debugstr_guid(riid
), *object
);
43 static ULONG WINAPI
ID3DXFontImpl_AddRef(LPD3DXFONT iface
)
45 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
46 ULONG ref
=InterlockedIncrement(&This
->ref
);
47 TRACE("(%p): AddRef from %d\n", This
, ref
-1);
51 static ULONG WINAPI
ID3DXFontImpl_Release(LPD3DXFONT iface
)
53 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
54 ULONG ref
=InterlockedDecrement(&This
->ref
);
55 TRACE("(%p): ReleaseRef to %d\n", This
, ref
);
58 HeapFree(GetProcessHeap(), 0, This
);
63 static HRESULT WINAPI
ID3DXFontImpl_GetDevice(LPD3DXFONT iface
, LPDIRECT3DDEVICE9
*device
)
65 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
66 FIXME("(%p): stub\n", This
);
70 static HRESULT WINAPI
ID3DXFontImpl_GetDescA(LPD3DXFONT iface
, D3DXFONT_DESCA
*desc
)
72 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
73 FIXME("(%p): stub\n", This
);
77 static HRESULT WINAPI
ID3DXFontImpl_GetDescW(LPD3DXFONT iface
, D3DXFONT_DESCW
*desc
)
79 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
80 FIXME("(%p): stub\n", This
);
84 static BOOL WINAPI
ID3DXFontImpl_GetTextMetricsA(LPD3DXFONT iface
, TEXTMETRICA
*metrics
)
86 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
87 FIXME("(%p): stub\n", This
);
91 static BOOL WINAPI
ID3DXFontImpl_GetTextMetricsW(LPD3DXFONT iface
, TEXTMETRICW
*metrics
)
93 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
94 FIXME("(%p): stub\n", This
);
98 static HDC WINAPI
ID3DXFontImpl_GetDC(LPD3DXFONT iface
)
100 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
101 FIXME("(%p): stub\n", This
);
105 static HRESULT WINAPI
ID3DXFontImpl_GetGlyphData(LPD3DXFONT iface
, UINT glyph
, LPDIRECT3DTEXTURE9
*texture
, RECT
*blackbox
, POINT
*cellinc
)
107 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
108 FIXME("(%p): stub\n", This
);
112 static HRESULT WINAPI
ID3DXFontImpl_PreloadCharacters(LPD3DXFONT iface
, UINT first
, UINT last
)
114 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
115 FIXME("(%p): stub\n", This
);
119 static HRESULT WINAPI
ID3DXFontImpl_PreloadGlyphs(LPD3DXFONT iface
, UINT first
, UINT last
)
121 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
122 FIXME("(%p): stub\n", This
);
126 static HRESULT WINAPI
ID3DXFontImpl_PreloadTextA(LPD3DXFONT iface
, LPCSTR string
, INT count
)
128 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
129 FIXME("(%p): stub\n", This
);
133 static HRESULT WINAPI
ID3DXFontImpl_PreloadTextW(LPD3DXFONT iface
, LPCWSTR string
, INT count
)
135 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
136 FIXME("(%p): stub\n", This
);
140 static INT WINAPI
ID3DXFontImpl_DrawTextA(LPD3DXFONT iface
, LPD3DXSPRITE sprite
, LPCSTR string
, INT count
, LPRECT rect
, DWORD format
, D3DCOLOR color
)
142 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
143 FIXME("(%p): stub\n", This
);
147 static INT WINAPI
ID3DXFontImpl_DrawTextW(LPD3DXFONT iface
, LPD3DXSPRITE sprite
, LPCWSTR string
, INT count
, LPRECT rect
, DWORD format
, D3DCOLOR color
)
149 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
150 FIXME("(%p): stub\n", This
);
154 static HRESULT WINAPI
ID3DXFontImpl_OnLostDevice(LPD3DXFONT iface
)
156 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
157 FIXME("(%p): stub\n", This
);
161 static HRESULT WINAPI
ID3DXFontImpl_OnResetDevice(LPD3DXFONT iface
)
163 ID3DXFontImpl
*This
=(ID3DXFontImpl
*)iface
;
164 FIXME("(%p): stub\n", This
);
168 static const ID3DXFontVtbl D3DXFont_Vtbl
=
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
,
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
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
)
197 if(!facename
) return D3DXERR_INVALIDDATA
;
202 desc
.MipLevels
=miplevels
;
204 desc
.CharSet
=charset
;
205 desc
.OutputPrecision
=precision
;
206 desc
.Quality
=quality
;
207 desc
.PitchAndFamily
=pitchandfamily
;
208 lstrcpyA(desc
.FaceName
, facename
);
210 return D3DXCreateFontIndirectA(device
, &desc
, font
);
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
)
218 if(!facename
) return D3DXERR_INVALIDDATA
;
223 desc
.MipLevels
=miplevels
;
225 desc
.CharSet
=charset
;
226 desc
.OutputPrecision
=precision
;
227 desc
.Quality
=quality
;
228 desc
.PitchAndFamily
=pitchandfamily
;
229 strcpyW(desc
.FaceName
, facename
);
231 return D3DXCreateFontIndirectW(device
, &desc
, font
);
234 /***********************************************************************
235 * D3DXCreateFontIndirectA (D3DX9_36.@)
237 HRESULT WINAPI
D3DXCreateFontIndirectA(LPDIRECT3DDEVICE9 device
, CONST D3DXFONT_DESCA
*desc
, LPD3DXFONT
*font
)
239 D3DXFONT_DESCW widedesc
;
241 if(!desc
) return D3DERR_INVALIDCALL
;
242 if(!desc
->FaceName
) return D3DERR_INVALIDCALL
;
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
);
252 /***********************************************************************
253 * D3DXCreateFontIndirectW (D3DX9_36.@)
255 HRESULT WINAPI
D3DXCreateFontIndirectW(LPDIRECT3DDEVICE9 device
, CONST D3DXFONT_DESCW
*desc
, LPD3DXFONT
*font
)
257 ID3DXFontImpl
*object
;
261 if(!desc
) return D3DERR_INVALIDCALL
;
263 object
=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(ID3DXFontImpl
));
266 return E_OUTOFMEMORY
;
268 object
->lpVtbl
=&D3DXFont_Vtbl
;
271 *font
=(LPD3DXFONT
)object
;