Fix atest SkQP crash at startup.
Support for GM tests was removed from SkQP at http://review.skia.org/516336. However, the Java harness still expects us to supply a non-null GM array, and will crash if we don't. Change-Id: I1f093254e680bf8d40dcb303cd29ae7b44e09b0a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/520538 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
c9e9131f44
commit
b9802c75ef
@ -63,6 +63,16 @@ static SkQP gSkQP;
|
||||
__FILE__ ": assert(" #cond ") failed."); \
|
||||
return ret; } } while (0)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static jobjectArray make_java_string_array(JNIEnv* env, jint arraySize) {
|
||||
jclass stringClass = env->FindClass("java/lang/String");
|
||||
jassert(env, stringClass, nullptr);
|
||||
jobjectArray jarray = env->NewObjectArray(arraySize, stringClass, nullptr);
|
||||
jassert(env, jarray != nullptr, nullptr);
|
||||
return jarray;
|
||||
}
|
||||
|
||||
static void set_string_array_element(JNIEnv* env, jobjectArray a, const char* s, unsigned i) {
|
||||
jstring jstr = env->NewStringUTF(s);
|
||||
jassert(env, jstr != nullptr,);
|
||||
@ -70,16 +80,11 @@ static void set_string_array_element(JNIEnv* env, jobjectArray a, const char* s,
|
||||
env->DeleteLocalRef(jstr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename T, typename F>
|
||||
jobjectArray to_java_string_array(JNIEnv* env,
|
||||
const std::vector<T>& array,
|
||||
F toString) {
|
||||
jclass stringClass = env->FindClass("java/lang/String");
|
||||
jassert(env, stringClass, nullptr);
|
||||
jobjectArray jarray = env->NewObjectArray((jint)array.size(), stringClass, nullptr);
|
||||
jassert(env, jarray != nullptr, nullptr);
|
||||
static jobjectArray to_java_string_array(JNIEnv* env,
|
||||
const std::vector<T>& array,
|
||||
F toString) {
|
||||
jobjectArray jarray = make_java_string_array(env, (jint)array.size());
|
||||
for (unsigned i = 0; i < array.size(); ++i) {
|
||||
set_string_array_element(env, jarray, std::string(toString(array[i])).c_str(), i);
|
||||
}
|
||||
@ -120,6 +125,8 @@ void Java_org_skia_skqp_SkQP_nInit(JNIEnv* env, jobject object, jobject assetMan
|
||||
to_java_string_array(env, backends, SkQP::GetBackendName));
|
||||
env->SetObjectField(object, env->GetFieldID(SkQP_class, "mUnitTests", kStringArrayType),
|
||||
to_java_string_array(env, unitTests, SkQP::GetUnitTestName));
|
||||
env->SetObjectField(object, env->GetFieldID(SkQP_class, "mGMs", kStringArrayType),
|
||||
make_java_string_array(env, 0));
|
||||
}
|
||||
|
||||
jlong Java_org_skia_skqp_SkQP_nExecuteGM(JNIEnv* env,
|
||||
|
Loading…
Reference in New Issue
Block a user