Make rounding code public

Change-Id: I37fec55277fe99734980c7473f964d37ca4248b8
Reviewed-on: https://skia-review.googlesource.com/123931
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2018-04-26 11:38:58 -04:00 committed by Skia Commit-Bot
parent c2a8870316
commit 927fcb13f2

View File

@ -72,6 +72,21 @@ public:
return {0, 0};
}
// The SubpixelPositionRounding function returns a point suitable for rounding a sub-pixel
// positioned glyph.
static SkPoint SubpixelPositionRounding(SkAxisAlignment axisAlignment) {
switch (axisAlignment) {
case kX_SkAxisAlignment:
return {kSubpixelRounding, SK_ScalarHalf};
case kY_SkAxisAlignment:
return {SK_ScalarHalf, kSubpixelRounding};
case kNone_SkAxisAlignment:
return {kSubpixelRounding, kSubpixelRounding};
}
SK_ABORT("Should not get here.");
return {0.0f, 0.0f};
}
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
@ -295,21 +310,6 @@ private:
// Needs to be a macro because you can't have a const float unless you make it constexpr.
static constexpr SkScalar kSubpixelRounding = SkFixedToScalar(SkGlyph::kSubpixelRound);
// The SubpixelPositionRounding function returns a point suitable for rounding a sub-pixel
// positioned glyph.
static SkPoint SubpixelPositionRounding(SkAxisAlignment axisAlignment) {
switch (axisAlignment) {
case kX_SkAxisAlignment:
return {kSubpixelRounding, SK_ScalarHalf};
case kY_SkAxisAlignment:
return {SK_ScalarHalf, kSubpixelRounding};
case kNone_SkAxisAlignment:
return {kSubpixelRounding, kSubpixelRounding};
}
SK_ABORT("Should not get here.");
return {0.0f, 0.0f};
}
// GlyphFindAndPlaceInterface given the text and position finds the correct glyph and does
// glyph specific position adjustment. The findAndPositionGlyph method takes text and
// position and calls processOneGlyph with the correct glyph, final position and rounding