aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkFindAndPlaceGlyph.h
diff options
context:
space:
mode:
authorGravatar benjaminwagner <benjaminwagner@google.com>2016-03-11 04:33:44 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-11 04:33:44 -0800
commitdb6bd3239fd5e35797a9aa36eb0044ecbe5557c4 (patch)
treed938660c3d40329ea6d67dc3e1a24a9d3d27dd72 /src/core/SkFindAndPlaceGlyph.h
parente683c56115a210b5993df9294260bb147b408bfa (diff)
Ensure only fractional floats are converted to SkFixed in SubpixelAlignment.
Diffstat (limited to 'src/core/SkFindAndPlaceGlyph.h')
-rw-r--r--src/core/SkFindAndPlaceGlyph.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core/SkFindAndPlaceGlyph.h b/src/core/SkFindAndPlaceGlyph.h
index 18b93f70a4..35ae77cfe3 100644
--- a/src/core/SkFindAndPlaceGlyph.h
+++ b/src/core/SkFindAndPlaceGlyph.h
@@ -381,14 +381,16 @@ private:
// produce the correct sub-pixel alignment. If a position is aligned with an axis a shortcut
// of 0 is used for the sub-pixel position.
static SkIPoint SubpixelAlignment(SkAxisAlignment axisAlignment, SkPoint position) {
+ // Only the fractional part of position.fX and position.fY matter, because the result of
+ // this function will just be passed to FixedToSub.
switch (axisAlignment) {
case kX_SkAxisAlignment:
- return {SkScalarToFixed(position.fX + kSubpixelRounding), 0};
+ return {SkScalarToFixed(SkScalarFraction(position.fX) + kSubpixelRounding), 0};
case kY_SkAxisAlignment:
- return {0, SkScalarToFixed(position.fY + kSubpixelRounding)};
+ return {0, SkScalarToFixed(SkScalarFraction(position.fY) + kSubpixelRounding)};
case kNone_SkAxisAlignment:
- return {SkScalarToFixed(position.fX + kSubpixelRounding),
- SkScalarToFixed(position.fY + kSubpixelRounding)};
+ return {SkScalarToFixed(SkScalarFraction(position.fX) + kSubpixelRounding),
+ SkScalarToFixed(SkScalarFraction(position.fY) + kSubpixelRounding)};
}
SkFAIL("Should not get here.");
return {0, 0};