Commit 7a83be7b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Optimize for the most common case of layout object initialization.

parent e9d47253
......@@ -326,6 +326,8 @@ static inline struct dwrite_textformat *impl_from_IDWriteTextFormat1(IDWriteText
return CONTAINING_RECORD(iface, struct dwrite_textformat, IDWriteTextFormat1_iface);
}
static struct dwrite_textformat *unsafe_impl_from_IDWriteTextFormat(IDWriteTextFormat*);
static inline struct dwrite_trimmingsign *impl_from_IDWriteInlineObject(IDWriteInlineObject *iface)
{
return CONTAINING_RECORD(iface, struct dwrite_trimmingsign, IDWriteInlineObject_iface);
......@@ -3896,10 +3898,29 @@ static const IDWriteTextAnalysisSourceVtbl dwritetextlayoutsourcevtbl = {
static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, IDWriteTextFormat *format)
{
struct dwrite_textformat *textformat;
IDWriteTextFormat1 *format1;
UINT32 len;
HRESULT hr;
if ((textformat = unsafe_impl_from_IDWriteTextFormat(format))) {
layout->format = textformat->format;
layout->format.locale = heap_strdupW(textformat->format.locale);
layout->format.family_name = heap_strdupW(textformat->format.family_name);
if (!layout->format.locale || !layout->format.family_name)
return E_OUTOFMEMORY;
if (layout->format.trimmingsign)
IDWriteInlineObject_AddRef(layout->format.trimmingsign);
if (layout->format.collection)
IDWriteFontCollection_AddRef(layout->format.collection);
if (layout->format.fallback)
IDWriteFontFallback_AddRef(layout->format.fallback);
return S_OK;
}
layout->format.weight = IDWriteTextFormat_GetFontWeight(format);
layout->format.style = IDWriteTextFormat_GetFontStyle(format);
layout->format.stretch = IDWriteTextFormat_GetFontStretch(format);
......@@ -4599,6 +4620,12 @@ static const IDWriteTextFormat1Vtbl dwritetextformatvtbl = {
dwritetextformat1_GetFontFallback
};
static struct dwrite_textformat *unsafe_impl_from_IDWriteTextFormat(IDWriteTextFormat *iface)
{
return (iface->lpVtbl == (IDWriteTextFormatVtbl*)&dwritetextformatvtbl) ?
CONTAINING_RECORD(iface, struct dwrite_textformat, IDWriteTextFormat1_iface) : NULL;
}
HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style,
DWRITE_FONT_STRETCH stretch, FLOAT size, const WCHAR *locale, IDWriteTextFormat **format)
{
......
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