diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/android/extract.cpp | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/src/plugins/platforms/android/extract.cpp b/src/plugins/platforms/android/extract.cpp index 82687e61a7..25c3a1c29d 100644 --- a/src/plugins/platforms/android/extract.cpp +++ b/src/plugins/platforms/android/extract.cpp @@ -47,9 +47,7 @@ #include <alloca.h> #define LOG_TAG "extractSyleInfo" -#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) -#define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,LOG_TAG,__VA_ARGS__) extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractNativeChunkInfo(JNIEnv * env, jobject, Res_png_9patch* chunk) { @@ -133,3 +131,63 @@ Res_png_9patch* Res_png_9patch::deserialize(const void* inData) deserializeInternal(inData, (Res_png_9patch*) inData); return (Res_png_9patch*) inData; } + +extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractNativeChunkInfo20(JNIEnv * env, jobject, long addr) +{ + Res_png_9patch20* chunk = reinterpret_cast<Res_png_9patch20*>(addr); + Res_png_9patch20::deserialize(chunk); + //printChunkInformation(chunk); + jintArray result; + size_t size = 3+chunk->numXDivs+chunk->numYDivs+chunk->numColors; + result = env->NewIntArray(size); + if (!result) + return 0; + + jint *data = (jint*)malloc(sizeof(jint)*size); + size_t pos = 0; + data[pos++] = chunk->numXDivs; + data[pos++] = chunk->numYDivs; + data[pos++] = chunk->numColors; + + int32_t* xDivs = chunk->getXDivs(); + int32_t* yDivs = chunk->getYDivs(); + uint32_t* colors = chunk->getColors(); + + for (int x = 0; x <chunk->numXDivs; x ++) + data[pos++]=xDivs[x]; + for (int y = 0; y <chunk->numYDivs; y ++) + data[pos++] = yDivs[y]; + for (int c = 0; c <chunk->numColors; c ++) + data[pos++] = colors[c]; + env->SetIntArrayRegion(result, 0, size, data); + free(data); + return result; +} + +extern "C" JNIEXPORT jintArray JNICALL Java_org_qtproject_qt5_android_ExtractStyle_extractChunkInfo20(JNIEnv * env, jobject obj, jbyteArray chunkObj) +{ + size_t chunkSize = env->GetArrayLength(chunkObj); + void* storage = alloca(chunkSize); + env->GetByteArrayRegion(chunkObj, 0, chunkSize, + reinterpret_cast<jbyte*>(storage)); + + if (!env->ExceptionCheck()) + return Java_org_qtproject_qt5_android_ExtractStyle_extractNativeChunkInfo20(env, obj, long(storage)); + else + env->ExceptionClear(); + return 0; +} + +static inline void fill9patchOffsets(Res_png_9patch20* patch) { + patch->xDivsOffset = sizeof(Res_png_9patch20); + patch->yDivsOffset = patch->xDivsOffset + (patch->numXDivs * sizeof(int32_t)); + patch->colorsOffset = patch->yDivsOffset + (patch->numYDivs * sizeof(int32_t)); +} + +Res_png_9patch20* Res_png_9patch20::deserialize(void* inData) +{ + Res_png_9patch20* patch = reinterpret_cast<Res_png_9patch20*>(inData); + patch->wasDeserialized = true; + fill9patchOffsets(patch); + return patch; +} |