aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
authorGravatar Bruce Wang <brucewang@google.com>2018-06-13 13:38:34 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-15 16:11:35 +0000
commit46f25635474e6b1e4289cf9fd5f6c3ddd3696ead (patch)
treea05b003b1a9322337e963277ac037058c5409126 /src/ports
parentd2b5084d972d3742e725d6d87d0ece9ea4e5ae9e (diff)
Implement SkScalerContext_DW::generateColorMetrics(SkGlyph* glyph) on Windows.
Fix layout problem for color glyph. BUG=chromium:698492 Change-Id: Iff586332ee0d7fdbf8c6c7f340536855b753769c Reviewed-on: https://skia-review.googlesource.com/134519 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkScalerContext_win_dw.cpp48
-rw-r--r--src/ports/SkScalerContext_win_dw.h4
2 files changed, 51 insertions, 1 deletions
diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp
index fa6b9101ea..a238562ebd 100644
--- a/src/ports/SkScalerContext_win_dw.cpp
+++ b/src/ports/SkScalerContext_win_dw.cpp
@@ -549,6 +549,46 @@ bool SkScalerContext_DW::getColorGlyphRun(const SkGlyph& glyph,
return true;
}
+void SkScalerContext_DW::generateColorMetrics(SkGlyph* glyph) {
+ SkTScopedComPtr<IDWriteColorGlyphRunEnumerator> colorLayers;
+ HRVM(getColorGlyphRun(*glyph, &colorLayers), "Could not get color glyph run");
+ SkASSERT(colorLayers.get());
+
+ SkRect bounds = SkRect::MakeEmpty();
+ BOOL hasNextRun = FALSE;
+ while (SUCCEEDED(colorLayers->MoveNext(&hasNextRun)) && hasNextRun) {
+ const DWRITE_COLOR_GLYPH_RUN* colorGlyph;
+ HRVM(colorLayers->GetCurrentRun(&colorGlyph), "Could not get current color glyph run");
+
+ SkPath path;
+ SkTScopedComPtr<IDWriteGeometrySink> geometryToPath;
+ HRVM(SkDWriteGeometrySink::Create(&path, &geometryToPath),
+ "Could not create geometry to path converter.");
+ {
+ SkAutoExclusive l(DWriteFactoryMutex);
+ HRVM(colorGlyph->glyphRun.fontFace->GetGlyphRunOutline(
+ colorGlyph->glyphRun.fontEmSize,
+ colorGlyph->glyphRun.glyphIndices,
+ colorGlyph->glyphRun.glyphAdvances,
+ colorGlyph->glyphRun.glyphOffsets,
+ colorGlyph->glyphRun.glyphCount,
+ colorGlyph->glyphRun.isSideways,
+ colorGlyph->glyphRun.bidiLevel % 2, //rtl
+ geometryToPath.get()),
+ "Could not create glyph outline.");
+ }
+ bounds.join(path.getBounds());
+ }
+ HRV(fSkXform.mapRect(&bounds));
+ // Round float bound values into integer.
+ SkIRect ibounds = bounds.roundOut();
+
+ glyph->fWidth = ibounds.fRight - ibounds.fLeft;
+ glyph->fHeight = ibounds.fBottom - ibounds.fTop;
+ glyph->fLeft = ibounds.fLeft;
+ glyph->fTop = ibounds.fTop;
+}
+
void SkScalerContext_DW::generateMetrics(SkGlyph* glyph) {
glyph->fWidth = 0;
glyph->fHeight = 0;
@@ -559,6 +599,14 @@ void SkScalerContext_DW::generateMetrics(SkGlyph* glyph) {
if (fIsColorFont && isColorGlyph(*glyph)) {
glyph->fMaskFormat = SkMask::kARGB32_Format;
+
+#ifndef SK_IGNORE_WIN_EMOJI_FIX
+
+ generateColorMetrics(glyph);
+ return;
+
+#endif
+
}
RECT bbox;
diff --git a/src/ports/SkScalerContext_win_dw.h b/src/ports/SkScalerContext_win_dw.h
index 430048c09e..d5a217d5b4 100644
--- a/src/ports/SkScalerContext_win_dw.h
+++ b/src/ports/SkScalerContext_win_dw.h
@@ -52,7 +52,9 @@ private:
}
bool getColorGlyphRun(const SkGlyph& glyph, IDWriteColorGlyphRunEnumerator** colorGlyph);
-
+
+ void generateColorMetrics(SkGlyph* glyph);
+
void generateColorGlyphImage(const SkGlyph& glyph);
SkTDArray<uint8_t> fBits;