[PATCH 1/3] dwrite: Translate rendered bitmap bounds to given origin
Nikolay Sivov
nsivov at codeweavers.com
Thu Jul 30 17:29:39 CDT 2015
---
-------------- next part --------------
From ccae75cba0865d562f5aabd95cec161e7c7046f4 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed, 29 Jul 2015 19:54:23 +0300
Subject: [PATCH 1/3] dwrite: Translate rendered bitmap bounds to given origin
---
dlls/dwrite/dwrite_private.h | 2 +-
dlls/dwrite/font.c | 10 +++++++++-
dlls/dwrite/main.c | 8 ++++----
dlls/dwrite/tests/font.c | 23 ++++++++++++++++++++++-
4 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 0c25483..59bef03 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,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;
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index a3f58b9..5f32c31 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -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);
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c
index 9f8454f..5a8c026 100644
--- a/dlls/dwrite/main.c
+++ b/dlls/dwrite/main.c
@@ -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,
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index aeb84bb..c132159 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -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,
--
2.1.4
More information about the wine-patches
mailing list