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>
This commit is contained in:
Ben Wagner 2017-08-17 14:05:04 -04:00 committed by Skia Commit-Bot
parent 800dc9949f
commit 7ca9a74fef
12 changed files with 18 additions and 38 deletions

View File

@ -248,9 +248,7 @@ public:
*/
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 @@ public:
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 @@ public:
bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator* allocator);
void allocPixels(Allocator* allocator) {
if (!this->tryAllocPixels(allocator)) {
sk_throw();
}
SkASSERT_RELEASE(this->tryAllocPixels(allocator));
}
/**

View File

@ -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

View File

@ -1382,8 +1382,7 @@ private:
}
void unexpected() {
SkDebugf("---- did not expect to get called here");
sk_throw();
SK_ABORT("---- did not expect to get called here");
}
};

View File

@ -50,9 +50,7 @@ bool SkAutoPixmapStorage::tryAlloc(const SkImageInfo& info) {
}
void SkAutoPixmapStorage::alloc(const SkImageInfo& info) {
if (!this->tryAlloc(info)) {
sk_throw();
}
SkASSERT_RELEASE(this->tryAlloc(info));
}
const SkData* SkAutoPixmapStorage::detachPixelsAsData() {

View File

@ -35,7 +35,7 @@ public:
* 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&);

View File

@ -109,9 +109,7 @@ bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmapProvider
}
}
// 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()));

View File

@ -64,10 +64,7 @@ sk_sp<SkData> SkData::PrivateNewWithCopy(const void* srcOrNull, size_t length) {
}
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));

View File

@ -80,7 +80,7 @@ public:
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 {

View File

@ -121,8 +121,7 @@ void SkPathMeasure_segTo(const SkPoint pts[], unsigned segType,
}
break;
default:
SkDEBUGFAIL("unknown segType");
sk_throw();
SK_ABORT("unknown segType");
}
}

View File

@ -230,19 +230,19 @@ protected:
// 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:

View File

@ -751,7 +751,7 @@ static void definePicture_handler(SkPipeReader& reader, uint32_t packedVerb, SkC
}
static void endPicture_handler(SkPipeReader& reader, uint32_t packedVerb, SkCanvas* canvas) {
sk_throw(); // never call me
SK_ABORT("not reached"); // never call me
}
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -418,9 +418,7 @@ class AutoFTAccess {
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 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(sk_sp<SkTypeface> typeface,
, fStrikeIndex(-1)
{
SkAutoMutexAcquire ac(gFTMutex);
if (!ref_ft_library()) {
sk_throw();
}
SkASSERT_RELEASE(ref_ft_library());
fFaceRec.reset(ref_ft_face(this->getTypeface()));