Allow printf-style formatting to be used in SK_ABORT.
(This is a simple reland of
https://skia-review.googlesource.com/c/skia/+/293272
and is functionally unchanged, but needed to be reconstructed
manually because JavaInputStreamAdaptor.cpp was deleted.)
SK_ABORT was already using SkDebugf to print the error message to the
console, so all the moving parts were there. This CL just adds a
mechanism for the calling code to pass in arguments.
Added a use case to demonstrate usage--when an allocation fails, the
requested size is now shown in the error message.
Change-Id: If8600a9febad15b7c8b7a04479a1d92442521f21
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294705
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/bench/TessellatePathBench.cpp b/bench/TessellatePathBench.cpp
index b52c100..7788d9b 100644
--- a/bench/TessellatePathBench.cpp
+++ b/bench/TessellatePathBench.cpp
@@ -61,9 +61,8 @@
void* makeVertexSpace(size_t vertexSize, int vertexCount, sk_sp<const GrBuffer>*,
int* startVertex) override {
if (vertexSize * vertexCount > sizeof(fStaticVertexData)) {
- SK_ABORT(SkStringPrintf(
- "FATAL: wanted %zu bytes of static vertex data; only have %zu.\n",
- vertexSize * vertexCount, SK_ARRAY_COUNT(fStaticVertexData)).c_str());
+ SK_ABORT("FATAL: wanted %zu bytes of static vertex data; only have %zu.\n",
+ vertexSize * vertexCount, SK_ARRAY_COUNT(fStaticVertexData));
}
*startVertex = 0;
return fStaticVertexData;
@@ -73,9 +72,8 @@
int drawCount, sk_sp<const GrBuffer>* buffer, size_t* offsetInBytes) override {
int staticBufferCount = (int)SK_ARRAY_COUNT(fStaticDrawIndexedIndirectData);
if (drawCount > staticBufferCount) {
- SK_ABORT(SkStringPrintf(
- "FATAL: wanted %i static drawIndexedIndirect elements; only have %i.\n",
- drawCount, staticBufferCount).c_str());
+ SK_ABORT("FATAL: wanted %i static drawIndexedIndirect elements; only have %i.\n",
+ drawCount, staticBufferCount);
}
return fStaticDrawIndexedIndirectData;
}