From 6ff9a28f783a78d27d47301023fd4f30c2afff13 Mon Sep 17 00:00:00 2001 From: halx99 Date: Mon, 24 May 2021 13:26:56 +0800 Subject: [PATCH] Better code style --- cocos/2d/CCParticleExamples.cpp | 2 +- cocos/platform/CCImage.cpp | 7 ++++++- cocos/platform/CCImage.h | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cocos/2d/CCParticleExamples.cpp b/cocos/2d/CCParticleExamples.cpp index 3991af5b27..f30a383d51 100644 --- a/cocos/2d/CCParticleExamples.cpp +++ b/cocos/2d/CCParticleExamples.cpp @@ -48,7 +48,7 @@ static Texture2D* getDefaultTexture() image = new (std::nothrow) 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); texture = Director::getInstance()->getTextureCache()->addImage(image, key); diff --git a/cocos/platform/CCImage.cpp b/cocos/platform/CCImage.cpp index 07a4d2de6a..a7125738d4 100644 --- a/cocos/platform/CCImage.cpp +++ b/cocos/platform/CCImage.cpp @@ -656,7 +656,12 @@ bool Image::initWithImageFileThreadSafe(const std::string& fullpath) 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(data), dataLen, false); +} + +bool Image::initWithImageData(uint8_t* data, ssize_t dataLen, bool ownData) { bool ret = false; diff --git a/cocos/platform/CCImage.h b/cocos/platform/CCImage.h index 8eecd2d5a3..2c56cbd5a0 100644 --- a/cocos/platform/CCImage.h +++ b/cocos/platform/CCImage.h @@ -157,7 +157,8 @@ public: * @js 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 bool initWithRawData(const uint8_t* data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti = false);