For React Native.
-- v3: dwrite: Implement dwritefactory3_GetFontDownloadQueue(). dwrite: Add IDWriteFontDownloadQueue tests.
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/dwrite/tests/font.c | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 362b87aa968..55aa3c61271 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -10493,6 +10493,55 @@ static void test_GetMatchingFontsByLOGFONT(void) ok(!refcount, "Factory wasn't released, %lu.\n", refcount); }
+static void test_font_download_queue(void) +{ + IDWriteFontDownloadQueue *queue, *queue2; + IDWriteFactory3 *factory, *factory2; + BOOL is_empty; + UINT64 count; + HRESULT hr; + ULONG ref; + + factory = create_factory_iid(&IID_IDWriteFactory3); + if (!factory) + { + win_skip("GetFontDownloadQueue() is not supported\n"); + return; + } + + hr = IDWriteFactory3_GetFontDownloadQueue(factory, &queue); + todo_wine + ok(hr == S_OK, "got %#lx\n", hr); + if (FAILED(hr)) + { + IDWriteFactory3_Release(factory); + return; + } + + hr = IDWriteFactory3_GetFontDownloadQueue(factory, &queue2); + ok(hr == S_OK, "got %#lx\n", hr); + ok(queue == queue2, "Got unexpected object\n"); + IDWriteFontDownloadQueue_Release(queue2); + + factory2 = create_factory_iid(&IID_IDWriteFactory3); + ok(!!factory2, "Create factory failed\n"); + hr = IDWriteFactory3_GetFontDownloadQueue(factory2, &queue2); + ok(hr == S_OK, "got %#lx\n", hr); + ok(queue != queue2, "Got unexpected object\n"); + IDWriteFontDownloadQueue_Release(queue2); + IDWriteFactory3_Release(factory2); + + is_empty = IDWriteFontDownloadQueue_IsEmpty(queue); + ok(is_empty, "Expected empty queue\n"); + + count = IDWriteFontDownloadQueue_GetGenerationCount(queue); + ok(count == 0, "Got unexpected generation count %I64u\n", count); + + IDWriteFontDownloadQueue_Release(queue); + ref = IDWriteFactory3_Release(factory); + ok(ref == 0, "factory not released, %lu\n", ref); +} + START_TEST(font) { IDWriteFactory *factory; @@ -10568,6 +10617,7 @@ START_TEST(font) test_system_font_set(); test_CreateFontCollectionFromFontSet(); test_GetMatchingFontsByLOGFONT(); + test_font_download_queue();
IDWriteFactory_Release(factory); }
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/dwrite/main.c | 95 +++++++++++++++++++++++++++++++++++++++- dlls/dwrite/tests/font.c | 6 --- 2 files changed, 93 insertions(+), 8 deletions(-)
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index 1dc5ae48baa..0acbbc97c1e 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -595,6 +595,7 @@ struct fileloader struct dwritefactory { IDWriteFactory7 IDWriteFactory7_iface; + IDWriteFontDownloadQueue IDWriteFontDownloadQueue_iface; LONG refcount;
IDWriteFontCollection *system_collections[DWRITE_FONT_FAMILY_MODEL_WEIGHT_STRETCH_STYLE + 1]; @@ -1707,9 +1708,13 @@ static HRESULT WINAPI dwritefactory3_GetSystemFontCollection(IDWriteFactory7 *if
static HRESULT WINAPI dwritefactory3_GetFontDownloadQueue(IDWriteFactory7 *iface, IDWriteFontDownloadQueue **queue) { - FIXME("%p, %p: stub\n", iface, queue); + struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
- return E_NOTIMPL; + TRACE("%p, %p.\n", iface, queue); + + *queue = &factory->IDWriteFontDownloadQueue_iface; + IDWriteFontDownloadQueue_AddRef(*queue); + return S_OK; }
static HRESULT WINAPI dwritefactory4_TranslateColorGlyphRun(IDWriteFactory7 *iface, D2D1_POINT_2F origin, @@ -2074,10 +2079,96 @@ static const IDWriteFactory7Vtbl shareddwritefactoryvtbl = dwritefactory7_GetSystemFontCollection, };
+static inline struct dwritefactory *impl_from_IDWriteFontDownloadQueue(IDWriteFontDownloadQueue *iface) +{ + return CONTAINING_RECORD(iface, struct dwritefactory, IDWriteFontDownloadQueue_iface); +} + +static HRESULT WINAPI dwritefontdownloadqueue_QueryInterface(IDWriteFontDownloadQueue *iface, + REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IDWriteFontDownloadQueue)) + { + *out = iface; + IDWriteFontDownloadQueue_AddRef(iface); + return S_OK; + } + + *out = NULL; + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI dwritefontdownloadqueue_AddRef(IDWriteFontDownloadQueue *iface) +{ + struct dwritefactory *impl = impl_from_IDWriteFontDownloadQueue(iface); + return IDWriteFactory7_AddRef(&impl->IDWriteFactory7_iface); +} + +static ULONG WINAPI dwritefontdownloadqueue_Release(IDWriteFontDownloadQueue *iface) +{ + struct dwritefactory *impl = impl_from_IDWriteFontDownloadQueue(iface); + return IDWriteFactory7_Release(&impl->IDWriteFactory7_iface); +} + +static HRESULT WINAPI dwritefontdownloadqueue_AddListener(IDWriteFontDownloadQueue *iface, + IDWriteFontDownloadListener *listener, UINT32 *token) +{ + FIXME("%p, %p, %p stub!\n", iface, listener, token); + return E_NOTIMPL; +} + +static HRESULT WINAPI dwritefontdownloadqueue_RemoveListener(IDWriteFontDownloadQueue *iface, UINT32 token) +{ + FIXME("%p, %#x stub!\n", iface, token); + return E_NOTIMPL; +} + +static BOOL WINAPI dwritefontdownloadqueue_IsEmpty(IDWriteFontDownloadQueue *iface) +{ + FIXME("%p stub!\n", iface); + return TRUE; +} + +static HRESULT WINAPI dwritefontdownloadqueue_BeginDownload(IDWriteFontDownloadQueue *iface, IUnknown *context) +{ + FIXME("%p, %p stub!\n", iface, context); + return E_NOTIMPL; +} + +static HRESULT WINAPI dwritefontdownloadqueue_CancelDownload(IDWriteFontDownloadQueue *iface) +{ + FIXME("%p stub!\n", iface); + return E_NOTIMPL; +} + +static UINT64 WINAPI dwritefontdownloadqueue_GetGenerationCount(IDWriteFontDownloadQueue *iface) +{ + FIXME("%p stub!\n", iface); + return 0; +} + +static const struct IDWriteFontDownloadQueueVtbl dwritefontdownloadqueue_vtbl = +{ + dwritefontdownloadqueue_QueryInterface, + dwritefontdownloadqueue_AddRef, + dwritefontdownloadqueue_Release, + /* IDWriteFontDownloadQueue methods */ + dwritefontdownloadqueue_AddListener, + dwritefontdownloadqueue_RemoveListener, + dwritefontdownloadqueue_IsEmpty, + dwritefontdownloadqueue_BeginDownload, + dwritefontdownloadqueue_CancelDownload, + dwritefontdownloadqueue_GetGenerationCount, +}; + static void init_dwritefactory(struct dwritefactory *factory, DWRITE_FACTORY_TYPE type) { factory->IDWriteFactory7_iface.lpVtbl = type == DWRITE_FACTORY_TYPE_SHARED ? &shareddwritefactoryvtbl : &dwritefactoryvtbl; + factory->IDWriteFontDownloadQueue_iface.lpVtbl = &dwritefontdownloadqueue_vtbl; factory->refcount = 1; factory->localfontfileloader = get_local_fontfile_loader();
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 55aa3c61271..f277134bc0d 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -10510,13 +10510,7 @@ static void test_font_download_queue(void) }
hr = IDWriteFactory3_GetFontDownloadQueue(factory, &queue); - todo_wine ok(hr == S_OK, "got %#lx\n", hr); - if (FAILED(hr)) - { - IDWriteFactory3_Release(factory); - return; - }
hr = IDWriteFactory3_GetFontDownloadQueue(factory, &queue2); ok(hr == S_OK, "got %#lx\n", hr);
Nikolay Sivov (@nsivov) commented about dlls/dwrite/main.c:
- if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IDWriteFontDownloadQueue))
- {
*out = iface;
IDWriteFontDownloadQueue_AddRef(iface);
return S_OK;
- }
- *out = NULL;
- WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
- return E_NOINTERFACE;
+}
+static ULONG WINAPI dwritefontdownloadqueue_AddRef(IDWriteFontDownloadQueue *iface) +{
- struct dwritefactory *impl = impl_from_IDWriteFontDownloadQueue(iface);
We don't use such naming anywhere else in this module. Please call it 'factory' instead.