dwrite: Translate rendered bitmap bounds to given origin.

This commit is contained in:
Nikolay Sivov 2015-07-31 01:29:39 +03:00 committed by Alexandre Julliard
parent 929ab3e527
commit 6d1f47902b
4 changed files with 36 additions and 7 deletions

View File

@ -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,DWRITE_GLYPH_RUN const*,FLOAT,IDWriteGlyphRunAnalysis**) DECLSPEC_HIDDEN;
extern HRESULT create_glyphrunanalysis(DWRITE_RENDERING_MODE,DWRITE_GLYPH_RUN const*,FLOAT,FLOAT,FLOAT,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;

View File

@ -117,6 +117,8 @@ struct dwrite_glyphrunanalysis {
DWRITE_RENDERING_MODE rendering_mode;
DWRITE_GLYPH_RUN run;
FLOAT ppdip;
FLOAT originX;
FLOAT originY;
UINT16 *glyphs;
FLOAT *advances;
DWRITE_GLYPH_OFFSET *offsets;
@ -2956,6 +2958,9 @@ static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *a
IDWriteFontFace2_Release(fontface2);
/* translate to given run origin */
OffsetRect(&analysis->bounds, analysis->originX, analysis->originY);
analysis->ready |= RUNANALYSIS_BOUNDS;
*bounds = analysis->bounds;
}
@ -3075,7 +3080,8 @@ static const struct IDWriteGlyphRunAnalysisVtbl glyphrunanalysisvtbl = {
glyphrunanalysis_GetAlphaBlendParams
};
HRESULT create_glyphrunanalysis(DWRITE_RENDERING_MODE rendering_mode, DWRITE_GLYPH_RUN const *run, FLOAT ppdip, IDWriteGlyphRunAnalysis **ret)
HRESULT create_glyphrunanalysis(DWRITE_RENDERING_MODE rendering_mode, DWRITE_GLYPH_RUN const *run, FLOAT ppdip,
FLOAT originX, FLOAT originY, IDWriteGlyphRunAnalysis **ret)
{
struct dwrite_glyphrunanalysis *analysis;
@ -3094,6 +3100,8 @@ HRESULT create_glyphrunanalysis(DWRITE_RENDERING_MODE rendering_mode, DWRITE_GLY
analysis->rendering_mode = rendering_mode;
analysis->ready = 0;
analysis->ppdip = ppdip;
analysis->originX = originX;
analysis->originY = originY;
SetRectEmpty(&analysis->bounds);
analysis->run = *run;
IDWriteFontFace_AddRef(analysis->run.fontFace);

View File

@ -1072,14 +1072,14 @@ static HRESULT WINAPI dwritefactory_CreateNumberSubstitution(IDWriteFactory2 *if
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)
DWRITE_MEASURING_MODE measuring_mode, FLOAT originX, FLOAT originY, IDWriteGlyphRunAnalysis **analysis)
{
struct dwritefactory *This = impl_from_IDWriteFactory2(iface);
TRACE("(%p)->(%p %.2f %p %d %d %f %f %p)\n", This, run, ppdip, transform, rendering_mode,
measuring_mode, baseline_x, baseline_y, analysis);
TRACE("(%p)->(%p %.2f %p %d %d %.2f %.2f %p)\n", This, run, ppdip, transform, rendering_mode,
measuring_mode, originX, originY, analysis);
return create_glyphrunanalysis(rendering_mode, run, ppdip, analysis);
return create_glyphrunanalysis(rendering_mode, run, ppdip, originX, originY, analysis);
}
static HRESULT WINAPI dwritefactory1_GetEudcFontCollection(IDWriteFactory2 *iface, IDWriteFontCollection **collection,

View File

@ -3435,7 +3435,7 @@ static void test_CreateGlyphRunAnalysis(void)
FLOAT advance;
HRESULT hr;
UINT32 ch;
RECT rect;
RECT rect, rect2;
DWRITE_GLYPH_OFFSET offset;
DWRITE_GLYPH_METRICS metrics;
DWRITE_FONT_METRICS fm;
@ -3489,8 +3489,29 @@ static void test_CreateGlyphRunAnalysis(void)
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
ok(rect.left == 0 && rect.right == 0 &&
rect.top == 0 && rect.bottom == 0, "unexpected rect\n");
/* check how origin affects bounds */
memset(&rect, 0, sizeof(rect));
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(!IsRectEmpty(&rect), "got empty rect\n");
IDWriteGlyphRunAnalysis_Release(analysis);
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_NATURAL,
10.0, -5.0, &analysis);
ok(hr == S_OK, "got 0x%08x\n", hr);
memset(&rect2, 0, sizeof(rect2));
hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect2);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(!IsRectEmpty(&rect2), "got empty rect\n");
IDWriteGlyphRunAnalysis_Release(analysis);
ok(!EqualRect(&rect, &rect2), "got equal bounds\n");
OffsetRect(&rect, 10, -5);
ok(EqualRect(&rect, &rect2), "got different bounds\n");
for (i = 0; i < sizeof(rendermodes)/sizeof(rendermodes[0]); i++) {
hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
rendermodes[i], DWRITE_MEASURING_MODE_NATURAL,