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

Side by Side Diff: include/core/SkScalar.h

Issue 111353003: deprecate SkScalarRound (and its ilk), use SkScalarRound[ToInt,ToScalar]. #define SK_SUPPORT_DEPREC… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « experimental/SkiaExamples/SkExample.cpp ('k') | include/core/SkSize.h » ('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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkScalar_DEFINED 8 #ifndef SkScalar_DEFINED
9 #define SkScalar_DEFINED 9 #define SkScalar_DEFINED
10 10
11 #include "SkFixed.h" 11 #include "SkFixed.h"
12 #include "SkFloatingPoint.h" 12 #include "SkFloatingPoint.h"
13 13
14 //#define SK_SUPPORT_DEPRECATED_SCALARROUND
15
14 typedef float SkScalar; 16 typedef float SkScalar;
15 17
16 /** SK_Scalar1 is defined to be 1.0 represented as an SkScalar 18 /** SK_Scalar1 is defined to be 1.0 represented as an SkScalar
17 */ 19 */
18 #define SK_Scalar1 (1.0f) 20 #define SK_Scalar1 (1.0f)
19 /** SK_Scalar1 is defined to be 1/2 represented as an SkScalar 21 /** SK_Scalar1 is defined to be 1/2 represented as an SkScalar
20 */ 22 */
21 #define SK_ScalarHalf (0.5f) 23 #define SK_ScalarHalf (0.5f)
22 /** SK_ScalarInfinity is defined to be infinity as an SkScalar 24 /** SK_ScalarInfinity is defined to be infinity as an SkScalar
23 */ 25 */
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 */ 103 */
102 inline SkScalar SkScalarSquare(SkScalar x) { return x * x; } 104 inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
103 /** Returns the product of two SkScalars 105 /** Returns the product of two SkScalars
104 */ 106 */
105 #define SkScalarMul(a, b) ((float)(a) * (b)) 107 #define SkScalarMul(a, b) ((float)(a) * (b))
106 /** Returns the product of two SkScalars plus a third SkScalar 108 /** Returns the product of two SkScalars plus a third SkScalar
107 */ 109 */
108 #define SkScalarMulAdd(a, b, c) ((float)(a) * (b) + (c)) 110 #define SkScalarMulAdd(a, b, c) ((float)(a) * (b) + (c))
109 /** Returns the product of a SkScalar and an int rounded to the nearest integer value 111 /** Returns the product of a SkScalar and an int rounded to the nearest integer value
110 */ 112 */
111 #define SkScalarMulRound(a, b) SkScalarRound((float)(a) * (b)) 113 #define SkScalarMulRound(a, b) SkScalarRoundToInt((float)(a) * (b))
112 /** Returns the product of a SkScalar and an int promoted to the next larger int 114 /** Returns the product of a SkScalar and an int promoted to the next larger int
113 */ 115 */
114 #define SkScalarMulCeil(a, b) SkScalarCeil((float)(a) * (b)) 116 #define SkScalarMulCeil(a, b) SkScalarCeilToInt((float)(a) * (b))
115 /** Returns the product of a SkScalar and an int truncated to the next smaller i nt 117 /** Returns the product of a SkScalar and an int truncated to the next smaller i nt
116 */ 118 */
117 #define SkScalarMulFloor(a, b) SkScalarFloor((float)(a) * (b)) 119 #define SkScalarMulFloor(a, b) SkScalarFloorToInt((float)(a) * (b))
118 /** Returns the quotient of two SkScalars (a/b) 120 /** Returns the quotient of two SkScalars (a/b)
119 */ 121 */
120 #define SkScalarDiv(a, b) ((float)(a) / (b)) 122 #define SkScalarDiv(a, b) ((float)(a) / (b))
121 /** Returns the mod of two SkScalars (a mod b) 123 /** Returns the mod of two SkScalars (a mod b)
122 */ 124 */
123 #define SkScalarMod(x,y) sk_float_mod(x,y) 125 #define SkScalarMod(x,y) sk_float_mod(x,y)
124 /** Returns the product of the first two arguments, divided by the third argumen t 126 /** Returns the product of the first two arguments, divided by the third argumen t
125 */ 127 */
126 #define SkScalarMulDiv(a, b, c) ((float)(a) * (b) / (c)) 128 #define SkScalarMulDiv(a, b, c) ((float)(a) * (b) / (c))
127 /** Returns the multiplicative inverse of the SkScalar (1/x) 129 /** Returns the multiplicative inverse of the SkScalar (1/x)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 #define SkScalarLog(x) (float)sk_float_log(x) 163 #define SkScalarLog(x) (float)sk_float_log(x)
162 164
163 inline SkScalar SkMaxScalar(SkScalar a, SkScalar b) { return a > b ? a : b; } 165 inline SkScalar SkMaxScalar(SkScalar a, SkScalar b) { return a > b ? a : b; }
164 inline SkScalar SkMinScalar(SkScalar a, SkScalar b) { return a < b ? a : b; } 166 inline SkScalar SkMinScalar(SkScalar a, SkScalar b) { return a < b ? a : b; }
165 167
166 static inline bool SkScalarIsInt(SkScalar x) { 168 static inline bool SkScalarIsInt(SkScalar x) {
167 return x == (float)(int)x; 169 return x == (float)(int)x;
168 } 170 }
169 171
170 // DEPRECATED : use ToInt or ToScalar variant 172 // DEPRECATED : use ToInt or ToScalar variant
171 #define SkScalarFloor(x) SkScalarFloorToInt(x) 173 #ifdef SK_SUPPORT_DEPRECATED_SCALARROUND
172 #define SkScalarCeil(x) SkScalarCeilToInt(x) 174 # define SkScalarFloor(x) SkScalarFloorToInt(x)
173 #define SkScalarRound(x) SkScalarRoundToInt(x) 175 # define SkScalarCeil(x) SkScalarCeilToInt(x)
176 # define SkScalarRound(x) SkScalarRoundToInt(x)
177 #endif
174 178
175 /** 179 /**
176 * Returns -1 || 0 || 1 depending on the sign of value: 180 * Returns -1 || 0 || 1 depending on the sign of value:
177 * -1 if x < 0 181 * -1 if x < 0
178 * 0 if x == 0 182 * 0 if x == 0
179 * 1 if x > 0 183 * 1 if x > 0
180 */ 184 */
181 static inline int SkScalarSignAsInt(SkScalar x) { 185 static inline int SkScalarSignAsInt(SkScalar x) {
182 return x < 0 ? -1 : (x > 0); 186 return x < 0 ? -1 : (x > 0);
183 } 187 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 SkASSERT(n >= 0); 242 SkASSERT(n >= 0);
239 for (int i = 0; i < n; ++i) { 243 for (int i = 0; i < n; ++i) {
240 if (a[i] != b[i]) { 244 if (a[i] != b[i]) {
241 return false; 245 return false;
242 } 246 }
243 } 247 }
244 return true; 248 return true;
245 } 249 }
246 250
247 #endif 251 #endif
OLDNEW
« no previous file with comments | « experimental/SkiaExamples/SkExample.cpp ('k') | include/core/SkSize.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698