Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/opentype.c | 103 +++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 60 deletions(-)
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index 68da6e4ecfb..1cf47e5ac69 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -3499,13 +3499,46 @@ static void opentype_layout_apply_gpos_value(struct scriptshaping_context *conte } }
+struct lookup +{ + unsigned short index; + unsigned short type; + unsigned short flags; + unsigned short subtable_count; + + unsigned int mask; + unsigned int offset; +}; + static unsigned int opentype_layout_get_gsubgpos_subtable(const struct scriptshaping_context *context, - unsigned int lookup_offset, unsigned int subtable) + const struct lookup *lookup, unsigned int subtable, unsigned int *lookup_type) { - unsigned int subtable_offset = table_read_be_word(&context->table->table, lookup_offset + + unsigned int subtable_offset = table_read_be_word(&context->table->table, lookup->offset + FIELD_OFFSET(struct ot_lookup_table, subtable[subtable])); + const struct ot_gsubgpos_extension_format1 *format1; + + subtable_offset += lookup->offset; + + if ((context->table == &context->cache->gsub && lookup->type != GSUB_LOOKUP_EXTENSION_SUBST) || + (context->table == &context->cache->gpos && lookup->type != GPOS_LOOKUP_EXTENSION_POSITION)) + { + *lookup_type = lookup->type; + return subtable_offset; + } + + *lookup_type = 0; + + if (!(format1 = table_read_ensure(&context->table->table, subtable_offset, sizeof(*format1)))) + return 0; + + if (GET_BE_WORD(format1->format) != 1) + { + WARN("Unexpected extension table format %#x.\n", format1->format); + return 0; + }
- return lookup_offset + subtable_offset; + *lookup_type = GET_BE_WORD(format1->lookup_type); + return subtable_offset + GET_BE_DWORD(format1->extension_offset); }
struct ot_lookup @@ -3715,17 +3748,6 @@ static BOOL glyph_iterator_prev(struct glyph_iterator *iter) return FALSE; }
-struct lookup -{ - unsigned short index; - unsigned short type; - unsigned short flags; - unsigned short subtable_count; - - unsigned int mask; - unsigned int offset; -}; - static BOOL opentype_layout_apply_gpos_single_adjustment(struct scriptshaping_context *context, const struct lookup *lookup, unsigned int subtable_offset) { @@ -4247,31 +4269,6 @@ static BOOL opentype_layout_apply_gpos_mark_to_mark_attachment(struct scriptshap return TRUE; }
-static unsigned int opentype_layout_adjust_extension_subtable(struct scriptshaping_context *context, - unsigned int *subtable_offset, const struct lookup *lookup) -{ - const struct ot_gsubgpos_extension_format1 *format1; - - if ((context->table == &context->cache->gsub && lookup->type != GSUB_LOOKUP_EXTENSION_SUBST) || - (context->table == &context->cache->gpos && lookup->type != GPOS_LOOKUP_EXTENSION_POSITION)) - { - return lookup->type; - } - - if (!(format1 = table_read_ensure(&context->table->table, *subtable_offset, sizeof(*format1)))) - return 0; - - if (GET_BE_WORD(format1->format) != 1) - { - WARN("Unexpected extension table format %#x.\n", format1->format); - return 0; - } - - *subtable_offset = *subtable_offset + GET_BE_DWORD(format1->extension_offset); - - return GET_BE_WORD(format1->lookup_type); -} - static BOOL opentype_layout_apply_context(struct scriptshaping_context *context, const struct lookup *lookup, unsigned int subtable_offset); static BOOL opentype_layout_apply_chain_context(struct scriptshaping_context *context, const struct lookup *lookup, @@ -4284,9 +4281,7 @@ static BOOL opentype_layout_apply_gpos_lookup(struct scriptshaping_context *cont
for (i = 0; i < lookup->subtable_count; ++i) { - unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup->offset, i); - - lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset, lookup); + unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup, i, &lookup_type);
switch (lookup_type) { @@ -5595,9 +5590,7 @@ static BOOL opentype_layout_apply_gsub_lookup(struct scriptshaping_context *cont
for (i = 0; i < lookup->subtable_count; ++i) { - unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup->offset, i); - - lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset, lookup); + unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup, i, &lookup_type);
switch (lookup_type) { @@ -5740,14 +5733,9 @@ static void opentype_get_nominal_glyphs(struct scriptshaping_context *context, c
static BOOL opentype_is_gsub_lookup_reversed(const struct scriptshaping_context *context, const struct lookup *lookup) { - unsigned int subtable_offset, lookup_type = lookup->type; + unsigned int lookup_type;
- if (lookup->type == GSUB_LOOKUP_EXTENSION_SUBST) - { - subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup->offset, 0); - /* Assumes format 1. */ - lookup_type = table_read_be_word(&context->table->table, subtable_offset + 2); - } + opentype_layout_get_gsubgpos_subtable(context, lookup, 0, &lookup_type); return lookup_type == GSUB_LOOKUP_REVERSE_CHAINING_CONTEXTUAL_SUBST; }
@@ -5914,9 +5902,7 @@ static BOOL opentype_layout_gsub_lookup_is_glyph_covered(struct scriptshaping_co
for (i = 0; i < lookup->subtable_count; ++i) { - unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup->offset, i); - - lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset, lookup); + unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup, i, &lookup_type);
format = table_read_be_word(gsub, subtable_offset);
@@ -5981,9 +5967,7 @@ static BOOL opentype_layout_gpos_lookup_is_glyph_covered(struct scriptshaping_co
for (i = 0; i < lookup->subtable_count; ++i) { - unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup->offset, i); - - lookup_type = opentype_layout_adjust_extension_subtable(context, &subtable_offset, lookup); + unsigned int subtable_offset = opentype_layout_get_gsubgpos_subtable(context, lookup, i, &lookup_type);
format = table_read_be_word(gpos, subtable_offset);
@@ -6104,8 +6088,7 @@ BOOL opentype_has_vertical_variants(struct dwrite_fontface *fontface)
for (j = 0; j < lookup->subtable_count && !count; ++j) { - subtable_offset = opentype_layout_get_gsubgpos_subtable(&context, lookup->offset, j); - lookup_type = opentype_layout_adjust_extension_subtable(&context, &subtable_offset, lookup); + subtable_offset = opentype_layout_get_gsubgpos_subtable(&context, lookup, j, &lookup_type);
if (lookup_type != GSUB_LOOKUP_SINGLE_SUBST) continue;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
This is handled when HAS_VERTICAL flag is set.
dlls/dwrite/opentype.c | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index 1cf47e5ac69..260a0a8f5db 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -6150,10 +6150,6 @@ HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, u { const struct lookup *lookup = &lookups.lookups[i];
- /* FIXME: should probably handle extension subtables. */ - if (lookup->type != GSUB_LOOKUP_SINGLE_SUBST) - continue; - context.cur = 0; while (context.cur < context.glyph_count) {
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/main.c | 54 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 24 deletions(-)
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index a96874b2c2c..cfb2e9f6a56 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -258,9 +258,7 @@ static inline struct localizedstrings *impl_from_IDWriteLocalizedStrings(IDWrite
static HRESULT WINAPI localizedstrings_QueryInterface(IDWriteLocalizedStrings *iface, REFIID riid, void **obj) { - struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteLocalizedStrings)) { @@ -358,60 +356,66 @@ static HRESULT WINAPI localizedstrings_GetLocaleNameLength(IDWriteLocalizedStrin
static HRESULT WINAPI localizedstrings_GetLocaleName(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size) { - struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface); + struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
- TRACE("(%p)->(%u %p %u)\n", This, index, buffer, size); + TRACE("%p, %u, %p, %u.\n", iface, index, buffer, size);
- if (index >= This->count) { + if (index >= strings->count) + { if (buffer) *buffer = 0; return E_FAIL; }
- if (size < strlenW(This->data[index].locale)+1) { + if (size < strlenW(strings->data[index].locale) + 1) + { if (buffer) *buffer = 0; return E_NOT_SUFFICIENT_BUFFER; }
- strcpyW(buffer, This->data[index].locale); + strcpyW(buffer, strings->data[index].locale); return S_OK; }
static HRESULT WINAPI localizedstrings_GetStringLength(IDWriteLocalizedStrings *iface, UINT32 index, UINT32 *length) { - struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface); + struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
- TRACE("(%p)->(%u %p)\n", This, index, length); + TRACE("%p, %u, %p.\n", iface, index, length);
- if (index >= This->count) { - *length = (UINT32)-1; + if (index >= strings->count) + { + *length = ~0u; return E_FAIL; }
- *length = strlenW(This->data[index].string); + *length = strlenW(strings->data[index].string); return S_OK; }
static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size) { - struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface); + struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
- TRACE("(%p)->(%u %p %u)\n", This, index, buffer, size); + TRACE("%p, %u, %p, %u.\n", iface, index, buffer, size);
- if (index >= This->count) { + if (index >= strings->count) + { if (buffer) *buffer = 0; return E_FAIL; }
- if (size < strlenW(This->data[index].string)+1) { + if (size < strlenW(strings->data[index].string) + 1) + { if (buffer) *buffer = 0; return E_NOT_SUFFICIENT_BUFFER; }
- strcpyW(buffer, This->data[index].string); + strcpyW(buffer, strings->data[index].string); return S_OK; }
-static const IDWriteLocalizedStringsVtbl localizedstringsvtbl = { +static const IDWriteLocalizedStringsVtbl localizedstringsvtbl = +{ localizedstrings_QueryInterface, localizedstrings_AddRef, localizedstrings_Release, @@ -511,13 +515,15 @@ HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedS void set_en_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *string) { static const WCHAR enusW[] = {'e','n','-','U','S',0}; - struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface); + struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface); UINT32 i;
- for (i = 0; i < This->count; i++) { - if (!strcmpiW(This->data[i].locale, enusW)) { - heap_free(This->data[i].string); - This->data[i].string = heap_strdupW(string); + for (i = 0; i < strings->count; i++) + { + if (!strcmpiW(strings->data[i].locale, enusW)) + { + heap_free(strings->data[i].string); + strings->data[i].string = heap_strdupW(string); break; } }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/main.c | 140 +++++++++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 62 deletions(-)
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index cfb2e9f6a56..dd9bd4dc6a3 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -54,14 +54,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved) return TRUE; }
-struct renderingparams { +struct renderingparams +{ IDWriteRenderingParams3 IDWriteRenderingParams3_iface; - LONG ref; + LONG refcount;
- FLOAT gamma; - FLOAT contrast; - FLOAT grayscalecontrast; - FLOAT cleartype_level; + float gamma; + float contrast; + float grayscalecontrast; + float cleartype_level; DWRITE_PIXEL_GEOMETRY geometry; DWRITE_RENDERING_MODE1 mode; DWRITE_GRID_FIT_MODE gridfit; @@ -74,9 +75,7 @@ static inline struct renderingparams *impl_from_IDWriteRenderingParams3(IDWriteR
static HRESULT WINAPI renderingparams_QueryInterface(IDWriteRenderingParams3 *iface, REFIID riid, void **obj) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IDWriteRenderingParams3) || IsEqualIID(riid, &IID_IDWriteRenderingParams2) || @@ -96,51 +95,61 @@ static HRESULT WINAPI renderingparams_QueryInterface(IDWriteRenderingParams3 *if
static ULONG WINAPI renderingparams_AddRef(IDWriteRenderingParams3 *iface) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); - ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%d)\n", This, ref); - return ref; + struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface); + ULONG refcount = InterlockedIncrement(¶ms->refcount); + + TRACE("%p, refcount %d.\n", iface, refcount); + + return refcount; }
static ULONG WINAPI renderingparams_Release(IDWriteRenderingParams3 *iface) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface); + ULONG refcount = InterlockedDecrement(¶ms->refcount);
- TRACE("(%p)->(%d)\n", This, ref); + TRACE("%p, refcount %d.\n", iface, refcount);
- if (!ref) - heap_free(This); + if (!refcount) + heap_free(params);
- return ref; + return refcount; }
-static FLOAT WINAPI renderingparams_GetGamma(IDWriteRenderingParams3 *iface) +static float WINAPI renderingparams_GetGamma(IDWriteRenderingParams3 *iface) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); - TRACE("(%p)\n", This); - return This->gamma; + struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface); + + TRACE("%p.\n", iface); + + return params->gamma; }
-static FLOAT WINAPI renderingparams_GetEnhancedContrast(IDWriteRenderingParams3 *iface) +static float WINAPI renderingparams_GetEnhancedContrast(IDWriteRenderingParams3 *iface) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); - TRACE("(%p)\n", This); - return This->contrast; + struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface); + + TRACE("%p.\n", iface); + + return params->contrast; }
-static FLOAT WINAPI renderingparams_GetClearTypeLevel(IDWriteRenderingParams3 *iface) +static float WINAPI renderingparams_GetClearTypeLevel(IDWriteRenderingParams3 *iface) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); - TRACE("(%p)\n", This); - return This->cleartype_level; + struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface); + + TRACE("%p.\n", iface); + + return params->cleartype_level; }
static DWRITE_PIXEL_GEOMETRY WINAPI renderingparams_GetPixelGeometry(IDWriteRenderingParams3 *iface) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); - TRACE("(%p)\n", This); - return This->geometry; + struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface); + + TRACE("%p.\n", iface); + + return params->geometry; }
static DWRITE_RENDERING_MODE rendering_mode_from_mode1(DWRITE_RENDERING_MODE1 mode) @@ -161,35 +170,42 @@ static DWRITE_RENDERING_MODE rendering_mode_from_mode1(DWRITE_RENDERING_MODE1 mo
static DWRITE_RENDERING_MODE WINAPI renderingparams_GetRenderingMode(IDWriteRenderingParams3 *iface) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); + struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
- TRACE("(%p)\n", This); + TRACE("%p.\n", iface);
- return rendering_mode_from_mode1(This->mode); + return rendering_mode_from_mode1(params->mode); }
-static FLOAT WINAPI renderingparams1_GetGrayscaleEnhancedContrast(IDWriteRenderingParams3 *iface) +static float WINAPI renderingparams1_GetGrayscaleEnhancedContrast(IDWriteRenderingParams3 *iface) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); - TRACE("(%p)\n", This); - return This->grayscalecontrast; + struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface); + + TRACE("%p.\n", iface); + + return params->grayscalecontrast; }
static DWRITE_GRID_FIT_MODE WINAPI renderingparams2_GetGridFitMode(IDWriteRenderingParams3 *iface) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); - TRACE("(%p)\n", This); - return This->gridfit; + struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface); + + TRACE("%p.\n", iface); + + return params->gridfit; }
static DWRITE_RENDERING_MODE1 WINAPI renderingparams3_GetRenderingMode1(IDWriteRenderingParams3 *iface) { - struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface); - TRACE("(%p)\n", This); - return This->mode; + struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface); + + TRACE("%p.\n", iface); + + return params->mode; }
-static const struct IDWriteRenderingParams3Vtbl renderingparamsvtbl = { +static const struct IDWriteRenderingParams3Vtbl renderingparamsvtbl = +{ renderingparams_QueryInterface, renderingparams_AddRef, renderingparams_Release, @@ -203,11 +219,11 @@ static const struct IDWriteRenderingParams3Vtbl renderingparamsvtbl = { renderingparams3_GetRenderingMode1 };
-static HRESULT create_renderingparams(FLOAT gamma, FLOAT contrast, FLOAT grayscalecontrast, FLOAT cleartype_level, +static HRESULT create_renderingparams(float gamma, float contrast, float grayscalecontrast, float cleartype_level, DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE1 mode, DWRITE_GRID_FIT_MODE gridfit, IDWriteRenderingParams3 **params) { - struct renderingparams *This; + struct renderingparams *object;
*params = NULL;
@@ -217,21 +233,21 @@ static HRESULT create_renderingparams(FLOAT gamma, FLOAT contrast, FLOAT graysca if ((UINT32)gridfit > DWRITE_GRID_FIT_MODE_ENABLED || (UINT32)geometry > DWRITE_PIXEL_GEOMETRY_BGR) return E_INVALIDARG;
- This = heap_alloc(sizeof(struct renderingparams)); - if (!This) return E_OUTOFMEMORY; + if (!(object = heap_alloc(sizeof(*object)))) + return E_OUTOFMEMORY;
- This->IDWriteRenderingParams3_iface.lpVtbl = &renderingparamsvtbl; - This->ref = 1; + object->IDWriteRenderingParams3_iface.lpVtbl = &renderingparamsvtbl; + object->refcount = 1;
- This->gamma = gamma; - This->contrast = contrast; - This->grayscalecontrast = grayscalecontrast; - This->cleartype_level = cleartype_level; - This->geometry = geometry; - This->mode = mode; - This->gridfit = gridfit; + object->gamma = gamma; + object->contrast = contrast; + object->grayscalecontrast = grayscalecontrast; + object->cleartype_level = cleartype_level; + object->geometry = geometry; + object->mode = mode; + object->gridfit = gridfit;
- *params = &This->IDWriteRenderingParams3_iface; + *params = &object->IDWriteRenderingParams3_iface;
return S_OK; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/font.c | 225 +++++++++++++++++++++------------------ dlls/dwrite/gdiinterop.c | 69 ++++++------ 2 files changed, 151 insertions(+), 143 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 02ac75d2419..2d764eca7c0 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -213,9 +213,10 @@ struct dwrite_colorglyphenum #define GLYPH_BLOCK_MASK (GLYPH_BLOCK_SIZE - 1) #define GLYPH_MAX 65536
-struct dwrite_fontfile { +struct dwrite_fontfile +{ IDWriteFontFile IDWriteFontFile_iface; - LONG ref; + LONG refcount;
IDWriteFontFileLoader *loader; void *reference_key; @@ -4786,9 +4787,7 @@ HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3
static HRESULT WINAPI dwritefontfile_QueryInterface(IDWriteFontFile *iface, REFIID riid, void **obj) { - struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFile)) { @@ -4805,46 +4804,53 @@ static HRESULT WINAPI dwritefontfile_QueryInterface(IDWriteFontFile *iface, REFI
static ULONG WINAPI dwritefontfile_AddRef(IDWriteFontFile *iface) { - struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface); - ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%d)\n", This, ref); - return ref; + struct dwrite_fontfile *file = impl_from_IDWriteFontFile(iface); + ULONG refcount = InterlockedIncrement(&file->refcount); + + TRACE("%p, refcount %d.\n", iface, refcount); + + return refcount; }
static ULONG WINAPI dwritefontfile_Release(IDWriteFontFile *iface) { - struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct dwrite_fontfile *file = impl_from_IDWriteFontFile(iface); + ULONG refcount = InterlockedDecrement(&file->refcount);
- TRACE("(%p)->(%d)\n", This, ref); + TRACE("%p, refcount %d.\n", iface, refcount);
- if (!ref) + if (!refcount) { - IDWriteFontFileLoader_Release(This->loader); - if (This->stream) IDWriteFontFileStream_Release(This->stream); - heap_free(This->reference_key); - heap_free(This); + IDWriteFontFileLoader_Release(file->loader); + if (file->stream) + IDWriteFontFileStream_Release(file->stream); + heap_free(file->reference_key); + heap_free(file); }
- return ref; + return refcount; }
-static HRESULT WINAPI dwritefontfile_GetReferenceKey(IDWriteFontFile *iface, const void **fontFileReferenceKey, UINT32 *fontFileReferenceKeySize) +static HRESULT WINAPI dwritefontfile_GetReferenceKey(IDWriteFontFile *iface, const void **key, UINT32 *key_size) { - struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface); - TRACE("(%p)->(%p, %p)\n", This, fontFileReferenceKey, fontFileReferenceKeySize); - *fontFileReferenceKey = This->reference_key; - *fontFileReferenceKeySize = This->key_size; + struct dwrite_fontfile *file = impl_from_IDWriteFontFile(iface); + + TRACE("%p, %p, %p.\n", iface, key, key_size); + + *key = file->reference_key; + *key_size = file->key_size;
return S_OK; }
-static HRESULT WINAPI dwritefontfile_GetLoader(IDWriteFontFile *iface, IDWriteFontFileLoader **fontFileLoader) +static HRESULT WINAPI dwritefontfile_GetLoader(IDWriteFontFile *iface, IDWriteFontFileLoader **loader) { - struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface); - TRACE("(%p)->(%p)\n", This, fontFileLoader); - *fontFileLoader = This->loader; - IDWriteFontFileLoader_AddRef(This->loader); + struct dwrite_fontfile *file = impl_from_IDWriteFontFile(iface); + + TRACE("%p, %p.\n", iface, loader); + + *loader = file->loader; + IDWriteFontFileLoader_AddRef(*loader);
return S_OK; } @@ -4852,11 +4858,11 @@ static HRESULT WINAPI dwritefontfile_GetLoader(IDWriteFontFile *iface, IDWriteFo static HRESULT WINAPI dwritefontfile_Analyze(IDWriteFontFile *iface, BOOL *is_supported, DWRITE_FONT_FILE_TYPE *file_type, DWRITE_FONT_FACE_TYPE *face_type, UINT32 *face_count) { - struct dwrite_fontfile *This = impl_from_IDWriteFontFile(iface); + struct dwrite_fontfile *file = impl_from_IDWriteFontFile(iface); IDWriteFontFileStream *stream; HRESULT hr;
- TRACE("(%p)->(%p, %p, %p, %p)\n", This, is_supported, file_type, face_type, face_count); + TRACE("%p, %p, %p, %p, %p.\n", iface, is_supported, file_type, face_type, face_count);
*is_supported = FALSE; *file_type = DWRITE_FONT_FILE_TYPE_UNKNOWN; @@ -4864,7 +4870,7 @@ static HRESULT WINAPI dwritefontfile_Analyze(IDWriteFontFile *iface, BOOL *is_su *face_type = DWRITE_FONT_FACE_TYPE_UNKNOWN; *face_count = 0;
- hr = IDWriteFontFileLoader_CreateStreamFromKey(This->loader, This->reference_key, This->key_size, &stream); + hr = IDWriteFontFileLoader_CreateStreamFromKey(file->loader, file->reference_key, file->key_size, &stream); if (FAILED(hr)) return hr;
@@ -4875,7 +4881,8 @@ static HRESULT WINAPI dwritefontfile_Analyze(IDWriteFontFile *iface, BOOL *is_su return S_OK; }
-static const IDWriteFontFileVtbl dwritefontfilevtbl = { +static const IDWriteFontFileVtbl dwritefontfilevtbl = +{ dwritefontfile_QueryInterface, dwritefontfile_AddRef, dwritefontfile_Release, @@ -4901,7 +4908,7 @@ HRESULT create_font_file(IDWriteFontFileLoader *loader, const void *reference_ke }
file->IDWriteFontFile_iface.lpVtbl = &dwritefontfilevtbl; - file->ref = 1; + file->refcount = 1; IDWriteFontFileLoader_AddRef(loader); file->loader = loader; file->stream = NULL; @@ -5042,16 +5049,17 @@ struct local_cached_stream struct dwrite_localfontfilestream { IDWriteFontFileStream IDWriteFontFileStream_iface; - LONG ref; + LONG refcount;
struct local_cached_stream *entry; const void *file_ptr; UINT64 size; };
-struct dwrite_localfontfileloader { +struct dwrite_localfontfileloader +{ IDWriteLocalFontFileLoader IDWriteLocalFontFileLoader_iface; - LONG ref; + LONG refcount;
struct list streams; CRITICAL_SECTION cs; @@ -5118,16 +5126,17 @@ static void release_inmemory_stream(struct dwrite_inmemory_stream_data *stream)
static HRESULT WINAPI localfontfilestream_QueryInterface(IDWriteFontFileStream *iface, REFIID riid, void **obj) { - struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface); + struct dwrite_localfontfilestream *stream = impl_from_IDWriteFontFileStream(iface);
- TRACE_(dwrite_file)("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj); + TRACE_(dwrite_file)("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IDWriteFontFileStream) || IsEqualIID(riid, &IID_IUnknown)) { *obj = iface; - if (InterlockedIncrement(&This->ref) == 1) { - InterlockedDecrement(&This->ref); + if (InterlockedIncrement(&stream->refcount) == 1) + { + InterlockedDecrement(&stream->refcount); *obj = NULL; return E_FAIL; } @@ -5142,10 +5151,12 @@ static HRESULT WINAPI localfontfilestream_QueryInterface(IDWriteFontFileStream *
static ULONG WINAPI localfontfilestream_AddRef(IDWriteFontFileStream *iface) { - struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface); - ULONG ref = InterlockedIncrement(&This->ref); - TRACE_(dwrite_file)("(%p)->(%d)\n", This, ref); - return ref; + struct dwrite_localfontfilestream *stream = impl_from_IDWriteFontFileStream(iface); + ULONG refcount = InterlockedIncrement(&stream->refcount); + + TRACE_(dwrite_file)("%p, refcount %d.\n", iface, refcount); + + return refcount; }
static inline void release_cached_stream(struct local_cached_stream *stream) @@ -5157,66 +5168,69 @@ static inline void release_cached_stream(struct local_cached_stream *stream)
static ULONG WINAPI localfontfilestream_Release(IDWriteFontFileStream *iface) { - struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct dwrite_localfontfilestream *stream = impl_from_IDWriteFontFileStream(iface); + ULONG refcount = InterlockedDecrement(&stream->refcount);
- TRACE_(dwrite_file)("(%p)->(%d)\n", This, ref); + TRACE_(dwrite_file)("%p, refcount %d.\n", iface, refcount);
- if (!ref) { - UnmapViewOfFile(This->file_ptr); + if (!refcount) + { + UnmapViewOfFile(stream->file_ptr);
EnterCriticalSection(&local_fontfile_loader.cs); - release_cached_stream(This->entry); + release_cached_stream(stream->entry); LeaveCriticalSection(&local_fontfile_loader.cs);
- heap_free(This); + heap_free(stream); }
- return ref; + return refcount; }
static HRESULT WINAPI localfontfilestream_ReadFileFragment(IDWriteFontFileStream *iface, void const **fragment_start, UINT64 offset, UINT64 fragment_size, void **fragment_context) { - struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface); + struct dwrite_localfontfilestream *stream = impl_from_IDWriteFontFileStream(iface);
- TRACE_(dwrite_file)("(%p)->(%p, 0x%s, 0x%s, %p)\n", This, fragment_start, + TRACE_(dwrite_file)("%p, %p, 0x%s, 0x%s, %p.\n", iface, fragment_start, wine_dbgstr_longlong(offset), wine_dbgstr_longlong(fragment_size), fragment_context);
*fragment_context = NULL;
- if ((offset >= This->size - 1) || (fragment_size > This->size - offset)) { + if ((offset >= stream->size - 1) || (fragment_size > stream->size - offset)) + { *fragment_start = NULL; return E_FAIL; }
- *fragment_start = (char*)This->file_ptr + offset; + *fragment_start = (char *)stream->file_ptr + offset; return S_OK; }
static void WINAPI localfontfilestream_ReleaseFileFragment(IDWriteFontFileStream *iface, void *fragment_context) { - struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface); - TRACE_(dwrite_file)("(%p)->(%p)\n", This, fragment_context); + TRACE_(dwrite_file)("%p, %p.\n", iface, fragment_context); }
static HRESULT WINAPI localfontfilestream_GetFileSize(IDWriteFontFileStream *iface, UINT64 *size) { - struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface); - TRACE_(dwrite_file)("(%p)->(%p)\n", This, size); - *size = This->size; + struct dwrite_localfontfilestream *stream = impl_from_IDWriteFontFileStream(iface); + + TRACE_(dwrite_file)("%p, %p.\n", iface, size); + + *size = stream->size; return S_OK; }
static HRESULT WINAPI localfontfilestream_GetLastWriteTime(IDWriteFontFileStream *iface, UINT64 *last_writetime) { - struct dwrite_localfontfilestream *This = impl_from_IDWriteFontFileStream(iface); + struct dwrite_localfontfilestream *stream = impl_from_IDWriteFontFileStream(iface); ULARGE_INTEGER li;
- TRACE_(dwrite_file)("(%p)->(%p)\n", This, last_writetime); + TRACE_(dwrite_file)("%p, %p.\n", iface, last_writetime);
- li.u.LowPart = This->entry->key->writetime.dwLowDateTime; - li.u.HighPart = This->entry->key->writetime.dwHighDateTime; + li.u.LowPart = stream->entry->key->writetime.dwLowDateTime; + li.u.HighPart = stream->entry->key->writetime.dwHighDateTime; *last_writetime = li.QuadPart;
return S_OK; @@ -5233,32 +5247,31 @@ static const IDWriteFontFileStreamVtbl localfontfilestreamvtbl = localfontfilestream_GetLastWriteTime };
-static HRESULT create_localfontfilestream(const void *file_ptr, UINT64 size, struct local_cached_stream *entry, IDWriteFontFileStream **ret) +static HRESULT create_localfontfilestream(const void *file_ptr, UINT64 size, struct local_cached_stream *entry, + IDWriteFontFileStream **ret) { - struct dwrite_localfontfilestream *This; + struct dwrite_localfontfilestream *object;
*ret = NULL;
- This = heap_alloc(sizeof(struct dwrite_localfontfilestream)); - if (!This) + if (!(object = heap_alloc(sizeof(*object)))) return E_OUTOFMEMORY;
- This->IDWriteFontFileStream_iface.lpVtbl = &localfontfilestreamvtbl; - This->ref = 1; + object->IDWriteFontFileStream_iface.lpVtbl = &localfontfilestreamvtbl; + object->refcount = 1; + + object->file_ptr = file_ptr; + object->size = size; + object->entry = entry;
- This->file_ptr = file_ptr; - This->size = size; - This->entry = entry; + *ret = &object->IDWriteFontFileStream_iface;
- *ret = &This->IDWriteFontFileStream_iface; return S_OK; }
static HRESULT WINAPI localfontfileloader_QueryInterface(IDWriteLocalFontFileLoader *iface, REFIID riid, void **obj) { - struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IDWriteLocalFontFileLoader) || IsEqualIID(riid, &IID_IDWriteFontFileLoader) || @@ -5277,20 +5290,22 @@ static HRESULT WINAPI localfontfileloader_QueryInterface(IDWriteLocalFontFileLoa
static ULONG WINAPI localfontfileloader_AddRef(IDWriteLocalFontFileLoader *iface) { - struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface); - ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%d)\n", This, ref); - return ref; + struct dwrite_localfontfileloader *loader = impl_from_IDWriteLocalFontFileLoader(iface); + ULONG refcount = InterlockedIncrement(&loader->refcount); + + TRACE("%p, refcount %d.\n", iface, refcount); + + return refcount; }
static ULONG WINAPI localfontfileloader_Release(IDWriteLocalFontFileLoader *iface) { - struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct dwrite_localfontfileloader *loader = impl_from_IDWriteLocalFontFileLoader(iface); + ULONG refcount = InterlockedDecrement(&loader->refcount);
- TRACE("(%p)->(%d)\n", This, ref); + TRACE("%p, refcount %d.\n", iface, refcount);
- return ref; + return refcount; }
static HRESULT create_local_cached_stream(const void *key, UINT32 key_size, struct local_cached_stream **ret) @@ -5359,53 +5374,53 @@ static HRESULT create_local_cached_stream(const void *key, UINT32 key_size, stru static HRESULT WINAPI localfontfileloader_CreateStreamFromKey(IDWriteLocalFontFileLoader *iface, const void *key, UINT32 key_size, IDWriteFontFileStream **ret) { - struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface); - const struct local_refkey *refkey = key; + struct dwrite_localfontfileloader *loader = impl_from_IDWriteLocalFontFileLoader(iface); struct local_cached_stream *stream; HRESULT hr = S_OK;
- TRACE("(%p)->(%p, %u, %p)\n", This, key, key_size, ret); - TRACE("name: %s\n", debugstr_w(refkey->name)); + TRACE("%p, %p, %u, %p.\n", iface, key, key_size, ret);
- EnterCriticalSection(&This->cs); + EnterCriticalSection(&loader->cs);
*ret = NULL;
/* search cache first */ - LIST_FOR_EACH_ENTRY(stream, &This->streams, struct local_cached_stream, entry) { + LIST_FOR_EACH_ENTRY(stream, &loader->streams, struct local_cached_stream, entry) + { if (key_size == stream->key_size && !memcmp(stream->key, key, key_size)) { IDWriteFontFileStream_QueryInterface(stream->stream, &IID_IDWriteFontFileStream, (void **)ret); break; } }
- if (*ret == NULL && (hr = create_local_cached_stream(key, key_size, &stream)) == S_OK) { - list_add_head(&This->streams, &stream->entry); + if (*ret == NULL && (hr = create_local_cached_stream(key, key_size, &stream)) == S_OK) + { + list_add_head(&loader->streams, &stream->entry); *ret = stream->stream; }
- LeaveCriticalSection(&This->cs); + LeaveCriticalSection(&loader->cs);
return hr; }
-static HRESULT WINAPI localfontfileloader_GetFilePathLengthFromKey(IDWriteLocalFontFileLoader *iface, void const *key, UINT32 key_size, UINT32 *length) +static HRESULT WINAPI localfontfileloader_GetFilePathLengthFromKey(IDWriteLocalFontFileLoader *iface, void const *key, + UINT32 key_size, UINT32 *length) { - struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface); const struct local_refkey *refkey = key;
- TRACE("(%p)->(%p, %i, %p)\n", This, key, key_size, length); + TRACE("%p, %p, %u, %p.\n", iface, key, key_size, length);
*length = strlenW(refkey->name); return S_OK; }
-static HRESULT WINAPI localfontfileloader_GetFilePathFromKey(IDWriteLocalFontFileLoader *iface, void const *key, UINT32 key_size, WCHAR *path, UINT32 length) +static HRESULT WINAPI localfontfileloader_GetFilePathFromKey(IDWriteLocalFontFileLoader *iface, void const *key, + UINT32 key_size, WCHAR *path, UINT32 length) { - struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface); const struct local_refkey *refkey = key;
- TRACE("(%p)->(%p, %i, %p, %i)\n", This, key, key_size, path, length); + TRACE("%p, %p, %u, %p, %u.\n", iface, key, key_size, path, length);
if (length < strlenW(refkey->name)) return E_INVALIDARG; @@ -5417,16 +5432,16 @@ static HRESULT WINAPI localfontfileloader_GetFilePathFromKey(IDWriteLocalFontFil static HRESULT WINAPI localfontfileloader_GetLastWriteTimeFromKey(IDWriteLocalFontFileLoader *iface, void const *key, UINT32 key_size, FILETIME *writetime) { - struct dwrite_localfontfileloader *This = impl_from_IDWriteLocalFontFileLoader(iface); const struct local_refkey *refkey = key;
- TRACE("(%p)->(%p, %u, %p)\n", This, key, key_size, writetime); + TRACE("%p, %p, %u, %p.\n", iface, key, key_size, writetime);
*writetime = refkey->writetime; return S_OK; }
-static const struct IDWriteLocalFontFileLoaderVtbl localfontfileloadervtbl = { +static const struct IDWriteLocalFontFileLoaderVtbl localfontfileloadervtbl = +{ localfontfileloader_QueryInterface, localfontfileloader_AddRef, localfontfileloader_Release, @@ -5439,7 +5454,7 @@ static const struct IDWriteLocalFontFileLoaderVtbl localfontfileloadervtbl = { void init_local_fontfile_loader(void) { local_fontfile_loader.IDWriteLocalFontFileLoader_iface.lpVtbl = &localfontfileloadervtbl; - local_fontfile_loader.ref = 1; + local_fontfile_loader.refcount = 1; list_init(&local_fontfile_loader.streams); InitializeCriticalSection(&local_fontfile_loader.cs); local_fontfile_loader.cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": localfileloader.lock"); diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c index 81cfc3a586b..2b9599cff5a 100644 --- a/dlls/dwrite/gdiinterop.c +++ b/dlls/dwrite/gdiinterop.c @@ -61,9 +61,10 @@ struct gdiinterop IDWriteFactory7 *factory; };
-struct memresource_stream { +struct memresource_stream +{ IDWriteFontFileStream IDWriteFontFileStream_iface; - LONG ref; + LONG refcount; DWORD key; };
@@ -899,9 +900,7 @@ static HRESULT WINAPI gdiinterop1_GetFontSignature_(IDWriteGdiInterop1 *iface, I
static HRESULT WINAPI gdiinterop1_GetFontSignature(IDWriteGdiInterop1 *iface, IDWriteFont *font, FONTSIGNATURE *fontsig) { - struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); - - TRACE("(%p)->(%p %p)\n", This, font, fontsig); + TRACE("%p, %p, %p.\n", iface, font, fontsig);
if (!font) return E_INVALIDARG; @@ -934,9 +933,7 @@ static const struct IDWriteGdiInterop1Vtbl gdiinteropvtbl = {
static HRESULT WINAPI memresourcestream_QueryInterface(IDWriteFontFileStream *iface, REFIID riid, void **out) { - struct memresource_stream *This = impl_from_IDWriteFontFileStream(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
if (IsEqualIID(&IID_IDWriteFontFileStream, riid) || IsEqualIID(&IID_IUnknown, riid)) { *out = iface; @@ -951,39 +948,41 @@ static HRESULT WINAPI memresourcestream_QueryInterface(IDWriteFontFileStream *if
static ULONG WINAPI memresourcestream_AddRef(IDWriteFontFileStream *iface) { - struct memresource_stream *This = impl_from_IDWriteFontFileStream(iface); - ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%d)\n", This, ref); - return ref; + struct memresource_stream *stream = impl_from_IDWriteFontFileStream(iface); + ULONG refcount = InterlockedIncrement(&stream->refcount); + + TRACE("%p, refcount %d.\n", iface, refcount); + + return refcount; }
static ULONG WINAPI memresourcestream_Release(IDWriteFontFileStream *iface) { - struct memresource_stream *This = impl_from_IDWriteFontFileStream(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct memresource_stream *stream = impl_from_IDWriteFontFileStream(iface); + ULONG refcount = InterlockedDecrement(&stream->refcount);
- TRACE("(%p)->(%d)\n", This, ref); + TRACE("%p, refcount %d.\n", iface, refcount);
- if (!ref) - heap_free(This); + if (!refcount) + heap_free(stream);
- return ref; + return refcount; }
static HRESULT WINAPI memresourcestream_ReadFileFragment(IDWriteFontFileStream *iface, void const **fragment_start, UINT64 offset, UINT64 fragment_size, void **fragment_context) { - struct memresource_stream *This = impl_from_IDWriteFontFileStream(iface); + struct memresource_stream *stream = impl_from_IDWriteFontFileStream(iface); struct font_fileinfo fileinfo; void *fragment;
- TRACE("(%p)->(%p %s %s %p)\n", This, fragment_start, wine_dbgstr_longlong(offset), + TRACE("%p, %p, %s, %s, %p.\n", iface, fragment_start, wine_dbgstr_longlong(offset), wine_dbgstr_longlong(fragment_size), fragment_context);
*fragment_context = NULL; *fragment_start = NULL;
- if (!GetFontFileInfo(This->key, 0, &fileinfo, sizeof(fileinfo), NULL)) + if (!GetFontFileInfo(stream->key, 0, &fileinfo, sizeof(fileinfo), NULL)) return E_INVALIDARG;
if ((offset >= fileinfo.size.QuadPart - 1) || (fragment_size > fileinfo.size.QuadPart - offset)) @@ -992,7 +991,7 @@ static HRESULT WINAPI memresourcestream_ReadFileFragment(IDWriteFontFileStream * if (!(fragment = heap_alloc(fragment_size))) return E_OUTOFMEMORY;
- if (!GetFontFileData(This->key, 0, offset, fragment, fragment_size)) + if (!GetFontFileData(stream->key, 0, offset, fragment, fragment_size)) return E_FAIL;
*fragment_start = *fragment_context = fragment; @@ -1001,21 +1000,19 @@ static HRESULT WINAPI memresourcestream_ReadFileFragment(IDWriteFontFileStream *
static void WINAPI memresourcestream_ReleaseFileFragment(IDWriteFontFileStream *iface, void *fragment_context) { - struct memresource_stream *This = impl_from_IDWriteFontFileStream(iface); - - TRACE("(%p)->(%p)\n", This, fragment_context); + TRACE("%p, %p.\n", iface, fragment_context);
heap_free(fragment_context); }
static HRESULT WINAPI memresourcestream_GetFileSize(IDWriteFontFileStream *iface, UINT64 *size) { - struct memresource_stream *This = impl_from_IDWriteFontFileStream(iface); + struct memresource_stream *stream = impl_from_IDWriteFontFileStream(iface); struct font_fileinfo fileinfo;
- TRACE("(%p)->(%p)\n", This, size); + TRACE("%p, %p.\n", iface, size);
- if (!GetFontFileInfo(This->key, 0, &fileinfo, sizeof(fileinfo), NULL)) + if (!GetFontFileInfo(stream->key, 0, &fileinfo, sizeof(fileinfo), NULL)) return E_INVALIDARG;
*size = fileinfo.size.QuadPart; @@ -1025,14 +1022,13 @@ static HRESULT WINAPI memresourcestream_GetFileSize(IDWriteFontFileStream *iface
static HRESULT WINAPI memresourcestream_GetLastWriteTime(IDWriteFontFileStream *iface, UINT64 *last_writetime) { - struct memresource_stream *This = impl_from_IDWriteFontFileStream(iface); - - TRACE("(%p)->(%p)\n", This, last_writetime); + TRACE("%p, %p.\n", iface, last_writetime);
return E_NOTIMPL; }
-static const struct IDWriteFontFileStreamVtbl memresourcestreamvtbl = { +static const struct IDWriteFontFileStreamVtbl memresourcestreamvtbl = +{ memresourcestream_QueryInterface, memresourcestream_AddRef, memresourcestream_Release, @@ -1044,9 +1040,7 @@ static const struct IDWriteFontFileStreamVtbl memresourcestreamvtbl = {
static HRESULT WINAPI memresourceloader_QueryInterface(IDWriteFontFileLoader *iface, REFIID riid, void **out) { - struct gdiinterop *This = impl_from_IDWriteFontFileLoader(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
if (IsEqualIID(&IID_IDWriteFontFileLoader, riid) || IsEqualIID(&IID_IUnknown, riid)) { *out = iface; @@ -1072,10 +1066,9 @@ static ULONG WINAPI memresourceloader_Release(IDWriteFontFileLoader *iface) static HRESULT WINAPI memresourceloader_CreateStreamFromKey(IDWriteFontFileLoader *iface, void const *key, UINT32 key_size, IDWriteFontFileStream **ret) { - struct gdiinterop *This = impl_from_IDWriteFontFileLoader(iface); struct memresource_stream *stream;
- TRACE("(%p)->(%p %u %p)\n", This, key, key_size, ret); + TRACE("%p, %p, %u, %p.\n", iface, key, key_size, ret);
*ret = NULL;
@@ -1086,7 +1079,7 @@ static HRESULT WINAPI memresourceloader_CreateStreamFromKey(IDWriteFontFileLoade return E_OUTOFMEMORY;
stream->IDWriteFontFileStream_iface.lpVtbl = &memresourcestreamvtbl; - stream->ref = 1; + stream->refcount = 1; memcpy(&stream->key, key, sizeof(stream->key));
*ret = &stream->IDWriteFontFileStream_iface;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/font.c | 88 +++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 41 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 2d764eca7c0..c10234e09fc 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -167,9 +167,10 @@ enum runanalysis_flags { RUNANALYSIS_USE_TRANSFORM = 1 << 2 };
-struct dwrite_glyphrunanalysis { +struct dwrite_glyphrunanalysis +{ IDWriteGlyphRunAnalysis IDWriteGlyphRunAnalysis_iface; - LONG ref; + LONG refcount;
DWRITE_RENDERING_MODE1 rendering_mode; DWRITE_TEXTURE_TYPE texture_type; /* derived from rendering mode specified on creation */ @@ -5496,12 +5497,9 @@ HRESULT get_local_refkey(const WCHAR *path, const FILETIME *writetime, void **ke return S_OK; }
-/* IDWriteGlyphRunAnalysis */ static HRESULT WINAPI glyphrunanalysis_QueryInterface(IDWriteGlyphRunAnalysis *iface, REFIID riid, void **ppv) { - struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), ppv);
if (IsEqualIID(riid, &IID_IDWriteGlyphRunAnalysis) || IsEqualIID(riid, &IID_IUnknown)) @@ -5519,29 +5517,32 @@ static HRESULT WINAPI glyphrunanalysis_QueryInterface(IDWriteGlyphRunAnalysis *i
static ULONG WINAPI glyphrunanalysis_AddRef(IDWriteGlyphRunAnalysis *iface) { - struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface); - ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%u)\n", This, ref); - return ref; + struct dwrite_glyphrunanalysis *analysis = impl_from_IDWriteGlyphRunAnalysis(iface); + ULONG refcount = InterlockedIncrement(&analysis->refcount); + + TRACE("%p, refcount %d.\n", iface, refcount); + + return refcount; }
static ULONG WINAPI glyphrunanalysis_Release(IDWriteGlyphRunAnalysis *iface) { - struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct dwrite_glyphrunanalysis *analysis = impl_from_IDWriteGlyphRunAnalysis(iface); + ULONG refcount = InterlockedDecrement(&analysis->refcount);
- TRACE("(%p)->(%u)\n", This, ref); + TRACE("%p, refcount %d.\n", iface, refcount);
- if (!ref) { - if (This->run.fontFace) - IDWriteFontFace_Release(This->run.fontFace); - heap_free(This->glyphs); - heap_free(This->origins); - heap_free(This->bitmap); - heap_free(This); + if (!refcount) + { + if (analysis->run.fontFace) + IDWriteFontFace_Release(analysis->run.fontFace); + heap_free(analysis->glyphs); + heap_free(analysis->origins); + heap_free(analysis->bitmap); + heap_free(analysis); }
- return ref; + return refcount; }
static BOOL is_natural_rendering_mode(DWRITE_RENDERING_MODE1 mode) @@ -5611,23 +5612,25 @@ static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *a *bounds = analysis->bounds; }
-static HRESULT WINAPI glyphrunanalysis_GetAlphaTextureBounds(IDWriteGlyphRunAnalysis *iface, DWRITE_TEXTURE_TYPE type, RECT *bounds) +static HRESULT WINAPI glyphrunanalysis_GetAlphaTextureBounds(IDWriteGlyphRunAnalysis *iface, + DWRITE_TEXTURE_TYPE type, RECT *bounds) { - struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface); + struct dwrite_glyphrunanalysis *analysis = impl_from_IDWriteGlyphRunAnalysis(iface);
- TRACE("(%p)->(%d %p)\n", This, type, bounds); + TRACE("%p, %d, %p.\n", iface, type, bounds);
if ((UINT32)type > DWRITE_TEXTURE_CLEARTYPE_3x1) { SetRectEmpty(bounds); return E_INVALIDARG; }
- if (type != This->texture_type) { + if (type != analysis->texture_type) + { SetRectEmpty(bounds); return S_OK; }
- glyphrunanalysis_get_texturebounds(This, bounds); + glyphrunanalysis_get_texturebounds(analysis, bounds); return S_OK; }
@@ -5769,45 +5772,47 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis) static HRESULT WINAPI glyphrunanalysis_CreateAlphaTexture(IDWriteGlyphRunAnalysis *iface, DWRITE_TEXTURE_TYPE type, RECT const *bounds, BYTE *bitmap, UINT32 size) { - struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface); + struct dwrite_glyphrunanalysis *analysis = impl_from_IDWriteGlyphRunAnalysis(iface); UINT32 required; RECT runbounds;
- TRACE("(%p)->(%d %s %p %u)\n", This, type, wine_dbgstr_rect(bounds), bitmap, size); + TRACE("%p, %d, %s, %p, %u.\n", iface, type, wine_dbgstr_rect(bounds), bitmap, size);
if (!bounds || !bitmap || (UINT32)type > DWRITE_TEXTURE_CLEARTYPE_3x1) return E_INVALIDARG;
/* make sure buffer is large enough for requested texture type */ required = (bounds->right - bounds->left) * (bounds->bottom - bounds->top); - if (This->texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1) + if (analysis->texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1) required *= 3;
if (size < required) return E_NOT_SUFFICIENT_BUFFER;
/* validate requested texture type */ - if (This->texture_type != type) + if (analysis->texture_type != type) return DWRITE_E_UNSUPPORTEDOPERATION;
memset(bitmap, 0, size); - glyphrunanalysis_get_texturebounds(This, &runbounds); - if (IntersectRect(&runbounds, &runbounds, bounds)) { + glyphrunanalysis_get_texturebounds(analysis, &runbounds); + if (IntersectRect(&runbounds, &runbounds, bounds)) + { int pixel_size = type == DWRITE_TEXTURE_CLEARTYPE_3x1 ? 3 : 1; - int src_width = (This->bounds.right - This->bounds.left) * pixel_size; + int src_width = (analysis->bounds.right - analysis->bounds.left) * pixel_size; int dst_width = (bounds->right - bounds->left) * pixel_size; int draw_width = (runbounds.right - runbounds.left) * pixel_size; BYTE *src, *dst; int y;
- if (!(This->flags & RUNANALYSIS_BITMAP_READY)) { + if (!(analysis->flags & RUNANALYSIS_BITMAP_READY)) + { HRESULT hr;
- if (FAILED(hr = glyphrunanalysis_render(This))) + if (FAILED(hr = glyphrunanalysis_render(analysis))) return hr; }
- src = get_pixel_ptr(This->bitmap, type, &runbounds, &This->bounds); + src = get_pixel_ptr(analysis->bitmap, type, &runbounds, &analysis->bounds); dst = get_pixel_ptr(bitmap, type, &runbounds, bounds);
for (y = 0; y < runbounds.bottom - runbounds.top; y++) { @@ -5823,14 +5828,14 @@ static HRESULT WINAPI glyphrunanalysis_CreateAlphaTexture(IDWriteGlyphRunAnalysi static HRESULT WINAPI glyphrunanalysis_GetAlphaBlendParams(IDWriteGlyphRunAnalysis *iface, IDWriteRenderingParams *params, FLOAT *gamma, FLOAT *contrast, FLOAT *cleartypelevel) { - struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface); + struct dwrite_glyphrunanalysis *analysis = impl_from_IDWriteGlyphRunAnalysis(iface);
- TRACE("(%p)->(%p %p %p %p)\n", This, params, gamma, contrast, cleartypelevel); + TRACE("%p, %p, %p, %p, %p.\n", iface, params, gamma, contrast, cleartypelevel);
if (!params) return E_INVALIDARG;
- switch (This->rendering_mode) + switch (analysis->rendering_mode) { case DWRITE_RENDERING_MODE1_GDI_CLASSIC: case DWRITE_RENDERING_MODE1_GDI_NATURAL: @@ -5859,7 +5864,8 @@ static HRESULT WINAPI glyphrunanalysis_GetAlphaBlendParams(IDWriteGlyphRunAnalys return S_OK; }
-static const struct IDWriteGlyphRunAnalysisVtbl glyphrunanalysisvtbl = { +static const struct IDWriteGlyphRunAnalysisVtbl glyphrunanalysisvtbl = +{ glyphrunanalysis_QueryInterface, glyphrunanalysis_AddRef, glyphrunanalysis_Release, @@ -5930,7 +5936,7 @@ HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc *desc, IDWrit return E_OUTOFMEMORY;
analysis->IDWriteGlyphRunAnalysis_iface.lpVtbl = &glyphrunanalysisvtbl; - analysis->ref = 1; + analysis->refcount = 1; analysis->rendering_mode = desc->rendering_mode;
if (desc->rendering_mode == DWRITE_RENDERING_MODE1_ALIASED