skia2/include/private/SkTo.h
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00

29 lines
1.2 KiB
C++

/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkTo_DEFINED
#define SkTo_DEFINED
#include "include/core/SkTypes.h"
#include "include/private/SkTFitsIn.h"
template <typename D, typename S> constexpr D SkTo(S s) {
return SkASSERT(SkTFitsIn<D>(s)),
static_cast<D>(s);
}
template <typename S> constexpr int8_t SkToS8(S x) { return SkTo<int8_t>(x); }
template <typename S> constexpr uint8_t SkToU8(S x) { return SkTo<uint8_t>(x); }
template <typename S> constexpr int16_t SkToS16(S x) { return SkTo<int16_t>(x); }
template <typename S> constexpr uint16_t SkToU16(S x) { return SkTo<uint16_t>(x); }
template <typename S> constexpr int32_t SkToS32(S x) { return SkTo<int32_t>(x); }
template <typename S> constexpr uint32_t SkToU32(S x) { return SkTo<uint32_t>(x); }
template <typename S> constexpr int SkToInt(S x) { return SkTo<int>(x); }
template <typename S> constexpr unsigned SkToUInt(S x) { return SkTo<unsigned>(x); }
template <typename S> constexpr size_t SkToSizeT(S x) { return SkTo<size_t>(x); }
#endif // SkTo_DEFINED