Commit 4d512f9e authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Keep factory reference for each layout.

parent af206b1b
...@@ -115,8 +115,9 @@ extern HRESULT convert_fontface_to_logfont(IDWriteFontFace*, LOGFONTW*) DECLSPEC ...@@ -115,8 +115,9 @@ extern HRESULT convert_fontface_to_logfont(IDWriteFontFace*, LOGFONTW*) DECLSPEC
extern HRESULT create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD,const WCHAR *locale,BOOL,IDWriteNumberSubstitution**) DECLSPEC_HIDDEN; extern HRESULT create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD,const WCHAR *locale,BOOL,IDWriteNumberSubstitution**) DECLSPEC_HIDDEN;
extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH, extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN; FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN;
extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,FLOAT,FLOAT,IDWriteTextLayout**) DECLSPEC_HIDDEN; extern HRESULT create_textlayout(IDWriteFactory2*,const WCHAR*,UINT32,IDWriteTextFormat*,FLOAT,FLOAT,IDWriteTextLayout**) DECLSPEC_HIDDEN;
extern HRESULT create_gdicompat_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,FLOAT,FLOAT,FLOAT,const DWRITE_MATRIX*,BOOL,IDWriteTextLayout**) DECLSPEC_HIDDEN; extern HRESULT create_gdicompat_textlayout(IDWriteFactory2*,const WCHAR*,UINT32,IDWriteTextFormat*,FLOAT,FLOAT,FLOAT,
const DWRITE_MATRIX*,BOOL,IDWriteTextLayout**) DECLSPEC_HIDDEN;
extern HRESULT create_trimmingsign(IDWriteFactory2*,IDWriteTextFormat*,IDWriteInlineObject**) DECLSPEC_HIDDEN; extern HRESULT create_trimmingsign(IDWriteFactory2*,IDWriteTextFormat*,IDWriteInlineObject**) DECLSPEC_HIDDEN;
extern HRESULT create_typography(IDWriteTypography**) DECLSPEC_HIDDEN; extern HRESULT create_typography(IDWriteTypography**) DECLSPEC_HIDDEN;
extern HRESULT create_gdiinterop(IDWriteFactory2*,IDWriteGdiInterop**) DECLSPEC_HIDDEN; extern HRESULT create_gdiinterop(IDWriteFactory2*,IDWriteGdiInterop**) DECLSPEC_HIDDEN;
......
...@@ -238,6 +238,8 @@ struct dwrite_textlayout { ...@@ -238,6 +238,8 @@ struct dwrite_textlayout {
IDWriteTextAnalysisSource1 IDWriteTextAnalysisSource1_iface; IDWriteTextAnalysisSource1 IDWriteTextAnalysisSource1_iface;
LONG ref; LONG ref;
IDWriteFactory2 *factory;
WCHAR *str; WCHAR *str;
UINT32 len; UINT32 len;
struct dwrite_textformat_data format; struct dwrite_textformat_data format;
...@@ -2548,6 +2550,7 @@ static ULONG WINAPI dwritetextlayout_Release(IDWriteTextLayout2 *iface) ...@@ -2548,6 +2550,7 @@ static ULONG WINAPI dwritetextlayout_Release(IDWriteTextLayout2 *iface)
TRACE("(%p)->(%d)\n", This, ref); TRACE("(%p)->(%d)\n", This, ref);
if (!ref) { if (!ref) {
IDWriteFactory2_Release(This->factory);
free_layout_ranges_list(This); free_layout_ranges_list(This);
free_layout_eruns(This); free_layout_eruns(This);
free_layout_runs(This); free_layout_runs(This);
...@@ -4353,7 +4356,8 @@ static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, I ...@@ -4353,7 +4356,8 @@ static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, I
return IDWriteTextFormat_GetFontCollection(format, &layout->format.collection); return IDWriteTextFormat_GetFontCollection(format, &layout->format.collection);
} }
static HRESULT init_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, FLOAT maxwidth, FLOAT maxheight, struct dwrite_textlayout *layout) static HRESULT init_textlayout(IDWriteFactory2 *factory, const WCHAR *str, UINT32 len, IDWriteTextFormat *format,
FLOAT maxwidth, FLOAT maxheight, struct dwrite_textlayout *layout)
{ {
struct layout_range_header *range, *strike, *underline, *effect, *spacing, *typography; struct layout_range_header *range, *strike, *underline, *effect, *spacing, *typography;
static const DWRITE_TEXT_RANGE r = { 0, ~0u }; static const DWRITE_TEXT_RANGE r = { 0, ~0u };
...@@ -4421,6 +4425,8 @@ static HRESULT init_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat * ...@@ -4421,6 +4425,8 @@ static HRESULT init_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *
goto fail; goto fail;
} }
layout->factory = factory;
IDWriteFactory2_AddRef(layout->factory);
list_add_head(&layout->ranges, &range->entry); list_add_head(&layout->ranges, &range->entry);
list_add_head(&layout->strike_ranges, &strike->entry); list_add_head(&layout->strike_ranges, &strike->entry);
list_add_head(&layout->underline_ranges, &underline->entry); list_add_head(&layout->underline_ranges, &underline->entry);
...@@ -4434,7 +4440,8 @@ fail: ...@@ -4434,7 +4440,8 @@ fail:
return hr; return hr;
} }
HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, FLOAT maxwidth, FLOAT maxheight, IDWriteTextLayout **ret) HRESULT create_textlayout(IDWriteFactory2 *factory, const WCHAR *str, UINT32 len, IDWriteTextFormat *format,
FLOAT maxwidth, FLOAT maxheight, IDWriteTextLayout **ret)
{ {
struct dwrite_textlayout *layout; struct dwrite_textlayout *layout;
HRESULT hr; HRESULT hr;
...@@ -4447,15 +4454,15 @@ HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *forma ...@@ -4447,15 +4454,15 @@ HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *forma
layout = heap_alloc(sizeof(struct dwrite_textlayout)); layout = heap_alloc(sizeof(struct dwrite_textlayout));
if (!layout) return E_OUTOFMEMORY; if (!layout) return E_OUTOFMEMORY;
hr = init_textlayout(str, len, format, maxwidth, maxheight, layout); hr = init_textlayout(factory, str, len, format, maxwidth, maxheight, layout);
if (hr == S_OK) if (hr == S_OK)
*ret = (IDWriteTextLayout*)&layout->IDWriteTextLayout2_iface; *ret = (IDWriteTextLayout*)&layout->IDWriteTextLayout2_iface;
return hr; return hr;
} }
HRESULT create_gdicompat_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, FLOAT maxwidth, FLOAT maxheight, HRESULT create_gdicompat_textlayout(IDWriteFactory2 *factory, const WCHAR *str, UINT32 len, IDWriteTextFormat *format,
FLOAT ppdip, const DWRITE_MATRIX *transform, BOOL use_gdi_natural, IDWriteTextLayout **ret) FLOAT maxwidth, FLOAT maxheight, FLOAT ppdip, const DWRITE_MATRIX *transform, BOOL use_gdi_natural, IDWriteTextLayout **ret)
{ {
struct dwrite_textlayout *layout; struct dwrite_textlayout *layout;
HRESULT hr; HRESULT hr;
...@@ -4468,7 +4475,7 @@ HRESULT create_gdicompat_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFor ...@@ -4468,7 +4475,7 @@ HRESULT create_gdicompat_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFor
layout = heap_alloc(sizeof(struct dwrite_textlayout)); layout = heap_alloc(sizeof(struct dwrite_textlayout));
if (!layout) return E_OUTOFMEMORY; if (!layout) return E_OUTOFMEMORY;
hr = init_textlayout(str, len, format, maxwidth, maxheight, layout); hr = init_textlayout(factory, str, len, format, maxwidth, maxheight, layout);
if (hr == S_OK) { if (hr == S_OK) {
layout->measuringmode = use_gdi_natural ? DWRITE_MEASURING_MODE_GDI_NATURAL : DWRITE_MEASURING_MODE_GDI_CLASSIC; layout->measuringmode = use_gdi_natural ? DWRITE_MEASURING_MODE_GDI_NATURAL : DWRITE_MEASURING_MODE_GDI_CLASSIC;
......
...@@ -1059,7 +1059,7 @@ static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory2 *iface, WCH ...@@ -1059,7 +1059,7 @@ static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory2 *iface, WCH
TRACE("(%p)->(%s:%u %p %f %f %p)\n", This, debugstr_wn(string, len), len, format, max_width, max_height, layout); TRACE("(%p)->(%s:%u %p %f %f %p)\n", This, debugstr_wn(string, len), len, format, max_width, max_height, layout);
return create_textlayout(string, len, format, max_width, max_height, layout); return create_textlayout(iface, string, len, format, max_width, max_height, layout);
} }
static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory2 *iface, WCHAR const* string, static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory2 *iface, WCHAR const* string,
...@@ -1071,7 +1071,7 @@ static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory ...@@ -1071,7 +1071,7 @@ static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory
TRACE("(%p)->(%s:%u %p %f %f %f %p %d %p)\n", This, debugstr_wn(string, len), len, format, layout_width, layout_height, TRACE("(%p)->(%s:%u %p %f %f %f %p %d %p)\n", This, debugstr_wn(string, len), len, format, layout_width, layout_height,
pixels_per_dip, transform, use_gdi_natural, layout); pixels_per_dip, transform, use_gdi_natural, layout);
return create_gdicompat_textlayout(string, len, format, layout_width, layout_height, pixels_per_dip, transform, return create_gdicompat_textlayout(iface, string, len, format, layout_width, layout_height, pixels_per_dip, transform,
use_gdi_natural, layout); use_gdi_natural, layout);
} }
......
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