Resolve local reference leak and function order

This commit is contained in:
pandamicro 2016-05-17 12:06:28 +08:00
parent 6b59dc24c7
commit c96bd9a4df
2 changed files with 26 additions and 20 deletions

View File

@ -100,6 +100,21 @@ public:
UNKNOWN UNKNOWN
}; };
/**
* Enables or disables premultiplied alpha for PNG files.
*
* @param enabled (default: true)
*/
static void setPNGPremultipliedAlphaEnabled(bool enabled) { PNG_PREMULTIPLIED_ALPHA_ENABLED = enabled; }
/** treats (or not) PVR files as if they have alpha premultiplied.
Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is
possible load them as if they have (or not) the alpha channel premultiplied.
By default it is disabled.
*/
static void setPVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
/** /**
@brief Load the image from the specified path. @brief Load the image from the specified path.
@param path the absolute file path. @param path the absolute file path.
@ -145,21 +160,6 @@ public:
*/ */
bool saveToFile(const std::string &filename, bool isToRGB = true); bool saveToFile(const std::string &filename, bool isToRGB = true);
/**
* Enables or disables premultiplied alpha for PNG files.
*
* @param enabled (default: true)
*/
static void setPNGPremultipliedAlphaEnabled(bool enabled) { PNG_PREMULTIPLIED_ALPHA_ENABLED = enabled; }
/** treats (or not) PVR files as if they have alpha premultiplied.
Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is
possible load them as if they have (or not) the alpha channel premultiplied.
By default it is disabled.
*/
static void setPVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
protected: protected:
#if defined(CC_USE_WIC) #if defined(CC_USE_WIC)
bool encodeWithWIC(const std::string& filePath, bool isToRGB, GUID containerFormat); bool encodeWithWIC(const std::string& filePath, bool isToRGB, GUID containerFormat);

View File

@ -96,13 +96,19 @@ bool localStorageGetItem( const std::string& key, std::string *outItem )
jstring jret = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, jkey); jstring jret = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, jkey);
if (jret == nullptr) if (jret == nullptr)
{ {
t.env->DeleteLocalRef(jret);
t.env->DeleteLocalRef(jkey);
t.env->DeleteLocalRef(t.classID);
return false; return false;
} }
outItem->assign(JniHelper::jstring2string(jret)); else
t.env->DeleteLocalRef(jret); {
t.env->DeleteLocalRef(jkey); outItem->assign(JniHelper::jstring2string(jret));
t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(jret);
return true; t.env->DeleteLocalRef(jkey);
t.env->DeleteLocalRef(t.classID);
return true;
}
} }
else else
{ {