Better code style

This commit is contained in:
halx99 2021-05-24 13:26:56 +08:00
parent 65b2b8f65d
commit 6ff9a28f78
3 changed files with 9 additions and 3 deletions

View File

@ -48,7 +48,7 @@ static Texture2D* getDefaultTexture()
image = new (std::nothrow) Image(); image = new (std::nothrow) Image();
CC_BREAK_IF(nullptr == image); CC_BREAK_IF(nullptr == image);
bool ret = image->initWithImageData(__firePngData, sizeof(__firePngData), false); bool ret = image->initWithImageData(__firePngData, sizeof(__firePngData));
CC_BREAK_IF(!ret); CC_BREAK_IF(!ret);
texture = Director::getInstance()->getTextureCache()->addImage(image, key); texture = Director::getInstance()->getTextureCache()->addImage(image, key);

View File

@ -656,7 +656,12 @@ bool Image::initWithImageFileThreadSafe(const std::string& fullpath)
return ret; return ret;
} }
bool Image::initWithImageData(const uint8_t* data, ssize_t dataLen, bool ownData) bool Image::initWithImageData(const uint8_t* data, ssize_t dataLen)
{
return initWithImageData(const_cast<uint8_t*>(data), dataLen, false);
}
bool Image::initWithImageData(uint8_t* data, ssize_t dataLen, bool ownData)
{ {
bool ret = false; bool ret = false;

View File

@ -157,7 +157,8 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
bool initWithImageData(const uint8_t* data, ssize_t dataLen, bool ownData = false); bool initWithImageData(const uint8_t* data, ssize_t dataLen);
bool initWithImageData(uint8_t* data, ssize_t dataLen, bool ownData);
// @warning kFmtRawData only support RGBA8888 // @warning kFmtRawData only support RGBA8888
bool initWithRawData(const uint8_t* data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti = false); bool initWithRawData(const uint8_t* data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti = false);