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); bool SK_WARN_UNUSED_RESULT tryAllocPixelsFlags(const SkImageInfo& info, uint32_t flags);
void allocPixelsFlags(const SkImageInfo& info, uint32_t flags) { void allocPixelsFlags(const SkImageInfo& info, uint32_t flags) {
if (!this->tryAllocPixelsFlags(info, flags)) { SkASSERT_RELEASE(this->tryAllocPixelsFlags(info, flags));
sk_throw();
}
} }
/** /**
@ -264,9 +262,7 @@ public:
bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info, size_t rowBytes); bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info, size_t rowBytes);
void allocPixels(const SkImageInfo& info, size_t rowBytes) { void allocPixels(const SkImageInfo& info, size_t rowBytes) {
if (!this->tryAllocPixels(info, rowBytes)) { SkASSERT_RELEASE(this->tryAllocPixels(info, rowBytes));
sk_throw();
}
} }
bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info) { bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info) {
@ -363,9 +359,7 @@ public:
bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator* allocator); bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator* allocator);
void allocPixels(Allocator* allocator) { void allocPixels(Allocator* allocator) {
if (!this->tryAllocPixels(allocator)) { SkASSERT_RELEASE(this->tryAllocPixels(allocator));
sk_throw();
}
} }
/** /**

View File

@ -19,7 +19,7 @@
enum { 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_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 /** Return a block of memory (at least 4-byte aligned) of at least the
specified size. If the requested memory cannot be returned, either specified size. If the requested memory cannot be returned, either

View File

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

View File

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

View File

@ -109,9 +109,7 @@ bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmapProvider
} }
} }
// diagnostic for a crasher... // diagnostic for a crasher...
if (nullptr == fCurrMip->data()) { SkASSERT_RELEASE(fCurrMip->data());
sk_throw();
}
const SkSize scale = SkSize::Make(SkScalarInvert(invScaleSize.width()), const SkSize scale = SkSize::Make(SkScalarInvert(invScaleSize.width()),
SkScalarInvert(invScaleSize.height())); 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); const size_t actualLength = length + sizeof(SkData);
if (actualLength < length) { SkASSERT_RELEASE(length < actualLength); // Check for overflow.
// we overflowed
sk_throw();
}
void* storage = ::operator new (actualLength); void* storage = ::operator new (actualLength);
sk_sp<SkData> data(new (storage) SkData(length)); sk_sp<SkData> data(new (storage) SkData(length));

View File

@ -80,7 +80,7 @@ public:
SK_TO_STRING_OVERRIDE() SK_TO_STRING_OVERRIDE()
// For serialization. This will never be called. // 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: protected:
Context* onMakeContext(const ContextRec& rec, SkArenaAlloc* alloc) const override { Context* onMakeContext(const ContextRec& rec, SkArenaAlloc* alloc) const override {

View File

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

View File

@ -230,19 +230,19 @@ protected:
// SHOULD NEVER BE CALLED // SHOULD NEVER BE CALLED
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override { 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*, void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
SrcRectConstraint) override { SrcRectConstraint) override {
sk_throw(); SK_ABORT("not reached");
} }
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override { const SkPaint*) override {
sk_throw(); SK_ABORT("not reached");
} }
void onDrawBitmapLattice(const SkBitmap&, const SkCanvas::Lattice& lattice, const SkRect& dst, void onDrawBitmapLattice(const SkBitmap&, const SkCanvas::Lattice& lattice, const SkRect& dst,
const SkPaint*) override { const SkPaint*) override {
sk_throw(); SK_ABORT("not reached");
} }
private: 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) { 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: public:
AutoFTAccess(const SkTypeface* tf) : fFaceRec(nullptr) { AutoFTAccess(const SkTypeface* tf) : fFaceRec(nullptr) {
gFTMutex.acquire(); gFTMutex.acquire();
if (!ref_ft_library()) { SkASSERT_RELEASE(ref_ft_library());
sk_throw();
}
fFaceRec = ref_ft_face(tf); fFaceRec = ref_ft_face(tf);
} }
@ -764,10 +762,7 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(sk_sp<SkTypeface> typeface,
, fStrikeIndex(-1) , fStrikeIndex(-1)
{ {
SkAutoMutexAcquire ac(gFTMutex); SkAutoMutexAcquire ac(gFTMutex);
SkASSERT_RELEASE(ref_ft_library());
if (!ref_ft_library()) {
sk_throw();
}
fFaceRec.reset(ref_ft_face(this->getTypeface())); fFaceRec.reset(ref_ft_face(this->getTypeface()));