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

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

Issue 1820433002: Revert of Templatize SkToXXX. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « include/core/SkString.h ('k') | include/private/SkTFitsIn.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 SkTypes_DEFINED 8 #ifndef SkTypes_DEFINED
9 #define SkTypes_DEFINED 9 #define SkTypes_DEFINED
10 10
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 * Fast type for unsigned 16 bits. Use for parameter passing and local 249 * Fast type for unsigned 16 bits. Use for parameter passing and local
250 * variables, not for storage 250 * variables, not for storage
251 */ 251 */
252 typedef unsigned U16CPU; 252 typedef unsigned U16CPU;
253 253
254 /** 254 /**
255 * Meant to be a small version of bool, for storage purposes. Will be 0 or 1 255 * Meant to be a small version of bool, for storage purposes. Will be 0 or 1
256 */ 256 */
257 typedef uint8_t SkBool8; 257 typedef uint8_t SkBool8;
258 258
259 #include "../private/SkTFitsIn.h" 259 #ifdef SK_DEBUG
260 template <typename D, typename S> D SkTo(S s) { 260 SK_API int8_t SkToS8(intmax_t);
261 SkASSERT(SkTFitsIn<D>(s)); 261 SK_API uint8_t SkToU8(uintmax_t);
262 return static_cast<D>(s); 262 SK_API int16_t SkToS16(intmax_t);
263 } 263 SK_API uint16_t SkToU16(uintmax_t);
264 #define SkToS8(x) SkTo<int8_t>(x) 264 SK_API int32_t SkToS32(intmax_t);
265 #define SkToU8(x) SkTo<uint8_t>(x) 265 SK_API uint32_t SkToU32(uintmax_t);
266 #define SkToS16(x) SkTo<int16_t>(x) 266 SK_API int SkToInt(intmax_t);
267 #define SkToU16(x) SkTo<uint16_t>(x) 267 SK_API unsigned SkToUInt(uintmax_t);
268 #define SkToS32(x) SkTo<int32_t>(x) 268 SK_API size_t SkToSizeT(uintmax_t);
269 #define SkToU32(x) SkTo<uint32_t>(x) 269 #else
270 #define SkToInt(x) SkTo<int>(x) 270 #define SkToS8(x) ((int8_t)(x))
271 #define SkToUInt(x) SkTo<unsigned>(x) 271 #define SkToU8(x) ((uint8_t)(x))
272 #define SkToSizeT(x) SkTo<size_t>(x) 272 #define SkToS16(x) ((int16_t)(x))
273 #define SkToU16(x) ((uint16_t)(x))
274 #define SkToS32(x) ((int32_t)(x))
275 #define SkToU32(x) ((uint32_t)(x))
276 #define SkToInt(x) ((int)(x))
277 #define SkToUInt(x) ((unsigned)(x))
278 #define SkToSizeT(x) ((size_t)(x))
279 #endif
273 280
274 /** Returns 0 or 1 based on the condition 281 /** Returns 0 or 1 based on the condition
275 */ 282 */
276 #define SkToBool(cond) ((cond) != 0) 283 #define SkToBool(cond) ((cond) != 0)
277 284
278 #define SK_MaxS16 32767 285 #define SK_MaxS16 32767
279 #define SK_MinS16 -32767 286 #define SK_MinS16 -32767
280 #define SK_MaxU16 0xFFFF 287 #define SK_MaxU16 0xFFFF
281 #define SK_MinU16 0 288 #define SK_MinU16 0
282 #define SK_MaxS32 0x7FFFFFFF 289 #define SK_MaxS32 0x7FFFFFFF
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 702
696 void* fPtr; 703 void* fPtr;
697 size_t fSize; // can be larger than the requested size (see kReuse) 704 size_t fSize; // can be larger than the requested size (see kReuse)
698 uint32_t fStorage[kSize >> 2]; 705 uint32_t fStorage[kSize >> 2];
699 }; 706 };
700 // Can't guard the constructor because it's a template class. 707 // Can't guard the constructor because it's a template class.
701 708
702 #endif /* C++ */ 709 #endif /* C++ */
703 710
704 #endif 711 #endif
OLDNEW
« no previous file with comments | « include/core/SkString.h ('k') | include/private/SkTFitsIn.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698