Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: src/core/SkFindAndPlaceGlyph.h

Issue 1779083003: Ensure only fractional floats are converted to SkFixed in SubpixelAlignment. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFindAndPlaceGlyph.h
diff --git a/src/core/SkFindAndPlaceGlyph.h b/src/core/SkFindAndPlaceGlyph.h
index 18b93f70a466291cc1f44989f3d75463442ad919..35ae77cfe3191c2cf8ff4dbfd54e1cb048bbfd8c 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};
bungeman-skia 2016/03/10 20:55:58 SkScalarFraction is currently really super slow. I
dogben 2016/03/10 21:16:22 I maybe ought to always return positive numbers to
bungeman-skia 2016/03/10 21:37:49 Always returning positive numbers would just be ex
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};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698