case kSHA1_ChecksumType: return "compute_sha1";
case kMurmur3_ChecksumType: return "compute_murmur3";
- default: SK_CRASH(); return "";
+ default: SK_ABORT("Invalid Type"); return "";
}
}
log->configOption("clip",
SkStringPrintf("%d %d %d %d", fClip.fLeft, fClip.fTop,
fClip.fRight, fClip.fBottom).c_str());
- SK_ALWAYSBREAK(fCurrentScale < fScales.count()); // debugging paranoia
+ SkASSERT_RELEASE(fCurrentScale < fScales.count()); // debugging paranoia
log->configOption("scale", SkStringPrintf("%.2g", fScales[fCurrentScale]).c_str());
if (fCurrentUseMPD > 0) {
SkASSERT(1 == fCurrentUseMPD || 2 == fCurrentUseMPD);
memcpy(buf.pos, pos.begin(), count * sizeof(SkScalar) * 2);
} break;
default:
- SkFAIL("unhandled pos value");
+ SK_ABORT("unhandled pos value");
}
currentGlyph += count;
//#define SK_DEBUG_GLYPH_CACHE
//#define SK_DEBUG_PATH
-/* If, in debugging mode, Skia needs to stop (presumably to invoke a debugger)
- it will call SK_CRASH(). If this is not defined it, it is defined in
- SkPostConfig.h to write to an illegal address
- */
-//#define SK_CRASH() *(int *)(uintptr_t)0 = 0
-
-
/* preconfig will have attempted to determine the endianness of the system,
but you can change these mutually exclusive flags here.
*/
// TODO(mdempsky): Move elsewhere as appropriate.
#include <new>
-#ifndef SK_CRASH
-# ifdef SK_BUILD_FOR_WIN
-# define SK_CRASH() __debugbreak()
-# else
-# if 1 // set to 0 for infinite loop, which can help connecting gdb
-# define SK_CRASH() do { SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef = 0; } while (false)
-# else
-# define SK_CRASH() do { SkNO_RETURN_HINT(); } while (true)
-# endif
-# endif
-#endif
///////////////////////////////////////////////////////////////////////////////
#endif
#if defined(GOOGLE3)
- // Used as argument to DumpStackTrace in SK_ALWAYSBREAK.
void SkDebugfForDumpStackTrace(const char* data, void* unused);
+ void DumpStackTrace(int skip_count, void w(const char*, void*), void* arg);
+# define SK_DUMP_GOOGLE3_STACK() DumpStackTrace(0, SkDebugfForDumpStackTrace, nullptr)
+#else
+# define SK_DUMP_GOOGLE3_STACK()
#endif
-#ifndef SK_ALWAYSBREAK
-# if defined(GOOGLE3)
- void DumpStackTrace(int skip_count, void w(const char*, void*),
- void* arg);
-# define SK_ALWAYSBREAK(cond) do { \
- if (cond) break; \
- SkNO_RETURN_HINT(); \
- SkDebugf("%s:%d: failed assertion \"%s\"\n", __FILE__, __LINE__, #cond); \
- DumpStackTrace(0, SkDebugfForDumpStackTrace, nullptr); \
- SK_CRASH(); \
- } while (false)
-# elif defined(SK_DEBUG)
-# define SK_ALWAYSBREAK(cond) do { \
- if (cond) break; \
- SkNO_RETURN_HINT(); \
- SkDebugf("%s:%d: failed assertion \"%s\"\n", __FILE__, __LINE__, #cond); \
- SK_CRASH(); \
- } while (false)
-# else
-# define SK_ALWAYSBREAK(cond) do { if (cond) break; SK_CRASH(); } while (false)
-# endif
+#ifndef SK_ABORT
+# define SK_ABORT(msg) \
+ do { \
+ SkNO_RETURN_HINT(); \
+ SkDebugf("%s:%d: fatal error: \"%s\"\n", __FILE__, __LINE__, #msg); \
+ SK_DUMP_GOOGLE3_STACK(); \
+ sk_abort_no_print(); \
+ } while (false)
#endif
/**
// exception.
template <typename T, bool MEM_COPY>
void operator delete(void*, SkTArray<T, MEM_COPY>* /*array*/, int /*atIndex*/) {
- SK_CRASH();
+ SK_ABORT("Invalid Operation");
}
// Constructs a new object as the last element of an SkTArray.
The platform implementation must not return, but should either throw
an exception or otherwise exit.
*/
-SK_API extern void sk_throw(void);
+SK_API extern void sk_abort_no_print(void);
enum {
SK_MALLOC_TEMP = 0x01, //!< hint to sk_malloc that the requested memory will be freed in the scope of the stack frame
SK_API void SkDebugf(const char format[], ...);
#endif
+#define SkASSERT_RELEASE(cond) if(!(cond)) { SK_ABORT(#cond); }
+
#ifdef SK_DEBUG
- #define SkASSERT(cond) SK_ALWAYSBREAK(cond)
+ #define SkASSERT(cond) SkASSERT_RELEASE(cond)
#define SkDEBUGFAIL(message) SkASSERT(false && message)
#define SkDEBUGFAILF(fmt, ...) SkASSERTF(false, fmt, ##__VA_ARGS__)
#define SkDEBUGCODE(code) code
#define SkAssertResult(cond) cond
#endif
-#define SkFAIL(message) SK_ALWAYSBREAK(false && message)
+// Legacy macro names for SK_ABORT
+#define SkFAIL(message) SK_ABORT(message)
+#define sk_throw() SK_ABORT("sk_throw")
// We want to evaluate cond only once, and inside the SkASSERT somewhere so we see its string form.
// So we use the comma operator to make an SkDebugf that always returns false: we'll evaluate cond,
orig.set(pts, iter.conicWeight());
SkPoint quadPts[5];
int count = orig.chopIntoQuadsPOW2(quadPts, 1);
- SK_ALWAYSBREAK(2 == count);
+ SkASSERT_RELEASE(2 == count);
if (!check_edge_against_rect(quadPts[0], quadPts[2], rect, direction)) {
return false;
SkASSERT(count >= SkRegion::kRectRegionRuns);
const int64_t size = sk_64_mul(count, sizeof(RunType)) + sizeof(RunHead);
- if (count < 0 || !sk_64_isS32(size)) { SK_CRASH(); }
+ if (count < 0 || !sk_64_isS32(size)) { SK_ABORT("Invalid Size"); }
RunHead* head = (RunHead*)sk_malloc_throw(size);
head->fRefCnt = 1;
case SkPaint::kGlyphID_TextEncoding:
return SkToInt(byteLength / 2);
default:
- SK_ALWAYSBREAK(true);
+ SK_ABORT("Invalid Text Encoding");
}
return 0;
}
#if 0
if (SkBaseDevice::kGeneral_Usage == info.fUsage) {
return nullptr;
- SK_CRASH();
//To what stream do we write?
//SkXPSDevice* dev = new SkXPSDevice(this);
//SkSize s = SkSize::Make(width, height);
// to match the op new silences warnings about missing op delete when a constructor throws an
// exception.
template <typename T> void operator delete(void*, GrTAllocator<T>*) {
- SK_CRASH();
+ SK_ABORT("Invalid Operation");
}
#define GrNEW_APPEND_TO_ALLOCATOR(allocator_ptr, type_name, args) \
void operator delete(void*, GrTRecorder<TBase, TAlign>&, const GrTRecorderAllocWrapper<TItem>&) {
// We only provide an operator delete to work around compiler warnings that can come
// up for an unmatched operator new when compiling with exceptions.
- SK_CRASH();
+ SK_ABORT("Invalid Operation");
}
#define GrNEW_APPEND_TO_RECORDER(recorder, type_name, args) \
const SkOpAngle* next = first;
SkTDArray<const SkOpAngle*>(angles);
do {
-// SK_ALWAYSBREAK(next->fSegment->debugContains(next));
+// SkASSERT_RELEASE(next->fSegment->debugContains(next));
angles.push(next);
next = next->next();
if (next == first) {
break;
}
- SK_ALWAYSBREAK(!angles.contains(next));
+ SkASSERT_RELEASE(!angles.contains(next));
if (!next) {
return;
}
break;
}
default:
- SK_CRASH();
+ SK_ABORT("Invalid Text Encoding");
}
if (sc) {
public:
SkAutoFc() : SkAutoTCallVProc<T, FcTDestroy<T, D> >(C()) {
T* obj = this->operator T*();
- SK_ALWAYSBREAK(nullptr != obj);
+ SkASSERT_RELEASE(nullptr != obj);
}
explicit SkAutoFc(T* obj) : SkAutoTCallVProc<T, FcTDestroy<T, D> >(obj) {}
};
if (!SUCCEEDED(fFactory->QueryInterface(&fFactory2))) {
// IUnknown::QueryInterface states that if it fails, punk will be set to nullptr.
// http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
- SK_ALWAYSBREAK(nullptr == fFactory2.get());
+ SkASSERT_RELEASE(nullptr == fFactory2.get());
}
#endif
memcpy(fLocaleName.get(), localeName, localeNameLength * sizeof(WCHAR));
return p;
}
-void sk_throw() {
- SkDEBUGFAIL("sk_throw");
+void sk_abort_no_print() {
abort();
}
#include "mozilla/mozalloc_abort.h"
#include "mozilla/mozalloc_oom.h"
-void sk_throw() {
- SkDEBUGFAIL("sk_throw");
- mozalloc_abort("Abort from sk_throw");
+void sk_abort_no_print() {
+ mozalloc_abort("Abort from sk_abort");
}
void sk_out_of_memory(void) {
break;
}
default:
- SK_CRASH();
+ SK_ABORT("Invalid Text Encoding");
}
for (int i = 0; i < glyphCount; ++i) {
if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) {
// IUnknown::QueryInterface states that if it fails, punk will be set to nullptr.
// http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
- SK_ALWAYSBREAK(nullptr == fDWriteFontFace1.get());
+ SkASSERT_RELEASE(nullptr == fDWriteFontFace1.get());
}
#endif
}
if (pool) {
SkDiscardableMemory* dm = pool->create(size);
// the pool "can" return null, but it shouldn't in these controlled conditions
- SK_ALWAYSBREAK(dm);
+ SkASSERT_RELEASE(dm);
return new SkCachedData(size, dm);
} else {
return new SkCachedData(sk_malloc_throw(size), size);
if (realRoots == 3) {
smallest = SkTMin(smallest, allRoots[2]);
}
- SK_ALWAYSBREAK(smallest < 0);
- SK_ALWAYSBREAK(smallest >= -1);
+ SkASSERT_RELEASE(smallest < 0);
+ SkASSERT_RELEASE(smallest >= -1);
largeBits = 0;
} else {
frexp(largest, &largeBits);
- SK_ALWAYSBREAK(largeBits >= 0);
- SK_ALWAYSBREAK(largeBits < 256);
+ SkASSERT_RELEASE(largeBits >= 0);
+ SkASSERT_RELEASE(largeBits < 256);
}
double step = 1e-6;
if (largeBits > 21) {
break;
}
step *= 1.5;
- SK_ALWAYSBREAK(step < 1);
+ SkASSERT_RELEASE(step < 1);
} while (true);
worstStep[largeBits] = SkTMax(worstStep[largeBits], diff);
#if 0
double allRoots[3] = {0}, validRoots[3] = {0};
int realRoots = SkDCubic::RootsReal(A, B, C, D, allRoots);
int valid = SkDQuad::AddValidTs(allRoots, realRoots, validRoots);
- SK_ALWAYSBREAK(valid == 1);
- SK_ALWAYSBREAK(realRoots != 1);
+ SkASSERT_RELEASE(valid == 1);
+ SkASSERT_RELEASE(realRoots != 1);
double t = validRoots[0];
SkDPoint calcPt = cubic.ptAtT(t);
- SK_ALWAYSBREAK(!calcPt.approximatelyEqual(pt));
+ SkASSERT_RELEASE(!calcPt.approximatelyEqual(pt));
int iters = 0;
double newT = binary_search(cubic, 0.1, pt, t, &iters);
return newT;
for (int index = 0; index < cubicLineFailuresCount; ++index) {
const CubicLineFailures& failure = cubicLineFailures[index];
double newT = testOneFailure(failure);
- SK_ALWAYSBREAK(newT >= 0);
+ SkASSERT_RELEASE(newT >= 0);
}
}
return; // disable for now
const CubicLineFailures& failure = cubicLineFailures[1];
double newT = testOneFailure(failure);
- SK_ALWAYSBREAK(newT >= 0);
+ SkASSERT_RELEASE(newT >= 0);
}
s /= (max - min);
s *= (SK_ARRAY_COUNT(kBars) - 1);
const size_t bar = (size_t)(s + 0.5);
- SK_ALWAYSBREAK(bar < SK_ARRAY_COUNT(kBars));
+ SkASSERT_RELEASE(bar < SK_ARRAY_COUNT(kBars));
plot.append(kBars[bar]);
}
}
}
if (!fontData) {
// Once all legacy callers to portable fonts are converted, replace this with
- // SK_CRASH();
+ // SK_ABORT();
SkDebugf("missing %s %d\n", name, style);
// If we called SkTypeface::CreateFromName() here we'd recurse infinitely,
// so we reimplement its core logic here inline without the recursive aspect.