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

Unified Diff: include/core/SkFixed.h

Issue 1583453002: clamp fixed divide to 32 bits (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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: include/core/SkFixed.h
diff --git a/include/core/SkFixed.h b/include/core/SkFixed.h
index 3140b7a35d2439e65a32eb7d7548bbb7d8ca5e93..f6dd3d60020207382e3f9bdf238bde5a0ba8955c 100644
--- a/include/core/SkFixed.h
+++ b/include/core/SkFixed.h
@@ -86,9 +86,9 @@ typedef int32_t SkFixed;
#if defined(SK_SUPPORT_LEGACY_DIVBITS_UB)
#define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16)
#else
- // TODO(reed): this clamp shouldn't be needed. Use SkToS32().
+ // The divide may exceed 32 bits. Clamp to a signed 32 bit result.
#define SkFixedDiv(numer, denom) \
- SkTPin<int32_t>((int32_t)(SkLeftShift((int64_t)numer, 16) / denom), SK_MinS32, SK_MaxS32)
+ SkToS32(SkTPin<int64_t>((SkLeftShift((int64_t)numer, 16) / denom), SK_MinS32, SK_MaxS32))
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////
« 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