dwrite: Implement another variant of CreateGlyphRunAnalysis().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2017-01-26 07:41:46 +03:00 committed by Alexandre Julliard
parent 1afcfc77d3
commit c32a19f198
3 changed files with 49 additions and 22 deletions

View File

@ -143,7 +143,7 @@ struct glyphrunanalysis_desc
{
const DWRITE_GLYPH_RUN *run;
const DWRITE_MATRIX *transform;
DWRITE_RENDERING_MODE rendering_mode;
DWRITE_RENDERING_MODE1 rendering_mode;
DWRITE_MEASURING_MODE measuring_mode;
DWRITE_GRID_FIT_MODE gridfit_mode;
DWRITE_TEXT_ANTIALIAS_MODE aa_mode;

View File

@ -166,7 +166,7 @@ struct dwrite_glyphrunanalysis {
IDWriteGlyphRunAnalysis IDWriteGlyphRunAnalysis_iface;
LONG ref;
DWRITE_RENDERING_MODE rendering_mode;
DWRITE_RENDERING_MODE1 rendering_mode;
DWRITE_GLYPH_RUN run; /* glyphAdvances and glyphOffsets are not used */
DWRITE_MATRIX m;
FLOAT ppdip;
@ -1167,7 +1167,7 @@ static HRESULT WINAPI dwritefontface3_GetRecommendedRenderingMode(IDWriteFontFac
emSize *= max(dpiX, dpiY) / 96.0f;
*rendering_mode = DWRITE_RENDERING_MODE_DEFAULT;
*rendering_mode = DWRITE_RENDERING_MODE1_DEFAULT;
*gridfit_mode = DWRITE_GRID_FIT_MODE_DEFAULT;
if (params) {
IDWriteRenderingParams3 *params3;
@ -4757,6 +4757,19 @@ static ULONG WINAPI glyphrunanalysis_Release(IDWriteGlyphRunAnalysis *iface)
return ref;
}
static BOOL is_natural_rendering_mode(DWRITE_RENDERING_MODE1 mode)
{
switch (mode)
{
case DWRITE_RENDERING_MODE1_NATURAL:
case DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC:
case DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED:
return TRUE;
default:
return FALSE;
}
}
static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *analysis, RECT *bounds)
{
struct dwrite_glyphbitmap glyph_bitmap;
@ -4787,8 +4800,7 @@ static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *a
memset(&glyph_bitmap, 0, sizeof(glyph_bitmap));
glyph_bitmap.fontface = fontface3;
glyph_bitmap.emsize = analysis->run.fontEmSize * analysis->ppdip;
glyph_bitmap.nohint = analysis->rendering_mode == DWRITE_RENDERING_MODE_NATURAL ||
analysis->rendering_mode == DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC;
glyph_bitmap.nohint = is_natural_rendering_mode(analysis->rendering_mode);
if (analysis->flags & RUNANALYSIS_USE_TRANSFORM)
glyph_bitmap.m = &analysis->m;
@ -4836,8 +4848,8 @@ static HRESULT WINAPI glyphrunanalysis_GetAlphaTextureBounds(IDWriteGlyphRunAnal
return E_INVALIDARG;
}
if ((type == DWRITE_TEXTURE_ALIASED_1x1 && This->rendering_mode != DWRITE_RENDERING_MODE_ALIASED) ||
(type == DWRITE_TEXTURE_CLEARTYPE_3x1 && This->rendering_mode == DWRITE_RENDERING_MODE_ALIASED)) {
if ((type == DWRITE_TEXTURE_ALIASED_1x1 && This->rendering_mode != DWRITE_RENDERING_MODE1_ALIASED) ||
(type == DWRITE_TEXTURE_CLEARTYPE_3x1 && This->rendering_mode == DWRITE_RENDERING_MODE1_ALIASED)) {
memset(bounds, 0, sizeof(*bounds));
return S_OK;
}
@ -4889,8 +4901,7 @@ static void glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis, DW
memset(&glyph_bitmap, 0, sizeof(glyph_bitmap));
glyph_bitmap.fontface = fontface2;
glyph_bitmap.emsize = analysis->run.fontEmSize * analysis->ppdip;
glyph_bitmap.nohint = analysis->rendering_mode == DWRITE_RENDERING_MODE_NATURAL ||
analysis->rendering_mode == DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC;
glyph_bitmap.nohint = is_natural_rendering_mode(analysis->rendering_mode);
glyph_bitmap.type = type;
if (analysis->flags & RUNANALYSIS_USE_TRANSFORM)
glyph_bitmap.m = &analysis->m;
@ -5018,14 +5029,15 @@ static HRESULT WINAPI glyphrunanalysis_CreateAlphaTexture(IDWriteGlyphRunAnalysi
/* validate requested texture type with rendering mode */
switch (This->rendering_mode)
{
case DWRITE_RENDERING_MODE_ALIASED:
case DWRITE_RENDERING_MODE1_ALIASED:
if (type != DWRITE_TEXTURE_ALIASED_1x1)
return DWRITE_E_UNSUPPORTEDOPERATION;
break;
case DWRITE_RENDERING_MODE_GDI_CLASSIC:
case DWRITE_RENDERING_MODE_GDI_NATURAL:
case DWRITE_RENDERING_MODE_NATURAL:
case DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC:
case DWRITE_RENDERING_MODE1_GDI_CLASSIC:
case DWRITE_RENDERING_MODE1_GDI_NATURAL:
case DWRITE_RENDERING_MODE1_NATURAL:
case DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC:
case DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED:
if (type != DWRITE_TEXTURE_CLEARTYPE_3x1)
return DWRITE_E_UNSUPPORTEDOPERATION;
break;
@ -5071,8 +5083,8 @@ static HRESULT WINAPI glyphrunanalysis_GetAlphaBlendParams(IDWriteGlyphRunAnalys
switch (This->rendering_mode)
{
case DWRITE_RENDERING_MODE_GDI_CLASSIC:
case DWRITE_RENDERING_MODE_GDI_NATURAL:
case DWRITE_RENDERING_MODE1_GDI_CLASSIC:
case DWRITE_RENDERING_MODE1_GDI_NATURAL:
{
UINT value = 0;
SystemParametersInfoW(SPI_GETFONTSMOOTHINGCONTRAST, 0, &value, 0);
@ -5081,9 +5093,12 @@ static HRESULT WINAPI glyphrunanalysis_GetAlphaBlendParams(IDWriteGlyphRunAnalys
*cleartypelevel = 1.0f;
break;
}
case DWRITE_RENDERING_MODE_ALIASED:
case DWRITE_RENDERING_MODE_NATURAL:
case DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC:
case DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED:
WARN("Downsampled mode is ignored.\n");
/* fallthrough */
case DWRITE_RENDERING_MODE1_ALIASED:
case DWRITE_RENDERING_MODE1_NATURAL:
case DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC:
*gamma = IDWriteRenderingParams_GetGamma(params);
*contrast = IDWriteRenderingParams_GetEnhancedContrast(params);
*cleartypelevel = IDWriteRenderingParams_GetClearTypeLevel(params);
@ -5133,7 +5148,9 @@ HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc *desc, IDWrit
*ret = NULL;
/* check for valid rendering mode */
if ((UINT32)desc->rendering_mode >= DWRITE_RENDERING_MODE_OUTLINE || desc->rendering_mode == DWRITE_RENDERING_MODE_DEFAULT)
if ((UINT32)desc->rendering_mode >= DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED ||
desc->rendering_mode == DWRITE_RENDERING_MODE1_OUTLINE ||
desc->rendering_mode == DWRITE_RENDERING_MODE1_DEFAULT)
return E_INVALIDARG;
analysis = heap_alloc(sizeof(*analysis));

View File

@ -1291,11 +1291,21 @@ static HRESULT WINAPI dwritefactory3_CreateGlyphRunAnalysis(IDWriteFactory4 *ifa
IDWriteGlyphRunAnalysis **analysis)
{
struct dwritefactory *This = impl_from_IDWriteFactory4(iface);
struct glyphrunanalysis_desc desc;
FIXME("(%p)->(%p %p %d %d %d %d %.2f %.2f %p): stub\n", This, run, transform, rendering_mode, measuring_mode,
TRACE("(%p)->(%p %p %d %d %d %d %.2f %.2f %p)\n", This, run, transform, rendering_mode, measuring_mode,
gridfit_mode, aa_mode, originX, originY, analysis);
return E_NOTIMPL;
desc.run = run;
desc.ppdip = 1.0f;
desc.transform = transform;
desc.rendering_mode = rendering_mode;
desc.measuring_mode = measuring_mode;
desc.gridfit_mode = gridfit_mode;
desc.aa_mode = aa_mode;
desc.origin_x = originX;
desc.origin_y = originY;
return create_glyphrunanalysis(&desc, analysis);
}
static HRESULT WINAPI dwritefactory3_CreateCustomRenderingParams(IDWriteFactory4 *iface, FLOAT gamma, FLOAT contrast,