Module: wine Branch: master Commit: 7342f34ef7936dce488adc832476877f48fb8540 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7342f34ef7936dce488adc8324...
Author: Michael Stefaniuc mstefani@redhat.de Date: Thu Jan 27 00:28:41 2011 +0100
d3dx9_36: COM cleanup for the ID3DXFont iface.
---
dlls/d3dx9_36/d3dx9_36_private.h | 15 ------ dlls/d3dx9_36/font.c | 96 +++++++++++++++++++++++--------------- 2 files changed, 58 insertions(+), 53 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_36_private.h b/dlls/d3dx9_36/d3dx9_36_private.h index 4b2e78d..f19a2fe 100644 --- a/dlls/d3dx9_36/d3dx9_36_private.h +++ b/dlls/d3dx9_36/d3dx9_36_private.h @@ -50,21 +50,6 @@ HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, LPVOID *buffer, const PixelFormatDesc *get_format_info(D3DFORMAT format); const PixelFormatDesc *get_format_info_idx(int idx);
-/* ID3DXFont */ -typedef struct ID3DXFontImpl -{ - /* IUnknown fields */ - const ID3DXFontVtbl *lpVtbl; - LONG ref; - - /* ID3DXFont fields */ - IDirect3DDevice9 *device; - D3DXFONT_DESCW desc; - - HDC hdc; - HFONT hfont; -} ID3DXFontImpl; - /* ID3DXMatrixStack */ typedef struct ID3DXMatrixStackImpl { diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 1113060..a27f80a 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -26,9 +26,26 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
-static HRESULT WINAPI ID3DXFontImpl_QueryInterface(LPD3DXFONT iface, REFIID riid, LPVOID *object) +typedef struct ID3DXFontImpl { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFont ID3DXFont_iface; + LONG ref; + + IDirect3DDevice9 *device; + D3DXFONT_DESCW desc; + + HDC hdc; + HFONT hfont; +} ID3DXFontImpl; + +static inline ID3DXFontImpl *impl_from_ID3DXFont(ID3DXFont *iface) +{ + return CONTAINING_RECORD(iface, ID3DXFontImpl, ID3DXFont_iface); +} + +static HRESULT WINAPI ID3DXFontImpl_QueryInterface(ID3DXFont *iface, REFIID riid, void **object) +{ + ID3DXFontImpl *This=impl_from_ID3DXFont(iface);
TRACE("(%p): QueryInterface from %s\n", This, debugstr_guid(riid)); if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ID3DXFont)) { @@ -40,17 +57,17 @@ static HRESULT WINAPI ID3DXFontImpl_QueryInterface(LPD3DXFONT iface, REFIID riid return E_NOINTERFACE; }
-static ULONG WINAPI ID3DXFontImpl_AddRef(LPD3DXFONT iface) +static ULONG WINAPI ID3DXFontImpl_AddRef(ID3DXFont *iface) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); ULONG ref=InterlockedIncrement(&This->ref); TRACE("(%p)->(): AddRef from %d\n", This, ref-1); return ref; }
-static ULONG WINAPI ID3DXFontImpl_Release(LPD3DXFONT iface) +static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); ULONG ref=InterlockedDecrement(&This->ref);
TRACE("(%p)->(): ReleaseRef to %d\n", This, ref); @@ -64,9 +81,9 @@ static ULONG WINAPI ID3DXFontImpl_Release(LPD3DXFONT iface) return ref; }
-static HRESULT WINAPI ID3DXFontImpl_GetDevice(LPD3DXFONT iface, LPDIRECT3DDEVICE9 *device) +static HRESULT WINAPI ID3DXFontImpl_GetDevice(ID3DXFont *iface, LPDIRECT3DDEVICE9 *device) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface);
TRACE("(%p)->(%p)\n", This, device);
@@ -77,9 +94,9 @@ static HRESULT WINAPI ID3DXFontImpl_GetDevice(LPD3DXFONT iface, LPDIRECT3DDEVICE return D3D_OK; }
-static HRESULT WINAPI ID3DXFontImpl_GetDescA(LPD3DXFONT iface, D3DXFONT_DESCA *desc) +static HRESULT WINAPI ID3DXFontImpl_GetDescA(ID3DXFont *iface, D3DXFONT_DESCA *desc) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface);
TRACE("(%p)->(%p)\n", This, desc);
@@ -90,9 +107,9 @@ static HRESULT WINAPI ID3DXFontImpl_GetDescA(LPD3DXFONT iface, D3DXFONT_DESCA *d return D3D_OK; }
-static HRESULT WINAPI ID3DXFontImpl_GetDescW(LPD3DXFONT iface, D3DXFONT_DESCW *desc) +static HRESULT WINAPI ID3DXFontImpl_GetDescW(ID3DXFont *iface, D3DXFONT_DESCW *desc) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface);
TRACE("(%p)->(%p)\n", This, desc);
@@ -102,86 +119,89 @@ static HRESULT WINAPI ID3DXFontImpl_GetDescW(LPD3DXFONT iface, D3DXFONT_DESCW *d return D3D_OK; }
-static BOOL WINAPI ID3DXFontImpl_GetTextMetricsA(LPD3DXFONT iface, TEXTMETRICA *metrics) +static BOOL WINAPI ID3DXFontImpl_GetTextMetricsA(ID3DXFont *iface, TEXTMETRICA *metrics) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); TRACE("(%p)->(%p)\n", This, metrics); return GetTextMetricsA(This->hdc, metrics); }
-static BOOL WINAPI ID3DXFontImpl_GetTextMetricsW(LPD3DXFONT iface, TEXTMETRICW *metrics) +static BOOL WINAPI ID3DXFontImpl_GetTextMetricsW(ID3DXFont *iface, TEXTMETRICW *metrics) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); TRACE("(%p)->(%p)\n", This, metrics); return GetTextMetricsW(This->hdc, metrics); }
-static HDC WINAPI ID3DXFontImpl_GetDC(LPD3DXFONT iface) +static HDC WINAPI ID3DXFontImpl_GetDC(ID3DXFont *iface) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); TRACE("(%p)->()\n", This); return This->hdc; }
-static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(LPD3DXFONT iface, UINT glyph, LPDIRECT3DTEXTURE9 *texture, RECT *blackbox, POINT *cellinc) +static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph, + LPDIRECT3DTEXTURE9 *texture, RECT *blackbox, POINT *cellinc) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); FIXME("(%p)->(%u, %p, %p, %p): stub\n", This, glyph, texture, blackbox, cellinc); return D3D_OK; }
-static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(LPD3DXFONT iface, UINT first, UINT last) +static HRESULT WINAPI ID3DXFontImpl_PreloadCharacters(ID3DXFont *iface, UINT first, UINT last) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); FIXME("(%p)->(%u, %u): stub\n", This, first, last); return D3D_OK; }
-static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(LPD3DXFONT iface, UINT first, UINT last) +static HRESULT WINAPI ID3DXFontImpl_PreloadGlyphs(ID3DXFont *iface, UINT first, UINT last) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); FIXME("(%p)->(%u, %u): stub\n", This, first, last); return D3D_OK; }
-static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(LPD3DXFONT iface, LPCSTR string, INT count) +static HRESULT WINAPI ID3DXFontImpl_PreloadTextA(ID3DXFont *iface, LPCSTR string, INT count) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); FIXME("(%p)->(%s, %d): stub\n", This, string, count); return D3D_OK; }
-static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(LPD3DXFONT iface, LPCWSTR string, INT count) +static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, LPCWSTR string, INT count) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); FIXME("(%p)->(%s, %d): stub\n", This, debugstr_w(string), count); return D3D_OK; }
-static INT WINAPI ID3DXFontImpl_DrawTextA(LPD3DXFONT iface, LPD3DXSPRITE sprite, LPCSTR string, INT count, LPRECT rect, DWORD format, D3DCOLOR color) +static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, LPD3DXSPRITE sprite, LPCSTR string, + INT count, LPRECT rect, DWORD format, D3DCOLOR color) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); FIXME("(%p)->(%p, %s, %d, %p, %d, %#x): stub\n", This, sprite, string, count, rect, format, color); return 1; }
-static INT WINAPI ID3DXFontImpl_DrawTextW(LPD3DXFONT iface, LPD3DXSPRITE sprite, LPCWSTR string, INT count, LPRECT rect, DWORD format, D3DCOLOR color) +static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, LPD3DXSPRITE sprite, LPCWSTR string, + INT count, LPRECT rect, DWORD format, D3DCOLOR color) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); FIXME("(%p)->(%p, %s, %d, %p, %d, %#x): stub\n", This, sprite, debugstr_w(string), count, rect, format, color); return 1; }
-static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(LPD3DXFONT iface) +static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(ID3DXFont *iface) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); FIXME("(%p)->(): stub\n", This); return D3D_OK; }
-static HRESULT WINAPI ID3DXFontImpl_OnResetDevice(LPD3DXFONT iface) +static HRESULT WINAPI ID3DXFontImpl_OnResetDevice(ID3DXFont *iface) { - ID3DXFontImpl *This=(ID3DXFontImpl*)iface; + ID3DXFontImpl *This=impl_from_ID3DXFont(iface); FIXME("(%p)->(): stub\n", This); return D3D_OK; } @@ -302,7 +322,7 @@ HRESULT WINAPI D3DXCreateFontIndirectW(LPDIRECT3DDEVICE9 device, CONST D3DXFONT_ *font=NULL; return E_OUTOFMEMORY; } - object->lpVtbl=&D3DXFont_Vtbl; + object->ID3DXFont_iface.lpVtbl = &D3DXFont_Vtbl; object->ref=1; object->device=device; object->desc=*desc; @@ -323,7 +343,7 @@ HRESULT WINAPI D3DXCreateFontIndirectW(LPDIRECT3DDEVICE9 device, CONST D3DXFONT_ SelectObject(object->hdc, object->hfont);
IDirect3DDevice9_AddRef(device); - *font=(LPD3DXFONT)object; + *font=&object->ID3DXFont_iface;
return D3D_OK; }