From d48ad8e33307ad651264a3c3068b4468201fccf6 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Tue, 1 Apr 2014 16:11:53 +0000 Subject: [PATCH] Fold SkTSetBit into SkOTSet*Bit. 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 | 10 ---------- src/sfnt/SkOTTableTypes.h | 8 +++++--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h index 4bcaf3f7b3..a6248f547f 100644 --- a/include/core/SkTemplates.h +++ b/include/core/SkTemplates.h @@ -11,7 +11,6 @@ #define SkTemplates_DEFINED #include "SkTypes.h" -#include #include #include @@ -66,15 +65,6 @@ template static D* SkTAddOffset(S* ptr, size_t byteOffs ); } -/** SkTSetBit::value is a T with the Nth bit set. */ -template struct SkTSetBit { - static const T value = static_cast(1) << N; - SK_COMPILE_ASSERT(sizeof(T)*CHAR_BIT > N, SkTSetBit_N_too_large); - SK_COMPILE_ASSERT(std::numeric_limits::is_integer, SkTSetBit_T_must_be_integer); - SK_COMPILE_ASSERT(!std::numeric_limits::is_signed, SkTSetBit_T_must_be_unsigned); - SK_COMPILE_ASSERT(std::numeric_limits::radix == 2, SkTSetBit_T_radix_must_be_2); -}; - /** \class SkAutoTCallVProc Call a function when this goes out of scope. The template uses two diff --git a/src/sfnt/SkOTTableTypes.h b/src/sfnt/SkOTTableTypes.h index c978cc0179..1f49518d59 100644 --- a/src/sfnt/SkOTTableTypes.h +++ b/src/sfnt/SkOTTableTypes.h @@ -48,13 +48,15 @@ public: /** SkOTSetUSHORTBit::value is an SK_OT_USHORT with the Nth BE bit set. */ template struct SkOTSetUSHORTBit { - static const uint16_t bit = SkTSetBit::value; + SK_COMPILE_ASSERT(N < 16, NTooBig); + static const uint16_t bit = 1u << N; static const SK_OT_USHORT value = SkTEndian_SwapBE16(bit); }; -/** SkOTSetUSHORTBit::value is an SK_OT_ULONG with the Nth BE bit set. */ +/** SkOTSetULONGBit::value is an SK_OT_ULONG with the Nth BE bit set. */ template struct SkOTSetULONGBit { - static const uint32_t bit = SkTSetBit::value; + SK_COMPILE_ASSERT(N < 32, NTooBig); + static const uint32_t bit = 1u << N; static const SK_OT_ULONG value = SkTEndian_SwapBE32(bit); };