diff options
author | Khushal <khushalsagar@chromium.org> | 2018-05-31 11:15:13 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-31 20:12:44 +0000 |
commit | 458f40a43e12260a3b73ee170b30d966d6c1fe56 (patch) | |
tree | c8129d44757148b5926726dbcb4faeaa942631fa /src/core/SkFindAndPlaceGlyph.h | |
parent | 82cecb6027e776f18840c4d983f838a285d67a5d (diff) |
font remoting: Fix errors with sub-pixel positioning mismatch.
1) Use correct offset from SkTextBlobRunIterator. Only
kHorizontal_Positioning needs to use the y offset specified on the run.
2) Use the same mapping function from SkFindAndPlaceGlyph for mapping
the glyph position from transform for the run. This avoids minor
rounding differences between analysis and draw.
R=bungeman@google.com,herb@google.com
Bug:829622
Change-Id: Iaef74a8d01f0850ce042149458b2ea795c2a2b61
Reviewed-on: https://skia-review.googlesource.com/131169
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Khusal Sagar <khushalsagar@chromium.org>
Diffstat (limited to 'src/core/SkFindAndPlaceGlyph.h')
-rw-r--r-- | src/core/SkFindAndPlaceGlyph.h | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/core/SkFindAndPlaceGlyph.h b/src/core/SkFindAndPlaceGlyph.h index 69debe4d59..6b157358e8 100644 --- a/src/core/SkFindAndPlaceGlyph.h +++ b/src/core/SkFindAndPlaceGlyph.h @@ -85,6 +85,33 @@ public: return {0.0f, 0.0f}; } + // MapperInterface given a point map it through the matrix. There are several shortcut + // variants. + // * TranslationMapper - assumes a translation only matrix. + // * XScaleMapper - assumes an X scaling and a translation. + // * GeneralMapper - Does all other matricies. + class MapperInterface { + public: + virtual ~MapperInterface() {} + + virtual SkPoint map(SkPoint position) const = 0; + }; + + static MapperInterface* CreateMapper(const SkMatrix& matrix, const SkPoint& offset, + int scalarsPerPosition, SkArenaAlloc* arena) { + auto mtype = matrix.getType(); + if (mtype & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask) || + scalarsPerPosition == 2) { + return arena->make<GeneralMapper>(matrix, offset); + } + + if (mtype & SkMatrix::kScale_Mask) { + return arena->make<XScaleMapper>(matrix, offset); + } + + return arena->make<TranslationMapper>(matrix, offset); + } + private: // GlyphFinderInterface is the polymorphic base for classes that parse a stream of chars into // the right UniChar (or GlyphID) and lookup up the glyph on the cache. The concrete @@ -230,18 +257,6 @@ private: const SkScalar* fPositions; }; - // MapperInterface given a point map it through the matrix. There are several shortcut - // variants. - // * TranslationMapper - assumes a translation only matrix. - // * XScaleMapper - assumes an X scaling and a translation. - // * GeneralMapper - Does all other matricies. - class MapperInterface { - public: - virtual ~MapperInterface() { } - - virtual SkPoint map(SkPoint position) const = 0; - }; - class TranslationMapper final : public MapperInterface { public: TranslationMapper(const SkMatrix& matrix, const SkPoint origin) @@ -457,16 +472,7 @@ inline void SkFindAndPlaceGlyph::ProcessPosText( positionReader = arena.make<HorizontalPositions>(pos); } - MapperInterface* mapper = nullptr; - if (mtype & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask) - || scalarsPerPosition == 2) { - mapper = arena.make<GeneralMapper>(matrix, offset); - } else if (mtype & SkMatrix::kScale_Mask) { - mapper = arena.make<XScaleMapper>(matrix, offset); - } else { - mapper = arena.make<TranslationMapper>(matrix, offset); - } - + MapperInterface* mapper = CreateMapper(matrix, offset, scalarsPerPosition, &arena); GlyphFindAndPlaceInterface<ProcessOneGlyph>* findAndPosition = nullptr; if (cache->isSubpixel()) { findAndPosition = getSubpixel<ProcessOneGlyph>(&arena, axisAlignment, glyphFinder); |