Nikolay Sivov : dwrite: Added IDWriteGlyphRunAnalysis stub.

Alexandre Julliard julliard at wine.codeweavers.com
Tue May 19 09:53:22 CDT 2015


Module: wine
Branch: master
Commit: f4790714fe69df7701cff666d6b5ab4be049cbf6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f4790714fe69df7701cff666d6b5ab4be049cbf6

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue May 19 15:23:57 2015 +0300

dwrite: Added IDWriteGlyphRunAnalysis stub.

---

 dlls/dwrite/dwrite_private.h |   1 +
 dlls/dwrite/font.c           | 104 +++++++++++++++++++++++++++++++++++++++++++
 dlls/dwrite/main.c           |   6 ++-
 dlls/dwrite/tests/font.c     |  81 +++++++++++++++++++++++++++++++++
 4 files changed, 190 insertions(+), 2 deletions(-)

diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index aa73b4b..cd6d08c 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -117,6 +117,7 @@ extern HRESULT create_font_file(IDWriteFontFileLoader *loader, const void *refer
 extern HRESULT create_localfontfileloader(IDWriteLocalFontFileLoader** iface) DECLSPEC_HIDDEN;
 extern HRESULT create_fontface(DWRITE_FONT_FACE_TYPE,UINT32,IDWriteFontFile* const*,UINT32,DWRITE_FONT_SIMULATIONS,IDWriteFontFace2**) DECLSPEC_HIDDEN;
 extern HRESULT create_font_collection(IDWriteFactory2*,IDWriteFontFileEnumerator*,BOOL,IDWriteFontCollection**) DECLSPEC_HIDDEN;
+extern HRESULT create_glyphrunanalysis(DWRITE_RENDERING_MODE,IDWriteGlyphRunAnalysis**) DECLSPEC_HIDDEN;
 extern BOOL    is_system_collection(IDWriteFontCollection*) DECLSPEC_HIDDEN;
 extern HRESULT get_local_refkey(const WCHAR*,const FILETIME*,void**,UINT32*) DECLSPEC_HIDDEN;
 extern HRESULT get_filestream_from_file(IDWriteFontFile*,IDWriteFontFileStream**) DECLSPEC_HIDDEN;
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index c591f4e..85b03f6 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -97,6 +97,11 @@ struct dwrite_fonttable {
     UINT32 size;
 };
 
+struct dwrite_glyphrunanalysis {
+    IDWriteGlyphRunAnalysis IDWriteGlyphRunAnalysis_iface;
+    LONG ref;
+};
+
 #define GLYPH_BLOCK_SHIFT 8
 #define GLYPH_BLOCK_SIZE  (1UL << GLYPH_BLOCK_SHIFT)
 #define GLYPH_BLOCK_MASK  (GLYPH_BLOCK_SIZE - 1)
@@ -155,6 +160,11 @@ static inline struct dwrite_fontcollection *impl_from_IDWriteFontCollection(IDWr
     return CONTAINING_RECORD(iface, struct dwrite_fontcollection, IDWriteFontCollection_iface);
 }
 
+static inline struct dwrite_glyphrunanalysis *impl_from_IDWriteGlyphRunAnalysis(IDWriteGlyphRunAnalysis *iface)
+{
+    return CONTAINING_RECORD(iface, struct dwrite_glyphrunanalysis, IDWriteGlyphRunAnalysis_iface);
+}
+
 static HRESULT get_cached_glyph_metrics(struct dwrite_fontface *fontface, UINT16 glyph, DWRITE_GLYPH_METRICS *metrics)
 {
     static const DWRITE_GLYPH_METRICS nil;
@@ -2569,3 +2579,97 @@ 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);
+
+    if (IsEqualIID(riid, &IID_IDWriteGlyphRunAnalysis) ||
+        IsEqualIID(riid, &IID_IUnknown))
+    {
+        *ppv = iface;
+        IDWriteGlyphRunAnalysis_AddRef(iface);
+        return S_OK;
+    }
+
+    *ppv = NULL;
+    return E_NOINTERFACE;
+}
+
+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;
+}
+
+static ULONG WINAPI glyphrunanalysis_Release(IDWriteGlyphRunAnalysis *iface)
+{
+    struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p)->(%u)\n", This, ref);
+
+    if (!ref) {
+        heap_free(This);
+    }
+
+    return ref;
+}
+
+static HRESULT WINAPI glyphrunanalysis_GetAlphaTextureBounds(IDWriteGlyphRunAnalysis *iface, DWRITE_TEXTURE_TYPE type, RECT* bounds)
+{
+    struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface);
+    FIXME("(%p)->(%d %p): stub\n", This, type, bounds);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI glyphrunanalysis_CreateAlphaTexture(IDWriteGlyphRunAnalysis *iface, DWRITE_TEXTURE_TYPE type,
+    RECT const* bounds, BYTE* alphaValues, UINT32 bufferSize)
+{
+    struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface);
+    FIXME("(%p)->(%d %p %p %u): stub\n", This, type, bounds, alphaValues, bufferSize);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI glyphrunanalysis_GetAlphaBlendParams(IDWriteGlyphRunAnalysis *iface, IDWriteRenderingParams *params,
+    FLOAT *blendGamma, FLOAT *blendEnhancedContrast, FLOAT *blendClearTypeLevel)
+{
+    struct dwrite_glyphrunanalysis *This = impl_from_IDWriteGlyphRunAnalysis(iface);
+    FIXME("(%p)->(%p %p %p %p): stub\n", This, params, blendGamma, blendEnhancedContrast, blendClearTypeLevel);
+    return E_NOTIMPL;
+}
+
+static const struct IDWriteGlyphRunAnalysisVtbl glyphrunanalysisvtbl = {
+    glyphrunanalysis_QueryInterface,
+    glyphrunanalysis_AddRef,
+    glyphrunanalysis_Release,
+    glyphrunanalysis_GetAlphaTextureBounds,
+    glyphrunanalysis_CreateAlphaTexture,
+    glyphrunanalysis_GetAlphaBlendParams
+};
+
+HRESULT create_glyphrunanalysis(DWRITE_RENDERING_MODE rendering_mode, IDWriteGlyphRunAnalysis **ret)
+{
+    struct dwrite_glyphrunanalysis *analysis;
+
+    *ret = NULL;
+
+    /* check for valid rendering mode */
+    if ((UINT32)rendering_mode >= DWRITE_RENDERING_MODE_OUTLINE || rendering_mode == DWRITE_RENDERING_MODE_DEFAULT)
+        return E_INVALIDARG;
+
+    analysis = heap_alloc(sizeof(*analysis));
+    if (!analysis)
+        return E_OUTOFMEMORY;
+
+    analysis->IDWriteGlyphRunAnalysis_iface.lpVtbl = &glyphrunanalysisvtbl;
+    analysis->ref = 1;
+
+    *ret = &analysis->IDWriteGlyphRunAnalysis_iface;
+    return S_OK;
+}
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c
index 3285f2d..20f9d36 100644
--- a/dlls/dwrite/main.c
+++ b/dlls/dwrite/main.c
@@ -1075,9 +1075,11 @@ static HRESULT WINAPI dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory2 *ifac
     DWRITE_MEASURING_MODE measuring_mode, FLOAT baseline_x, FLOAT baseline_y, IDWriteGlyphRunAnalysis **analysis)
 {
     struct dwritefactory *This = impl_from_IDWriteFactory2(iface);
-    FIXME("(%p)->(%p %f %p %d %d %f %f %p): stub\n", This, glyph_run, pixels_per_dip, transform, rendering_mode,
+
+    TRACE("(%p)->(%p %f %p %d %d %f %f %p)\n", This, glyph_run, pixels_per_dip, transform, rendering_mode,
         measuring_mode, baseline_x, baseline_y, analysis);
-    return E_NOTIMPL;
+
+    return create_glyphrunanalysis(rendering_mode, analysis);
 }
 
 static HRESULT WINAPI dwritefactory1_GetEudcFontCollection(IDWriteFactory2 *iface, IDWriteFontCollection **collection,
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 126fba9..1815105 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -70,6 +70,37 @@ static IDWriteFactory *create_factory(void)
     return factory;
 }
 
+static IDWriteFontFace *create_fontface(IDWriteFactory *factory)
+{
+    static const WCHAR tahomaW[] = {'T','a','h','o','m','a',0};
+    IDWriteGdiInterop *interop;
+    IDWriteFontFace *fontface;
+    IDWriteFont *font;
+    LOGFONTW logfont;
+    HRESULT hr;
+
+    hr = IDWriteFactory_GetGdiInterop(factory, &interop);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    memset(&logfont, 0, sizeof(logfont));
+    logfont.lfHeight = 12;
+    logfont.lfWidth  = 12;
+    logfont.lfWeight = FW_NORMAL;
+    logfont.lfItalic = 1;
+    lstrcpyW(logfont.lfFaceName, tahomaW);
+
+    hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    hr = IDWriteFont_CreateFontFace(font, &fontface);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    IDWriteFont_Release(font);
+    IDWriteGdiInterop_Release(interop);
+
+    return fontface;
+}
+
 static WCHAR *create_testfontfile(const WCHAR *filename)
 {
     static WCHAR pathW[MAX_PATH];
@@ -3238,6 +3269,55 @@ static void test_CreateRenderingParams(void)
     IDWriteFactory_Release(factory);
 }
 
+static void test_CreateGlyphRunAnalysis(void)
+{
+    IDWriteGlyphRunAnalysis *analysis;
+    IDWriteFactory *factory;
+    DWRITE_GLYPH_RUN run;
+    IDWriteFontFace *face;
+    UINT16 index;
+    FLOAT advance;
+    HRESULT hr;
+    UINT32 ch;
+
+    factory = create_factory();
+    face = create_fontface(factory);
+
+    ch = 'A';
+    hr = IDWriteFontFace_GetGlyphIndices(face, &ch, 1, &index);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    run.fontFace = face;
+    run.fontEmSize = 24.0;
+    run.glyphCount = 1;
+    run.glyphIndices = &index;
+    run.glyphAdvances = &advance;
+    run.glyphOffsets = NULL;
+    run.isSideways = FALSE;
+    run.bidiLevel = 0;
+
+    /* default mode is not allowed */
+    hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
+        DWRITE_RENDERING_MODE_DEFAULT, DWRITE_MEASURING_MODE_NATURAL,
+        0.0, 0.0, &analysis);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    /* outline too */
+    hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
+        DWRITE_RENDERING_MODE_OUTLINE, DWRITE_MEASURING_MODE_NATURAL,
+        0.0, 0.0, &analysis);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+    hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
+        DWRITE_RENDERING_MODE_GDI_CLASSIC, DWRITE_MEASURING_MODE_NATURAL,
+        0.0, 0.0, &analysis);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    IDWriteGlyphRunAnalysis_Release(analysis);
+
+    IDWriteFontFace_Release(face);
+    IDWriteFactory_Release(factory);
+}
+
 START_TEST(font)
 {
     IDWriteFactory *factory;
@@ -3280,6 +3360,7 @@ START_TEST(font)
     test_GetGlyphCount();
     test_GetKerningPairAdjustments();
     test_CreateRenderingParams();
+    test_CreateGlyphRunAnalysis();
 
     IDWriteFactory_Release(factory);
 }




More information about the wine-cvs mailing list