Commit 2e977e11 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Separate format data and keep it in both layout and text format.

parent 22508806
...@@ -32,17 +32,7 @@ ...@@ -32,17 +32,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(dwrite); WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
struct dwrite_textlayout { struct dwrite_textformat_data {
IDWriteTextLayout IDWriteTextLayout_iface;
LONG ref;
WCHAR *str;
};
struct dwrite_textformat {
IDWriteTextFormat IDWriteTextFormat_iface;
LONG ref;
WCHAR *family_name; WCHAR *family_name;
WCHAR *locale; WCHAR *locale;
...@@ -55,6 +45,27 @@ struct dwrite_textformat { ...@@ -55,6 +45,27 @@ struct dwrite_textformat {
IDWriteFontCollection *collection; IDWriteFontCollection *collection;
}; };
struct dwrite_textlayout {
IDWriteTextLayout IDWriteTextLayout_iface;
LONG ref;
WCHAR *str;
struct dwrite_textformat_data format;
};
struct dwrite_textformat {
IDWriteTextFormat IDWriteTextFormat_iface;
LONG ref;
struct dwrite_textformat_data format;
};
static void release_format_data(struct dwrite_textformat_data *data)
{
if (data->collection) IDWriteFontCollection_Release(data->collection);
heap_free(data->family_name);
heap_free(data->locale);
}
static inline struct dwrite_textlayout *impl_from_IDWriteTextLayout(IDWriteTextLayout *iface) static inline struct dwrite_textlayout *impl_from_IDWriteTextLayout(IDWriteTextLayout *iface)
{ {
return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextLayout_iface); return CONTAINING_RECORD(iface, struct dwrite_textlayout, IDWriteTextLayout_iface);
...@@ -665,6 +676,7 @@ HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextLayout **layo ...@@ -665,6 +676,7 @@ HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextLayout **layo
This->IDWriteTextLayout_iface.lpVtbl = &dwritetextlayoutvtbl; This->IDWriteTextLayout_iface.lpVtbl = &dwritetextlayoutvtbl;
This->ref = 1; This->ref = 1;
This->str = heap_strdupnW(str, len); This->str = heap_strdupnW(str, len);
memset(&This->format, 0, sizeof(This->format));
*layout = &This->IDWriteTextLayout_iface; *layout = &This->IDWriteTextLayout_iface;
...@@ -707,9 +719,7 @@ static ULONG WINAPI dwritetextformat_Release(IDWriteTextFormat *iface) ...@@ -707,9 +719,7 @@ static ULONG WINAPI dwritetextformat_Release(IDWriteTextFormat *iface)
if (!ref) if (!ref)
{ {
if (This->collection) IDWriteFontCollection_Release(This->collection); release_format_data(&This->format);
heap_free(This->family_name);
heap_free(This->locale);
heap_free(This); heap_free(This);
} }
...@@ -838,7 +848,7 @@ static HRESULT WINAPI dwritetextformat_GetFontCollection(IDWriteTextFormat *ifac ...@@ -838,7 +848,7 @@ static HRESULT WINAPI dwritetextformat_GetFontCollection(IDWriteTextFormat *ifac
TRACE("(%p)->(%p)\n", This, collection); TRACE("(%p)->(%p)\n", This, collection);
*collection = This->collection; *collection = This->format.collection;
IDWriteFontCollection_AddRef(*collection); IDWriteFontCollection_AddRef(*collection);
return S_OK; return S_OK;
...@@ -943,20 +953,20 @@ HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *colle ...@@ -943,20 +953,20 @@ HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *colle
This->IDWriteTextFormat_iface.lpVtbl = &dwritetextformatvtbl; This->IDWriteTextFormat_iface.lpVtbl = &dwritetextformatvtbl;
This->ref = 1; This->ref = 1;
This->family_name = heap_strdupW(family_name); This->format.family_name = heap_strdupW(family_name);
This->locale = heap_strdupW(locale); This->format.locale = heap_strdupW(locale);
This->weight = weight; This->format.weight = weight;
This->style = style; This->format.style = style;
This->size = size; This->format.size = size;
if (collection) if (collection)
{ {
This->collection = collection; This->format.collection = collection;
IDWriteFontCollection_AddRef(collection); IDWriteFontCollection_AddRef(collection);
} }
else else
{ {
HRESULT hr = get_system_fontcollection(&This->collection); HRESULT hr = get_system_fontcollection(&This->format.collection);
if (hr != S_OK) if (hr != S_OK)
{ {
IDWriteTextFormat_Release(&This->IDWriteTextFormat_iface); IDWriteTextFormat_Release(&This->IDWriteTextFormat_iface);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment