diff options
author | Hal Canary <halcanary@google.com> | 2018-06-13 15:01:39 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-14 14:10:47 +0000 |
commit | e1bc7de7c07686b28b00b850e44e0722189f3592 (patch) | |
tree | 827ddab1abd7f6df76287bdab1ed65ccf6801e36 | |
parent | b6b5b7a8082eddc6b198817ab0ea7d9c9f5dd4e4 (diff) |
Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines.
sed 's/SK_MaxSizeT/SIZE_MAX/g'
sed 's/SK_MaxU32/UINT32_MAX/g'
sed 's/SK_MaxU16/UINT16_MAX/g'
SK_MinU32 and SK_MinU16 were unused
Change-Id: I6b6c824df47b05bde7e73b13a58e851a5f63fe0e
Reviewed-on: https://skia-review.googlesource.com/134607
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
-rw-r--r-- | include/core/SkImageInfo.h | 10 | ||||
-rw-r--r-- | include/core/SkTypes.h | 15 | ||||
-rw-r--r-- | src/core/SkImageInfo.cpp | 2 | ||||
-rw-r--r-- | src/core/SkMath.cpp | 4 | ||||
-rw-r--r-- | src/core/SkResourceCache.cpp | 2 | ||||
-rw-r--r-- | src/core/SkString.cpp | 10 | ||||
-rw-r--r-- | src/core/SkStringUtils.cpp | 2 | ||||
-rw-r--r-- | src/core/SkVertices.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrProgramDesc.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrResourceCache.cpp | 4 | ||||
-rw-r--r-- | src/gpu/effects/GrPorterDuffXferProcessor.cpp | 2 | ||||
-rw-r--r-- | src/gpu/effects/GrXfermodeFragmentProcessor.cpp | 2 | ||||
-rw-r--r-- | src/gpu/ops/GrDrawVerticesOp.cpp | 4 | ||||
-rw-r--r-- | src/pdf/SkPDFFont.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkFontHost_win.cpp | 2 | ||||
-rw-r--r-- | tests/PDFGlyphsToUnicodeTest.cpp | 2 | ||||
-rw-r--r-- | tests/ResourceCacheTest.cpp | 2 | ||||
-rw-r--r-- | tests/StringTest.cpp | 2 | ||||
-rw-r--r-- | tests/VerticesTest.cpp | 4 |
19 files changed, 36 insertions, 41 deletions
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h index f09b8d6b03..42491de5e7 100644 --- a/include/core/SkImageInfo.h +++ b/include/core/SkImageInfo.h @@ -553,7 +553,7 @@ public: and rowBytes. rowBytes is assumed to be at least as large as minRowBytes(). Returns zero if height is zero. - Returns SK_MaxSizeT if answer exceeds the range of size_t. + Returns SIZE_MAX if answer exceeds the range of size_t. @param rowBytes size of pixel row or larger @return memory required by pixel buffer @@ -564,7 +564,7 @@ public: SkColorType. Uses minRowBytes() to compute bytes for pixel row. Returns zero if height is zero. - Returns SK_MaxSizeT if answer exceeds the range of size_t. + Returns SIZE_MAX if answer exceeds the range of size_t. @return least memory required by pixel buffer */ @@ -572,14 +572,14 @@ public: return this->computeByteSize(this->minRowBytes()); } - /** Returns true if byteSize equals SK_MaxSizeT. computeByteSize() and - computeMinByteSize() return SK_MaxSizeT if size_t can not hold buffer size. + /** Returns true if byteSize equals SIZE_MAX. computeByteSize() and + computeMinByteSize() return SIZE_MAX if size_t can not hold buffer size. @param byteSize result of computeByteSize() or computeMinByteSize() @return true if computeByteSize() or computeMinByteSize() result exceeds size_t */ static bool ByteSizeOverflowed(size_t byteSize) { - return SK_MaxSizeT == byteSize; + return SIZE_MAX == byteSize; } /** Returns true if rowBytes is smaller than width times pixel size. diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h index 75146341fe..2fe28fc6ce 100644 --- a/include/core/SkTypes.h +++ b/include/core/SkTypes.h @@ -115,17 +115,12 @@ template <typename D, typename S> constexpr D SkTo(S s) { */ #define SkToBool(cond) ((cond) != 0) -#define SK_MaxS16 32767 -#define SK_MinS16 -32767 -#define SK_MaxU16 0xFFFF -#define SK_MinU16 0 -#define SK_MaxS32 0x7FFFFFFF +#define SK_MaxS16 INT16_MAX +#define SK_MinS16 -SK_MaxS16 +#define SK_MaxS32 INT32_MAX #define SK_MinS32 -SK_MaxS32 -#define SK_MaxU32 0xFFFFFFFF -#define SK_MinU32 0 -#define SK_NaN32 ((int) (1U << 31)) -#define SK_MaxSizeT SIZE_MAX -static constexpr int64_t SK_MaxS64 = 0x7FFFFFFFFFFFFFFF; +#define SK_NaN32 INT32_MIN +static constexpr int64_t SK_MaxS64 = INT64_MAX; static constexpr int64_t SK_MinS64 = -SK_MaxS64; static inline constexpr int32_t SkLeftShift(int32_t value, int32_t shift) { diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp index a743dbce70..15c070cd4e 100644 --- a/src/core/SkImageInfo.cpp +++ b/src/core/SkImageInfo.cpp @@ -67,7 +67,7 @@ size_t SkImageInfo::computeByteSize(size_t rowBytes) const { SkSafeMath safe; size_t bytes = safe.add(safe.mul(safe.addInt(fHeight, -1), rowBytes), safe.mul(fWidth, this->bytesPerPixel())); - return safe ? bytes : SK_MaxSizeT; + return safe ? bytes : SIZE_MAX; } SkImageInfo SkImageInfo::MakeS32(int width, int height, SkAlphaType at) { diff --git a/src/core/SkMath.cpp b/src/core/SkMath.cpp index 58645dab8f..2d2ddacbaf 100644 --- a/src/core/SkMath.cpp +++ b/src/core/SkMath.cpp @@ -89,11 +89,11 @@ float SkScalarSinCos(float radians, float* cosValue) { size_t SkSafeMath::Add(size_t x, size_t y) { SkSafeMath tmp; size_t sum = tmp.add(x, y); - return tmp.ok() ? sum : SK_MaxSizeT; + return tmp.ok() ? sum : SIZE_MAX; } size_t SkSafeMath::Mul(size_t x, size_t y) { SkSafeMath tmp; size_t prod = tmp.mul(x, y); - return tmp.ok() ? prod : SK_MaxSizeT; + return tmp.ok() ? prod : SIZE_MAX; } diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp index 5928b48b07..ee9d2d82c1 100644 --- a/src/core/SkResourceCache.cpp +++ b/src/core/SkResourceCache.cpp @@ -195,7 +195,7 @@ void SkResourceCache::purgeAsNeeded(bool forcePurge) { if (fDiscardableFactory) { countLimit = SK_DISCARDABLEMEMORY_SCALEDIMAGECACHE_COUNT_LIMIT; - byteLimit = SK_MaxU32; // no limit based on bytes + byteLimit = UINT32_MAX; // no limit based on bytes } else { countLimit = SK_MaxS32; // no limit based on count byteLimit = fTotalByteLimit; diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp index a6d9335318..a9c1d827f9 100644 --- a/src/core/SkString.cpp +++ b/src/core/SkString.cpp @@ -178,18 +178,18 @@ const SkString::Rec SkString::gEmptyRec(0, 0); static uint32_t trim_size_t_to_u32(size_t value) { if (sizeof(size_t) > sizeof(uint32_t)) { - if (value > SK_MaxU32) { - value = SK_MaxU32; + if (value > UINT32_MAX) { + value = UINT32_MAX; } } return (uint32_t)value; } static size_t check_add32(size_t base, size_t extra) { - SkASSERT(base <= SK_MaxU32); + SkASSERT(base <= UINT32_MAX); if (sizeof(size_t) > sizeof(uint32_t)) { - if (base + extra > SK_MaxU32) { - extra = SK_MaxU32 - base; + if (base + extra > UINT32_MAX) { + extra = UINT32_MAX - base; } } return extra; diff --git a/src/core/SkStringUtils.cpp b/src/core/SkStringUtils.cpp index 00d8c8787c..c4c1739b19 100644 --- a/src/core/SkStringUtils.cpp +++ b/src/core/SkStringUtils.cpp @@ -63,7 +63,7 @@ SkString SkStringFromUTF16(const uint16_t* src, size_t count) { const uint16_t* last = ptr; SkUnichar u = SkUTF16_NextUnichar(&ptr); size_t s = SkUTF8_FromUnichar(u); - if (n > SK_MaxU32 - s) { + if (n > UINT32_MAX - s) { end = last; // truncate input string break; } diff --git a/src/core/SkVertices.cpp b/src/core/SkVertices.cpp index e23d65f7a9..c0f3eb23f9 100644 --- a/src/core/SkVertices.cpp +++ b/src/core/SkVertices.cpp @@ -43,7 +43,7 @@ struct SkVertices::Sizes { numFanTris = vertexCount - 2; // By forcing this to become indexed we are adding a constraint to the maximum // number of vertices. - if (vertexCount > (SK_MaxU16 + 1)) { + if (vertexCount > (UINT16_MAX + 1)) { sk_bzero(this, sizeof(*this)); return; } diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp index 0a558e06b9..5b7e5e3bff 100644 --- a/src/gpu/GrProgramDesc.cpp +++ b/src/gpu/GrProgramDesc.cpp @@ -99,7 +99,7 @@ static bool gen_meta_key(const GrResourceIOProcessor& proc, uint32_t classID = proc.classID(); // Currently we allow 16 bits for the class id and the overall processor key size. - static const uint32_t kMetaKeyInvalidMask = ~((uint32_t)SK_MaxU16); + static const uint32_t kMetaKeyInvalidMask = ~((uint32_t)UINT16_MAX); if ((processorKeySize | classID) & kMetaKeyInvalidMask) { return false; } @@ -119,7 +119,7 @@ static bool gen_meta_key(const GrXferProcessor& xp, uint32_t classID = xp.classID(); // Currently we allow 16 bits for the class id and the overall processor key size. - static const uint32_t kMetaKeyInvalidMask = ~((uint32_t)SK_MaxU16); + static const uint32_t kMetaKeyInvalidMask = ~((uint32_t)UINT16_MAX); if ((processorKeySize | classID) & kMetaKeyInvalidMask) { return false; } diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp index 2e072533a2..8ed359410c 100644 --- a/src/gpu/GrResourceCache.cpp +++ b/src/gpu/GrResourceCache.cpp @@ -29,7 +29,7 @@ GrScratchKey::ResourceType GrScratchKey::GenerateResourceType() { static int32_t gType = INHERITED::kInvalidDomain + 1; int32_t type = sk_atomic_inc(&gType); - if (type > SK_MaxU16) { + if (type > UINT16_MAX) { SK_ABORT("Too many Resource Types"); } @@ -40,7 +40,7 @@ GrUniqueKey::Domain GrUniqueKey::GenerateDomain() { static int32_t gDomain = INHERITED::kInvalidDomain + 1; int32_t domain = sk_atomic_inc(&gDomain); - if (domain > SK_MaxU16) { + if (domain > UINT16_MAX) { SK_ABORT("Too many GrUniqueKey Domains"); } diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp index f4af7a4679..c727670b4f 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp @@ -618,7 +618,7 @@ private: class GLPDLCDXferProcessor : public GrGLSLXferProcessor { public: - GLPDLCDXferProcessor(const GrProcessor&) : fLastAlpha(SK_MaxU32) {} + GLPDLCDXferProcessor(const GrProcessor&) : fLastAlpha(UINT32_MAX) {} ~GLPDLCDXferProcessor() override {} diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp index 6b764f453a..2ce40c8fa4 100644 --- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp +++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp @@ -395,7 +395,7 @@ private: } void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { - GR_STATIC_ASSERT(((int)SkBlendMode::kLastMode & SK_MaxU16) == (int)SkBlendMode::kLastMode); + GR_STATIC_ASSERT(((int)SkBlendMode::kLastMode & UINT16_MAX) == (int)SkBlendMode::kLastMode); b->add32((int)fMode | (fChild << 16)); } diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp index b35fee08a3..55d97f6866 100644 --- a/src/gpu/ops/GrDrawVerticesOp.cpp +++ b/src/gpu/ops/GrDrawVerticesOp.cpp @@ -276,7 +276,7 @@ bool GrDrawVerticesOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) { return false; } - if (fVertexCount + that->fVertexCount > SK_MaxU16) { + if (fVertexCount + that->fVertexCount > UINT16_MAX) { return false; } @@ -366,7 +366,7 @@ static void randomize_params(size_t count, size_t maxVertex, SkScalar min, SkSca colors->push_back(GrRandomColor(random)); } if (hasIndices) { - SkASSERT(maxVertex <= SK_MaxU16); + SkASSERT(maxVertex <= UINT16_MAX); indices->push_back(random->nextULessThan((uint16_t)maxVertex)); } } diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp index cbb627f797..2db87556ac 100644 --- a/src/pdf/SkPDFFont.cpp +++ b/src/pdf/SkPDFFont.cpp @@ -147,7 +147,7 @@ const SkAdvancedTypefaceMetrics* SkPDFFont::GetMetrics(SkTypeface* typeface, return ptr->get(); // canon retains ownership. } int count = typeface->countGlyphs(); - if (count <= 0 || count > 1 + SK_MaxU16) { + if (count <= 0 || count > 1 + UINT16_MAX) { // Cache nullptr to skip this check. Use SkSafeUnref(). canon->fTypefaceMetrics.set(id, nullptr); return nullptr; diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index 93e1cadbf3..a202a72df6 100644 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -169,7 +169,7 @@ static unsigned calculateGlyphCount(HDC hdc, const LOGFONT& lf) { // Binary search for glyph count. static const MAT2 mat2 = {{0, 1}, {0, 0}, {0, 0}, {0, 1}}; - int32_t max = SK_MaxU16 + 1; + int32_t max = UINT16_MAX + 1; int32_t min = 0; GLYPHMETRICS gm; while (min < max) { diff --git a/tests/PDFGlyphsToUnicodeTest.cpp b/tests/PDFGlyphsToUnicodeTest.cpp index 2aeedf0330..b90e11126d 100644 --- a/tests/PDFGlyphsToUnicodeTest.cpp +++ b/tests/PDFGlyphsToUnicodeTest.cpp @@ -14,7 +14,7 @@ #include "SkPDFMakeToUnicodeCmap.h" #include "SkStream.h" -static const int kMaximumGlyphCount = SK_MaxU16 + 1; +static const int kMaximumGlyphCount = UINT16_MAX + 1; static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset, const char* buffer, size_t len) { diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index b6ccd515c2..113945b414 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -1094,7 +1094,7 @@ static void test_timestamp_wrap(skiatest::Reporter* reporter) { GrGpu* gpu = context->contextPriv().getGpu(); // Pick a random number of resources to add before the timestamp will wrap. - cache->changeTimestamp(SK_MaxU32 - random.nextULessThan(kCount + 1)); + cache->changeTimestamp(UINT32_MAX - random.nextULessThan(kCount + 1)); static const int kNumToPurge = kCount - kBudgetCnt; diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp index f8c319e9be..503dbb8158 100644 --- a/tests/StringTest.cpp +++ b/tests/StringTest.cpp @@ -300,7 +300,7 @@ DEF_TEST(String_Threaded, r) { // let us create a string with a requested length longer than we can manage. DEF_TEST(String_huge, r) { // start testing slightly below max 32 - size_t size = SK_MaxU32 - 16; + size_t size = UINT32_MAX - 16; // See where we crash, and manually check that its at the right point. // // To test, change the false to true diff --git a/tests/VerticesTest.cpp b/tests/VerticesTest.cpp index 59d06472ac..b38a9de8ba 100644 --- a/tests/VerticesTest.cpp +++ b/tests/VerticesTest.cpp @@ -91,13 +91,13 @@ DEF_TEST(Vertices, reporter) { { // This has the maximum number of vertices to be rewritten as indexed triangles without // overflowing a 16bit index. - SkVertices::Builder builder(SkVertices::kTriangleFan_VertexMode, SK_MaxU16 + 1, 0, + SkVertices::Builder builder(SkVertices::kTriangleFan_VertexMode, UINT16_MAX + 1, 0, SkVertices::kHasColors_BuilderFlag); REPORTER_ASSERT(reporter, builder.isValid()); } { // This has too many to be rewritten. - SkVertices::Builder builder(SkVertices::kTriangleFan_VertexMode, SK_MaxU16 + 2, 0, + SkVertices::Builder builder(SkVertices::kTriangleFan_VertexMode, UINT16_MAX + 2, 0, SkVertices::kHasColors_BuilderFlag); REPORTER_ASSERT(reporter, !builder.isValid()); } |