Remove uses of sk_throw.
The sk_throw macro is now an alias to SK_ABORT, but is often used when
other macros better describe the situation. This change replaces
sk_throw with SK_ABORT or SkASSERT_RELEASE as appropriate.
Change-Id: I313facc6d535c8e8bec90ceeaf17ae3a381c48f3
Reviewed-on: https://skia-review.googlesource.com/35882
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 65b797b..f880883 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -248,9 +248,7 @@
*/
bool SK_WARN_UNUSED_RESULT tryAllocPixelsFlags(const SkImageInfo& info, uint32_t flags);
void allocPixelsFlags(const SkImageInfo& info, uint32_t flags) {
- if (!this->tryAllocPixelsFlags(info, flags)) {
- sk_throw();
- }
+ SkASSERT_RELEASE(this->tryAllocPixelsFlags(info, flags));
}
/**
@@ -264,9 +262,7 @@
bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info, size_t rowBytes);
void allocPixels(const SkImageInfo& info, size_t rowBytes) {
- if (!this->tryAllocPixels(info, rowBytes)) {
- sk_throw();
- }
+ SkASSERT_RELEASE(this->tryAllocPixels(info, rowBytes));
}
bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info) {
@@ -363,9 +359,7 @@
bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator* allocator);
void allocPixels(Allocator* allocator) {
- if (!this->tryAllocPixels(allocator)) {
- sk_throw();
- }
+ SkASSERT_RELEASE(this->tryAllocPixels(allocator));
}
/**
diff --git a/include/private/SkMalloc.h b/include/private/SkMalloc.h
index 58e11f6..18714e4 100644
--- a/include/private/SkMalloc.h
+++ b/include/private/SkMalloc.h
@@ -19,7 +19,7 @@
enum {
SK_MALLOC_TEMP = 0x01, //!< hint to sk_malloc that the requested memory will be freed in the scope of the stack frame
- SK_MALLOC_THROW = 0x02 //!< instructs sk_malloc to call sk_throw if the memory cannot be allocated.
+ SK_MALLOC_THROW = 0x02 //!< instructs sk_malloc to not return normally if the memory cannot be allocated.
};
/** Return a block of memory (at least 4-byte aligned) of at least the
specified size. If the requested memory cannot be returned, either
diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp
index 092eb69..7ef82ed 100644
--- a/src/core/SkAAClip.cpp
+++ b/src/core/SkAAClip.cpp
@@ -1382,8 +1382,7 @@
}
void unexpected() {
- SkDebugf("---- did not expect to get called here");
- sk_throw();
+ SK_ABORT("---- did not expect to get called here");
}
};
diff --git a/src/core/SkAutoPixmapStorage.cpp b/src/core/SkAutoPixmapStorage.cpp
index b41bc90..be13e71 100644
--- a/src/core/SkAutoPixmapStorage.cpp
+++ b/src/core/SkAutoPixmapStorage.cpp
@@ -50,9 +50,7 @@
}
void SkAutoPixmapStorage::alloc(const SkImageInfo& info) {
- if (!this->tryAlloc(info)) {
- sk_throw();
- }
+ SkASSERT_RELEASE(this->tryAlloc(info));
}
const SkData* SkAutoPixmapStorage::detachPixelsAsData() {
diff --git a/src/core/SkAutoPixmapStorage.h b/src/core/SkAutoPixmapStorage.h
index 0886644..5473628 100644
--- a/src/core/SkAutoPixmapStorage.h
+++ b/src/core/SkAutoPixmapStorage.h
@@ -35,7 +35,7 @@
* to point to that memory. The storage will be freed when this object is destroyed,
* or if another call to tryAlloc() or alloc() is made.
*
- * If the memory cannot be allocated, calls sk_throw().
+ * If the memory cannot be allocated, calls SK_ABORT().
*/
void alloc(const SkImageInfo&);
diff --git a/src/core/SkBitmapController.cpp b/src/core/SkBitmapController.cpp
index 586210d..91fdc6f 100644
--- a/src/core/SkBitmapController.cpp
+++ b/src/core/SkBitmapController.cpp
@@ -109,9 +109,7 @@
}
}
// diagnostic for a crasher...
- if (nullptr == fCurrMip->data()) {
- sk_throw();
- }
+ SkASSERT_RELEASE(fCurrMip->data());
const SkSize scale = SkSize::Make(SkScalarInvert(invScaleSize.width()),
SkScalarInvert(invScaleSize.height()));
diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp
index 84b60be..0e4d17f 100644
--- a/src/core/SkData.cpp
+++ b/src/core/SkData.cpp
@@ -64,10 +64,7 @@
}
const size_t actualLength = length + sizeof(SkData);
- if (actualLength < length) {
- // we overflowed
- sk_throw();
- }
+ SkASSERT_RELEASE(length < actualLength); // Check for overflow.
void* storage = ::operator new (actualLength);
sk_sp<SkData> data(new (storage) SkData(length));
diff --git a/src/core/SkDraw_vertices.cpp b/src/core/SkDraw_vertices.cpp
index 4f7fc13..8df9946 100644
--- a/src/core/SkDraw_vertices.cpp
+++ b/src/core/SkDraw_vertices.cpp
@@ -80,7 +80,7 @@
SK_TO_STRING_OVERRIDE()
// For serialization. This will never be called.
- Factory getFactory() const override { sk_throw(); return nullptr; }
+ Factory getFactory() const override { SK_ABORT("not reached"); return nullptr; }
protected:
Context* onMakeContext(const ContextRec& rec, SkArenaAlloc* alloc) const override {
diff --git a/src/core/SkPathMeasure.cpp b/src/core/SkPathMeasure.cpp
index 34b1648..0da448f 100644
--- a/src/core/SkPathMeasure.cpp
+++ b/src/core/SkPathMeasure.cpp
@@ -121,8 +121,7 @@
}
break;
default:
- SkDEBUGFAIL("unknown segType");
- sk_throw();
+ SK_ABORT("unknown segType");
}
}
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index f3d991a..4b6750c 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -230,19 +230,19 @@
// SHOULD NEVER BE CALLED
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override {
- sk_throw();
+ SK_ABORT("not reached");
}
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
SrcRectConstraint) override {
- sk_throw();
+ SK_ABORT("not reached");
}
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override {
- sk_throw();
+ SK_ABORT("not reached");
}
void onDrawBitmapLattice(const SkBitmap&, const SkCanvas::Lattice& lattice, const SkRect& dst,
const SkPaint*) override {
- sk_throw();
+ SK_ABORT("not reached");
}
private:
diff --git a/src/pipe/SkPipeReader.cpp b/src/pipe/SkPipeReader.cpp
index 07b360c..7854a78 100644
--- a/src/pipe/SkPipeReader.cpp
+++ b/src/pipe/SkPipeReader.cpp
@@ -751,7 +751,7 @@
}
static void endPicture_handler(SkPipeReader& reader, uint32_t packedVerb, SkCanvas* canvas) {
- sk_throw(); // never call me
+ SK_ABORT("not reached"); // never call me
}
///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 5af6190..f892438 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -418,9 +418,7 @@
public:
AutoFTAccess(const SkTypeface* tf) : fFaceRec(nullptr) {
gFTMutex.acquire();
- if (!ref_ft_library()) {
- sk_throw();
- }
+ SkASSERT_RELEASE(ref_ft_library());
fFaceRec = ref_ft_face(tf);
}
@@ -764,10 +762,7 @@
, fStrikeIndex(-1)
{
SkAutoMutexAcquire ac(gFTMutex);
-
- if (!ref_ft_library()) {
- sk_throw();
- }
+ SkASSERT_RELEASE(ref_ft_library());
fFaceRec.reset(ref_ft_face(this->getTypeface()));