Ensure only fractional floats are converted to SkFixed in SubpixelAlignment.
BUG=skia:4632 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1779083003 Review URL: https://codereview.chromium.org/1779083003
This commit is contained in:
parent
e683c56115
commit
db6bd3239f
@ -381,14 +381,16 @@ private:
|
|||||||
// produce the correct sub-pixel alignment. If a position is aligned with an axis a shortcut
|
// 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.
|
// of 0 is used for the sub-pixel position.
|
||||||
static SkIPoint SubpixelAlignment(SkAxisAlignment axisAlignment, SkPoint 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) {
|
switch (axisAlignment) {
|
||||||
case kX_SkAxisAlignment:
|
case kX_SkAxisAlignment:
|
||||||
return {SkScalarToFixed(position.fX + kSubpixelRounding), 0};
|
return {SkScalarToFixed(SkScalarFraction(position.fX) + kSubpixelRounding), 0};
|
||||||
case kY_SkAxisAlignment:
|
case kY_SkAxisAlignment:
|
||||||
return {0, SkScalarToFixed(position.fY + kSubpixelRounding)};
|
return {0, SkScalarToFixed(SkScalarFraction(position.fY) + kSubpixelRounding)};
|
||||||
case kNone_SkAxisAlignment:
|
case kNone_SkAxisAlignment:
|
||||||
return {SkScalarToFixed(position.fX + kSubpixelRounding),
|
return {SkScalarToFixed(SkScalarFraction(position.fX) + kSubpixelRounding),
|
||||||
SkScalarToFixed(position.fY + kSubpixelRounding)};
|
SkScalarToFixed(SkScalarFraction(position.fY) + kSubpixelRounding)};
|
||||||
}
|
}
|
||||||
SkFAIL("Should not get here.");
|
SkFAIL("Should not get here.");
|
||||||
return {0, 0};
|
return {0, 0};
|
||||||
|
Loading…
Reference in New Issue
Block a user