fix some bugs (#3581)

This commit is contained in:
江战
2021-05-28 18:39:14 +08:00
committed by GitHub
parent a645fb917f
commit 1029bd2759
6 changed files with 75 additions and 37 deletions
@@ -224,10 +224,10 @@ public:
if (_bufferWidth < 1.0F || _bufferHeight < 1.0F) {
return;
}
auto arr = JniHelper::getEnv()->NewIntArray(imageData.getSize()/ 4);
JniHelper::getEnv()->SetIntArrayRegion(arr, 0, imageData.getSize()/4,
reinterpret_cast<const jint *>(imageData.getBytes()));
auto arr = JniHelper::getEnv()->NewIntArray(imageData.getSize() / 4);
JniHelper::getEnv()->SetIntArrayRegion(arr, 0, imageData.getSize() / 4,
reinterpret_cast<const jint *>(imageData.getBytes()));
JniHelper::callObjectVoidMethod(_obj, JCLS_CANVASIMPL, "_fillImageData", arr, imageWidth,
imageHeight, offsetX, offsetY);
ccDeleteLocalRef(JniHelper::getEnv(), arr);
@@ -269,7 +269,9 @@ public:
jsize len = JniHelper::getEnv()->GetArrayLength(arr);
auto *jbarray = static_cast<jbyte *>(malloc(len * sizeof(jbyte)));
JniHelper::getEnv()->GetByteArrayRegion(arr, 0, len, jbarray);
#if CC_PLATFORM != CC_PLATFORM_OHOS
unMultiplyAlpha(reinterpret_cast<unsigned char *>(jbarray), len);
#endif
_data.fastSet(reinterpret_cast<unsigned char *>(jbarray), len); //IDEA: DON'T create new jbarray every time.
ccDeleteLocalRef(JniHelper::getEnv(), arr);
}