[PATCH 1/4] dwrite: Store run info for IDWriteGlyphRunAnalysis instance
Nikolay Sivov
nsivov at codeweavers.com
Wed Jul 29 03:57:52 CDT 2015
---
-------------- next part --------------
>From 57cc683e7d3a88b0cb346986098326432a9e5406 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed, 29 Jul 2015 11:50:48 +0300
Subject: [PATCH 1/4] dwrite: Store run info for IDWriteGlyphRunAnalysis
instance
---
dlls/dwrite/dwrite_private.h | 2 +-
dlls/dwrite/font.c | 35 ++++++++++++++++++++++++++++++++++-
dlls/dwrite/main.c | 8 ++++----
3 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 65cf4b0..aa24550 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -124,7 +124,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 HRESULT create_glyphrunanalysis(DWRITE_RENDERING_MODE,DWRITE_GLYPH_RUN const*,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 4fdea6c..9876451 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -111,6 +111,10 @@ struct dwrite_glyphrunanalysis {
LONG ref;
DWRITE_RENDERING_MODE rendering_mode;
+ DWRITE_GLYPH_RUN run;
+ UINT16 *glyphs;
+ FLOAT *advances;
+ DWRITE_GLYPH_OFFSET *offsets;
};
#define GLYPH_BLOCK_SHIFT 8
@@ -2890,6 +2894,10 @@ static ULONG WINAPI glyphrunanalysis_Release(IDWriteGlyphRunAnalysis *iface)
TRACE("(%p)->(%u)\n", This, ref);
if (!ref) {
+ IDWriteFontFace_Release(This->run.fontFace);
+ heap_free(This->glyphs);
+ heap_free(This->advances);
+ heap_free(This->offsets);
heap_free(This);
}
@@ -2941,7 +2949,7 @@ static const struct IDWriteGlyphRunAnalysisVtbl glyphrunanalysisvtbl = {
glyphrunanalysis_GetAlphaBlendParams
};
-HRESULT create_glyphrunanalysis(DWRITE_RENDERING_MODE rendering_mode, IDWriteGlyphRunAnalysis **ret)
+HRESULT create_glyphrunanalysis(DWRITE_RENDERING_MODE rendering_mode, DWRITE_GLYPH_RUN const *run, IDWriteGlyphRunAnalysis **ret)
{
struct dwrite_glyphrunanalysis *analysis;
@@ -2958,6 +2966,31 @@ HRESULT create_glyphrunanalysis(DWRITE_RENDERING_MODE rendering_mode, IDWriteGly
analysis->IDWriteGlyphRunAnalysis_iface.lpVtbl = &glyphrunanalysisvtbl;
analysis->ref = 1;
analysis->rendering_mode = rendering_mode;
+ analysis->run = *run;
+ IDWriteFontFace_AddRef(analysis->run.fontFace);
+ analysis->glyphs = heap_alloc(run->glyphCount*sizeof(*run->glyphIndices));
+ analysis->advances = heap_alloc(run->glyphCount*sizeof(*run->glyphAdvances));
+ analysis->offsets = heap_alloc(run->glyphCount*sizeof(*run->glyphOffsets));
+ if (!analysis->glyphs || !analysis->advances || !analysis->offsets) {
+ heap_free(analysis->glyphs);
+ heap_free(analysis->advances);
+ heap_free(analysis->offsets);
+
+ analysis->glyphs = NULL;
+ analysis->advances = NULL;
+ analysis->offsets = NULL;
+
+ IDWriteGlyphRunAnalysis_Release(&analysis->IDWriteGlyphRunAnalysis_iface);
+ return E_OUTOFMEMORY;
+ }
+
+ analysis->run.glyphIndices = analysis->glyphs;
+ analysis->run.glyphAdvances = analysis->advances;
+ analysis->run.glyphOffsets = analysis->offsets;
+
+ memcpy(analysis->glyphs, run->glyphIndices, run->glyphCount*sizeof(*run->glyphIndices));
+ memcpy(analysis->advances, run->glyphAdvances, run->glyphCount*sizeof(*run->glyphAdvances));
+ memcpy(analysis->offsets, run->glyphOffsets, run->glyphCount*sizeof(*run->glyphOffsets));
*ret = &analysis->IDWriteGlyphRunAnalysis_iface;
return S_OK;
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c
index 96b4925..7c027f9 100644
--- a/dlls/dwrite/main.c
+++ b/dlls/dwrite/main.c
@@ -1070,16 +1070,16 @@ static HRESULT WINAPI dwritefactory_CreateNumberSubstitution(IDWriteFactory2 *if
return create_numbersubstitution(method, locale, ignore_user_override, substitution);
}
-static HRESULT WINAPI dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory2 *iface, DWRITE_GLYPH_RUN const *glyph_run,
- FLOAT pixels_per_dip, DWRITE_MATRIX const* transform, DWRITE_RENDERING_MODE rendering_mode,
+static HRESULT WINAPI dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory2 *iface, DWRITE_GLYPH_RUN const *run,
+ FLOAT ppdip, DWRITE_MATRIX const* transform, DWRITE_RENDERING_MODE rendering_mode,
DWRITE_MEASURING_MODE measuring_mode, FLOAT baseline_x, FLOAT baseline_y, IDWriteGlyphRunAnalysis **analysis)
{
struct dwritefactory *This = impl_from_IDWriteFactory2(iface);
- TRACE("(%p)->(%p %f %p %d %d %f %f %p)\n", This, glyph_run, pixels_per_dip, transform, rendering_mode,
+ TRACE("(%p)->(%p %f %p %d %d %f %f %p)\n", This, run, ppdip, transform, rendering_mode,
measuring_mode, baseline_x, baseline_y, analysis);
- return create_glyphrunanalysis(rendering_mode, analysis);
+ return create_glyphrunanalysis(rendering_mode, run, analysis);
}
static HRESULT WINAPI dwritefactory1_GetEudcFontCollection(IDWriteFactory2 *iface, IDWriteFontCollection **collection,
--
2.1.4
More information about the wine-patches
mailing list