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

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2015-12-25 15:57:58 +03:00 committed by Alexandre Julliard
parent e9d4725326
commit 7a83be7bd2
1 changed files with 27 additions and 0 deletions

View File

@ -326,6 +326,8 @@ static inline struct dwrite_textformat *impl_from_IDWriteTextFormat1(IDWriteText
return CONTAINING_RECORD(iface, struct dwrite_textformat, IDWriteTextFormat1_iface); 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) static inline struct dwrite_trimmingsign *impl_from_IDWriteInlineObject(IDWriteInlineObject *iface)
{ {
return CONTAINING_RECORD(iface, struct dwrite_trimmingsign, 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) static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, IDWriteTextFormat *format)
{ {
struct dwrite_textformat *textformat;
IDWriteTextFormat1 *format1; IDWriteTextFormat1 *format1;
UINT32 len; UINT32 len;
HRESULT hr; 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.weight = IDWriteTextFormat_GetFontWeight(format);
layout->format.style = IDWriteTextFormat_GetFontStyle(format); layout->format.style = IDWriteTextFormat_GetFontStyle(format);
layout->format.stretch = IDWriteTextFormat_GetFontStretch(format); layout->format.stretch = IDWriteTextFormat_GetFontStretch(format);
@ -4599,6 +4620,12 @@ static const IDWriteTextFormat1Vtbl dwritetextformatvtbl = {
dwritetextformat1_GetFontFallback 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, 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) DWRITE_FONT_STRETCH stretch, FLOAT size, const WCHAR *locale, IDWriteTextFormat **format)
{ {