Fold SkTSetBit into SkOTSet*Bit.
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 1 Apr 2014 16:11:53 +0000 (16:11 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 1 Apr 2014 16:11:53 +0000 (16:11 +0000)
BUG=b/13729420
R=bungeman@google.com, mtklein@google.com, bsalomon@google.com, reed@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/219023011

git-svn-id: http://skia.googlecode.com/svn/trunk@14009 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkTemplates.h
src/sfnt/SkOTTableTypes.h

index 4bcaf3f..a6248f5 100644 (file)
@@ -11,7 +11,6 @@
 #define SkTemplates_DEFINED
 
 #include "SkTypes.h"
-#include <limits>
 #include <limits.h>
 #include <new>
 
@@ -66,15 +65,6 @@ template <typename D, typename S> static D* SkTAddOffset(S* ptr, size_t byteOffs
     );
 }
 
-/** SkTSetBit<N, T>::value is a T with the Nth bit set. */
-template<unsigned N, typename T = uintmax_t> struct SkTSetBit {
-    static const T value = static_cast<T>(1) << N;
-    SK_COMPILE_ASSERT(sizeof(T)*CHAR_BIT > N, SkTSetBit_N_too_large);
-    SK_COMPILE_ASSERT(std::numeric_limits<T>::is_integer, SkTSetBit_T_must_be_integer);
-    SK_COMPILE_ASSERT(!std::numeric_limits<T>::is_signed, SkTSetBit_T_must_be_unsigned);
-    SK_COMPILE_ASSERT(std::numeric_limits<T>::radix == 2, SkTSetBit_T_radix_must_be_2);
-};
-
 /** \class SkAutoTCallVProc
 
     Call a function when this goes out of scope. The template uses two
index c978cc0..1f49518 100644 (file)
@@ -48,13 +48,15 @@ public:
 
 /** SkOTSetUSHORTBit<N>::value is an SK_OT_USHORT with the Nth BE bit set. */
 template <unsigned N> struct SkOTSetUSHORTBit {
-    static const uint16_t bit = SkTSetBit<N, uint16_t>::value;
+    SK_COMPILE_ASSERT(N < 16, NTooBig);
+    static const uint16_t bit = 1u << N;
     static const SK_OT_USHORT value = SkTEndian_SwapBE16(bit);
 };
 
-/** SkOTSetUSHORTBit<N>::value is an SK_OT_ULONG with the Nth BE bit set. */
+/** SkOTSetULONGBit<N>::value is an SK_OT_ULONG with the Nth BE bit set. */
 template <unsigned N> struct SkOTSetULONGBit {
-    static const uint32_t bit = SkTSetBit<N, uint32_t>::value;
+    SK_COMPILE_ASSERT(N < 32, NTooBig);
+    static const uint32_t bit = 1u << N;
     static const SK_OT_ULONG value = SkTEndian_SwapBE32(bit);
 };