| 280 | } |
| 281 | |
| 282 | uint32_t JNIHelper::LoadCubemapTexture(const char* file_name, |
| 283 | const int32_t face, |
| 284 | const int32_t miplevel, const bool, |
| 285 | int32_t* outWidth, int32_t* outHeight, |
| 286 | bool* hasAlpha) { |
| 287 | if (activity_ == NULL) { |
| 288 | LOGI( |
| 289 | "JNIHelper has not been initialized. Call init() to initialize the " |
| 290 | "helper"); |
| 291 | return 0; |
| 292 | } |
| 293 | |
| 294 | // Lock mutex |
| 295 | std::lock_guard<std::mutex> lock(mutex_); |
| 296 | |
| 297 | JNIEnv* env = AttachCurrentThread(); |
| 298 | jstring name = env->NewStringUTF(file_name); |
| 299 | |
| 300 | jmethodID mid = env->GetMethodID(jni_helper_java_class_, "loadCubemapTexture", |
| 301 | "(Ljava/lang/String;IIZ)Ljava/lang/Object;"); |
| 302 | |
| 303 | jobject out = |
| 304 | env->CallObjectMethod(jni_helper_java_ref_, mid, name, face, miplevel); |
| 305 | |
| 306 | jclass javaCls = |
| 307 | RetrieveClass(env, "com/sample/helper/NDKHelper$TextureInformation"); |
| 308 | jfieldID fidRet = env->GetFieldID(javaCls, "ret", "Z"); |
| 309 | jfieldID fidHasAlpha = env->GetFieldID(javaCls, "alphaChannel", "Z"); |
| 310 | jfieldID fidWidth = env->GetFieldID(javaCls, "originalWidth", "I"); |
| 311 | jfieldID fidHeight = env->GetFieldID(javaCls, "originalHeight", "I"); |
| 312 | bool ret = env->GetBooleanField(out, fidRet); |
| 313 | bool alpha = env->GetBooleanField(out, fidHasAlpha); |
| 314 | int32_t width = env->GetIntField(out, fidWidth); |
| 315 | int32_t height = env->GetIntField(out, fidHeight); |
| 316 | if (!ret) { |
| 317 | LOGI("Texture load failed %s", file_name); |
| 318 | } |
| 319 | LOGI("Loaded texture original size:%dx%d alpha:%d", width, height, |
| 320 | (int32_t)alpha); |
| 321 | if (outWidth != NULL) { |
| 322 | *outWidth = width; |
| 323 | } |
| 324 | if (outHeight != NULL) { |
| 325 | *outHeight = height; |
| 326 | } |
| 327 | if (hasAlpha != NULL) { |
| 328 | *hasAlpha = alpha; |
| 329 | } |
| 330 | |
| 331 | env->DeleteLocalRef(name); |
| 332 | env->DeleteLocalRef(javaCls); |
| 333 | |
| 334 | return 0; |
| 335 | } |
| 336 | |
| 337 | jobject JNIHelper::LoadImage(const char* file_name, int32_t* outWidth, |
| 338 | int32_t* outHeight, bool* hasAlpha) { |
nothing calls this directly
no test coverage detected