From f6fde175b81db98cd3799ee88714a4c579bb44bd Mon Sep 17 00:00:00 2001 From: mtklein Date: Tue, 30 Sep 2014 15:22:06 -0700 Subject: [PATCH] Archive more dead code. BUG=skia: R=reed@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/617003004 --- gyp/core.gypi | 2 - gyp/tests.gypi | 1 - include/core/SkFixed.h | 12 -- src/core/SkMath.cpp | 113 ---------------- src/core/SkMiniData.cpp | 80 ------------ src/core/SkMiniData.h | 24 ---- src/core/SkSinTable.h | 277 ---------------------------------------- tests/MiniDataTest.cpp | 16 --- 8 files changed, 525 deletions(-) delete mode 100644 src/core/SkMiniData.cpp delete mode 100644 src/core/SkMiniData.h delete mode 100644 src/core/SkSinTable.h delete mode 100644 tests/MiniDataTest.cpp diff --git a/gyp/core.gypi b/gyp/core.gypi index 49027a91f2..e6a131c426 100644 --- a/gyp/core.gypi +++ b/gyp/core.gypi @@ -110,7 +110,6 @@ '<(skia_src_path)/core/SkMatrix.cpp', '<(skia_src_path)/core/SkMessageBus.h', '<(skia_src_path)/core/SkMetaData.cpp', - '<(skia_src_path)/core/SkMiniData.cpp', '<(skia_src_path)/core/SkMipMap.cpp', '<(skia_src_path)/core/SkMultiPictureDraw.cpp', '<(skia_src_path)/core/SkPackBits.cpp', @@ -174,7 +173,6 @@ '<(skia_src_path)/core/SkShader.cpp', '<(skia_src_path)/core/SkSpriteBlitter_ARGB32.cpp', '<(skia_src_path)/core/SkSpriteBlitter_RGB16.cpp', - '<(skia_src_path)/core/SkSinTable.h', '<(skia_src_path)/core/SkSpriteBlitter.h', '<(skia_src_path)/core/SkSpriteBlitterTemplate.h', '<(skia_src_path)/core/SkStream.cpp', diff --git a/gyp/tests.gypi b/gyp/tests.gypi index f50dc295cd..6afc7f07ad 100644 --- a/gyp/tests.gypi +++ b/gyp/tests.gypi @@ -139,7 +139,6 @@ '../tests/MemsetTest.cpp', '../tests/MessageBusTest.cpp', '../tests/MetaDataTest.cpp', - '../tests/MiniDataTest.cpp', '../tests/MipMapTest.cpp', '../tests/NameAllocatorTest.cpp', '../tests/OSPathTest.cpp', diff --git a/include/core/SkFixed.h b/include/core/SkFixed.h index 6f168c8edd..488836c060 100644 --- a/include/core/SkFixed.h +++ b/include/core/SkFixed.h @@ -82,18 +82,6 @@ SkFixed SkFixedMul_portable(SkFixed, SkFixed); #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16) -/////////////////////////////////////////////////////////////////////////////// -// TODO: move fixed sin/cos into SkCosineMapper, as that is the only caller -// or rewrite SkCosineMapper to not use it at all - -SkFixed SkFixedSinCos(SkFixed radians, SkFixed* cosValueOrNull); -#define SkFixedSin(radians) SkFixedSinCos(radians, NULL) -static inline SkFixed SkFixedCos(SkFixed radians) { - SkFixed cosValue; - (void)SkFixedSinCos(radians, &cosValue); - return cosValue; -} - ////////////////////////////////////////////////////////////////////////////////////////////////////// // Now look for ASM overrides for our portable versions (should consider putting this in its own file) diff --git a/src/core/SkMath.cpp b/src/core/SkMath.cpp index aeacebecd4..e33fe55e01 100644 --- a/src/core/SkMath.cpp +++ b/src/core/SkMath.cpp @@ -174,116 +174,3 @@ float SkScalarSinCos(float radians, float* cosValue) { } return sinValue; } - -#define INTERP_SINTABLE -#define BUILD_TABLE_AT_RUNTIMEx - -#define kTableSize 256 - -#ifdef BUILD_TABLE_AT_RUNTIME - static uint16_t gSkSinTable[kTableSize]; - - static void build_sintable(uint16_t table[]) { - for (int i = 0; i < kTableSize; i++) { - double rad = i * 3.141592653589793 / (2*kTableSize); - double val = sin(rad); - int ival = (int)(val * SK_Fixed1); - table[i] = SkToU16(ival); - } - } -#else - #include "SkSinTable.h" -#endif - -#define SK_Fract1024SizeOver2PI 0x28BE60 /* floatToFract(1024 / 2PI) */ - -#ifdef INTERP_SINTABLE -static SkFixed interp_table(const uint16_t table[], int index, int partial255) { - SkASSERT((unsigned)index < kTableSize); - SkASSERT((unsigned)partial255 <= 255); - - SkFixed lower = table[index]; - SkFixed upper = (index == kTableSize - 1) ? SK_Fixed1 : table[index + 1]; - - SkASSERT(lower < upper); - SkASSERT(lower >= 0); - SkASSERT(upper <= SK_Fixed1); - - partial255 += (partial255 >> 7); - return lower + ((upper - lower) * partial255 >> 8); -} -#endif - -SkFixed SkFixedSinCos(SkFixed radians, SkFixed* cosValuePtr) { - SkASSERT(SK_ARRAY_COUNT(gSkSinTable) == kTableSize); - -#ifdef BUILD_TABLE_AT_RUNTIME - static bool gFirstTime = true; - if (gFirstTime) { - build_sintable(gSinTable); - gFirstTime = false; - } -#endif - - // make radians positive - SkFixed sinValue, cosValue; - int32_t cosSign = 0; - int32_t sinSign = SkExtractSign(radians); - radians = SkApplySign(radians, sinSign); - // scale it to 0...1023 ... - -#ifdef INTERP_SINTABLE - radians = SkMulDiv(radians, 2 * kTableSize * 256, SK_FixedPI); - int findex = radians & (kTableSize * 256 - 1); - int index = findex >> 8; - int partial = findex & 255; - sinValue = interp_table(gSkSinTable, index, partial); - - findex = kTableSize * 256 - findex - 1; - index = findex >> 8; - partial = findex & 255; - cosValue = interp_table(gSkSinTable, index, partial); - - int quad = ((unsigned)radians / (kTableSize * 256)) & 3; -#else - radians = SkMulDiv(radians, 2 * kTableSize, SK_FixedPI); - int index = radians & (kTableSize - 1); - - if (index == 0) { - sinValue = 0; - cosValue = SK_Fixed1; - } else { - sinValue = gSkSinTable[index]; - cosValue = gSkSinTable[kTableSize - index]; - } - int quad = ((unsigned)radians / kTableSize) & 3; -#endif - - if (quad & 1) { - SkTSwap(sinValue, cosValue); - } - if (quad & 2) { - sinSign = ~sinSign; - } - if (((quad - 1) & 2) == 0) { - cosSign = ~cosSign; - } - - // restore the sign for negative angles - sinValue = SkApplySign(sinValue, sinSign); - cosValue = SkApplySign(cosValue, cosSign); - -#ifdef SK_DEBUG - if (1) { - SkFixed sin2 = SkFixedMul(sinValue, sinValue); - SkFixed cos2 = SkFixedMul(cosValue, cosValue); - int diff = cos2 + sin2 - SK_Fixed1; - SkASSERT(SkAbs32(diff) <= 7); - } -#endif - - if (cosValuePtr) { - *cosValuePtr = cosValue; - } - return sinValue; -} diff --git a/src/core/SkMiniData.cpp b/src/core/SkMiniData.cpp deleted file mode 100644 index ded62d1687..0000000000 --- a/src/core/SkMiniData.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "SkMiniData.h" - -namespace { - -// SkMiniData::fRep either stores a LongData* or is punned into a ShortData. -// We use the low bits to distinguish the two: all pointers from malloc are at -// least 8-byte aligned, leaving those low bits clear when it's a LongData*. - -static bool is_long(uint64_t rep) { - // Even on 32-bit machines, we require the bottom 3 bits from malloc'd pointers are clear. - // If any of those bottom 3 bits are set, it's from a ShortData's len. And if no bits are - // set anywhere, it's an empty SkMiniData, which also follows the ShortData path. - return rep && SkIsAlign8(rep); -} - -// Can be used for any length, but we always use it for >=8. -struct LongData { - size_t len; - uint8_t data[8]; // There are actually len >= 8 bytes here. - - static uint64_t Create(const void* data, size_t len) { - SkASSERT(len > 7); - LongData* s = (LongData*)sk_malloc_throw(sizeof(size_t) + len); - s->len = len; - memcpy(s->data, data, len); - - uint64_t rep = reinterpret_cast(s); - SkASSERT(is_long(rep)); - return rep; - } -}; - -// At most 7 bytes fit, but never mallocs. -struct ShortData { - // Order matters here. len must align with the least signficant bits of a pointer. -#ifdef SK_CPU_LENDIAN - uint8_t len; - uint8_t data[7]; -#else // Warning! Only the little-endian path has been tested. - uint8_t data[7]; - uint8_t len; -#endif - - static uint64_t Create(const void* data, size_t len) { - SkASSERT(len <= 7); -#ifdef SK_CPU_LENDIAN - ShortData s = { (uint8_t)len, {0, 0, 0, 0, 0, 0, 0} }; -#else // Warning! Only the little-endian path has been tested. - ShortData s = { {0, 0, 0, 0, 0, 0, 0}, (uint8_t)len }; -#endif - memcpy(s.data, data, len); - return *reinterpret_cast(&s); - } -}; - -} // namespace - -SkMiniData::SkMiniData(const void* data, size_t len) - : fRep(len <= 7 ? ShortData::Create(data, len) - : LongData::Create(data, len)) {} - -SkMiniData::SkMiniData(const SkMiniData& s) - : fRep(s.len() <= 7 ? ShortData::Create(s.data(), s.len()) - : LongData::Create(s.data(), s.len())) {} - -SkMiniData::~SkMiniData() { - if (is_long(fRep)) { - sk_free(reinterpret_cast(fRep)); - } -} - -const void* SkMiniData::data() const { - return is_long(fRep) ? reinterpret_cast( fRep)->data - : reinterpret_cast(&fRep)->data; -} - -size_t SkMiniData::len() const { - return is_long(fRep) ? reinterpret_cast( fRep)->len - : reinterpret_cast(&fRep)->len; -} diff --git a/src/core/SkMiniData.h b/src/core/SkMiniData.h deleted file mode 100644 index fd22cea9ca..0000000000 --- a/src/core/SkMiniData.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef SkMiniData_DEFINED -#define SkMiniData_DEFINED - -// A class that can store any immutable byte string, -// but optimized to store <=7 bytes. - -#include "SkTypes.h" - -class SkMiniData { -public: - SkMiniData(const void*, size_t); - SkMiniData(const SkMiniData&); - ~SkMiniData(); - - const void* data() const; - size_t len() const; - -private: - SkMiniData& operator=(const SkMiniData&); - - const uint64_t fRep; -}; - -#endif//SkMiniData_DEFINED diff --git a/src/core/SkSinTable.h b/src/core/SkSinTable.h deleted file mode 100644 index ac26b9e59b..0000000000 --- a/src/core/SkSinTable.h +++ /dev/null @@ -1,277 +0,0 @@ - -/* - * Copyright 2006 The Android Open Source Project - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#ifndef SkSinTable_DEFINED -#define SkSinTable_DEFINED - -#include "SkTypes.h" - -/* Fixed point values (low 16 bits) of sin(radians) for - radians in [0...PI/2) -*/ -static const uint16_t gSkSinTable[256] = { - 0x0000, - 0x0192, - 0x0324, - 0x04B6, - 0x0648, - 0x07DA, - 0x096C, - 0x0AFE, - 0x0C8F, - 0x0E21, - 0x0FB2, - 0x1144, - 0x12D5, - 0x1466, - 0x15F6, - 0x1787, - 0x1917, - 0x1AA7, - 0x1C37, - 0x1DC7, - 0x1F56, - 0x20E5, - 0x2273, - 0x2402, - 0x2590, - 0x271D, - 0x28AA, - 0x2A37, - 0x2BC4, - 0x2D50, - 0x2EDB, - 0x3066, - 0x31F1, - 0x337B, - 0x3505, - 0x368E, - 0x3817, - 0x399F, - 0x3B26, - 0x3CAD, - 0x3E33, - 0x3FB9, - 0x413E, - 0x42C3, - 0x4447, - 0x45CA, - 0x474D, - 0x48CE, - 0x4A50, - 0x4BD0, - 0x4D50, - 0x4ECF, - 0x504D, - 0x51CA, - 0x5347, - 0x54C3, - 0x563E, - 0x57B8, - 0x5931, - 0x5AAA, - 0x5C22, - 0x5D98, - 0x5F0E, - 0x6083, - 0x61F7, - 0x636A, - 0x64DC, - 0x664D, - 0x67BD, - 0x692D, - 0x6A9B, - 0x6C08, - 0x6D74, - 0x6EDF, - 0x7049, - 0x71B1, - 0x7319, - 0x7480, - 0x75E5, - 0x774A, - 0x78AD, - 0x7A0F, - 0x7B70, - 0x7CD0, - 0x7E2E, - 0x7F8B, - 0x80E7, - 0x8242, - 0x839C, - 0x84F4, - 0x864B, - 0x87A1, - 0x88F5, - 0x8A48, - 0x8B9A, - 0x8CEA, - 0x8E39, - 0x8F87, - 0x90D3, - 0x921E, - 0x9368, - 0x94B0, - 0x95F6, - 0x973C, - 0x987F, - 0x99C2, - 0x9B02, - 0x9C42, - 0x9D7F, - 0x9EBC, - 0x9FF6, - 0xA12F, - 0xA267, - 0xA39D, - 0xA4D2, - 0xA605, - 0xA736, - 0xA866, - 0xA994, - 0xAAC0, - 0xABEB, - 0xAD14, - 0xAE3B, - 0xAF61, - 0xB085, - 0xB1A8, - 0xB2C8, - 0xB3E7, - 0xB504, - 0xB620, - 0xB73A, - 0xB852, - 0xB968, - 0xBA7C, - 0xBB8F, - 0xBCA0, - 0xBDAE, - 0xBEBC, - 0xBFC7, - 0xC0D0, - 0xC1D8, - 0xC2DE, - 0xC3E2, - 0xC4E3, - 0xC5E4, - 0xC6E2, - 0xC7DE, - 0xC8D8, - 0xC9D1, - 0xCAC7, - 0xCBBB, - 0xCCAE, - 0xCD9F, - 0xCE8D, - 0xCF7A, - 0xD064, - 0xD14D, - 0xD233, - 0xD318, - 0xD3FA, - 0xD4DB, - 0xD5B9, - 0xD695, - 0xD770, - 0xD848, - 0xD91E, - 0xD9F2, - 0xDAC4, - 0xDB94, - 0xDC61, - 0xDD2D, - 0xDDF6, - 0xDEBE, - 0xDF83, - 0xE046, - 0xE106, - 0xE1C5, - 0xE282, - 0xE33C, - 0xE3F4, - 0xE4AA, - 0xE55E, - 0xE60F, - 0xE6BE, - 0xE76B, - 0xE816, - 0xE8BF, - 0xE965, - 0xEA09, - 0xEAAB, - 0xEB4B, - 0xEBE8, - 0xEC83, - 0xED1C, - 0xEDB2, - 0xEE46, - 0xEED8, - 0xEF68, - 0xEFF5, - 0xF080, - 0xF109, - 0xF18F, - 0xF213, - 0xF294, - 0xF314, - 0xF391, - 0xF40B, - 0xF484, - 0xF4FA, - 0xF56D, - 0xF5DE, - 0xF64D, - 0xF6BA, - 0xF724, - 0xF78B, - 0xF7F1, - 0xF853, - 0xF8B4, - 0xF912, - 0xF96E, - 0xF9C7, - 0xFA1E, - 0xFA73, - 0xFAC5, - 0xFB14, - 0xFB61, - 0xFBAC, - 0xFBF5, - 0xFC3B, - 0xFC7E, - 0xFCBF, - 0xFCFE, - 0xFD3A, - 0xFD74, - 0xFDAB, - 0xFDE0, - 0xFE13, - 0xFE43, - 0xFE70, - 0xFE9B, - 0xFEC4, - 0xFEEA, - 0xFF0E, - 0xFF2F, - 0xFF4E, - 0xFF6A, - 0xFF84, - 0xFF9C, - 0xFFB1, - 0xFFC3, - 0xFFD3, - 0xFFE1, - 0xFFEC, - 0xFFF4, - 0xFFFB, - 0xFFFE -}; - -#endif diff --git a/tests/MiniDataTest.cpp b/tests/MiniDataTest.cpp deleted file mode 100644 index cb656b3e5a..0000000000 --- a/tests/MiniDataTest.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "SkMiniData.h" -#include "Test.h" - -DEF_TEST(MiniData, r) { - static const char* s = "abcdefghijklmnopqrstuvwxyz"; - - for (size_t len = 0; len <= 26; len++) { - SkMiniData md(s, len); - REPORTER_ASSERT(r, md.len() == len); - REPORTER_ASSERT(r, 0 == memcmp(md.data(), s, len)); - - SkMiniData copy(md); - REPORTER_ASSERT(r, copy.len() == len); - REPORTER_ASSERT(r, 0 == memcmp(copy.data(), s, len)); - } -}