blob: b705a650ea2ce237ffef6a0f9d39b252052f9aab [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
reed@android.com8a1c16f2008-12-17 15:59:43 +00009
10#include "SkTypes.h"
11
12#ifdef SK_DEBUG
13
bungeman@google.com777ded02013-07-19 22:30:11 +000014int8_t SkToS8(intmax_t x) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000015 SkASSERT((int8_t)x == x);
16 return (int8_t)x;
17}
18
bungeman@google.com777ded02013-07-19 22:30:11 +000019uint8_t SkToU8(uintmax_t x) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000020 SkASSERT((uint8_t)x == x);
21 return (uint8_t)x;
22}
23
bungeman@google.com777ded02013-07-19 22:30:11 +000024int16_t SkToS16(intmax_t x) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000025 SkASSERT((int16_t)x == x);
26 return (int16_t)x;
27}
28
bungeman@google.com777ded02013-07-19 22:30:11 +000029uint16_t SkToU16(uintmax_t x) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000030 SkASSERT((uint16_t)x == x);
31 return (uint16_t)x;
32}
33
bungeman@google.com777ded02013-07-19 22:30:11 +000034int32_t SkToS32(intmax_t x) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000035 SkASSERT((int32_t)x == x);
36 return (int32_t)x;
37}
38
bungeman@google.com777ded02013-07-19 22:30:11 +000039uint32_t SkToU32(uintmax_t x) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000040 SkASSERT((uint32_t)x == x);
41 return (uint32_t)x;
42}
43
commit-bot@chromium.orga8c7f772014-01-24 21:46:29 +000044int SkToInt(intmax_t x) {
45 SkASSERT((int)x == x);
46 return (int)x;
47}
48
reed@google.com7fa2a652014-01-27 13:42:58 +000049unsigned SkToUInt(uintmax_t x) {
50 SkASSERT((unsigned)x == x);
51 return (unsigned)x;
52}
53
commit-bot@chromium.org490fb6b2014-03-06 17:16:26 +000054size_t SkToSizeT(uintmax_t x) {
55 SkASSERT((size_t)x == x);
56 return (size_t)x;
57}
58
reed@android.com8a1c16f2008-12-17 15:59:43 +000059#endif