Chromium Code Reviews| Index: src/ports/SkScalerContext_win_dw.cpp |
| diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp |
| index f27497be62ef7e40fdc88fede12c183624cbb227..46769dfb288a96d4385de5e9df5d4de2cf2538b7 100644 |
| --- a/src/ports/SkScalerContext_win_dw.cpp |
| +++ b/src/ports/SkScalerContext_win_dw.cpp |
| @@ -398,11 +398,11 @@ void SkScalerContext_DW::generateAdvance(SkGlyph* glyph) { |
| glyph->fAdvanceY = SkScalarToFixed(vecs[0].fY); |
| } |
| -void SkScalerContext_DW::generateMetrics(SkGlyph* glyph) { |
| - glyph->fWidth = 0; |
| - |
| - this->generateAdvance(glyph); |
| - |
| +void SkScalerContext_DW::getBoundingBox(SkGlyph* glyph, |
| + DWRITE_RENDERING_MODE renderingMode, |
| + DWRITE_TEXTURE_TYPE textureType, |
| + RECT* bbox) |
| +{ |
| //Measure raster size. |
| fXform.dx = SkFixedToFloat(glyph->getSubXFixed()); |
| fXform.dy = SkFixedToFloat(glyph->getSubYFixed()); |
| @@ -430,16 +430,37 @@ void SkScalerContext_DW::generateMetrics(SkGlyph* glyph) { |
| &run, |
| 1.0f, // pixelsPerDip, |
| &fXform, |
| - fRenderingMode, |
| + renderingMode, |
| fMeasuringMode, |
| 0.0f, // baselineOriginX, |
| 0.0f, // baselineOriginY, |
| &glyphRunAnalysis), |
| "Could not create glyph run analysis."); |
| - RECT bbox; |
| - HRVM(glyphRunAnalysis->GetAlphaTextureBounds(fTextureType, &bbox), |
| + HRVM(glyphRunAnalysis->GetAlphaTextureBounds(textureType, bbox), |
| "Could not get texture bounds."); |
| +} |
| + |
| +void SkScalerContext_DW::generateMetrics(SkGlyph* glyph) { |
| + glyph->fWidth = 0; |
| + |
| + this->generateAdvance(glyph); |
| + |
| + RECT bbox; |
| + this->getBoundingBox(glyph, fRenderingMode, fTextureType, &bbox); |
| + |
| + if (bbox.left == bbox.right || bbox.top == bbox.bottom) { |
| + if (DWRITE_TEXTURE_CLEARTYPE_3x1 == fTextureType) { |
| + this->getBoundingBox(glyph, |
| + DWRITE_RENDERING_MODE_ALIASED, |
| + DWRITE_TEXTURE_ALIASED_1x1, |
| + &bbox); |
| + if (bbox.left != bbox.right && bbox.top != bbox.bottom) { |
|
reed1
2014/08/27 22:07:33
I'd add a comment inside the if...
// We concede
|
| + fTextureType = DWRITE_TEXTURE_ALIASED_1x1; |
| + fRenderingMode = DWRITE_RENDERING_MODE_ALIASED; |
| + } |
| + } |
| + } |
| glyph->fWidth = SkToU16(bbox.right - bbox.left); |
| glyph->fHeight = SkToU16(bbox.bottom - bbox.top); |