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

Unified Diff: src/core/SkEdge.cpp

Issue 1503423003: ubsan shift fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add cast to work around win compiler Created 5 years 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 | « src/core/SkEdge.h ('k') | src/core/SkFDot6.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkEdge.cpp
diff --git a/src/core/SkEdge.cpp b/src/core/SkEdge.cpp
index f91f5f87829c45cd221dcefecfe00f6091f8f0e4..c64896f2e0345125ba35d8b5728fb92c612773f9 100644
--- a/src/core/SkEdge.cpp
+++ b/src/core/SkEdge.cpp
@@ -26,7 +26,7 @@
static inline SkFixed SkFDot6ToFixedDiv2(SkFDot6 value) {
// we want to return SkFDot6ToFixed(value >> 1), but we don't want to throw
// away data in value, so just perform a modify up-shift
- return value << (16 - 6 - 1);
+ return SkLeftShift(value, 16 - 6 - 1);
}
/////////////////////////////////////////////////////////////////////////
@@ -214,8 +214,8 @@ int SkQuadraticEdge::setQuadratic(const SkPoint pts[3], int shift)
// compute number of steps needed (1 << shift)
{
- SkFDot6 dx = ((x1 << 1) - x0 - x2) >> 2;
- SkFDot6 dy = ((y1 << 1) - y0 - y2) >> 2;
+ SkFDot6 dx = (SkLeftShift(x1, 1) - x0 - x2) >> 2;
+ SkFDot6 dy = (SkLeftShift(y1, 1) - y0 - y2) >> 2;
shift = diff_to_shift(dx, dy);
SkASSERT(shift >= 0);
}
@@ -312,8 +312,8 @@ int SkQuadraticEdge::updateQuadratic()
/////////////////////////////////////////////////////////////////////////
static inline int SkFDot6UpShift(SkFDot6 x, int upShift) {
- SkASSERT((x << upShift >> upShift) == x);
- return x << upShift;
+ SkASSERT((SkLeftShift(x, upShift) >> upShift) == x);
+ return SkLeftShift(x, upShift);
}
/* f(1/3) = (8a + 12b + 6c + d) / 27
@@ -403,7 +403,7 @@ int SkCubicEdge::setCubic(const SkPoint pts[4], int shift) {
}
fWinding = SkToS8(winding);
- fCurveCount = SkToS8(-1 << shift);
+ fCurveCount = SkToS8(SkLeftShift(-1, shift));
fCurveShift = SkToU8(shift);
fCubicDShift = SkToU8(downShift);
« no previous file with comments | « src/core/SkEdge.h ('k') | src/core/SkFDot6.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698