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

Side by Side Diff: src/core/SkFDot6.h

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 unified diff | Download patch
« no previous file with comments | « src/core/SkEdge.cpp ('k') | src/core/SkFloatBits.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkFDot6_DEFINED 10 #ifndef SkFDot6_DEFINED
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #define SkIntToFDot6(x) ((x) << 6) 49 #define SkIntToFDot6(x) ((x) << 6)
50 #endif 50 #endif
51 51
52 #define SkFDot6Floor(x) ((x) >> 6) 52 #define SkFDot6Floor(x) ((x) >> 6)
53 #define SkFDot6Ceil(x) (((x) + 63) >> 6) 53 #define SkFDot6Ceil(x) (((x) + 63) >> 6)
54 #define SkFDot6Round(x) (((x) + 32) >> 6) 54 #define SkFDot6Round(x) (((x) + 32) >> 6)
55 55
56 #define SkFixedToFDot6(x) ((x) >> 10) 56 #define SkFixedToFDot6(x) ((x) >> 10)
57 57
58 inline SkFixed SkFDot6ToFixed(SkFDot6 x) { 58 inline SkFixed SkFDot6ToFixed(SkFDot6 x) {
59 SkASSERT((x << 10 >> 10) == x); 59 SkASSERT((SkLeftShift(x, 10) >> 10) == x);
60 60
61 return x << 10; 61 return SkLeftShift(x, 10);
62 } 62 }
63 63
64 #define SkScalarToFDot6(x) (SkFDot6)((x) * 64) 64 #define SkScalarToFDot6(x) (SkFDot6)((x) * 64)
65 #define SkFDot6ToScalar(x) ((SkScalar)(x) * 0.015625f) 65 #define SkFDot6ToScalar(x) ((SkScalar)(x) * 0.015625f)
66 66
67 inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b) { 67 inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b) {
68 SkASSERT(b != 0); 68 SkASSERT(b != 0);
69 69
70 if (a == (int16_t)a) { 70 if (a == (int16_t)a) {
71 return (a << 16) / b; 71 return SkLeftShift(a, 16) / b;
72 } else { 72 } else {
73 return SkFixedDiv(a, b); 73 return SkFixedDiv(a, b);
74 } 74 }
75 } 75 }
76 76
77 #endif 77 #endif
OLDNEW
« no previous file with comments | « src/core/SkEdge.cpp ('k') | src/core/SkFloatBits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698