diff --git a/native/cocos/3d/assets/Mesh.cpp b/native/cocos/3d/assets/Mesh.cpp index fed2f9f2aa..e343ba38d5 100644 --- a/native/cocos/3d/assets/Mesh.cpp +++ b/native/cocos/3d/assets/Mesh.cpp @@ -980,7 +980,7 @@ void Mesh::updateSubMesh(index_t primitiveIndex, const IDynamicGeometry &geometr auto * dstBuffer = _data.buffer()->getData() + bundle.view.offset; const auto *srcBuffer = vertices.buffer()->getData() + vertices.byteOffset(); auto * vertexBuffer = subMesh->getVertexBuffers()[index]; - CCASSERT(vertexCount <= info.maxSubMeshVertices, "Too many vertices."); + CC_ASSERT(vertexCount <= info.maxSubMeshVertices); if (updateSize > 0U) { std::memcpy(dstBuffer, srcBuffer, updateSize); @@ -1000,7 +1000,7 @@ void Mesh::updateSubMesh(index_t primitiveIndex, const IDynamicGeometry &geometr const auto *srcBuffer = (stride == sizeof(uint16_t)) ? geometry.indices16.value().buffer()->getData() + geometry.indices16.value().byteOffset() : geometry.indices32.value().buffer()->getData() + geometry.indices32.value().byteOffset(); auto * indexBuffer = subMesh->getIndexBuffer(); - CCASSERT(indexCount <= info.maxSubMeshIndices, "Too many indices."); + CC_ASSERT(indexCount <= info.maxSubMeshIndices); if (updateSize > 0U) { std::memcpy(dstBuffer, srcBuffer, updateSize); diff --git a/native/cocos/application/CocosApplication.cpp b/native/cocos/application/CocosApplication.cpp index 2a81a42f3a..9ce8efd599 100644 --- a/native/cocos/application/CocosApplication.cpp +++ b/native/cocos/application/CocosApplication.cpp @@ -41,7 +41,7 @@ namespace cc { CocosApplication::CocosApplication() { _engine = BaseEngine::createEngine(); _systemWidow = _engine->getInterface(); - CCASSERT(_systemWidow != nullptr, "Invalid interface pointer"); + CC_ASSERT(_systemWidow != nullptr); } CocosApplication::~CocosApplication() { diff --git a/native/cocos/base/Macros.h b/native/cocos/base/Macros.h index 44c10a9d7f..29b0d55477 100644 --- a/native/cocos/base/Macros.h +++ b/native/cocos/base/Macros.h @@ -75,17 +75,6 @@ #define CC_DLL #endif -#ifndef CCASSERT - #if CC_DEBUG > 0 - #define CCASSERT(cond, msg) CC_ASSERT(cond) - // #endif - #else - #define CCASSERT(cond, msg) - #endif - - #define GP_ASSERT(cond) CCASSERT(cond, "") -#endif // CCASSERT - /** @def CC_DEGREES_TO_RADIANS converts degrees to radians */ diff --git a/native/cocos/base/RefMap.h b/native/cocos/base/RefMap.h index eba474ea07..1d7f689182 100644 --- a/native/cocos/base/RefMap.h +++ b/native/cocos/base/RefMap.h @@ -204,7 +204,7 @@ public: * @param object The object to be inserted. */ void insert(const K &key, V object) { - CCASSERT(object != nullptr, "Object is nullptr!"); + CC_ASSERT(object != nullptr); object->addRef(); erase(key); _data.insert(std::make_pair(key, object)); @@ -217,7 +217,7 @@ public: * Member type const_iterator is a forward iterator type. */ iterator erase(const_iterator position) { - CCASSERT(position != _data.cend(), "Invalid iterator!"); + CC_ASSERT(position != _data.cend()); position->second->release(); return _data.erase(position); } diff --git a/native/cocos/base/Scheduler.cpp b/native/cocos/base/Scheduler.cpp index fe08ee7c0d..4af2bf8946 100644 --- a/native/cocos/base/Scheduler.cpp +++ b/native/cocos/base/Scheduler.cpp @@ -149,8 +149,8 @@ void Scheduler::schedule(const ccSchedulerFunc &callback, void *target, float in } void Scheduler::schedule(const ccSchedulerFunc &callback, void *target, float interval, unsigned int repeat, float delay, bool paused, const ccstd::string &key) { - CCASSERT(target, "Argument target must be non-nullptr"); - CCASSERT(!key.empty(), "key should not be empty!"); + CC_ASSERT(target); + CC_ASSERT(!key.empty()); auto iter = _hashForTimers.find(target); HashTimerEntry *element = nullptr; @@ -164,7 +164,7 @@ void Scheduler::schedule(const ccSchedulerFunc &callback, void *target, float in element->paused = paused; } else { element = iter->second; - CCASSERT(element->paused == paused, "element's paused should be paused!"); + CC_ASSERT(element->paused == paused); } if (element->timers.empty()) { @@ -232,8 +232,8 @@ void Scheduler::unschedule(const ccstd::string &key, void *target) { } bool Scheduler::isScheduled(const ccstd::string &key, void *target) { - CCASSERT(!key.empty(), "Argument key must not be empty"); - CCASSERT(target, "Argument target must be non-nullptr"); + CC_ASSERT(!key.empty()); + CC_ASSERT(target); auto iter = _hashForTimers.find(target); if (iter == _hashForTimers.end()) { @@ -290,7 +290,7 @@ void Scheduler::unscheduleAllForTarget(void *target) { } void Scheduler::resumeTarget(void *target) { - CCASSERT(target != nullptr, "target can't be nullptr!"); + CC_ASSERT(target != nullptr); // custom selectors auto iter = _hashForTimers.find(target); @@ -300,7 +300,7 @@ void Scheduler::resumeTarget(void *target) { } void Scheduler::pauseTarget(void *target) { - CCASSERT(target != nullptr, "target can't be nullptr!"); + CC_ASSERT(target != nullptr); // custom selectors auto iter = _hashForTimers.find(target); @@ -310,7 +310,7 @@ void Scheduler::pauseTarget(void *target) { } bool Scheduler::isTargetPaused(void *target) { - CCASSERT(target != nullptr, "target must be non nil"); + CC_ASSERT(target != nullptr); // Custom selectors auto iter = _hashForTimers.find(target); diff --git a/native/cocos/base/TypeDef.h b/native/cocos/base/TypeDef.h index 2eafbd20d5..f79d4f05fb 100644 --- a/native/cocos/base/TypeDef.h +++ b/native/cocos/base/TypeDef.h @@ -60,7 +60,7 @@ using index_t = int32_t; inline void operator^=(T &lhs, const T rhs) { lhs = static_cast(static_cast::type>(lhs) ^ static_cast::type>(rhs)); } \ inline bool hasFlag(const T flags, const T flagToTest) { \ using ValueType = std::underlying_type::type; \ - CCASSERT((static_cast(flagToTest) & (static_cast(flagToTest) - 1)) == 0, "More than one flag specified"); \ + CC_ASSERT((static_cast(flagToTest) & (static_cast(flagToTest) - 1)) == 0); \ return (static_cast(flags) & static_cast(flagToTest)) != 0; \ } \ inline bool hasAnyFlags(const T flags, const T flagsToTest) { \ diff --git a/native/cocos/base/Utils.h b/native/cocos/base/Utils.h index de0bb89f63..d08348f276 100644 --- a/native/cocos/base/Utils.h +++ b/native/cocos/base/Utils.h @@ -120,8 +120,7 @@ template inline uint toUint(T value) { static_assert(std::is_arithmetic::value, "T must be numeric"); - CCASSERT(static_cast(value) <= static_cast(std::numeric_limits::max()), - "value is too big to be converted to uint"); + CC_ASSERT(static_cast(value) <= static_cast(std::numeric_limits::max())); return static_cast(value); } diff --git a/native/cocos/base/Value.cpp b/native/cocos/base/Value.cpp index f5c69824c2..cae51bde27 100644 --- a/native/cocos/base/Value.cpp +++ b/native/cocos/base/Value.cpp @@ -405,7 +405,7 @@ bool Value::operator==(const Value &v) const { //NOLINT(misc-no-recursion) /// Convert value to a specified type unsigned char Value::asByte() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); + CC_ASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP); if (_type == Type::BYTE) { return _field.byteVal; @@ -439,13 +439,13 @@ unsigned char Value::asByte() const { } int Value::asInt() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); + CC_ASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP); if (_type == Type::INTEGER) { return _field.intVal; } if (_type == Type::UNSIGNED) { - CCASSERT(_field.unsignedVal < INT_MAX, "Can only convert values < INT_MAX"); + CC_ASSERT(_field.unsignedVal < INT_MAX); return static_cast(_field.unsignedVal); } @@ -473,13 +473,13 @@ int Value::asInt() const { } unsigned int Value::asUnsignedInt() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); + CC_ASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP); if (_type == Type::UNSIGNED) { return _field.unsignedVal; } if (_type == Type::INTEGER) { - CCASSERT(_field.intVal >= 0, "Only values >= 0 can be converted to unsigned"); + CC_ASSERT(_field.intVal >= 0); return static_cast(_field.intVal); } @@ -508,7 +508,7 @@ unsigned int Value::asUnsignedInt() const { } float Value::asFloat() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); + CC_ASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP); if (_type == Type::FLOAT) { return _field.floatVal; } @@ -541,7 +541,7 @@ float Value::asFloat() const { } double Value::asDouble() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); + CC_ASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP); if (_type == Type::DOUBLE) { return _field.doubleVal; } @@ -574,7 +574,7 @@ double Value::asDouble() const { } bool Value::asBool() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); + CC_ASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP); if (_type == Type::BOOLEAN) { return _field.boolVal; } @@ -607,7 +607,7 @@ bool Value::asBool() const { } ccstd::string Value::asString() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); + CC_ASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP); if (_type == Type::STRING) { return *_field.strVal; @@ -641,32 +641,32 @@ ccstd::string Value::asString() const { } ValueVector &Value::asValueVector() { - CCASSERT(_type == Type::VECTOR, "The value type isn't Type::VECTOR"); + CC_ASSERT(_type == Type::VECTOR); return *_field.vectorVal; } const ValueVector &Value::asValueVector() const { - CCASSERT(_type == Type::VECTOR, "The value type isn't Type::VECTOR"); + CC_ASSERT(_type == Type::VECTOR); return *_field.vectorVal; } ValueMap &Value::asValueMap() { - CCASSERT(_type == Type::MAP, "The value type isn't Type::MAP"); + CC_ASSERT(_type == Type::MAP); return *_field.mapVal; } const ValueMap &Value::asValueMap() const { - CCASSERT(_type == Type::MAP, "The value type isn't Type::MAP"); + CC_ASSERT(_type == Type::MAP); return *_field.mapVal; } ValueMapIntKey &Value::asIntKeyMap() { - CCASSERT(_type == Type::INT_KEY_MAP, "The value type isn't Type::INT_KEY_MAP"); + CC_ASSERT(_type == Type::INT_KEY_MAP); return *_field.intKeyMapVal; } const ValueMapIntKey &Value::asIntKeyMap() const { - CCASSERT(_type == Type::INT_KEY_MAP, "The value type isn't Type::INT_KEY_MAP"); + CC_ASSERT(_type == Type::INT_KEY_MAP); return *_field.intKeyMapVal; } @@ -746,7 +746,7 @@ static ccstd::string visit(const Value &v, int depth) { //NOLINT[misc-no-recursi ret << visitMap(v.asIntKeyMap(), depth); break; default: - CCASSERT(false, "Invalid type!"); + CC_ASSERT(false); break; } diff --git a/native/cocos/base/ZipUtils.cpp b/native/cocos/base/ZipUtils.cpp index 05df667261..3716a55dd3 100644 --- a/native/cocos/base/ZipUtils.cpp +++ b/native/cocos/base/ZipUtils.cpp @@ -70,10 +70,10 @@ inline void ZipUtils::decodeEncodedPvr(unsigned int *data, uint32_t len) { // check if key was set // make sure to call caw_setkey_part() for all 4 key parts - CCASSERT(ZipUtils::encryptedPvrKeyParts[0] != 0, "ZipUtils: CCZ file is encrypted but key part 0 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); - CCASSERT(ZipUtils::encryptedPvrKeyParts[1] != 0, "ZipUtils: CCZ file is encrypted but key part 1 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); - CCASSERT(ZipUtils::encryptedPvrKeyParts[2] != 0, "ZipUtils: CCZ file is encrypted but key part 2 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); - CCASSERT(ZipUtils::encryptedPvrKeyParts[3] != 0, "ZipUtils: CCZ file is encrypted but key part 3 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); + CC_ASSERT(ZipUtils::encryptedPvrKeyParts[0] != 0); // CCZ file is encrypted but key part 0 is not set. Call ZipUtils::setPvrEncryptionKeyPart(...)? + CC_ASSERT(ZipUtils::encryptedPvrKeyParts[1] != 0); // CCZ file is encrypted but key part 1 is not set. Call ZipUtils::setPvrEncryptionKeyPart(...)? + CC_ASSERT(ZipUtils::encryptedPvrKeyParts[2] != 0); // CCZ file is encrypted but key part 2 is not set. Call ZipUtils::setPvrEncryptionKeyPart(...)? + CC_ASSERT(ZipUtils::encryptedPvrKeyParts[3] != 0); // CCZ file is encrypted but key part 3 is not set. Call ZipUtils::setPvrEncryptionKeyPart(...)? // create long key if (!ZipUtils::encryptionKeyIsValid) { @@ -236,8 +236,8 @@ int ZipUtils::inflateGZipFile(const char *path, unsigned char **out) { int len; int offset = 0; - CCASSERT(out, "out can't be nullptr."); - CCASSERT(&*out, "&*out can't be nullptr."); + CC_ASSERT(out); + CC_ASSERT(&*out); gzFile inFile = gzopen(FileUtils::getInstance()->getSuitableFOpen(path).c_str(), "rb"); if (inFile == nullptr) { @@ -413,7 +413,7 @@ int ZipUtils::inflateCCZBuffer(const unsigned char *buffer, uint32_t bufferLen, } int ZipUtils::inflateCCZFile(const char *path, unsigned char **out) { - CCASSERT(out, "Invalid pointer for buffer!"); + CC_ASSERT(out); // load file into memory Data compressedData = FileUtils::getInstance()->getDataFromFile(path); @@ -427,8 +427,8 @@ int ZipUtils::inflateCCZFile(const char *path, unsigned char **out) { } void ZipUtils::setPvrEncryptionKeyPart(int index, unsigned int value) { - CCASSERT(index >= 0, "key part index cannot be less than 0"); - CCASSERT(index <= 3, "key part index cannot be greater than 3"); + CC_ASSERT(index >= 0); + CC_ASSERT(index <= 3); if (ZipUtils::encryptedPvrKeyParts[index] != value) { ZipUtils::encryptedPvrKeyParts[index] = value; @@ -573,7 +573,7 @@ unsigned char *ZipFile::getFileData(const ccstd::string &fileName, uint32_t *siz buffer = static_cast(malloc(fileInfo.uncompressed_size)); int CC_UNUSED nSize = unzReadCurrentFile(*zipFile, buffer, static_cast(fileInfo.uncompressed_size)); - CCASSERT(nSize == 0 || nSize == (int)fileInfo.uncompressed_size, "the file size is wrong"); + CC_ASSERT(nSize == 0 || nSize == (int)fileInfo.uncompressed_size); if (size) { *size = static_cast(fileInfo.uncompressed_size); @@ -604,7 +604,7 @@ bool ZipFile::getFileData(const ccstd::string &fileName, ResizableBuffer *buffer buffer->resize(fileInfo.uncompressed_size); int CC_UNUSED nSize = unzReadCurrentFile(*zipFile, buffer->buffer(), static_cast(fileInfo.uncompressed_size)); - CCASSERT(nSize == 0 || nSize == (int)fileInfo.uncompressed_size, "the file size is wrong"); + CC_ASSERT(nSize == 0 || nSize == (int)fileInfo.uncompressed_size); unzCloseCurrentFile(*zipFile); res = true; } while (false); diff --git a/native/cocos/base/memory/CallStack.cpp b/native/cocos/base/memory/CallStack.cpp index 506c2396e8..918026b5b7 100644 --- a/native/cocos/base/memory/CallStack.cpp +++ b/native/cocos/base/memory/CallStack.cpp @@ -283,8 +283,8 @@ ccstd::vector CallStack::backtraceSymbols(const ccstd::vector> _entryBits; uint entry = _entryMask & id; - CCASSERT(chunk < _chunks.size() && entry < _entriesPerChunk, "BufferPool: Invalid buffer pool entry id"); + CC_ASSERT(chunk < _chunks.size() && entry < _entriesPerChunk); return reinterpret_cast(_chunks[chunk] + (entry * _bytesPerEntry)); } diff --git a/native/cocos/bindings/event/EventDispatcher.cpp b/native/cocos/bindings/event/EventDispatcher.cpp index 5a18c483c3..638f36088a 100644 --- a/native/cocos/bindings/event/EventDispatcher.cpp +++ b/native/cocos/bindings/event/EventDispatcher.cpp @@ -325,7 +325,7 @@ void EventDispatcher::doDispatchEvent(const char *eventName, const char *jsFunct if (eventName) { CustomEvent event; event.name = eventName; - CCASSERT(CC_GET_PLATFORM_INTERFACE(ISystemWindow) != nullptr, "System window interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(ISystemWindow) != nullptr); event.args->ptrVal = reinterpret_cast(CC_GET_PLATFORM_INTERFACE(ISystemWindow)->getWindowHandler()); EventDispatcher::dispatchCustomEvent(event); diff --git a/native/cocos/bindings/jswrapper/sm/Class.cpp b/native/cocos/bindings/jswrapper/sm/Class.cpp index 4892a2d053..2a5791c4d2 100644 --- a/native/cocos/bindings/jswrapper/sm/Class.cpp +++ b/native/cocos/bindings/jswrapper/sm/Class.cpp @@ -78,7 +78,7 @@ Class *Class::create(const std::initializer_list &classPath, se::O se::Value tmp; for (auto i = 0; i < classPath.size() - 1; i++) { bool ok = currentParent->getProperty(*(classPath.begin() + i), &tmp); - CCASSERT(ok, "class or namespace in path is not defined"); + CC_ASSERT(ok); // class or namespace in path is not defined currentParent = tmp.toObject(); } return create(*(classPath.end() - 1), currentParent, parentProto, ctor); diff --git a/native/cocos/bindings/jswrapper/v8/Class.cpp b/native/cocos/bindings/jswrapper/v8/Class.cpp index 50a652a403..99c1994ee6 100644 --- a/native/cocos/bindings/jswrapper/v8/Class.cpp +++ b/native/cocos/bindings/jswrapper/v8/Class.cpp @@ -81,7 +81,7 @@ Class *Class::create(const std::initializer_list &classPath, se::O se::Value tmp; for (auto i = 0; i < classPath.size() - 1; i++) { bool ok = currentParent->getProperty(*(classPath.begin() + i), &tmp); - CCASSERT(ok, "class or namespace in path is not defined"); + CC_ASSERT(ok); // class or namespace in path is not defined currentParent = tmp.toObject(); } return create(*(classPath.end() - 1), currentParent, parentProto, ctor); diff --git a/native/cocos/bindings/manual/jsb_global.cpp b/native/cocos/bindings/manual/jsb_global.cpp index e04cb38a4b..ceba8f310c 100644 --- a/native/cocos/bindings/manual/jsb_global.cpp +++ b/native/cocos/bindings/manual/jsb_global.cpp @@ -346,7 +346,7 @@ SE_BIND_FUNC(JSBCore_os) static bool JSBCore_getCurrentLanguage(se::State &s) { //NOLINT ISystem *systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); - CCASSERT(systemIntf != nullptr, "System interface does not exist"); + CC_ASSERT(systemIntf != nullptr); ccstd::string languageStr = systemIntf->getCurrentLanguageToString(); s.rval().setString(languageStr); return true; @@ -355,7 +355,7 @@ SE_BIND_FUNC(JSBCore_getCurrentLanguage) static bool JSBCore_getCurrentLanguageCode(se::State &s) { //NOLINT ISystem *systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); - CCASSERT(systemIntf != nullptr, "System interface does not exist"); + CC_ASSERT(systemIntf != nullptr); ccstd::string language = systemIntf->getCurrentLanguageCode(); s.rval().setString(language); return true; @@ -364,7 +364,7 @@ SE_BIND_FUNC(JSBCore_getCurrentLanguageCode) static bool JSB_getOSVersion(se::State &s) { //NOLINT ISystem *systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); - CCASSERT(systemIntf != nullptr, "System interface does not exist"); + CC_ASSERT(systemIntf != nullptr); ccstd::string systemVersion = systemIntf->getSystemVersion(); s.rval().setString(systemVersion); return true; @@ -409,7 +409,7 @@ static bool JSB_setCursorEnabled(se::State &s) { //NOLINT SE_PRECONDITION2(ok, false, "Error processing arguments"); auto *systemWindowIntf = CC_GET_PLATFORM_INTERFACE(ISystemWindow); - CCASSERT(systemWindowIntf != nullptr, "System window interface does not exist"); + CC_ASSERT(systemWindowIntf != nullptr); systemWindowIntf->setCursorEnabled(value); return true; } @@ -674,7 +674,7 @@ static bool JSB_openURL(se::State &s) { //NOLINT ok = sevalue_to_native(args[0], &url); SE_PRECONDITION2(ok, false, "url is invalid!"); ISystem *systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem); - CCASSERT(systemIntf != nullptr, "System interface does not exist"); + CC_ASSERT(systemIntf != nullptr); systemIntf->openURL(url); return true; } @@ -693,7 +693,7 @@ static bool JSB_copyTextToClipboard(se::State &s) { //NOLINT ok = sevalue_to_native(args[0], &text); SE_PRECONDITION2(ok, false, "text is invalid!"); ISystemWindow *systemWindowIntf = CC_GET_PLATFORM_INTERFACE(ISystemWindow); - CCASSERT(systemWindowIntf != nullptr, "System window interface does not exist"); + CC_ASSERT(systemWindowIntf != nullptr); systemWindowIntf->copyTextToClipboard(text); return true; } diff --git a/native/cocos/bindings/manual/jsb_spine_manual.cpp b/native/cocos/bindings/manual/jsb_spine_manual.cpp index e4df93ec27..5e50eb15bf 100644 --- a/native/cocos/bindings/manual/jsb_spine_manual.cpp +++ b/native/cocos/bindings/manual/jsb_spine_manual.cpp @@ -115,13 +115,13 @@ static bool js_register_spine_initSkeletonData(se::State &s) { spine::SkeletonBinary binary(attachmentLoader); binary.setScale(scale); skeletonData = binary.readSkeletonData(cocos2dData.getBytes(), (int)cocos2dData.getSize()); - CCASSERT(skeletonData, !binary.getError().isEmpty() ? binary.getError().buffer() : "Error reading binary skeleton data."); + CC_ASSERT(skeletonData); // Can use binary.getError() to get error message. } } else { spine::SkeletonJson json(attachmentLoader); json.setScale(scale); skeletonData = json.readSkeletonData(skeletonDataFile.c_str()); - CCASSERT(skeletonData, !json.getError().isEmpty() ? json.getError().buffer() : "Error reading json skeleton data."); + CC_ASSERT(skeletonData); // Can use json.getError() to get error message. } if (skeletonData) { diff --git a/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp b/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp index 975d370c5f..80835615f7 100644 --- a/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp +++ b/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp @@ -256,7 +256,7 @@ bool XMLHttpRequest::open(const ccstd::string &method, const ccstd::string &url) requestType = HttpRequest::Type::DELETE; } - CCASSERT(requestType != HttpRequest::Type::UNKNOWN, (ccstd::string("XMLHttpRequest.open: Unknown method: ") + method).c_str()); + CC_ASSERT(requestType != HttpRequest::Type::UNKNOWN); _httpRequest->setRequestType(requestType); _httpRequest->setUrl(_url); diff --git a/native/cocos/core/assets/Font.cpp b/native/cocos/core/assets/Font.cpp index f38077fdac..9077cb9b7c 100644 --- a/native/cocos/core/assets/Font.cpp +++ b/native/cocos/core/assets/Font.cpp @@ -52,7 +52,7 @@ FontFaceInfo::FontFaceInfo(uint32_t size) FontFaceInfo::FontFaceInfo(uint32_t size, uint32_t width, uint32_t height) : fontSize(size), textureWidth(width), textureHeight(height) { - CCASSERT(math::IsPowerOfTwo(width) && math::IsPowerOfTwo(height), "Font texture size must be power of 2."); + CC_ASSERT(math::IsPowerOfTwo(width) && math::IsPowerOfTwo(height)); // Font texture size must be power of 2. // preload digit & alphabet characters by default for (auto i = 0U; i < 128; i++) { @@ -64,7 +64,7 @@ FontFaceInfo::FontFaceInfo(uint32_t size, uint32_t width, uint32_t height) FontFaceInfo::FontFaceInfo(uint32_t size, uint32_t width, uint32_t height, ccstd::vector chars) : fontSize(size), textureWidth(width), textureHeight(height), preLoadedCharacters(std::move(chars)) { - CCASSERT(math::IsPowerOfTwo(width) && math::IsPowerOfTwo(height), "Font texture size must be power of 2."); + CC_ASSERT(math::IsPowerOfTwo(width) && math::IsPowerOfTwo(height)); // Font texture size must be power of 2. } /** diff --git a/native/cocos/editor-support/dragonbones/parser/JSONDataParser.cpp b/native/cocos/editor-support/dragonbones/parser/JSONDataParser.cpp index 007122a83f..03714c72e8 100644 --- a/native/cocos/editor-support/dragonbones/parser/JSONDataParser.cpp +++ b/native/cocos/editor-support/dragonbones/parser/JSONDataParser.cpp @@ -1126,7 +1126,7 @@ unsigned JSONDataParser::_parseZOrderFrame(const rapidjson::Value &rawData, unsi } unsigned index = originalIndex + zOrderOffset; - // CCASSERT(index >= 0 && index < zOrders.size(), "DragonBones::JSONDataParser index is invalid"); + // CC_ASSERT(index >= 0 && index < zOrders.size()); if (!(index >= 0 && index < zOrders.size())) { originalIndex++; diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp index 46b983578b..a8fbda055e 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp +++ b/native/cocos/editor-support/spine-creator-support/SkeletonAnimation.cpp @@ -132,7 +132,7 @@ void SkeletonAnimation::update(float deltaTime) { } void SkeletonAnimation::setAnimationStateData(AnimationStateData *stateData) { - CCASSERT(stateData, "stateData cannot be null."); + CC_ASSERT(stateData); if (_state) { if (_ownsAnimationStateData) delete _state->getData(); diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp index ea14a4f518..af3dfcb654 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp +++ b/native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp @@ -173,7 +173,7 @@ void SkeletonRenderer::initWithUUID(const std::string &uuid) { _ownsSkeleton = true; _uuid = uuid; SkeletonData *skeletonData = SkeletonDataMgr::getInstance()->retainByUUID(uuid); - CCASSERT(skeletonData, "Skeleton data is is null"); + CC_ASSERT(skeletonData); setSkeletonData(skeletonData, false); initialize(); @@ -201,7 +201,7 @@ void SkeletonRenderer::initWithJsonFile(const std::string &skeletonDataFile, Atl SkeletonJson json(_attachmentLoader); json.setScale(scale); SkeletonData *skeletonData = json.readSkeletonDataFile(skeletonDataFile.c_str()); - CCASSERT(skeletonData, !json.getError().isEmpty() ? json.getError().buffer() : "Error reading skeleton data."); + CC_ASSERT(skeletonData); // Can use json.getError() to get error message. _ownsSkeleton = true; setSkeletonData(skeletonData, true); @@ -211,14 +211,14 @@ void SkeletonRenderer::initWithJsonFile(const std::string &skeletonDataFile, Atl void SkeletonRenderer::initWithJsonFile(const std::string &skeletonDataFile, const std::string &atlasFile, float scale) { _atlas = new (__FILE__, __LINE__) Atlas(atlasFile.c_str(), &textureLoader); - CCASSERT(_atlas, "Error reading atlas file."); + CC_ASSERT(_atlas); _attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas); SkeletonJson json(_attachmentLoader); json.setScale(scale); SkeletonData *skeletonData = json.readSkeletonDataFile(skeletonDataFile.c_str()); - CCASSERT(skeletonData, !json.getError().isEmpty() ? json.getError().buffer() : "Error reading skeleton data."); + CC_ASSERT(skeletonData); // Can use json.getError() to get error message. _ownsSkeleton = true; _ownsAtlas = true; @@ -234,7 +234,7 @@ void SkeletonRenderer::initWithBinaryFile(const std::string &skeletonDataFile, A SkeletonBinary binary(_attachmentLoader); binary.setScale(scale); SkeletonData *skeletonData = binary.readSkeletonDataFile(skeletonDataFile.c_str()); - CCASSERT(skeletonData, !binary.getError().isEmpty() ? binary.getError().buffer() : "Error reading skeleton data."); + CC_ASSERT(skeletonData); // Can use binary.getError() to get error message. _ownsSkeleton = true; setSkeletonData(skeletonData, true); @@ -244,14 +244,14 @@ void SkeletonRenderer::initWithBinaryFile(const std::string &skeletonDataFile, A void SkeletonRenderer::initWithBinaryFile(const std::string &skeletonDataFile, const std::string &atlasFile, float scale) { _atlas = new (__FILE__, __LINE__) Atlas(atlasFile.c_str(), &textureLoader); - CCASSERT(_atlas, "Error reading atlas file."); + CC_ASSERT(_atlas); _attachmentLoader = new (__FILE__, __LINE__) Cocos2dAtlasAttachmentLoader(_atlas); SkeletonBinary binary(_attachmentLoader); binary.setScale(scale); SkeletonData *skeletonData = binary.readSkeletonDataFile(skeletonDataFile.c_str()); - CCASSERT(skeletonData, !binary.getError().isEmpty() ? binary.getError().buffer() : "Error reading skeleton data."); + CC_ASSERT(skeletonData); // Can use binary.getError() to get error message. _ownsSkeleton = true; _ownsAtlas = true; diff --git a/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp b/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp index ab555d7d74..d1898f0614 100644 --- a/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp +++ b/native/cocos/editor-support/spine-creator-support/spine-cocos2dx.cpp @@ -107,7 +107,7 @@ void Cocos2dTextureLoader::load(AtlasPage &page, const spine::String &path) { if (spine::customTextureLoader) { texture = spine::customTextureLoader(path.buffer()); } - CCASSERT(texture != nullptr, "Invalid image"); + CC_ASSERT(texture != nullptr); if (texture) { texture->addRef(); diff --git a/native/cocos/engine/Engine.cpp b/native/cocos/engine/Engine.cpp index abadb2ac27..253dbfcf71 100644 --- a/native/cocos/engine/Engine.cpp +++ b/native/cocos/engine/Engine.cpp @@ -203,8 +203,8 @@ void Engine::removeEventCallback(OSEventType evType) { return; } - // For debugging. - CCASSERT(false, "Interface does not exist"); + // For debugging. Interface does not exist. + CC_ASSERT(false); } void Engine::tick() { diff --git a/native/cocos/math/Geometry.cpp b/native/cocos/math/Geometry.cpp index 4768ca2f72..dd2122db7c 100644 --- a/native/cocos/math/Geometry.cpp +++ b/native/cocos/math/Geometry.cpp @@ -35,17 +35,13 @@ namespace cc { // implementation of Size -Size::Size(void) : width(0), - height(0) { -} +Size::Size() = default; Size::Size(float w, float h) : width(w), height(h) { } -Size::Size(const Size &other) : width(other.width), - height(other.height) { -} +Size::Size(const Size &other) = default; Size::Size(const Vec2 &point) : width(point.x), height(point.y) { @@ -74,7 +70,7 @@ Size Size::operator*(float a) const { } Size Size::operator/(float a) const { - CCASSERT(a != 0, "CCSize division by 0."); + CC_ASSERT(a != 0); return Size(this->width / a, this->height / a); } @@ -91,8 +87,8 @@ const Size Size::ZERO = Size(0, 0); // implementation of Rect -Rect::Rect(void) { - setRect(0.0f, 0.0f, 0.0f, 0.0f); +Rect::Rect() { + setRect(0.0F, 0.0F, 0.0F, 0.0F); } Rect::Rect(float x, float y, float width, float height) { @@ -113,7 +109,7 @@ Rect &Rect::operator=(const Rect &other) { void Rect::setRect(float x, float y, float width, float height) { // CGRect can support width<0 or height<0 - // CCASSERT(width >= 0.0f && height >= 0.0f, "width and height of Rect must not less than 0."); + // CC_ASSERT(width >= 0.0f && height >= 0.0f); origin.x = x; origin.y = y; @@ -132,7 +128,7 @@ float Rect::getMaxX() const { } float Rect::getMidX() const { - return origin.x + size.width / 2.0f; + return origin.x + size.width / 2.0F; } float Rect::getMinX() const { @@ -144,7 +140,7 @@ float Rect::getMaxY() const { } float Rect::getMidY() const { - return origin.y + size.height / 2.0f; + return origin.y + size.height / 2.0F; } float Rect::getMinY() const { diff --git a/native/cocos/math/Geometry.h b/native/cocos/math/Geometry.h index 466bb9babe..0f1f0ea6e1 100644 --- a/native/cocos/math/Geometry.h +++ b/native/cocos/math/Geometry.h @@ -24,33 +24,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __MATH_CCGEOMETRY_H__ -#define __MATH_CCGEOMETRY_H__ +#pragma once #include "base/Macros.h" #include "math/Vec2.h" -/** - * @addtogroup base - * @{ - */ - namespace cc { class CC_DLL Size { public: /**Width of the Size.*/ - float width; + float width{0.F}; /**Height of the Size.*/ - float height; + float height{0.F}; -public: /**Conversion from Vec2 to Size.*/ operator Vec2() const { return Vec2(width, height); } -public: /** @{ Constructor. @@ -65,45 +57,18 @@ public: explicit Size(const Vec2 &point); /**@}*/ - /** - * @js NA - * @lua NA - */ Size &operator=(const Size &other); - /** - * @js NA - * @lua NA - */ Size &operator=(const Vec2 &point); - /** - * @js NA - * @lua NA - */ Size operator+(const Size &right) const; - /** - * @js NA - * @lua NA - */ Size operator-(const Size &right) const; - /** - * @js NA - * @lua NA - */ Size operator*(float a) const; - /** - * @js NA - * @lua NA - */ Size operator/(float a) const; /** Set the width and height of Size. - * @js NA - * @lua NA */ void setSize(float width, float height); /** Check if two size is the same. - * @js NA */ bool equals(const Size &target) const; /**Size(0,0).*/ @@ -118,93 +83,52 @@ public: /**Width and height of the rect.*/ Size size; -public: - /** - Constructor an empty Rect. - * @js NA - */ Rect(); - /** - Constructor a rect. - * @js NA - */ Rect(float x, float y, float width, float height); - /** - Constructor a rect. - * @js NA - */ Rect(const Vec2 &pos, const Size &dimension); - /** - Copy constructor. - * @js NA - * @lua NA - */ Rect(const Rect &other); - /** - * @js NA - * @lua NA - */ Rect &operator=(const Rect &other); - /** - Set the x, y, width and height of Rect. - * @js NA - * @lua NA - */ void setRect(float x, float y, float width, float height); /** Get the left of the rect. - * @js NA */ float getMinX() const; /// return the leftmost x-value of current rect /** Get the X coordinate of center point. - * @js NA */ float getMidX() const; /// return the midpoint x-value of current rect /** Get the right of rect. - * @js NA */ float getMaxX() const; /// return the rightmost x-value of current rect /** Get the bottom of rect. - * @js NA */ float getMinY() const; /// return the bottommost y-value of current rect /** Get the Y coordinate of center point. - * @js NA */ float getMidY() const; /// return the midpoint y-value of current rect /** Get top of rect. - * @js NA */ float getMaxY() const; /// return the topmost y-value of current rect - /** - Compare two rects. - * @js NA - */ + bool equals(const Rect &rect) const; /** Check if the points is contained in the rect. - * @js NA */ bool containsPoint(const Vec2 &point) const; /** Check the intersect status of two rects. - * @js NA */ bool intersectsRect(const Rect &rect) const; /** Check the intersect status of the rect and a circle. - * @js NA */ bool intersectsCircle(const Vec2 ¢er, float radius) const; /** Get the min rect which can contain this and rect. - * @js NA - * @lua NA */ Rect unionWithRect(const Rect &rect) const; /**Compute the min rect which can contain this and rect, assign it to this.*/ @@ -214,8 +138,3 @@ public: }; } // namespace cc - -// end of base group -/// @} - -#endif // __MATH_CCGEOMETRY_H__ diff --git a/native/cocos/math/Mat3.cpp b/native/cocos/math/Mat3.cpp index 0e97f4734a..68708596ee 100644 --- a/native/cocos/math/Mat3.cpp +++ b/native/cocos/math/Mat3.cpp @@ -63,7 +63,7 @@ void Mat3::set(float m11, float m12, float m13, float m21, float m22, float m23, } void Mat3::set(const float *mat) { - GP_ASSERT(mat); + CC_ASSERT(mat); memcpy(this->m, mat, MATRIX3_SIZE); } @@ -84,11 +84,11 @@ void Mat3::identity(Mat3 &mat) { } void Mat3::fromViewUp(const Vec3 &view, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); fromViewUp(view, Vec3(0, 1, 0), out); } void Mat3::fromViewUp(const Vec3 &view, const Vec3 &up, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); if (view.lengthSquared() < math::EPSILON * math::EPSILON) { Mat3::identity(*out); return; @@ -121,7 +121,7 @@ void Mat3::transpose() { } void Mat3::transpose(const Mat3 &mat, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); out->m[0] = mat.m[0]; out->m[1] = mat.m[3]; out->m[2] = mat.m[6]; @@ -164,7 +164,7 @@ void Mat3::inverse() { } void Mat3::adjoint(const Mat3 &mat, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); float a00 = mat.m[0]; float a01 = mat.m[1]; float a02 = mat.m[2]; @@ -191,7 +191,7 @@ float Mat3::determinant() { } void Mat3::multiply(const Mat3 &a, const Mat3 &b, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); float a00 = a.m[0]; float a01 = a.m[1]; float a02 = a.m[2]; @@ -226,7 +226,7 @@ void Mat3::multiply(const Mat3 &a, const Mat3 &b, Mat3 *out) { } void Mat3::translate(const Mat3 &mat, const Vec2 &vec, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); float a00 = mat.m[0]; float a01 = mat.m[1]; float a02 = mat.m[2]; @@ -253,7 +253,7 @@ void Mat3::translate(const Mat3 &mat, const Vec2 &vec, Mat3 *out) { } void Mat3::rotate(const Mat3 &mat, float rad, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); float a00 = mat.m[0]; float a01 = mat.m[1]; float a02 = mat.m[2]; @@ -281,7 +281,7 @@ void Mat3::rotate(const Mat3 &mat, float rad, Mat3 *out) { } void Mat3::scale(const Mat3 &mat, const Vec2 &vec, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); float x = vec.x; float y = vec.y; @@ -299,7 +299,7 @@ void Mat3::scale(const Mat3 &mat, const Vec2 &vec, Mat3 *out) { } void Mat3::fromMat4(const Mat4 &mat, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); out->m[0] = mat.m[0]; out->m[1] = mat.m[1]; out->m[2] = mat.m[2]; @@ -312,7 +312,7 @@ void Mat3::fromMat4(const Mat4 &mat, Mat3 *out) { } void Mat3::fromTranslation(const Vec2 &vec, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); out->m[0] = 1; out->m[1] = 0; out->m[2] = 0; @@ -325,7 +325,7 @@ void Mat3::fromTranslation(const Vec2 &vec, Mat3 *out) { } void Mat3::fromRotation(float rad, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); float s = sin(rad); float c = cos(rad); @@ -343,7 +343,7 @@ void Mat3::fromRotation(float rad, Mat3 *out) { } void Mat3::fromScaling(const Vec2 &vec, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); out->m[0] = vec.x; out->m[1] = 0; out->m[2] = 0; @@ -358,7 +358,7 @@ void Mat3::fromScaling(const Vec2 &vec, Mat3 *out) { } void Mat3::fromQuat(const Quaternion &quat, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); float x = quat.x; float y = quat.y; float z = quat.z; @@ -391,7 +391,7 @@ void Mat3::fromQuat(const Quaternion &quat, Mat3 *out) { } void Mat3::add(const Mat3 &a, const Mat3 &b, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); out->m[0] = a.m[0] + b.m[0]; out->m[1] = a.m[1] + b.m[1]; out->m[2] = a.m[2] + b.m[2]; @@ -404,7 +404,7 @@ void Mat3::add(const Mat3 &a, const Mat3 &b, Mat3 *out) { } void Mat3::subtract(const Mat3 &a, const Mat3 &b, Mat3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); out->m[0] = a.m[0] - b.m[0]; out->m[1] = a.m[1] - b.m[1]; out->m[2] = a.m[2] - b.m[2]; diff --git a/native/cocos/math/Mat4.cpp b/native/cocos/math/Mat4.cpp index 6937eb97bc..185af03b34 100644 --- a/native/cocos/math/Mat4.cpp +++ b/native/cocos/math/Mat4.cpp @@ -68,7 +68,7 @@ void Mat4::createLookAt(const Vec3 &eyePosition, const Vec3 &targetPosition, con void Mat4::createLookAt(float eyePositionX, float eyePositionY, float eyePositionZ, float targetPositionX, float targetPositionY, float targetPositionZ, float upX, float upY, float upZ, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); Vec3 eye(eyePositionX, eyePositionY, eyePositionZ); Vec3 target(targetPositionX, targetPositionY, targetPositionZ); @@ -110,9 +110,9 @@ void Mat4::createLookAt(float eyePositionX, float eyePositionY, float eyePositio void Mat4::createPerspective(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane, bool isFieldOfViewY, float minClipZ, float projectionSignY, int orientation, Mat4 *dst) { - GP_ASSERT(dst); - GP_ASSERT(zFarPlane != zNearPlane); - GP_ASSERT(fieldOfView != 0.0F); + CC_ASSERT(dst); + CC_ASSERT(zFarPlane != zNearPlane); + CC_ASSERT(fieldOfView != 0.0F); const float f = 1.0F / tanf(fieldOfView / 2.0F); const float nf = 1.0F / (zNearPlane - zFarPlane); @@ -150,10 +150,10 @@ void Mat4::createOrthographicOffCenter(float left, float right, float bottom, fl } void Mat4::createOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane, float minClipZ, float projectionSignY, int orientation, Mat4 *dst) { - GP_ASSERT(dst); - GP_ASSERT(right != left); - GP_ASSERT(top != bottom); - GP_ASSERT(zFarPlane != zNearPlane); + CC_ASSERT(dst); + CC_ASSERT(right != left); + CC_ASSERT(top != bottom); + CC_ASSERT(zFarPlane != zNearPlane); const ccstd::array &preTransform = PRE_TRANSFORMS[orientation]; const float lr = 1.F / (left - right); @@ -245,7 +245,7 @@ void Mat4::createBillboardHelper(const Vec3 &objectPosition, const Vec3 &cameraP // } void Mat4::createScale(const Vec3 &scale, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); memcpy(dst->m, IDENTITY.m, MATRIX_SIZE); @@ -255,7 +255,7 @@ void Mat4::createScale(const Vec3 &scale, Mat4 *dst) { } void Mat4::createScale(float xScale, float yScale, float zScale, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); memcpy(dst->m, IDENTITY.m, MATRIX_SIZE); @@ -265,7 +265,7 @@ void Mat4::createScale(float xScale, float yScale, float zScale, Mat4 *dst) { } void Mat4::createRotation(const Quaternion &q, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); float x2 = q.x + q.x; float y2 = q.y + q.y; @@ -303,7 +303,7 @@ void Mat4::createRotation(const Quaternion &q, Mat4 *dst) { } void Mat4::createRotation(const Vec3 &axis, float angle, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); float x = axis.x; float y = axis.y; @@ -359,7 +359,7 @@ void Mat4::createRotation(const Vec3 &axis, float angle, Mat4 *dst) { } void Mat4::createRotationX(float angle, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); memcpy(dst->m, IDENTITY.m, MATRIX_SIZE); @@ -373,7 +373,7 @@ void Mat4::createRotationX(float angle, Mat4 *dst) { } void Mat4::createRotationY(float angle, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); memcpy(dst->m, IDENTITY.m, MATRIX_SIZE); @@ -387,7 +387,7 @@ void Mat4::createRotationY(float angle, Mat4 *dst) { } void Mat4::createRotationZ(float angle, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); memcpy(dst->m, IDENTITY.m, MATRIX_SIZE); @@ -401,7 +401,7 @@ void Mat4::createRotationZ(float angle, Mat4 *dst) { } void Mat4::createTranslation(const Vec3 &translation, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); memcpy(dst->m, IDENTITY.m, MATRIX_SIZE); @@ -411,7 +411,7 @@ void Mat4::createTranslation(const Vec3 &translation, Mat4 *dst) { } void Mat4::createTranslation(float xTranslation, float yTranslation, float zTranslation, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); memcpy(dst->m, IDENTITY.m, MATRIX_SIZE); @@ -425,7 +425,7 @@ void Mat4::add(float scalar) { } void Mat4::add(float scalar, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); #ifdef __SSE__ MathUtil::addMatrix(col, scalar, dst->col); #else @@ -438,7 +438,7 @@ void Mat4::add(const Mat4 &mat) { } void Mat4::add(const Mat4 &m1, const Mat4 &m2, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); #ifdef __SSE__ MathUtil::addMatrix(m1.col, m2.col, dst->col); #else @@ -722,7 +722,7 @@ void Mat4::getTranslation(Vec3 *translation) const { } void Mat4::getUpVector(Vec3 *dst) const { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = m[4]; dst->y = m[5]; @@ -730,7 +730,7 @@ void Mat4::getUpVector(Vec3 *dst) const { } void Mat4::getDownVector(Vec3 *dst) const { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = -m[4]; dst->y = -m[5]; @@ -738,7 +738,7 @@ void Mat4::getDownVector(Vec3 *dst) const { } void Mat4::getLeftVector(Vec3 *dst) const { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = -m[0]; dst->y = -m[1]; @@ -746,7 +746,7 @@ void Mat4::getLeftVector(Vec3 *dst) const { } void Mat4::getRightVector(Vec3 *dst) const { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = m[0]; dst->y = m[1]; @@ -754,7 +754,7 @@ void Mat4::getRightVector(Vec3 *dst) const { } void Mat4::getForwardVector(Vec3 *dst) const { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = -m[8]; dst->y = -m[9]; @@ -762,7 +762,7 @@ void Mat4::getForwardVector(Vec3 *dst) const { } void Mat4::getBackVector(Vec3 *dst) const { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = m[8]; dst->y = m[9]; @@ -842,7 +842,7 @@ void Mat4::multiply(float scalar, Mat4 *dst) const { } void Mat4::multiply(const Mat4 &m, float scalar, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); #ifdef __SSE__ MathUtil::multiplyMatrix(m.col, scalar, dst->col); #else @@ -855,7 +855,7 @@ void Mat4::multiply(const Mat4 &mat) { } void Mat4::multiply(const Mat4 &m1, const Mat4 &m2, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); #ifdef __SSE__ MathUtil::multiplyMatrix(m1.col, m2.col, dst->col); #else @@ -974,7 +974,7 @@ void Mat4::set(float m11, float m12, float m13, float m14, float m21, float m22, } void Mat4::set(const float *mat) { - GP_ASSERT(mat); + CC_ASSERT(mat); memcpy(this->m, mat, MATRIX_SIZE); } @@ -995,7 +995,7 @@ void Mat4::subtract(const Mat4 &mat) { } void Mat4::subtract(const Mat4 &m1, const Mat4 &m2, Mat4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); #ifdef __SSE__ MathUtil::subtractMatrix(m1.col, m2.col, dst->col); #else @@ -1004,7 +1004,7 @@ void Mat4::subtract(const Mat4 &m1, const Mat4 &m2, Mat4 *dst) { } void Mat4::transformVector(Vec3 *vector) const { - GP_ASSERT(vector); + CC_ASSERT(vector); transformVector(vector->x, vector->y, vector->z, 0.0F, vector); } @@ -1013,18 +1013,18 @@ void Mat4::transformVector(const Vec3 &vector, Vec3 *dst) const { } void Mat4::transformVector(float x, float y, float z, float w, Vec3 *dst) const { - GP_ASSERT(dst); + CC_ASSERT(dst); MathUtil::transformVec4(m, x, y, z, w, reinterpret_cast(dst)); } void Mat4::transformVector(Vec4 *vector) const { - GP_ASSERT(vector); + CC_ASSERT(vector); transformVector(*vector, vector); } void Mat4::transformVector(const Vec4 &vector, Vec4 *dst) const { - GP_ASSERT(dst); + CC_ASSERT(dst); #ifdef __SSE__ MathUtil::transformVec4(col, vector.v, dst->v); #else diff --git a/native/cocos/math/Mat4.h b/native/cocos/math/Mat4.h index 455fe9d7b0..591fa6ec73 100644 --- a/native/cocos/math/Mat4.h +++ b/native/cocos/math/Mat4.h @@ -794,7 +794,7 @@ public: * @param point The point to transform and also a vector to hold the result in. */ inline void transformPoint(Vec3 *point) const { - GP_ASSERT(point); + CC_ASSERT(point); transformVector(point->x, point->y, point->z, 1.0F, point); } @@ -806,7 +806,7 @@ public: * @param dst A vector to store the transformed point in. */ inline void transformPoint(const Vec3 &point, Vec3 *dst) const { - GP_ASSERT(dst); + CC_ASSERT(dst); transformVector(point.x, point.y, point.z, 1.0F, dst); } diff --git a/native/cocos/math/MathUtil.cpp b/native/cocos/math/MathUtil.cpp index ae98c0d2e5..bbf9d728c3 100644 --- a/native/cocos/math/MathUtil.cpp +++ b/native/cocos/math/MathUtil.cpp @@ -77,7 +77,7 @@ This file was modified to fit the cocos2d-x project NS_CC_MATH_BEGIN void MathUtil::smooth(float *x, float target, float elapsedTime, float responseTime) { - GP_ASSERT(x); + CC_ASSERT(x); if (elapsedTime > 0) { *x += (target - *x) * elapsedTime / (elapsedTime + responseTime); @@ -85,7 +85,7 @@ void MathUtil::smooth(float *x, float target, float elapsedTime, float responseT } void MathUtil::smooth(float *x, float target, float elapsedTime, float riseTime, float fallTime) { - GP_ASSERT(x); + CC_ASSERT(x); if (elapsedTime > 0) { float delta = target - *x; diff --git a/native/cocos/math/Quaternion.cpp b/native/cocos/math/Quaternion.cpp index acf32ccfa3..b7be5ba39e 100644 --- a/native/cocos/math/Quaternion.cpp +++ b/native/cocos/math/Quaternion.cpp @@ -75,7 +75,7 @@ void Quaternion::createFromRotationMatrix(const Mat4 &m, Quaternion *dst) { } void Quaternion::createFromAxisAngle(const Vec3 &axis, float angle, Quaternion *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); float halfAngle = angle * 0.5F; float sinHalfAngle = sinf(halfAngle); @@ -89,7 +89,7 @@ void Quaternion::createFromAxisAngle(const Vec3 &axis, float angle, Quaternion * } void Quaternion::createFromAngleZ(float z, Quaternion *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); z *= mathutils::HALF_TO_RAD; dst->x = dst->y = 0.F; @@ -146,7 +146,7 @@ void Quaternion::multiply(const Quaternion &q) { } void Quaternion::multiply(const Quaternion &q1, const Quaternion &q2, Quaternion *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); float x = q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y; float y = q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z * q2.x; @@ -194,7 +194,7 @@ void Quaternion::set(float xx, float yy, float zz, float ww) { } void Quaternion::set(const float *array) { - GP_ASSERT(array); + CC_ASSERT(array); x = array[0]; y = array[1]; z = array[2]; @@ -224,7 +224,7 @@ void Quaternion::setIdentity() { } float Quaternion::toAxisAngle(Vec3 *axis) const { - GP_ASSERT(axis); + CC_ASSERT(axis); Quaternion q(x, y, z, w); q.normalize(); @@ -237,8 +237,8 @@ float Quaternion::toAxisAngle(Vec3 *axis) const { } void Quaternion::lerp(const Quaternion &q1, const Quaternion &q2, float t, Quaternion *dst) { - GP_ASSERT(dst); - GP_ASSERT(!(t < 0.F || t > 1.F)); + CC_ASSERT(dst); + CC_ASSERT(!(t < 0.F || t > 1.F)); if (t == 0.F) { memcpy(dst, &q1, sizeof(float) * 4); @@ -258,12 +258,12 @@ void Quaternion::lerp(const Quaternion &q1, const Quaternion &q2, float t, Quate } void Quaternion::slerp(const Quaternion &q1, const Quaternion &q2, float t, Quaternion *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); slerp(q1.x, q1.y, q1.z, q1.w, q2.x, q2.y, q2.z, q2.w, t, &dst->x, &dst->y, &dst->z, &dst->w); } void Quaternion::squad(const Quaternion &q1, const Quaternion &q2, const Quaternion &s1, const Quaternion &s2, float t, Quaternion *dst) { - GP_ASSERT(!(t < 0.F || t > 1.F)); + CC_ASSERT(!(t < 0.F || t > 1.F)); Quaternion dstQ(0.F, 0.F, 0.F, 1.F); Quaternion dstS(0.F, 0.F, 0.F, 1.F); @@ -274,11 +274,11 @@ void Quaternion::squad(const Quaternion &q1, const Quaternion &q2, const Quatern } void Quaternion::fromViewUp(const Vec3 &view, Quaternion *out) { - GP_ASSERT(out); + CC_ASSERT(out); fromViewUp(view, Vec3(0, 1, 0), out); } void Quaternion::fromViewUp(const Vec3 &view, const Vec3 &up, Quaternion *out) { - GP_ASSERT(out); + CC_ASSERT(out); Mat3 mTemp{Mat3::IDENTITY}; Mat3::fromViewUp(view, up, &mTemp); Quaternion::fromMat3(mTemp, out); @@ -286,7 +286,7 @@ void Quaternion::fromViewUp(const Vec3 &view, const Vec3 &up, Quaternion *out) { } void Quaternion::fromEuler(float x, float y, float z, Quaternion *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); float halfToRad = 0.5F * cc::math::PI / 180.F; x *= halfToRad; y *= halfToRad; @@ -305,7 +305,7 @@ void Quaternion::fromEuler(float x, float y, float z, Quaternion *dst) { } void Quaternion::toEuler(const Quaternion &q, bool outerZ, Vec3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); float x{q.x}; float y{q.y}; float z{q.z}; @@ -342,7 +342,7 @@ void Quaternion::toEuler(const Quaternion &q, bool outerZ, Vec3 *out) { } void Quaternion::fromMat3(const Mat3 &m, Quaternion *out) { - GP_ASSERT(out); + CC_ASSERT(out); float m00 = m.m[0]; float m03 = m.m[1]; float m06 = m.m[2]; @@ -388,8 +388,8 @@ void Quaternion::slerp(float q1x, float q1y, float q1z, float q1w, float q2x, fl // It contains no division operations, no trig, no inverse trig // and no sqrt. Not only does this code tolerate small constraint // errors in the input quaternions, it actually corrects for them. - GP_ASSERT(dstx && dsty && dstz && dstw); - GP_ASSERT(!(t < 0.F || t > 1.F)); + CC_ASSERT(dstx && dsty && dstz && dstw); + CC_ASSERT(!(t < 0.F || t > 1.F)); if (t == 0.F) { *dstx = q1x; @@ -492,7 +492,7 @@ void Quaternion::slerp(float q1x, float q1y, float q1z, float q1w, float q2x, fl } void Quaternion::slerpForSquad(const Quaternion &q1, const Quaternion &q2, float t, Quaternion *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); // cos(omega) = q1 * q2; // slerp(q1, q2, t) = (q1*sin((1-t)*omega) + q2*sin(t*omega))/sin(omega); diff --git a/native/cocos/math/Vec2.cpp b/native/cocos/math/Vec2.cpp index 199d3bfed2..5f0a15ef1e 100644 --- a/native/cocos/math/Vec2.cpp +++ b/native/cocos/math/Vec2.cpp @@ -26,37 +26,37 @@ NS_CC_MATH_BEGIN -// returns true if segment A-B intersects with segment C-D. S->E is the overlap part -bool isOneDimensionSegmentOverlap(float A, float B, float C, float D, float *S, float *E) { - float ABmin = std::min(A, B); - float ABmax = std::max(A, B); - float CDmin = std::min(C, D); - float CDmax = std::max(C, D); +// returns true if segment a-b intersects with segment c-d. s->e is the overlap part +bool isOneDimensionSegmentOverlap(float a, float b, float c, float d, float *s, float *e) { + float abmin = std::min(a, b); + float abmax = std::max(a, b); + float cdmin = std::min(c, d); + float cdmax = std::max(c, d); - if (ABmax < CDmin || CDmax < ABmin) { - // ABmin->ABmax->CDmin->CDmax or CDmin->CDmax->ABmin->ABmax + if (abmax < cdmin || cdmax < abmin) { + // abmin->abmax->cdmin->cdmax or cdmin->cdmax->abmin->abmax return false; } else { - if (ABmin >= CDmin && ABmin <= CDmax) { - // CDmin->ABmin->CDmax->ABmax or CDmin->ABmin->ABmax->CDmax - if (S != nullptr) *S = ABmin; - if (E != nullptr) *E = CDmax < ABmax ? CDmax : ABmax; - } else if (ABmax >= CDmin && ABmax <= CDmax) { + if (abmin >= cdmin && abmin <= cdmax) { + // cdmin->abmin->cdmax->abmax or cdmin->abmin->abmax->cdmax + if (s != nullptr) *s = abmin; + if (e != nullptr) *e = cdmax < abmax ? cdmax : abmax; + } else if (abmax >= cdmin && abmax <= cdmax) { // ABmin->CDmin->ABmax->CDmax - if (S != nullptr) *S = CDmin; - if (E != nullptr) *E = ABmax; + if (s != nullptr) *s = cdmin; + if (e != nullptr) *e = abmax; } else { // ABmin->CDmin->CDmax->ABmax - if (S != nullptr) *S = CDmin; - if (E != nullptr) *E = CDmax; + if (s != nullptr) *s = cdmin; + if (e != nullptr) *e = cdmax; } return true; } } -// cross product of 2 vector. A->B X C->D -float crossProduct2Vector(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D) { - return (D.y - C.y) * (B.x - A.x) - (D.x - C.x) * (B.y - A.y); +// cross product of 2 vector. a->b X c->d +float crossProduct2Vector(const Vec2 &a, const Vec2 &b, const Vec2 &c, const Vec2 &d) { + return (d.y - c.y) * (b.x - a.x) - (d.x - c.x) * (b.y - a.y); } float Vec2::angle(const Vec2 &v1, const Vec2 &v2) { @@ -65,45 +65,53 @@ float Vec2::angle(const Vec2 &v1, const Vec2 &v2) { } void Vec2::add(const Vec2 &v1, const Vec2 &v2, Vec2 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = v1.x + v2.x; dst->y = v1.y + v2.y; } void Vec2::clamp(const Vec2 &min, const Vec2 &max) { - GP_ASSERT(!(min.x > max.x || min.y > max.y)); + CC_ASSERT(!(min.x > max.x || min.y > max.y)); // Clamp the x value. - if (x < min.x) + if (x < min.x) { x = min.x; - if (x > max.x) + } + if (x > max.x) { x = max.x; + } // Clamp the y value. - if (y < min.y) + if (y < min.y) { y = min.y; - if (y > max.y) + } + if (y > max.y) { y = max.y; + } } void Vec2::clamp(const Vec2 &v, const Vec2 &min, const Vec2 &max, Vec2 *dst) { - GP_ASSERT(dst); - GP_ASSERT(!(min.x > max.x || min.y > max.y)); + CC_ASSERT(dst); + CC_ASSERT(!(min.x > max.x || min.y > max.y)); // Clamp the x value. dst->x = v.x; - if (dst->x < min.x) + if (dst->x < min.x) { dst->x = min.x; - if (dst->x > max.x) + } + if (dst->x > max.x) { dst->x = max.x; + } // Clamp the y value. dst->y = v.y; - if (dst->y < min.y) + if (dst->y < min.y) { dst->y = min.y; - if (dst->y > max.y) + } + if (dst->y > max.y) { dst->y = max.y; + } } float Vec2::distance(const Vec2 &v) const { @@ -124,15 +132,17 @@ float Vec2::length() const { void Vec2::normalize() { float n = x * x + y * y; // Already normalized. - if (n == 1.0f) + if (n == 1.0F) { return; + } n = std::sqrt(n); // Too close to zero. - if (n < MATH_TOLERANCE) + if (n < MATH_TOLERANCE) { return; + } - n = 1.0f / n; + n = 1.0F / n; x *= n; y *= n; } @@ -149,8 +159,8 @@ void Vec2::rotate(const Vec2 &point, float angle) { if (point.isZero()) { float tempX = x * cosAngle - y * sinAngle; - y = y * cosAngle + x * sinAngle; - x = tempX; + y = y * cosAngle + x * sinAngle; + x = tempX; } else { float tempX = x - point.x; float tempY = y - point.y; @@ -161,14 +171,14 @@ void Vec2::rotate(const Vec2 &point, float angle) { } void Vec2::set(const float *array) { - GP_ASSERT(array); + CC_ASSERT(array); x = array[0]; y = array[1]; } void Vec2::subtract(const Vec2 &v1, const Vec2 &v2, Vec2 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = v1.x - v2.x; dst->y = v1.y - v2.y; @@ -179,17 +189,22 @@ bool Vec2::equals(const Vec2 &target) const { } bool Vec2::fuzzyEquals(const Vec2 &b, float var) const { - if (x - var <= b.x && b.x <= x + var) - if (y - var <= b.y && b.y <= y + var) + if (x - var <= b.x && b.x <= x + var) { + if (y - var <= b.y && b.y <= y + var) { return true; + } + } + return false; } float Vec2::getAngle(const Vec2 &other) const { - Vec2 a2 = getNormalized(); - Vec2 b2 = other.getNormalized(); + Vec2 a2 = getNormalized(); + Vec2 b2 = other.getNormalized(); float angle = atan2f(a2.cross(b2), a2.dot(b2)); - if (std::abs(angle) < FLT_EPSILON) return 0.f; + if (std::abs(angle) < FLT_EPSILON) { + return 0.F; + } return angle; } @@ -197,37 +212,37 @@ Vec2 Vec2::rotateByAngle(const Vec2 &pivot, float angle) const { return pivot + (*this - pivot).rotate(Vec2::forAngle(angle)); } -bool Vec2::isLineIntersect(const Vec2 &A, const Vec2 &B, - const Vec2 &C, const Vec2 &D, - float *S, float *T) { +bool Vec2::isLineIntersect(const Vec2 &a, const Vec2 &b, + const Vec2 &c, const Vec2 &d, + float *s, float *t) { // FAIL: Line undefined - if ((A.x == B.x && A.y == B.y) || (C.x == D.x && C.y == D.y)) { + if ((a.x == b.x && a.y == b.y) || (c.x == d.x && c.y == d.y)) { return false; } - const float denom = crossProduct2Vector(A, B, C, D); + const float denom = crossProduct2Vector(a, b, c, d); if (denom == 0) { // Lines parallel or overlap return false; } - if (S != nullptr) *S = crossProduct2Vector(C, D, C, A) / denom; - if (T != nullptr) *T = crossProduct2Vector(A, B, C, A) / denom; + if (s != nullptr) *s = crossProduct2Vector(c, d, c, a) / denom; + if (t != nullptr) *t = crossProduct2Vector(a, b, c, a) / denom; return true; } -bool Vec2::isLineParallel(const Vec2 &A, const Vec2 &B, - const Vec2 &C, const Vec2 &D) { +bool Vec2::isLineParallel(const Vec2 &a, const Vec2 &b, + const Vec2 &c, const Vec2 &d) { // FAIL: Line undefined - if ((A.x == B.x && A.y == B.y) || (C.x == D.x && C.y == D.y)) { + if ((a.x == b.x && a.y == b.y) || (c.x == d.x && c.y == d.y)) { return false; } - if (crossProduct2Vector(A, B, C, D) == 0) { + if (crossProduct2Vector(a, b, c, d) == 0) { // line overlap - if (crossProduct2Vector(C, D, C, A) == 0 || crossProduct2Vector(A, B, C, A) == 0) { + if (crossProduct2Vector(c, d, c, a) == 0 || crossProduct2Vector(a, b, c, a) == 0) { return false; } @@ -237,68 +252,68 @@ bool Vec2::isLineParallel(const Vec2 &A, const Vec2 &B, return false; } -bool Vec2::isLineOverlap(const Vec2 &A, const Vec2 &B, - const Vec2 &C, const Vec2 &D) { +bool Vec2::isLineOverlap(const Vec2 &a, const Vec2 &b, + const Vec2 &c, const Vec2 &d) { // FAIL: Line undefined - if ((A.x == B.x && A.y == B.y) || (C.x == D.x && C.y == D.y)) { + if ((a.x == b.x && a.y == b.y) || (c.x == d.x && c.y == d.y)) { return false; } - if (crossProduct2Vector(A, B, C, D) == 0 && - (crossProduct2Vector(C, D, C, A) == 0 || crossProduct2Vector(A, B, C, A) == 0)) { + if (crossProduct2Vector(a, b, c, d) == 0 && + (crossProduct2Vector(c, d, c, a) == 0 || crossProduct2Vector(a, b, c, a) == 0)) { return true; } return false; } -bool Vec2::isSegmentOverlap(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D, Vec2 *S, Vec2 *E) { +bool Vec2::isSegmentOverlap(const Vec2 &a, const Vec2 &b, const Vec2 &c, const Vec2 &d, Vec2 *s, Vec2 *e) { - if (isLineOverlap(A, B, C, D)) { - return isOneDimensionSegmentOverlap(A.x, B.x, C.x, D.x, &S->x, &E->x) && - isOneDimensionSegmentOverlap(A.y, B.y, C.y, D.y, &S->y, &E->y); + if (isLineOverlap(a, b, c, d)) { + return isOneDimensionSegmentOverlap(a.x, b.x, c.x, d.x, &s->x, &e->x) && + isOneDimensionSegmentOverlap(a.y, b.y, c.y, d.y, &s->y, &e->y); } return false; } -bool Vec2::isSegmentIntersect(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D) { - float S, T; +bool Vec2::isSegmentIntersect(const Vec2 &a, const Vec2 &b, const Vec2 &c, const Vec2 &d) { + float s, t; - if (isLineIntersect(A, B, C, D, &S, &T) && - (S >= 0.0f && S <= 1.0f && T >= 0.0f && T <= 1.0f)) { + if (isLineIntersect(a, b, c, d, &s, &t) && + (s >= 0.0F && s <= 1.0F && t >= 0.0F && t <= 1.0F)) { return true; } return false; } -Vec2 Vec2::getIntersectPoint(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D) { - float S, T; +Vec2 Vec2::getIntersectPoint(const Vec2 &a, const Vec2 &b, const Vec2 &c, const Vec2 &d) { + float s, t; - if (isLineIntersect(A, B, C, D, &S, &T)) { + if (isLineIntersect(a, b, c, d, &s, &t)) { // Vec2 of intersection - Vec2 P; - P.x = A.x + S * (B.x - A.x); - P.y = A.y + S * (B.y - A.y); - return P; + Vec2 p; + p.x = a.x + s * (b.x - a.x); + p.y = a.y + s * (b.y - a.y); + return p; } return Vec2::ZERO; } -const Vec2 Vec2::ZERO(0.0f, 0.0f); -const Vec2 Vec2::ONE(1.0f, 1.0f); -const Vec2 Vec2::UNIT_X(1.0f, 0.0f); -const Vec2 Vec2::UNIT_Y(0.0f, 1.0f); -const Vec2 Vec2::ANCHOR_MIDDLE(0.5f, 0.5f); -const Vec2 Vec2::ANCHOR_BOTTOM_LEFT(0.0f, 0.0f); -const Vec2 Vec2::ANCHOR_TOP_LEFT(0.0f, 1.0f); -const Vec2 Vec2::ANCHOR_BOTTOM_RIGHT(1.0f, 0.0f); -const Vec2 Vec2::ANCHOR_TOP_RIGHT(1.0f, 1.0f); -const Vec2 Vec2::ANCHOR_MIDDLE_RIGHT(1.0f, 0.5f); -const Vec2 Vec2::ANCHOR_MIDDLE_LEFT(0.0f, 0.5f); -const Vec2 Vec2::ANCHOR_MIDDLE_TOP(0.5f, 1.0f); -const Vec2 Vec2::ANCHOR_MIDDLE_BOTTOM(0.5f, 0.0f); +const Vec2 Vec2::ZERO(0.0F, 0.0F); +const Vec2 Vec2::ONE(1.0F, 1.0F); +const Vec2 Vec2::UNIT_X(1.0F, 0.0F); +const Vec2 Vec2::UNIT_Y(0.0F, 1.0F); +const Vec2 Vec2::ANCHOR_MIDDLE(0.5F, 0.5F); +const Vec2 Vec2::ANCHOR_BOTTOM_LEFT(0.0F, 0.0F); +const Vec2 Vec2::ANCHOR_TOP_LEFT(0.0F, 1.0F); +const Vec2 Vec2::ANCHOR_BOTTOM_RIGHT(1.0F, 0.0F); +const Vec2 Vec2::ANCHOR_TOP_RIGHT(1.0F, 1.0F); +const Vec2 Vec2::ANCHOR_MIDDLE_RIGHT(1.0F, 0.5F); +const Vec2 Vec2::ANCHOR_MIDDLE_LEFT(0.0F, 0.5F); +const Vec2 Vec2::ANCHOR_MIDDLE_TOP(0.5F, 1.0F); +const Vec2 Vec2::ANCHOR_MIDDLE_BOTTOM(0.5F, 0.0F); NS_CC_MATH_END diff --git a/native/cocos/math/Vec2.h b/native/cocos/math/Vec2.h index 738a05ef4e..aad6a8564c 100644 --- a/native/cocos/math/Vec2.h +++ b/native/cocos/math/Vec2.h @@ -20,29 +20,23 @@ This file was modified to fit the cocos2d-x project */ -#ifndef MATH_VEC2_H -#define MATH_VEC2_H +#pragma once #include #include #include #include "math/MathBase.h" -/** - * @addtogroup base - * @{ - */ - NS_CC_MATH_BEGIN /** Clamp a value between from and to. */ -inline float clampf(float value, float min_inclusive, float max_inclusive) { - if (min_inclusive > max_inclusive) { - std::swap(min_inclusive, max_inclusive); +inline float clampf(float value, float minInclusive, float maxInclusive) { + if (minInclusive > maxInclusive) { + std::swap(minInclusive, maxInclusive); } - return value < min_inclusive ? min_inclusive : value < max_inclusive ? value : max_inclusive; + return value < minInclusive ? minInclusive : value < maxInclusive ? value : maxInclusive; } class Mat4; @@ -80,7 +74,7 @@ public: * * @param array An array containing the elements of the vector in the order x, y. */ - Vec2(const float *array); + explicit Vec2(const float *array); /** * Constructs a vector that describes the direction between the specified points. @@ -449,12 +443,6 @@ public: */ inline bool operator!=(const Vec2 &v) const; - //code added compatible for Point -public: - /** - * @js NA - * @lua NA - */ inline void setPoint(float xx, float yy); /** * @js NA @@ -463,16 +451,12 @@ public: /** @returns if points have fuzzy equality which means equal with some degree of variance. @since v2.1.4 - * @js NA - * @lua NA */ bool fuzzyEquals(const Vec2 &target, float variance) const; /** Calculates distance between point an origin @return float @since v2.1.4 - * @js NA - * @lua NA */ inline float getLength() const { return sqrtf(x * x + y * y); @@ -481,8 +465,6 @@ public: /** Calculates the square length of a Vec2 (not calling sqrt() ) @return float @since v2.1.4 - * @js NA - * @lua NA */ inline float getLengthSq() const { return dot(*this); //x*x + y*y; @@ -491,8 +473,6 @@ public: /** Calculates the square distance between two points (not calling sqrt() ) @return float @since v2.1.4 - * @js NA - * @lua NA */ inline float getDistanceSq(const Vec2 &other) const { return (*this - other).getLengthSq(); @@ -501,8 +481,6 @@ public: /** Calculates the distance between two points @return float @since v2.1.4 - * @js NA - * @lua NA */ inline float getDistance(const Vec2 &other) const { return (*this - other).getLength(); @@ -510,8 +488,6 @@ public: /** @returns the angle in radians between this vector and the x axis @since v2.1.4 - * @js NA - * @lua NA */ inline float getAngle() const { return atan2f(y, x); @@ -519,16 +495,12 @@ public: /** @returns the angle in radians between two vector directions @since v2.1.4 - * @js NA - * @lua NA */ float getAngle(const Vec2 &other) const; /** Calculates cross product of two points. @return float @since v2.1.4 - * @js NA - * @lua NA */ inline float cross(const Vec2 &other) const { return x * other.y - y * other.x; @@ -537,8 +509,6 @@ public: /** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0 @return Vec2 @since v2.1.4 - * @js NA - * @lua NA */ inline Vec2 getPerp() const { return Vec2(-y, x); @@ -547,8 +517,6 @@ public: /** Calculates midpoint between two points. @return Vec2 @since v3.0 - * @js NA - * @lua NA */ inline Vec2 getMidpoint(const Vec2 &other) const { return Vec2((x + other.x) / 2.0f, (y + other.y) / 2.0f); @@ -556,8 +524,6 @@ public: /** Clamp a point between from and to. @since v3.0 - * @js NA - * @lua NA */ inline Vec2 getClampPoint(const Vec2 &min_inclusive, const Vec2 &max_inclusive) const { return Vec2(clampf(x, min_inclusive.x, max_inclusive.x), clampf(y, min_inclusive.y, max_inclusive.y)); @@ -569,8 +535,6 @@ public: * For example: let's try to take the floor of x,y * p.compOp(floorf); @since v3.0 - * @js NA - * @lua NA */ inline Vec2 compOp(std::function function) const { return Vec2(function(x), function(y)); @@ -579,8 +543,6 @@ public: /** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0 @return Vec2 @since v2.1.4 - * @js NA - * @lua NA */ inline Vec2 getRPerp() const { return Vec2(y, -x); @@ -589,8 +551,6 @@ public: /** Calculates the projection of this over other. @return Vec2 @since v2.1.4 - * @js NA - * @lua NA */ inline Vec2 project(const Vec2 &other) const { return other * (dot(other) / other.dot(other)); @@ -600,8 +560,6 @@ public: @return Vec2 vector with an angle of this.getAngle() + other.getAngle(), and a length of this.getLength() * other.getLength(). @since v2.1.4 - * @js NA - * @lua NA */ inline Vec2 rotate(const Vec2 &other) const { return Vec2(x * other.x - y * other.y, x * other.y + y * other.x); @@ -611,8 +569,6 @@ public: @return Vec2 vector with an angle of this.getAngle() - other.getAngle(), and a length of this.getLength() * other.getLength(). @since v2.1.4 - * @js NA - * @lua NA */ inline Vec2 unrotate(const Vec2 &other) const { return Vec2(x * other.x + y * other.y, y * other.x - x * other.y); @@ -624,8 +580,6 @@ public: alpha == 1 ? b otherwise a value between a..b @since v2.1.4 - * @js NA - * @lua NA */ inline Vec2 lerp(const Vec2 &other, float alpha) const { return *this * (1.f - alpha) + other * alpha; @@ -636,83 +590,65 @@ public: @param angle is the angle of rotation ccw in radians @returns the rotated point @since v2.1.4 - * @js NA - * @lua NA */ Vec2 rotateByAngle(const Vec2 &pivot, float angle) const; - /** - * @js NA - * @lua NA - */ static inline Vec2 forAngle(const float a) { return Vec2(cosf(a), sinf(a)); } /** A general line-line intersection test - @param A the startpoint for the first line L1 = (A - B) - @param B the endpoint for the first line L1 = (A - B) - @param C the startpoint for the second line L2 = (C - D) - @param D the endpoint for the second line L2 = (C - D) - @param S the range for a hitpoint in L1 (p = A + S*(B - A)) - @param T the range for a hitpoint in L2 (p = C + T*(D - C)) + @param a the startpoint for the first line L1 = (a - b) + @param b the endpoint for the first line L1 = (a - b) + @param c the startpoint for the second line L2 = (c - d) + @param d the endpoint for the second line L2 = (c - d) + @param s the range for a hitpoint in L1 (p = a + s*(b - a)) + @param t the range for a hitpoint in L2 (p = c + t*(d - c)) @return whether these two lines intersects. Note that to truly test intersection for segments we have to make - sure that S & T lie within [0..1] and for rays, make sure S & T > 0 - the hit point is C + T * (D - C); - the hit point also is A + S * (B - A); + sure that s & t lie within [0..1] and for rays, make sure s & t > 0 + the hit point is c + t * (d - c); + the hit point also is a + b * (b - a); @since 3.0 - * @js NA - * @lua NA */ - static bool isLineIntersect(const Vec2 &A, const Vec2 &B, - const Vec2 &C, const Vec2 &D, - float *S = nullptr, float *T = nullptr); + static bool isLineIntersect(const Vec2 &a, const Vec2 &b, + const Vec2 &c, const Vec2 &d, + float *s = nullptr, float *t = nullptr); /** - returns true if Line A-B overlap with segment C-D + returns true if Line a-b overlap with segment c-d @since v3.0 - * @js NA - * @lua NA */ - static bool isLineOverlap(const Vec2 &A, const Vec2 &B, - const Vec2 &C, const Vec2 &D); + static bool isLineOverlap(const Vec2 &a, const Vec2 &b, + const Vec2 &c, const Vec2 &d); /** - returns true if Line A-B parallel with segment C-D + returns true if Line a-b parallel with segment c-d @since v3.0 - * @js NA - * @lua NA */ - static bool isLineParallel(const Vec2 &A, const Vec2 &B, - const Vec2 &C, const Vec2 &D); + static bool isLineParallel(const Vec2 &a, const Vec2 &b, + const Vec2 &c, const Vec2 &d); /** - returns true if Segment A-B overlap with segment C-D + returns true if Segment a-b overlap with segment c-d @since v3.0 - * @js NA - * @lua NA */ - static bool isSegmentOverlap(const Vec2 &A, const Vec2 &B, - const Vec2 &C, const Vec2 &D, - Vec2 *S = nullptr, Vec2 *E = nullptr); + static bool isSegmentOverlap(const Vec2 &a, const Vec2 &b, + const Vec2 &c, const Vec2 &d, + Vec2 *s = nullptr, Vec2 *e = nullptr); /** - returns true if Segment A-B intersects with segment C-D + returns true if Segment a-b intersects with segment c-d @since v3.0 - * @js NA - * @lua NA */ - static bool isSegmentIntersect(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D); + static bool isSegmentIntersect(const Vec2 &a, const Vec2 &b, const Vec2 &c, const Vec2 &d); /** - returns the intersection point of line A-B, C-D + returns the intersection point of line a-b, c-d @since v3.0 - * @js NA - * @lua NA */ - static Vec2 getIntersectPoint(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D); + static Vec2 getIntersectPoint(const Vec2 &a, const Vec2 &b, const Vec2 &c, const Vec2 &d); /** equals to Vec2(0,0) */ static const Vec2 ZERO; @@ -755,11 +691,6 @@ typedef Vec2 Point; NS_CC_MATH_END -/** - end of base group - @} - */ #include "math/Vec2.inl" -#endif // MATH_VEC2_H diff --git a/native/cocos/math/Vec3.cpp b/native/cocos/math/Vec3.cpp index 71dc7349c8..9227429044 100644 --- a/native/cocos/math/Vec3.cpp +++ b/native/cocos/math/Vec3.cpp @@ -61,7 +61,7 @@ Vec3 Vec3::fromColor(unsigned int color) { } void Vec3::transformInverseRTS(const Vec3 &v, const Quaternion &r, const Vec3 &t, const Vec3 &s, Vec3 *out) { - GP_ASSERT(out); + CC_ASSERT(out); const float x = v.x - t.x; const float y = v.y - t.y; const float z = v.z - t.z; @@ -84,7 +84,7 @@ float Vec3::angle(const Vec3 &v1, const Vec3 &v2) { } void Vec3::add(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = v1.x + v2.x; dst->y = v1.y + v2.y; @@ -92,7 +92,7 @@ void Vec3::add(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { } void Vec3::clamp(const Vec3 &min, const Vec3 &max) { - GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z)); + CC_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z)); // Clamp the x value. if (x < min.x) { @@ -120,8 +120,8 @@ void Vec3::clamp(const Vec3 &min, const Vec3 &max) { } void Vec3::clamp(const Vec3 &v, const Vec3 &min, const Vec3 &max, Vec3 *dst) { - GP_ASSERT(dst); - GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z)); + CC_ASSERT(dst); + CC_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z)); // Clamp the x value. dst->x = v.x; @@ -156,7 +156,7 @@ void Vec3::cross(const Vec3 &v) { } void Vec3::cross(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); // NOTE: This code assumes Vec3 struct members are contiguous floats in memory. // We might want to revisit this (and other areas of code that make this assumption) @@ -284,7 +284,7 @@ Vec3 Vec3::getNormalized() const { } void Vec3::subtract(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = v1.x - v2.x; dst->y = v1.y - v2.y; @@ -292,7 +292,7 @@ void Vec3::subtract(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { } void Vec3::max(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = std::fmaxf(v1.x, v2.x); dst->y = std::fmaxf(v1.y, v2.y); @@ -300,7 +300,7 @@ void Vec3::max(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { } void Vec3::min(const Vec3 &v1, const Vec3 &v2, Vec3 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = std::fminf(v1.x, v2.x); dst->y = std::fminf(v1.y, v2.y); diff --git a/native/cocos/math/Vec3.inl b/native/cocos/math/Vec3.inl index b34455d2ee..9beceee4ec 100644 --- a/native/cocos/math/Vec3.inl +++ b/native/cocos/math/Vec3.inl @@ -88,7 +88,7 @@ inline void Vec3::set(float xx, float yy, float zz) inline void Vec3::set(const float* array) { - GP_ASSERT(array); + CC_ASSERT(array); x = array[0]; y = array[1]; diff --git a/native/cocos/math/Vec4.cpp b/native/cocos/math/Vec4.cpp index e68fc199b2..b8f31cbf11 100644 --- a/native/cocos/math/Vec4.cpp +++ b/native/cocos/math/Vec4.cpp @@ -93,7 +93,7 @@ void Vec4::add(const Vec4 &v) { } void Vec4::add(const Vec4 &v1, const Vec4 &v2, Vec4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = v1.x + v2.x; dst->y = v1.y + v2.y; @@ -102,7 +102,7 @@ void Vec4::add(const Vec4 &v1, const Vec4 &v2, Vec4 *dst) { } void Vec4::clamp(const Vec4 &min, const Vec4 &max) { - GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w)); + CC_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w)); // Clamp the x value. if (x < min.x) { @@ -138,8 +138,8 @@ void Vec4::clamp(const Vec4 &min, const Vec4 &max) { } void Vec4::clamp(const Vec4 &v, const Vec4 &min, const Vec4 &max, Vec4 *dst) { - GP_ASSERT(dst); - GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w)); + CC_ASSERT(dst); + CC_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w)); // Clamp the x value. dst->x = v.x; @@ -260,7 +260,7 @@ void Vec4::set(float xx, float yy, float zz, float ww) { } void Vec4::set(const float *array) { - GP_ASSERT(array); + CC_ASSERT(array); x = array[0]; y = array[1]; @@ -290,7 +290,7 @@ void Vec4::subtract(const Vec4 &v) { } void Vec4::subtract(const Vec4 &v1, const Vec4 &v2, Vec4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = v1.x - v2.x; dst->y = v1.y - v2.y; @@ -299,7 +299,7 @@ void Vec4::subtract(const Vec4 &v1, const Vec4 &v2, Vec4 *dst) { } void Vec4::lerp(const Vec4 &a, const Vec4 &b, float t, Vec4 *dst) { - GP_ASSERT(dst); + CC_ASSERT(dst); dst->x = a.x + t * (b.x - a.x); dst->y = a.y + t * (b.y - a.y); dst->z = a.z + t * (b.z - a.z); diff --git a/native/cocos/math/Vertex.cpp b/native/cocos/math/Vertex.cpp index b8215f2511..29a7d2961a 100644 --- a/native/cocos/math/Vertex.cpp +++ b/native/cocos/math/Vertex.cpp @@ -31,7 +31,7 @@ namespace cc { void ccVertexLineToPolygon(const ccstd::vector &points, float stroke, unsigned int offset, unsigned int nuPoints, ccstd::vector *vertices) { - GP_ASSERT(vertices); + CC_ASSERT(vertices); nuPoints += offset; if (nuPoints <= 1) return; diff --git a/native/cocos/network/HttpClient-apple.mm b/native/cocos/network/HttpClient-apple.mm index 074393da45..8ce670264c 100644 --- a/native/cocos/network/HttpClient-apple.mm +++ b/native/cocos/network/HttpClient-apple.mm @@ -456,7 +456,7 @@ void HttpClient::processResponse(HttpResponse *response, char *responseMessage) break; default: - CCASSERT(false, "CCHttpClient: unknown request type, only GET,POST,PUT or DELETE is supported"); + CC_ASSERT(false); break; } diff --git a/native/cocos/network/HttpClient-java.cpp b/native/cocos/network/HttpClient-java.cpp index 674f558a3d..1f6784adfb 100644 --- a/native/cocos/network/HttpClient-java.cpp +++ b/native/cocos/network/HttpClient-java.cpp @@ -591,7 +591,7 @@ void HttpClient::processResponse(HttpResponse *response, char *responseMessage) HttpRequest::Type::PUT != requestType && HttpRequest::Type::HEAD != requestType && HttpRequest::Type::DELETE != requestType) { - CCASSERT(true, "CCHttpClient: unknown request type, only GET、POST、PUT、DELETE are supported"); + CC_ASSERT(false); return; } diff --git a/native/cocos/network/HttpClient.cpp b/native/cocos/network/HttpClient.cpp index 00195a9cce..d04bbf2e11 100644 --- a/native/cocos/network/HttpClient.cpp +++ b/native/cocos/network/HttpClient.cpp @@ -506,7 +506,7 @@ void HttpClient::processResponse(HttpResponse *response, char *responseMessage) break; default: - CCASSERT(false, "CCHttpClient: unknown request type, only GET, POST, PUT, HEAD or DELETE is supported"); + CC_ASSERT(false); break; } diff --git a/native/cocos/network/HttpRequest.h b/native/cocos/network/HttpRequest.h index c0b4153d8f..75ed3179e8 100644 --- a/native/cocos/network/HttpRequest.h +++ b/native/cocos/network/HttpRequest.h @@ -89,19 +89,6 @@ public: /** Destructor. */ ~HttpRequest() override = default; - /** - * Override autorelease method to avoid developers to call it. - * If this function was called, it would trigger assert in debug mode - * - * @return Ref* always return nullptr. - */ - RefCounted *autorelease() { // NOLINT(readability-convert-member-functions-to-static) - CCASSERT(false, - "HttpResponse is used between network thread and ui thread \ - therefore, autorelease is forbidden here"); - return nullptr; - } - // setter/getters for properties /** diff --git a/native/cocos/network/HttpResponse.h b/native/cocos/network/HttpResponse.h index fd9b44781f..9c03fecca8 100644 --- a/native/cocos/network/HttpResponse.h +++ b/native/cocos/network/HttpResponse.h @@ -70,18 +70,6 @@ public: } } - /** - * Override autorelease method to prevent developers from calling it. - * If this method is called , it would trigger CCASSERT. - * @return cc::Ref* always return nullptr. - */ - cc::RefCounted *autorelease() { - CCASSERT(false, - "HttpResponse is used between network thread and ui thread \ - therefore, autorelease is forbidden here"); - return nullptr; - } - // getters, will be called by users /** diff --git a/native/cocos/network/WebSocket-libwebsockets.cpp b/native/cocos/network/WebSocket-libwebsockets.cpp index a858759df1..975c30661c 100644 --- a/native/cocos/network/WebSocket-libwebsockets.cpp +++ b/native/cocos/network/WebSocket-libwebsockets.cpp @@ -895,10 +895,10 @@ struct lws_vhost *WebSocketImpl::createVhost(struct lws_protocols *protocols, in _caFilePath = newCaFilePath; info.ssl_ca_filepath = _caFilePath.c_str(); } else { - CCASSERT(false, "Open new CA file failed"); + CC_ASSERT(false); // Open new CA file failed } } else { - CCASSERT(false, "CA file is empty!"); + CC_ASSERT(false); // CA file is empty! } } else { LOGD("CA file isn't in APK!"); @@ -906,7 +906,7 @@ struct lws_vhost *WebSocketImpl::createVhost(struct lws_protocols *protocols, in info.ssl_ca_filepath = _caFilePath.c_str(); } } else { - CCASSERT(false, "CA file doesn't exist!"); + CC_ASSERT(false); // CA file doesn't exist! } } #else diff --git a/native/cocos/platform/BasePlatform.h b/native/cocos/platform/BasePlatform.h index 5db064fcc9..a4a40a23d3 100644 --- a/native/cocos/platform/BasePlatform.h +++ b/native/cocos/platform/BasePlatform.h @@ -124,7 +124,7 @@ public: return intf; } } - CCASSERT(false, "Interface does not exist"); + CC_ASSERT(false); return nullptr; } @@ -132,7 +132,7 @@ public: * @brief Registration system interface. */ bool registerInterface(const OSInterface::Ptr& osInterface) { - CCASSERT(osInterface != nullptr, "Invalid interface pointer"); + CC_ASSERT(osInterface != nullptr); auto it = std::find(_osInterfaces.begin(), _osInterfaces.end(), osInterface); if (it != _osInterfaces.end()) { CC_LOG_WARNING("Duplicate registration interface"); @@ -145,7 +145,7 @@ public: * @brief Unregistration system interface. */ void unregisterInterface(const OSInterface::Ptr& osInterface) { - CCASSERT(osInterface != nullptr, "Invalid interface pointer"); + CC_ASSERT(osInterface != nullptr); auto it = std::find(_osInterfaces.begin(), _osInterfaces.end(), osInterface); if (it != _osInterfaces.end()) { CC_LOG_WARNING("Interface is not registrated"); diff --git a/native/cocos/platform/FileUtils.cpp b/native/cocos/platform/FileUtils.cpp index 39b56f448d..e8af3d6edb 100644 --- a/native/cocos/platform/FileUtils.cpp +++ b/native/cocos/platform/FileUtils.cpp @@ -95,7 +95,7 @@ public: _resultType = SAX_RESULT_DICT; SAXParser parser; - CCASSERT(parser.init("UTF-8"), "The file format isn't UTF-8"); + CC_ASSERT(parser.init("UTF-8")); parser.setDelegator(this); parser.parse(fileName); @@ -106,7 +106,7 @@ public: _resultType = SAX_RESULT_DICT; SAXParser parser; - CCASSERT(parser.init("UTF-8"), "The file format isn't UTF-8"); + CC_ASSERT(parser.init("UTF-8")); parser.setDelegator(this); parser.parse(filedata, filesize); @@ -117,7 +117,7 @@ public: _resultType = SAX_RESULT_ARRAY; SAXParser parser; - CCASSERT(parser.init("UTF-8"), "The file format isn't UTF-8"); + CC_ASSERT(parser.init("UTF-8")); parser.setDelegator(this); parser.parse(fileName); @@ -146,7 +146,7 @@ public: _curDict = &(_curArray->rbegin())->asValueMap(); } else if (SAX_DICT == preState) { // add a new dictionary into the pre dictionary - CCASSERT(!_dictStack.empty(), "The state is wrong!"); + CC_ASSERT(!_dictStack.empty()); // The state is wrong. ValueMap *preDict = _dictStack.top(); (*preDict)[_curKey] = Value(ValueMap()); _curDict = &(*preDict)[_curKey].asValueMap(); @@ -178,7 +178,7 @@ public: (*_curDict)[_curKey] = Value(ValueVector()); _curArray = &(*_curDict)[_curKey].asValueVector(); } else if (preState == SAX_ARRAY) { - CCASSERT(!_arrayStack.empty(), "The state is wrong!"); + CC_ASSERT(!_arrayStack.empty()); // The state is wrong! ValueVector *preArray = _arrayStack.top(); preArray->push_back(Value(ValueVector())); _curArray = &(_curArray->rbegin())->asValueVector(); @@ -261,7 +261,8 @@ public: case SAX_REAL: case SAX_STRING: { if (curState == SAX_DICT) { - CCASSERT(!_curKey.empty(), "key not found : "); + // "key not found : " + CC_ASSERT(!_curKey.empty()); } _curValue.append(text); @@ -506,7 +507,7 @@ bool FileUtils::writeDataToFile(const Data &data, const ccstd::string &fullPath) size_t size = 0; const char *mode = "wb"; - CCASSERT(!fullPath.empty() && data.getSize() != 0, "Invalid parameters."); + CC_ASSERT(!fullPath.empty() && data.getSize() != 0); auto *fileutils = FileUtils::getInstance(); do { @@ -612,7 +613,7 @@ unsigned char *FileUtils::getFileDataFromZip(const ccstd::string &zipFilePath, c buffer = static_cast(malloc(fileInfo.uncompressed_size)); int CC_UNUSED readedSize = unzReadCurrentFile(file, buffer, static_cast(fileInfo.uncompressed_size)); - CCASSERT(readedSize == 0 || readedSize == (int)fileInfo.uncompressed_size, "the file size is wrong"); + CC_ASSERT(readedSize == 0 || readedSize == (int)fileInfo.uncompressed_size); *size = fileInfo.uncompressed_size; unzCloseCurrentFile(file); @@ -785,7 +786,7 @@ bool FileUtils::isAbsolutePath(const ccstd::string &path) const { } bool FileUtils::isDirectoryExist(const ccstd::string &dirPath) const { - CCASSERT(!dirPath.empty(), "Invalid path"); + CC_ASSERT(!dirPath.empty()); if (isAbsolutePath(dirPath)) { return isDirectoryExistInternal(normalizePath(dirPath)); @@ -915,42 +916,50 @@ void FileUtils::listFilesRecursively(const ccstd::string &dirPath, ccstd::vector #if (CC_PLATFORM == CC_PLATFORM_WINDOWS) || (CC_PLATFORM == CC_PLATFORM_WINRT) // windows os implement should override in platform specific FileUtiles class bool FileUtils::isDirectoryExistInternal(const ccstd::string &dirPath) const { - CCASSERT(false, "FileUtils not support isDirectoryExistInternal"); + // FileUtils not support isDirectoryExistInternal. + CC_ASSERT(false); return false; } bool FileUtils::createDirectory(const ccstd::string &path) { - CCASSERT(false, "FileUtils not support createDirectory"); + // FileUtils not support createDirectory. + CC_ASSERT(false); return false; } bool FileUtils::removeDirectory(const ccstd::string &path) { - CCASSERT(false, "FileUtils not support removeDirectory"); + // FileUtils not support removeDirectory. + CC_ASSERT(false); return false; } bool FileUtils::removeFile(const ccstd::string &path) { - CCASSERT(false, "FileUtils not support removeFile"); + // FileUtils not support removeFile. + CC_ASSERT(false); return false; } bool FileUtils::renameFile(const ccstd::string &oldfullpath, const ccstd::string &newfullpath) { - CCASSERT(false, "FileUtils not support renameFile"); + // FileUtils not support renameFile. + CC_ASSERT(false); return false; } bool FileUtils::renameFile(const ccstd::string &path, const ccstd::string &oldname, const ccstd::string &name) { - CCASSERT(false, "FileUtils not support renameFile"); + // FileUtils not support renameFile. + CC_ASSERT(false); return false; } ccstd::string FileUtils::getSuitableFOpen(const ccstd::string &filenameUtf8) const { - CCASSERT(false, "getSuitableFOpen should be override by platform FileUtils"); + // getSuitableFOpen should be override by platform FileUtils + CC_ASSERT(false); return filenameUtf8; } long FileUtils::getFileSize(const ccstd::string &filepath) { - CCASSERT(false, "getFileSize should be override by platform FileUtils"); + // getFileSize should be override by platform FileUtils + CC_ASSERT(false); return 0; } @@ -974,7 +983,7 @@ bool FileUtils::isDirectoryExistInternal(const ccstd::string &dirPath) const { } bool FileUtils::createDirectory(const ccstd::string &path) { - CCASSERT(!path.empty(), "Invalid path"); + CC_ASSERT(!path.empty()); if (isDirectoryExist(path)) { return true; @@ -1065,8 +1074,8 @@ bool FileUtils::removeFile(const ccstd::string &path) { } bool FileUtils::renameFile(const ccstd::string &oldfullpath, const ccstd::string &newfullpath) { - CCASSERT(!oldfullpath.empty(), "Invalid path"); - CCASSERT(!newfullpath.empty(), "Invalid path"); + CC_ASSERT(!oldfullpath.empty()); + CC_ASSERT(!newfullpath.empty()); int errorCode = rename(oldfullpath.c_str(), newfullpath.c_str()); @@ -1078,7 +1087,7 @@ bool FileUtils::renameFile(const ccstd::string &oldfullpath, const ccstd::string } bool FileUtils::renameFile(const ccstd::string &path, const ccstd::string &oldname, const ccstd::string &name) { - CCASSERT(!path.empty(), "Invalid path"); + CC_ASSERT(!path.empty()); ccstd::string oldPath = path + oldname; ccstd::string newPath = path + name; @@ -1090,7 +1099,7 @@ ccstd::string FileUtils::getSuitableFOpen(const ccstd::string &filenameUtf8) con } long FileUtils::getFileSize(const ccstd::string &filepath) { //NOLINT(google-runtime-int) - CCASSERT(!filepath.empty(), "Invalid path"); + CC_ASSERT(!filepath.empty()); ccstd::string fullpath{filepath}; if (!isAbsolutePath(filepath)) { diff --git a/native/cocos/platform/SDLHelper.cpp b/native/cocos/platform/SDLHelper.cpp index 069345a78a..93973023a9 100644 --- a/native/cocos/platform/SDLHelper.cpp +++ b/native/cocos/platform/SDLHelper.cpp @@ -391,7 +391,7 @@ uintptr_t SDLHelper::getWindowHandler() const { #elif (CC_PLATFORM == CC_PLATFORM_LINUX) return reinterpret_cast(wmInfo.info.x11.window); #endif - CCASSERT(false, "Only valid in windows, linux"); + CC_ASSERT(false); return 0; } diff --git a/native/cocos/platform/apple/FileUtils-apple.mm b/native/cocos/platform/apple/FileUtils-apple.mm index 9f6ecec41f..06bc980030 100644 --- a/native/cocos/platform/apple/FileUtils-apple.mm +++ b/native/cocos/platform/apple/FileUtils-apple.mm @@ -169,7 +169,7 @@ static void addCCValueToNSArray(const Value &value, NSMutableArray *array) { static void addNSObjectToCCMap(id nsKey, id nsValue, ValueMap &dict) { // the key must be a string - CCASSERT([nsKey isKindOfClass:[NSString class]], "The key should be a string!"); + CC_ASSERT([nsKey isKindOfClass:[NSString class]]); ccstd::string key = [nsKey UTF8String]; dict[key] = convertNSObjectToCCValue(nsValue); } @@ -423,7 +423,7 @@ ValueVector FileUtilsApple::getValueVectorFromFile(const ccstd::string &filename } bool FileUtilsApple::createDirectory(const ccstd::string &path) { - CCASSERT(!path.empty(), "Invalid path"); + CC_ASSERT(!path.empty()); if (isDirectoryExist(path)) return true; diff --git a/native/cocos/platform/apple/Reachability.cpp b/native/cocos/platform/apple/Reachability.cpp index 6d9d7749d8..8474f939dd 100644 --- a/native/cocos/platform/apple/Reachability.cpp +++ b/native/cocos/platform/apple/Reachability.cpp @@ -162,7 +162,7 @@ Reachability::~Reachability() { } void Reachability::onReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) { - CCASSERT(info != nullptr, "info was nullptr in onReachabilityCallback"); + CC_ASSERT(info != nullptr); cc::Reachability *thiz = reinterpret_cast(info); if (thiz->_callback != nullptr) { @@ -194,7 +194,7 @@ void Reachability::stopNotifier() { } bool Reachability::isConnectionRequired() const { - CCASSERT(_reachabilityRef != nullptr, "connectionRequired called with nullptr reachabilityRef"); + CC_ASSERT(_reachabilityRef != nullptr); SCNetworkReachabilityFlags flags; if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) { @@ -205,7 +205,7 @@ bool Reachability::isConnectionRequired() const { } Reachability::NetworkStatus Reachability::getCurrentReachabilityStatus() const { - CCASSERT(_reachabilityRef != nullptr, "currentNetworkStatus called with nullptr SCNetworkReachabilityRef"); + CC_ASSERT(_reachabilityRef != nullptr); NetworkStatus returnValue = NetworkStatus::NOT_REACHABLE; SCNetworkReachabilityFlags flags; diff --git a/native/cocos/platform/interfaces/modules/Device.cpp b/native/cocos/platform/interfaces/modules/Device.cpp index 57b425765f..966e3224b0 100644 --- a/native/cocos/platform/interfaces/modules/Device.cpp +++ b/native/cocos/platform/interfaces/modules/Device.cpp @@ -35,62 +35,62 @@ namespace cc { int Device::getDPI() { - CCASSERT(CC_GET_PLATFORM_INTERFACE(IScreen) != nullptr, "Screen interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(IScreen) != nullptr); return CC_GET_PLATFORM_INTERFACE(IScreen)->getDPI(); } float Device::getDevicePixelRatio() { - CCASSERT(CC_GET_PLATFORM_INTERFACE(IScreen) != nullptr, "Screen interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(IScreen) != nullptr); return CC_GET_PLATFORM_INTERFACE(IScreen)->getDevicePixelRatio(); } void Device::setKeepScreenOn(bool keepScreenOn) { - CCASSERT(CC_GET_PLATFORM_INTERFACE(IScreen) != nullptr, "Screen interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(IScreen) != nullptr); return CC_GET_PLATFORM_INTERFACE(IScreen)->setKeepScreenOn(keepScreenOn); } void Device::setAccelerometerEnabled(bool isEnabled) { - CCASSERT(CC_GET_PLATFORM_INTERFACE(IAccelerometer) != nullptr, "Accelerometer interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(IAccelerometer) != nullptr); return CC_GET_PLATFORM_INTERFACE(IAccelerometer)->setAccelerometerEnabled(isEnabled); } void Device::setAccelerometerInterval(float interval) { - CCASSERT(CC_GET_PLATFORM_INTERFACE(IAccelerometer) != nullptr, "Accelerometer interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(IAccelerometer) != nullptr); return CC_GET_PLATFORM_INTERFACE(IAccelerometer)->setAccelerometerInterval(interval); } const IAccelerometer::MotionValue &Device::getDeviceMotionValue() { - CCASSERT(CC_GET_PLATFORM_INTERFACE(IAccelerometer) != nullptr, "Accelerometer interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(IAccelerometer) != nullptr); return CC_GET_PLATFORM_INTERFACE(IAccelerometer)->getDeviceMotionValue(); } IScreen::Orientation Device::getDeviceOrientation() { - CCASSERT(CC_GET_PLATFORM_INTERFACE(IScreen) != nullptr, "Screen interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(IScreen) != nullptr); return CC_GET_PLATFORM_INTERFACE(IScreen)->getDeviceOrientation(); } ccstd::string Device::getDeviceModel() { - CCASSERT(CC_GET_PLATFORM_INTERFACE(ISystem) != nullptr, "System interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(ISystem) != nullptr); return CC_GET_PLATFORM_INTERFACE(ISystem)->getDeviceModel(); } void Device::vibrate(float duration) { - CCASSERT(CC_GET_PLATFORM_INTERFACE(IVibrator) != nullptr, "Vibrator interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(IVibrator) != nullptr); return CC_GET_PLATFORM_INTERFACE(IVibrator)->vibrate(duration); } float Device::getBatteryLevel() { - CCASSERT(CC_GET_PLATFORM_INTERFACE(IBattery) != nullptr, "Battery interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(IBattery) != nullptr); return CC_GET_PLATFORM_INTERFACE(IBattery)->getBatteryLevel(); } INetwork::NetworkType Device::getNetworkType() { - CCASSERT(CC_GET_PLATFORM_INTERFACE(INetwork) != nullptr, "Network interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(INetwork) != nullptr); return CC_GET_PLATFORM_INTERFACE(INetwork)->getNetworkType(); } Vec4 Device::getSafeAreaEdge() { - CCASSERT(CC_GET_PLATFORM_INTERFACE(IScreen) != nullptr, "Screen interface does not exist"); + CC_ASSERT(CC_GET_PLATFORM_INTERFACE(IScreen) != nullptr); return CC_GET_PLATFORM_INTERFACE(IScreen)->getSafeAreaEdge(); } diff --git a/native/cocos/platform/ios/AppDelegateBridge.mm b/native/cocos/platform/ios/AppDelegateBridge.mm index c67a581c8a..05609e118a 100644 --- a/native/cocos/platform/ios/AppDelegateBridge.mm +++ b/native/cocos/platform/ios/AppDelegateBridge.mm @@ -31,7 +31,7 @@ cc::IOSPlatform *_platform = nullptr; - (void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { _platform = dynamic_cast(cc::BasePlatform::getPlatform()); - CCASSERT(_platform != nullptr, "Platform pointer can't be null"); + CC_ASSERT(_platform != nullptr); _platform->loop(); } diff --git a/native/cocos/platform/ios/View.mm b/native/cocos/platform/ios/View.mm index cc6fa04f04..d41f56d04a 100644 --- a/native/cocos/platform/ios/View.mm +++ b/native/cocos/platform/ios/View.mm @@ -56,7 +56,7 @@ namespace { static_cast([touch locationInView:[touch view]].y), static_cast((intptr_t)touch)}); } - CCASSERT(_platform != nullptr, "Platform point cannot be null"); + CC_ASSERT(_platform != nullptr); _platform->dispatchEvent(touchEvent); } diff --git a/native/cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.cpp b/native/cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.cpp index 3121f88084..ca7a87f243 100644 --- a/native/cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.cpp +++ b/native/cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.cpp @@ -39,7 +39,7 @@ static const char gdefaultFontName[] = "lucidasans-24"; CanvasRenderingContext2DDelegate::CanvasRenderingContext2DDelegate() { SystemWindow* window = BasePlatform::getPlatform()->getInterface(); - CCASSERT(window != nullptr, "System window is not registered"); + CC_ASSERT(window != nullptr); _dis = reinterpret_cast(window->getDisplay()); _win = reinterpret_cast(window->getWindowHandler()); } diff --git a/native/cocos/platform/mac/AppDelegate.mm b/native/cocos/platform/mac/AppDelegate.mm index fc11b7a69c..2105174c9e 100644 --- a/native/cocos/platform/mac/AppDelegate.mm +++ b/native/cocos/platform/mac/AppDelegate.mm @@ -76,7 +76,7 @@ - (void)applicationDidFinishLaunching:(NSNotification*)aNotification { _platform = dynamic_cast(cc::BasePlatform::getPlatform()); - CCASSERT(_platform != nullptr, "Platform pointer can't be null"); + CC_ASSERT(_platform != nullptr); _platform->loop(); } diff --git a/native/cocos/platform/ohos/FileUtils-ohos.cpp b/native/cocos/platform/ohos/FileUtils-ohos.cpp index 43318282a4..c80598336e 100644 --- a/native/cocos/platform/ohos/FileUtils-ohos.cpp +++ b/native/cocos/platform/ohos/FileUtils-ohos.cpp @@ -74,7 +74,7 @@ void printRawfiles(ResourceManager *mgr, const ccstd::string &path) { } // namespace bool FileUtilsOHOS::initResourceManager(ResourceManager *mgr, const ccstd::string &assetPath, const ccstd::string &moduleName) { - CCASSERT(mgr, "ResourceManager should not be empty!"); + CC_ASSERT(mgr); ohosResourceMgr = mgr; if (!assetPath.empty() && assetPath[assetPath.length() - 1] != '/') { ohosAssetPath = assetPath + "/"; diff --git a/native/cocos/platform/qnx/modules/CanvasRenderingContext2DDelegate.cpp b/native/cocos/platform/qnx/modules/CanvasRenderingContext2DDelegate.cpp index 675569473e..7d29c13138 100644 --- a/native/cocos/platform/qnx/modules/CanvasRenderingContext2DDelegate.cpp +++ b/native/cocos/platform/qnx/modules/CanvasRenderingContext2DDelegate.cpp @@ -99,12 +99,12 @@ void CanvasRenderingContext2DDelegate::closePath() { } void CanvasRenderingContext2DDelegate::moveTo(float x, float y) { - CCASSERT(_cr != nullptr, "Cr pointer cannot be empty"); + CC_ASSERT(_cr != nullptr); cairo_move_to(_cr, x, y); } void CanvasRenderingContext2DDelegate::lineTo(float x, float y) { - CCASSERT(_cr != nullptr, "Cr pointer cannot be empty"); + CC_ASSERT(_cr != nullptr); cairo_line_to(_cr, x, y); } @@ -133,7 +133,7 @@ void CanvasRenderingContext2DDelegate::fillRect(float x, float y, float w, float if (_bufferWidth < 1.0F || _bufferHeight < 1.0F) { return; } - CCASSERT(_cr != nullptr, "Cr pointer cannot be empty"); + CC_ASSERT(_cr != nullptr); cairo_set_source_rgba(_cr, _fillStyle[0], _fillStyle[1], _fillStyle[2], _fillStyle[3]); cairo_rectangle(_cr, x, y, w, h); cairo_fill(_cr); diff --git a/native/cocos/platform/win32/FileUtils-win32.cpp b/native/cocos/platform/win32/FileUtils-win32.cpp index 41504bf3d3..6cf15994d7 100644 --- a/native/cocos/platform/win32/FileUtils-win32.cpp +++ b/native/cocos/platform/win32/FileUtils-win32.cpp @@ -239,8 +239,8 @@ string FileUtilsWin32::getWritablePath() const { } bool FileUtilsWin32::renameFile(const ccstd::string &oldfullpath, const ccstd::string &newfullpath) { - CCASSERT(!oldfullpath.empty(), "Invalid path"); - CCASSERT(!newfullpath.empty(), "Invalid path"); + CC_ASSERT(!oldfullpath.empty()); + CC_ASSERT(!newfullpath.empty()); std::wstring _wNew = StringUtf8ToWideChar(newfullpath); std::wstring _wOld = StringUtf8ToWideChar(oldfullpath); @@ -260,7 +260,7 @@ bool FileUtilsWin32::renameFile(const ccstd::string &oldfullpath, const ccstd::s } bool FileUtilsWin32::renameFile(const ccstd::string &path, const ccstd::string &oldname, const ccstd::string &name) { - CCASSERT(!path.empty(), "Invalid path"); + CC_ASSERT(!path.empty()); ccstd::string oldPath = path + oldname; ccstd::string newPath = path + name; @@ -272,7 +272,7 @@ bool FileUtilsWin32::renameFile(const ccstd::string &path, const ccstd::string & } bool FileUtilsWin32::createDirectory(const ccstd::string &dirPath) { - CCASSERT(!dirPath.empty(), "Invalid path"); + CC_ASSERT(!dirPath.empty()); if (isDirectoryExist(dirPath)) return true; diff --git a/native/cocos/profiler/Profiler.cpp b/native/cocos/profiler/Profiler.cpp index 421f6aaee2..8320063358 100644 --- a/native/cocos/profiler/Profiler.cpp +++ b/native/cocos/profiler/Profiler.cpp @@ -171,7 +171,7 @@ void Profiler::beginFrame() { } void Profiler::endFrame() { - CCASSERT(_current == _root, "Call stack data is not matched."); + CC_ASSERT(_current == _root); // Call stack data is not matched. _root->end(); _root->onFrameEnd(); diff --git a/native/cocos/renderer/core/PassUtils.cpp b/native/cocos/renderer/core/PassUtils.cpp index a9f3fed37c..6d2501143c 100644 --- a/native/cocos/renderer/core/PassUtils.cpp +++ b/native/cocos/renderer/core/PassUtils.cpp @@ -262,4 +262,45 @@ bool overrideMacros(MacroRecord &target, const MacroRecord &source) { return isDifferent; } +MaterialProperty toMaterialProperty(gfx::Type type, const ccstd::vector &vec) { + MaterialProperty ret; + size_t size = vec.size(); + + switch (type) { + case gfx::Type::FLOAT: + CC_ASSERT(size >= 1); + ret = vec[0]; + break; + case gfx::Type::FLOAT2: + CC_ASSERT(size >= 2); + ret = Vec2(vec[0], vec[1]); + break; + case gfx::Type::FLOAT3: + CC_ASSERT(size >= 3); + ret = Vec3(vec[0], vec[1], vec[2]); + break; + case gfx::Type::FLOAT4: + CC_ASSERT(size >= 4); + ret = Vec4(vec[0], vec[1], vec[2], vec[3]); + break; + case gfx::Type::MAT3: + CC_ASSERT(size >= 9); + ret = Mat3(vec.data()); + break; + case gfx::Type::MAT4: + CC_ASSERT(size >= 16); + ret = Mat4(vec.data()); + break; + case gfx::Type::INT: + case gfx::Type::INT2: + case gfx::Type::INT3: + case gfx::Type::INT4: + default: + CC_ASSERT(false); + break; + } + + return ret; +} + }; // namespace cc diff --git a/native/cocos/renderer/core/PassUtils.h b/native/cocos/renderer/core/PassUtils.h index 50289c58f1..dd548b833d 100644 --- a/native/cocos/renderer/core/PassUtils.h +++ b/native/cocos/renderer/core/PassUtils.h @@ -28,7 +28,8 @@ #include "base/Ptr.h" #include "base/TypeDef.h" #include "base/std/container/string.h" -#include "cocos/base/Variant.h" +#include "base/std/container/vector.h" +#include "base/Variant.h" #include "math/Color.h" #include "math/Mat3.h" @@ -39,6 +40,7 @@ #include "math/Vec4.h" #include "renderer/gfx-base/GFXDef.h" +#include "renderer/gfx-base/GFXTexture.h" namespace cc { @@ -107,4 +109,6 @@ const ccstd::string & getDefaultStringFromType(gfx::Type type); */ bool overrideMacros(MacroRecord &target, const MacroRecord &source); +MaterialProperty toMaterialProperty(gfx::Type type, const ccstd::vector &vec); + } // namespace cc diff --git a/native/cocos/renderer/gfx-base/GFXDescriptorSet.cpp b/native/cocos/renderer/gfx-base/GFXDescriptorSet.cpp index a7137fc7ca..e712af3f2e 100644 --- a/native/cocos/renderer/gfx-base/GFXDescriptorSet.cpp +++ b/native/cocos/renderer/gfx-base/GFXDescriptorSet.cpp @@ -37,7 +37,7 @@ DescriptorSet::DescriptorSet() DescriptorSet::~DescriptorSet() = default; void DescriptorSet::initialize(const DescriptorSetInfo &info) { - CCASSERT(info.layout, "Invalid set layout"); + CC_ASSERT(info.layout); _layout = info.layout; uint32_t descriptorCount = _layout->getDescriptorCount(); diff --git a/native/cocos/renderer/gfx-base/GFXSwapchain.cpp b/native/cocos/renderer/gfx-base/GFXSwapchain.cpp index d846f58ddc..083d755864 100644 --- a/native/cocos/renderer/gfx-base/GFXSwapchain.cpp +++ b/native/cocos/renderer/gfx-base/GFXSwapchain.cpp @@ -35,7 +35,7 @@ Swapchain::Swapchain() Swapchain::~Swapchain() = default; void Swapchain::initialize(const SwapchainInfo &info) { - CCASSERT(info.windowHandle, "Invalid window handle"); + CC_ASSERT(info.windowHandle); _windowHandle = info.windowHandle; _vsyncMode = info.vsyncMode; diff --git a/native/cocos/renderer/gfx-base/SPIRVUtils.cpp b/native/cocos/renderer/gfx-base/SPIRVUtils.cpp index 8671b4ceb3..0c2ef15741 100644 --- a/native/cocos/renderer/gfx-base/SPIRVUtils.cpp +++ b/native/cocos/renderer/gfx-base/SPIRVUtils.cpp @@ -45,7 +45,7 @@ EShLanguage getShaderStage(ShaderStageFlagBit type) { case ShaderStageFlagBit::FRAGMENT: return EShLangFragment; case ShaderStageFlagBit::COMPUTE: return EShLangCompute; default: { - CCASSERT(false, "Unsupported ShaderStageFlagBit, convert to EShLanguage failed."); + CC_ASSERT(false); return EShLangVertex; } } @@ -57,7 +57,7 @@ glslang::EShTargetClientVersion getClientVersion(int vulkanMinorVersion) { case 1: return glslang::EShTargetVulkan_1_1; case 2: return glslang::EShTargetVulkan_1_2; default: { - CCASSERT(false, "Unsupported vulkan version, convert to EShTargetClientVersion failed."); + CC_ASSERT(false); return glslang::EShTargetVulkan_1_0; } } @@ -69,7 +69,7 @@ glslang::EShTargetLanguageVersion getTargetVersion(int vulkanMinorVersion) { case 1: return glslang::EShTargetSpv_1_3; case 2: return glslang::EShTargetSpv_1_5; default: { - CCASSERT(false, "Unsupported vulkan version, convert to EShTargetLanguageVersion failed."); + CC_ASSERT(false); return glslang::EShTargetSpv_1_0; } } @@ -217,7 +217,8 @@ void SPIRVUtils::compressInputLocations(gfx::AttributeList &attributes) { } } - CCASSERT(found, "missing attribute declarations?"); + // Missing attribute declarations? + CC_ASSERT(found); } } diff --git a/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.cpp b/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.cpp index 47a187aee7..4f8939f2e2 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.cpp @@ -148,7 +148,7 @@ void GLES2CommandBuffer::bindPipelineState(PipelineState *pso) { } void GLES2CommandBuffer::bindDescriptorSet(uint32_t set, DescriptorSet *descriptorSet, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets) { - CCASSERT(_curGPUDescriptorSets.size() > set, "Invalid set index"); + CC_ASSERT(_curGPUDescriptorSets.size() > set); GLES2GPUDescriptorSet *gpuDescriptorSet = static_cast(descriptorSet)->gpuDescriptorSet(); if (_curGPUDescriptorSets[set] != gpuDescriptorSet) { @@ -326,7 +326,7 @@ void GLES2CommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, c } void GLES2CommandBuffer::execute(CommandBuffer *const *cmdBuffs, uint32_t count) { - CCASSERT(false, "Command 'execute' must be recorded in primary command buffers."); + CC_ASSERT(false); // Command 'execute' must be recorded in primary command buffers. for (uint32_t i = 0; i < count; ++i) { auto * cmdBuff = static_cast(cmdBuffs[i]); @@ -390,7 +390,7 @@ void GLES2CommandBuffer::bindStates() { cmd->dynamicOffsets.resize(_curGPUPipelineState->gpuPipelineLayout->dynamicOffsetCount); for (size_t i = 0U; i < _curDynamicOffsets.size(); i++) { size_t count = dynamicOffsetOffsets[i + 1] - dynamicOffsetOffsets[i]; - //CCASSERT(_curDynamicOffsets[i].size() >= count, "missing dynamic offsets?"); + // CC_ASSERT(_curDynamicOffsets[i].size() >= count); count = std::min(count, _curDynamicOffsets[i].size()); if (count) memcpy(&cmd->dynamicOffsets[dynamicOffsetOffsets[i]], _curDynamicOffsets[i].data(), count * sizeof(uint32_t)); } diff --git a/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp b/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp index a5837d7c4f..1a6fda0cfe 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp @@ -115,7 +115,7 @@ GLenum mapGLFormat(Format format) { case Format::ASTC_SRGBA_12X12: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; default: { - CCASSERT(false, "Unsupported Format, convert to GL format failed."); + CC_ASSERT(false); return GL_NONE; } } @@ -167,7 +167,7 @@ GLenum mapGLType(Type type) { case Type::SAMPLER3D: return GL_SAMPLER_3D_OES; case Type::SAMPLER_CUBE: return GL_SAMPLER_CUBE; default: { - CCASSERT(false, "Unsupported Type, convert to GL type failed."); + CC_ASSERT(false); return GL_NONE; } } @@ -195,7 +195,7 @@ Type mapType(GLenum glType) { case GL_SAMPLER_3D_OES: return Type::SAMPLER3D; case GL_SAMPLER_CUBE: return Type::SAMPLER_CUBE; default: { - CCASSERT(false, "Unsupported GL type, convert to Type failed."); + CC_ASSERT(false); return Type::UNKNOWN; } } @@ -316,7 +316,7 @@ GLenum formatToGLType(Format format) { return GL_UNSIGNED_BYTE; default: { - CCASSERT(false, "Unsupported Format, convert to GL type failed."); + CC_ASSERT(false); return GL_NONE; } } @@ -348,7 +348,7 @@ uint32_t glTypeSize(GLenum glType) { case GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES: case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES: return 4; default: { - CCASSERT(false, "Unsupported GL type, get type size failed."); + CC_ASSERT(false); return 0; } } @@ -473,7 +473,7 @@ void cmdFuncGLES2CreateBuffer(GLES2Device *device, GLES2GPUBuffer *gpuBuffer) { gpuBuffer->buffer = static_cast(CC_MALLOC(gpuBuffer->size)); gpuBuffer->glTarget = GL_NONE; } else { - CCASSERT(false, "Unsupported BufferType, create buffer failed."); + CC_ASSERT(false); gpuBuffer->glTarget = GL_NONE; } } @@ -566,7 +566,7 @@ void cmdFuncGLES2ResizeBuffer(GLES2Device *device, GLES2GPUBuffer *gpuBuffer) { gpuBuffer->buffer = static_cast(CC_MALLOC(gpuBuffer->size)); gpuBuffer->glTarget = GL_NONE; } else { - CCASSERT(false, "Unsupported BufferType, resize buffer failed."); + CC_ASSERT(false); gpuBuffer->glTarget = GL_NONE; } } @@ -620,7 +620,7 @@ void cmdFuncGLES2CreateTexture(GLES2Device *device, GLES2GPUTexture *gpuTexture) break; } default: - CCASSERT(false, "Unsupported TextureType, create texture failed."); + CC_ASSERT(false); break; } } else { @@ -700,7 +700,7 @@ void cmdFuncGLES2CreateTexture(GLES2Device *device, GLES2GPUTexture *gpuTexture) break; } default: - CCASSERT(false, "Unsupported TextureType, create texture failed."); + CC_ASSERT(false); break; } } @@ -797,7 +797,7 @@ void cmdFuncGLES2ResizeTexture(GLES2Device *device, GLES2GPUTexture *gpuTexture) break; } default: - CCASSERT(false, "Unsupported TextureType, resize texture failed."); + CC_ASSERT(false); break; } } else { @@ -818,7 +818,7 @@ void cmdFuncGLES2ResizeTexture(GLES2Device *device, GLES2GPUTexture *gpuTexture) break; } default: - CCASSERT(false, "Unsupported TextureType, resize texture failed."); + CC_ASSERT(false); break; } } @@ -877,7 +877,7 @@ void cmdFuncGLES2CreateShader(GLES2Device *device, GLES2GPUShader *gpuShader) { break; } default: { - CCASSERT(false, "Unsupported ShaderStageFlagBit"); + CC_ASSERT(false); return; } } @@ -1396,7 +1396,7 @@ static GLES2GPUSwapchain *getSwapchainIfExists(const ccstd::vectorgpuTexture; GLuint glTexture = gpuTexture->glTexture; - CCASSERT(!gpuTexture->glRenderbuffer, "Can not sample renderbuffers!"); + CC_ASSERT(!gpuTexture->glRenderbuffer); // Can not sample renderbuffers! if (cache->glTextures[unit] != glTexture) { if (cache->texUint != unit) { @@ -2504,7 +2504,7 @@ void cmdFuncGLES2Draw(GLES2Device *device, const DrawInfo &drawInfo) { void cmdFuncGLES2UpdateBuffer(GLES2Device *device, GLES2GPUBuffer *gpuBuffer, const void *buffer, uint32_t offset, uint32_t size) { GLES2ObjectCache &gfxStateCache = device->stateCache()->gfxStateCache; - CCASSERT(buffer, "Buffer should not be nullptr"); + CC_ASSERT(buffer); if ((hasFlag(gpuBuffer->usage, BufferUsageBit::UNIFORM)) || (hasFlag(gpuBuffer->usage, BufferUsageBit::TRANSFER_SRC))) { memcpy(gpuBuffer->buffer + offset, buffer, size); @@ -2543,7 +2543,7 @@ void cmdFuncGLES2UpdateBuffer(GLES2Device *device, GLES2GPUBuffer *gpuBuffer, co break; } default: - CCASSERT(false, "Unsupported BufferType, update buffer failed."); + CC_ASSERT(false); break; } } @@ -2699,7 +2699,7 @@ void cmdFuncGLES2CopyBuffersToTexture(GLES2Device *device, const uint8_t *const break; } default: - CCASSERT(false, "Unsupported TextureType, copy buffers to texture failed."); + CC_ASSERT(false); break; } diff --git a/native/cocos/renderer/gfx-gles2/GLES2Device.cpp b/native/cocos/renderer/gfx-gles2/GLES2Device.cpp index f992dcbe7b..8c6fc5d7b2 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Device.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2Device.cpp @@ -224,8 +224,8 @@ void GLES2Device::doDestroy() { CC_SAFE_DELETE(_gpuBlitManager) CC_SAFE_DELETE(_gpuStateCache) - CCASSERT(!_memoryStatus.bufferSize, "Buffer memory leaked"); - CCASSERT(!_memoryStatus.textureSize, "Texture memory leaked"); + CC_ASSERT(!_memoryStatus.bufferSize); // Buffer memory leaked. + CC_ASSERT(!_memoryStatus.textureSize); // Texture memory leaked. CC_SAFE_DESTROY_AND_DELETE(_cmdBuff) CC_SAFE_DESTROY_AND_DELETE(_queryPool) diff --git a/native/cocos/renderer/gfx-gles2/GLES2GPUContext.cpp b/native/cocos/renderer/gfx-gles2/GLES2GPUContext.cpp index 994878779c..c4de68d56c 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2GPUContext.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2GPUContext.cpp @@ -76,7 +76,7 @@ void GL_APIENTRY GLES2EGLDebugProc(GLenum source, GLenum type, GLuint id, GLenum if (severity == GL_DEBUG_SEVERITY_HIGH_KHR) { CC_LOG_ERROR(msg.c_str()); - CCASSERT(DISABLE_VALIDATION_ASSERTIONS, "Validation Error"); + CC_ASSERT(DISABLE_VALIDATION_ASSERTIONS); } else if (severity == GL_DEBUG_SEVERITY_MEDIUM_KHR) { CC_LOG_WARNING(msg.c_str()); } else { diff --git a/native/cocos/renderer/gfx-gles2/GLES2GPUObjects.h b/native/cocos/renderer/gfx-gles2/GLES2GPUObjects.h index 5a5e19a1b5..5f7b33b03e 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2GPUObjects.h +++ b/native/cocos/renderer/gfx-gles2/GLES2GPUObjects.h @@ -531,7 +531,7 @@ public: GLenum status; GL_CHECK(status = glCheckFramebufferStatus(GL_FRAMEBUFFER)); - CCASSERT(status == GL_FRAMEBUFFER_COMPLETE, "frambuffer incomplete"); + CC_ASSERT(status == GL_FRAMEBUFFER_COMPLETE); cacheMap[glResource].glFramebuffer = glFramebuffer; } diff --git a/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.cpp b/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.cpp index 1f977c7a12..f2094cc36a 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.cpp +++ b/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.cpp @@ -88,7 +88,7 @@ void GLES2PrimaryCommandBuffer::draw(const DrawInfo &info) { ccstd::vector &dynamicOffsets = _curGPUPipelineState->gpuPipelineLayout->dynamicOffsets; for (size_t i = 0U; i < _curDynamicOffsets.size(); i++) { size_t count = dynamicOffsetOffsets[i + 1] - dynamicOffsetOffsets[i]; - //CCASSERT(_curDynamicOffsets[i].size() >= count, "missing dynamic offsets?"); + // CC_ASSERT(_curDynamicOffsets[i].size() >= count); count = std::min(count, _curDynamicOffsets[i].size()); if (count) memcpy(&dynamicOffsets[dynamicOffsetOffsets[i]], _curDynamicOffsets[i].data(), count * sizeof(uint32_t)); } @@ -186,7 +186,7 @@ void GLES2PrimaryCommandBuffer::bindStates() { ccstd::vector &dynamicOffsets = _curGPUPipelineState->gpuPipelineLayout->dynamicOffsets; for (size_t i = 0U; i < _curDynamicOffsets.size(); i++) { size_t count = dynamicOffsetOffsets[i + 1] - dynamicOffsetOffsets[i]; - //CCASSERT(_curDynamicOffsets[i].size() >= count, "missing dynamic offsets?"); + // CC_ASSERT(_curDynamicOffsets[i].size() >= count); count = std::min(count, _curDynamicOffsets[i].size()); if (count) memcpy(&dynamicOffsets[dynamicOffsetOffsets[i]], _curDynamicOffsets[i].data(), count * sizeof(uint32_t)); } diff --git a/native/cocos/renderer/gfx-gles2/GLES2Std.h b/native/cocos/renderer/gfx-gles2/GLES2Std.h index b766fb44d1..698285c0c8 100644 --- a/native/cocos/renderer/gfx-gles2/GLES2Std.h +++ b/native/cocos/renderer/gfx-gles2/GLES2Std.h @@ -48,7 +48,7 @@ GLenum err = glGetError(); \ if (err != GL_NO_ERROR) { \ CC_LOG_ERROR("%s returned GL error: 0x%x", #x, err); \ - CCASSERT(0, "GL error"); \ + CC_ASSERT(false); \ } \ } while (0) #define EGL_CHECK(x) \ @@ -57,7 +57,7 @@ EGLint err = eglGetError(); \ if (err != EGL_SUCCESS) { \ CC_LOG_ERROR("%s returned EGL error: 0x%x", #x, err); \ - CCASSERT(0, "EGL error"); \ + CC_ASSERT(false); \ } \ } while (0) #else diff --git a/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.cpp b/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.cpp index 5b58cccc94..30cde51ede 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.cpp @@ -149,7 +149,7 @@ void GLES3CommandBuffer::bindPipelineState(PipelineState *pso) { } void GLES3CommandBuffer::bindDescriptorSet(uint32_t set, DescriptorSet *descriptorSet, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets) { - CCASSERT(_curGPUDescriptorSets.size() > set, "Invalid set index"); + CC_ASSERT(_curGPUDescriptorSets.size() > set); GLES3GPUDescriptorSet *gpuDescriptorSet = static_cast(descriptorSet)->gpuDescriptorSet(); if (_curGPUDescriptorSets[set] != gpuDescriptorSet) { @@ -327,7 +327,7 @@ void GLES3CommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Tex } void GLES3CommandBuffer::execute(CommandBuffer *const *cmdBuffs, uint32_t count) { - CCASSERT(false, "Command 'execute' must be recorded in primary command buffers."); + CC_ASSERT(false); // Command 'execute' must be recorded in primary command buffers. for (uint32_t i = 0; i < count; ++i) { auto * cmdBuff = static_cast(cmdBuffs[i]); @@ -400,7 +400,7 @@ void GLES3CommandBuffer::bindStates() { cmd->dynamicOffsets.resize(_curGPUPipelineState->gpuPipelineLayout->dynamicOffsetCount); for (size_t i = 0U; i < _curDynamicOffsets.size(); i++) { size_t count = dynamicOffsetOffsets[i + 1] - dynamicOffsetOffsets[i]; - //CCASSERT(_curDynamicOffsets[i].size() >= count, "missing dynamic offsets?"); + // CC_ASSERT(_curDynamicOffsets[i].size() >= count); count = std::min(count, _curDynamicOffsets[i].size()); if (count) memcpy(&cmd->dynamicOffsets[dynamicOffsetOffsets[i]], _curDynamicOffsets[i].data(), count * sizeof(uint32_t)); } diff --git a/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp b/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp index ef8eba6291..2a975c94ca 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp @@ -158,7 +158,7 @@ GLenum mapGLInternalFormat(Format format) { case Format::ASTC_SRGBA_12X12: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; default: { - CCASSERT(false, "Unsupported Format, convert to GL internal format failed."); + CC_ASSERT(false); return GL_NONE; } } @@ -282,7 +282,7 @@ GLenum mapGLFormat(Format format) { case Format::ASTC_SRGBA_12X12: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; default: { - CCASSERT(false, "Unsupported Format, convert to GL format failed."); + CC_ASSERT(false); return GL_NONE; } } @@ -317,7 +317,7 @@ GLenum mapGLType(Type type) { case Type::SAMPLER3D: return GL_SAMPLER_3D; case Type::SAMPLER_CUBE: return GL_SAMPLER_CUBE; default: { - CCASSERT(false, "Unsupported Type, convert to GL type failed."); + CC_ASSERT(false); return GL_NONE; } } @@ -355,7 +355,7 @@ Type mapType(GLenum glType) { case GL_SAMPLER_3D: return Type::SAMPLER3D; case GL_SAMPLER_CUBE: return Type::SAMPLER_CUBE; default: { - CCASSERT(false, "Unsupported GL type, convert to Type failed."); + CC_ASSERT(false); return Type::UNKNOWN; } } @@ -484,7 +484,7 @@ GLenum formatToGLType(Format format) { return GL_UNSIGNED_BYTE; default: { - CCASSERT(false, "Unsupported Format, convert to GL type failed."); + CC_ASSERT(false); return GL_NONE; } } @@ -662,7 +662,7 @@ void cmdFuncGLES3CreateBuffer(GLES3Device *device, GLES3GPUBuffer *gpuBuffer) { gpuBuffer->buffer = static_cast(CC_MALLOC(gpuBuffer->size)); gpuBuffer->glTarget = GL_NONE; } else { - CCASSERT(false, "Unsupported BufferType, create buffer failed."); + CC_ASSERT(false); gpuBuffer->glTarget = GL_NONE; } } @@ -794,7 +794,7 @@ void cmdFuncGLES3ResizeBuffer(GLES3Device *device, GLES3GPUBuffer *gpuBuffer) { gpuBuffer->buffer = static_cast(CC_MALLOC(gpuBuffer->size)); gpuBuffer->glTarget = GL_NONE; } else { - CCASSERT(false, "Unsupported BufferType, resize buffer failed."); + CC_ASSERT(false); gpuBuffer->glTarget = GL_NONE; } } @@ -853,7 +853,7 @@ void cmdFuncGLES3CreateTexture(GLES3Device *device, GLES3GPUTexture *gpuTexture) break; } default: - CCASSERT(false, "Unsupported TextureType, create texture failed."); + CC_ASSERT(false); break; } } else { @@ -889,7 +889,7 @@ void cmdFuncGLES3CreateTexture(GLES3Device *device, GLES3GPUTexture *gpuTexture) break; } default: - CCASSERT(false, "Unsupported TextureType, create texture failed."); + CC_ASSERT(false); break; } } @@ -944,7 +944,7 @@ void cmdFuncGLES3ResizeTexture(GLES3Device *device, GLES3GPUTexture *gpuTexture) break; } default: - CCASSERT(false, "Unsupported TextureType, resize texture failed."); + CC_ASSERT(false); break; } } @@ -1023,7 +1023,7 @@ void cmdFuncGLES3CreateShader(GLES3Device *device, GLES3GPUShader *gpuShader) { break; } default: { - CCASSERT(false, "Unsupported ShaderStageFlagBit"); + CC_ASSERT(false); return; } } @@ -1550,7 +1550,7 @@ static GLES3GPUSwapchain *getSwapchainIfExists(const ccstd::vectorswapchain) return gpuTexture->swapchain->glFramebuffer; - CCASSERT(gpuTexture->glTexture || gpuTexture->glRenderbuffer, "Texture already destroyed?"); + CC_ASSERT(gpuTexture->glTexture || gpuTexture->glRenderbuffer); if (cacheMap[glResource].empty()) cacheMap[glResource].resize(gpuTexture->mipLevel); @@ -610,7 +610,7 @@ public: GLenum status; GL_CHECK(status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER)); - CCASSERT(status == GL_FRAMEBUFFER_COMPLETE, "frambuffer incomplete"); + CC_ASSERT(status == GL_FRAMEBUFFER_COMPLETE); cacheMap[glResource][mipLevel].glFramebuffer = glFramebuffer; } diff --git a/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.cpp b/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.cpp index c2a5a151f0..5d55000af0 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.cpp @@ -202,7 +202,7 @@ void GLES3PrimaryCommandBuffer::bindStates() { ccstd::vector &dynamicOffsets = _curGPUPipelineState->gpuPipelineLayout->dynamicOffsets; for (size_t i = 0U, len = dynamicOffsetOffsets.size() - 1; i < len; i++) { size_t count = dynamicOffsetOffsets[i + 1] - dynamicOffsetOffsets[i]; - //CCASSERT(_curDynamicOffsets[i].size() >= count, "missing dynamic offsets?"); + // CC_ASSERT(_curDynamicOffsets[i].size() >= count); count = std::min(count, _curDynamicOffsets[i].size()); if (count) memcpy(&dynamicOffsets[dynamicOffsetOffsets[i]], _curDynamicOffsets[i].data(), count * sizeof(uint32_t)); } diff --git a/native/cocos/renderer/gfx-gles3/GLES3Std.h b/native/cocos/renderer/gfx-gles3/GLES3Std.h index fcec83334e..226ac3b91f 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Std.h +++ b/native/cocos/renderer/gfx-gles3/GLES3Std.h @@ -48,7 +48,7 @@ GLenum err = glGetError(); \ if (err != GL_NO_ERROR) { \ CC_LOG_ERROR("%s returned GL error: 0x%x", #x, err); \ - CCASSERT(0, "GL error"); \ + CC_ASSERT(false); \ } \ } while (0) #define EGL_CHECK(x) \ @@ -57,7 +57,7 @@ EGLint err = eglGetError(); \ if (err != EGL_SUCCESS) { \ CC_LOG_ERROR("%s returned EGL error: 0x%x", #x, err); \ - CCASSERT(0, "EGL error"); \ + CC_ASSERT(false); \ } \ } while (0) #else diff --git a/native/cocos/renderer/gfx-gles3/GLES3Texture.cpp b/native/cocos/renderer/gfx-gles3/GLES3Texture.cpp index c6e0e095e8..a2884d8b46 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3Texture.cpp +++ b/native/cocos/renderer/gfx-gles3/GLES3Texture.cpp @@ -73,7 +73,7 @@ void GLES3Texture::doInit(const TextureInfo & /*info*/) { void GLES3Texture::doInit(const TextureViewInfo & /*info*/) { _gpuTexture = static_cast(_viewInfo.texture)->gpuTexture(); - CCASSERT(_viewInfo.texture->getFormat() == _viewInfo.format, "Invalid TextureView fromat"); + CC_ASSERT(_viewInfo.texture->getFormat() == _viewInfo.format); _gpuTextureView = CC_NEW(GLES3GPUTextureView); createTextureView(); diff --git a/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm b/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm index 38501bda85..50e02ca26c 100644 --- a/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm +++ b/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm @@ -434,7 +434,7 @@ void CCMTLCommandBuffer::bindPipelineState(PipelineState *pso) { } void CCMTLCommandBuffer::bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) { - CCASSERT(set < _GPUDescriptorSets.size(), "Invalid set index"); + CC_ASSERT(set < _GPUDescriptorSets.size()); if (dynamicOffsetCount) { _dynamicOffsets[set].assign(dynamicOffsets, dynamicOffsets + dynamicOffsetCount); if (set < _firstDirtyDescriptorSet) { diff --git a/native/cocos/renderer/gfx-metal/MTLDevice.mm b/native/cocos/renderer/gfx-metal/MTLDevice.mm index 57f17cd017..1674213e8c 100644 --- a/native/cocos/renderer/gfx-metal/MTLDevice.mm +++ b/native/cocos/renderer/gfx-metal/MTLDevice.mm @@ -179,8 +179,8 @@ void CCMTLDevice::doDestroy() { CCMTLTexture::deleteDefaultTexture(); CCMTLSampler::deleteDefaultSampler(); - CCASSERT(!_memoryStatus.bufferSize, "Buffer memory leaked"); - CCASSERT(!_memoryStatus.textureSize, "Texture memory leaked"); + CC_ASSERT(!_memoryStatus.bufferSize); // Buffer memory leaked + CC_ASSERT(!_memoryStatus.textureSize); // Texture memory leaked } void CCMTLDevice::acquire(Swapchain *const *swapchains, uint32_t count) { @@ -326,7 +326,7 @@ void CCMTLDevice::getQueryPoolResults(QueryPool *queryPool) { auto * mtlQueryPool = static_cast(queryPool); CCMTLGPUQueryPool *gpuQueryPool = mtlQueryPool->gpuQueryPool(); auto queryCount = static_cast(mtlQueryPool->_ids.size()); - CCASSERT(queryCount <= mtlQueryPool->getMaxQueryObjects(), "Too many query commands."); + CC_ASSERT(queryCount <= mtlQueryPool->getMaxQueryObjects()); // Too many query commands. gpuQueryPool->semaphore->wait(); uint64_t *results = queryCount > 0U ? static_cast(gpuQueryPool->visibilityResultBuffer.contents) : nullptr; diff --git a/native/cocos/renderer/gfx-metal/MTLPipelineLayout.mm b/native/cocos/renderer/gfx-metal/MTLPipelineLayout.mm index 7e6c02529e..f600770825 100644 --- a/native/cocos/renderer/gfx-metal/MTLPipelineLayout.mm +++ b/native/cocos/renderer/gfx-metal/MTLPipelineLayout.mm @@ -44,7 +44,7 @@ void CCMTLPipelineLayout::doInit(const PipelineLayoutInfo &info) { for (size_t i = 0; i < setCount; i++) { const auto *setLayout = _setLayouts[i]; - CCASSERT(setLayout != nullptr, "SetLayout should not be nullptr."); + CC_ASSERT(setLayout != nullptr); auto gpuDescriptorSetLayout = static_cast(setLayout)->gpuDescriptorSetLayout(); auto dynamicCount = gpuDescriptorSetLayout->dynamicBindings.size(); auto &indices = _gpuPipelineLayout->dynamicOffsetIndices[i]; diff --git a/native/cocos/renderer/gfx-metal/MTLTexture.mm b/native/cocos/renderer/gfx-metal/MTLTexture.mm index 7804dd05bb..a947be95f9 100644 --- a/native/cocos/renderer/gfx-metal/MTLTexture.mm +++ b/native/cocos/renderer/gfx-metal/MTLTexture.mm @@ -77,7 +77,7 @@ void CCMTLTexture::doInit(const TextureInfo &info) { nil, &CVMTLTextureCache); - CCASSERT(cvret == kCVReturnSuccess, @"Failed to create Metal texture cache"); + CC_ASSERT(cvret == kCVReturnSuccess); // Failed to create Metal texture cache. _convertedFormat = mu::convertGFXPixelFormat(_info.format); MTLPixelFormat mtlFormat = mu::toMTLPixelFormat(_convertedFormat); @@ -91,13 +91,13 @@ void CCMTLTexture::doInit(const TextureInfo &info) { 0, &CVMTLTexture); - CCASSERT(cvret == kCVReturnSuccess, @"Failed to create CoreVideo Metal texture from image"); + CC_ASSERT(cvret == kCVReturnSuccess); // Failed to create CoreVideo Metal texture from image. _mtlTexture = CVMetalTextureGetTexture(CVMTLTexture); CFRelease(CVMTLTexture); CFRelease(CVMTLTextureCache); - CCASSERT(_mtlTexture, @"Failed to create Metal texture CoreVideo Metal Texture"); + CC_ASSERT(_mtlTexture); // Failed to create Metal texture CoreVideo Metal Texture } if (!createMTLTexture()) { @@ -171,7 +171,7 @@ bool CCMTLTexture::createMTLTexture() { mipmapped:NO]; break; default: - CCASSERT(false, "Unsupported MTLTextureType, create MTLTextureDescriptor failed."); + CC_ASSERT(false); break; } diff --git a/native/cocos/renderer/gfx-metal/MTLUtils.mm b/native/cocos/renderer/gfx-metal/MTLUtils.mm index 2fe212c32c..d884ea2c4b 100644 --- a/native/cocos/renderer/gfx-metal/MTLUtils.mm +++ b/native/cocos/renderer/gfx-metal/MTLUtils.mm @@ -52,7 +52,7 @@ EShLanguage getShaderStage(ShaderStageFlagBit type) { case ShaderStageFlagBit::FRAGMENT: return EShLangFragment; case ShaderStageFlagBit::COMPUTE: return EShLangCompute; default: { - CCASSERT(false, "Unsupported ShaderStageFlagBit, convert to EShLanguage failed."); + CC_ASSERT(false); return EShLangVertex; } } @@ -64,7 +64,7 @@ glslang::EShTargetClientVersion getClientVersion(int vulkanMinorVersion) { case 1: return glslang::EShTargetVulkan_1_1; case 2: return glslang::EShTargetVulkan_1_2; default: { - CCASSERT(false, "Unsupported vulkan version, convert to EShTargetClientVersion failed."); + CC_ASSERT(false); return glslang::EShTargetVulkan_1_0; } } @@ -76,7 +76,7 @@ glslang::EShTargetLanguageVersion getTargetVersion(int vulkanMinorVersion) { case 1: return glslang::EShTargetSpv_1_3; case 2: return glslang::EShTargetSpv_1_5; default: { - CCASSERT(false, "Unsupported vulkan version, convert to EShTargetLanguageVersion failed."); + CC_ASSERT(false); return glslang::EShTargetSpv_1_0; } } diff --git a/native/cocos/renderer/gfx-validator/BufferValidator.cpp b/native/cocos/renderer/gfx-validator/BufferValidator.cpp index 530720d1ad..0afa3ddab3 100644 --- a/native/cocos/renderer/gfx-validator/BufferValidator.cpp +++ b/native/cocos/renderer/gfx-validator/BufferValidator.cpp @@ -50,20 +50,22 @@ BufferValidator::~BufferValidator() { } void BufferValidator::doInit(const BufferInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + // Initialize twice? + CC_ASSERT(!isInited()); _inited = true; - CCASSERT(info.usage != BufferUsageBit::NONE, "invalid buffer param"); - CCASSERT(info.memUsage != MemoryUsageBit::NONE, "invalid buffer param"); - CCASSERT(info.size, "zero-sized buffer?"); - CCASSERT(info.size / info.stride * info.stride == info.size, "size is not multiple of stride?"); + CC_ASSERT(info.usage != BufferUsageBit::NONE); + CC_ASSERT(info.memUsage != MemoryUsageBit::NONE); + CC_ASSERT(info.size); + CC_ASSERT(info.size / info.stride * info.stride == info.size); _initStack = utils::getStacktraceJS(); _creationFrame = DeviceValidator::getInstance()->currentFrame(); _totalUpdateTimes = 0U; if (hasFlag(info.usage, BufferUsageBit::VERTEX) && !info.stride) { - CCASSERT(false, "invalid stride for vertex buffer"); + // Invalid stride for vertex buffer. + CC_ASSERT(false); } /////////// execute /////////// @@ -72,15 +74,19 @@ void BufferValidator::doInit(const BufferInfo &info) { } void BufferValidator::doInit(const BufferViewInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + // Initialize twice? + CC_ASSERT(!isInited()); _inited = true; - CCASSERT(info.buffer && static_cast(info.buffer)->isInited(), "already destroyed?"); - CCASSERT(info.offset + info.range <= info.buffer->getSize(), "invalid range"); - CCASSERT(info.range, "zero-sized buffer?"); + // Already been destroyed? + CC_ASSERT(info.buffer && static_cast(info.buffer)->isInited()); + CC_ASSERT(info.offset + info.range <= info.buffer->getSize()); + // zero-sized buffer? + CC_ASSERT(info.range); uint32_t stride = info.buffer->getStride(); - CCASSERT(info.offset / stride * stride == info.offset, "offset is not multiple of stride?"); + // Offset is not multiple of stride? + CC_ASSERT(info.offset / stride * stride == info.offset); /////////// execute /////////// @@ -91,10 +97,12 @@ void BufferValidator::doInit(const BufferViewInfo &info) { } void BufferValidator::doResize(uint32_t size, uint32_t /*count*/) { - CCASSERT(isInited(), "alread destroyed?"); + // Already been destroyed? + CC_ASSERT(isInited()); - CCASSERT(!_isBufferView, "cannot resize through buffer views"); - CCASSERT(size, "invalid size"); + // Cannot resize through buffer views. + CC_ASSERT(!_isBufferView); + CC_ASSERT(size); /////////// execute /////////// @@ -102,7 +110,8 @@ void BufferValidator::doResize(uint32_t size, uint32_t /*count*/) { } void BufferValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + // Be destroyed twice?" + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// @@ -111,11 +120,12 @@ void BufferValidator::doDestroy() { } void BufferValidator::update(const void *buffer, uint32_t size) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); - CCASSERT(!_isBufferView, "cannot update through buffer views"); - CCASSERT(size && size <= _size, "invalid size"); - CCASSERT(buffer, "invalid buffer data"); + // Cannot update through buffer views. + CC_ASSERT(!_isBufferView); + CC_ASSERT(size && size <= _size); + CC_ASSERT(buffer); if (hasFlag(_usage, BufferUsageBit::INDIRECT)) { const auto * drawInfo = static_cast(buffer); @@ -123,7 +133,8 @@ void BufferValidator::update(const void *buffer, uint32_t size) { const bool isIndexed = drawInfoCount > 0 && drawInfo->indexCount > 0; for (size_t i = 1U; i < drawInfoCount; ++i) { if ((++drawInfo)->indexCount > 0 != isIndexed) { - CCASSERT(false, "inconsistent indirect draw infos on using index buffer"); + // Inconsistent indirect draw infos on using index buffer. + CC_ASSERT(false); } } } diff --git a/native/cocos/renderer/gfx-validator/CommandBufferValidator.cpp b/native/cocos/renderer/gfx-validator/CommandBufferValidator.cpp index a026d7ce9d..a961fa5a89 100644 --- a/native/cocos/renderer/gfx-validator/CommandBufferValidator.cpp +++ b/native/cocos/renderer/gfx-validator/CommandBufferValidator.cpp @@ -54,7 +54,7 @@ CommandBufferValidator::~CommandBufferValidator() { } void CommandBufferValidator::initValidator() { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; size_t descriptorSetCount = DeviceValidator::getInstance()->bindingMappingInfo().setIndices.size(); @@ -68,7 +68,8 @@ void CommandBufferValidator::destroyValidator() { void CommandBufferValidator::doInit(const CommandBufferInfo &info) { initValidator(); - CCASSERT(info.queue && static_cast(info.queue)->isInited(), "already destroyed?"); + // Already been destroyed? + CC_ASSERT(info.queue && static_cast(info.queue)->isInited()); /////////// execute /////////// @@ -79,7 +80,8 @@ void CommandBufferValidator::doInit(const CommandBufferInfo &info) { } void CommandBufferValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + // Destroy twice? + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// @@ -88,12 +90,13 @@ void CommandBufferValidator::doDestroy() { } void CommandBufferValidator::begin(RenderPass *renderPass, uint32_t subpass, Framebuffer *framebuffer) { - CCASSERT(isInited(), "alread destroyed?"); - CCASSERT(!renderPass || static_cast(renderPass)->isInited(), "already destroyed?"); - CCASSERT(!framebuffer || static_cast(framebuffer)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(!renderPass || static_cast(renderPass)->isInited()); + CC_ASSERT(!framebuffer || static_cast(framebuffer)->isInited()); - CCASSERT(!_insideRenderPass, "Already inside a render pass?"); - CCASSERT(_type != CommandBufferType::PRIMARY || !renderPass, "Primary command buffer cannot inherit render passes"); + CC_ASSERT(!_insideRenderPass); + // Primary command buffer cannot inherit render passes. + CC_ASSERT(_type != CommandBufferType::PRIMARY || !renderPass); // secondary command buffers enter the render pass right here _insideRenderPass = !!renderPass; @@ -111,9 +114,11 @@ void CommandBufferValidator::begin(RenderPass *renderPass, uint32_t subpass, Fra } void CommandBufferValidator::end() { - CCASSERT(isInited(), "alread destroyed?"); + // Alread been destroyed? + CC_ASSERT(isInited()); - CCASSERT(_type != CommandBufferType::PRIMARY || !_insideRenderPass, "Still inside a render pass?"); + // Still inside a render pass? + CC_ASSERT(_type != CommandBufferType::PRIMARY || !_insideRenderPass); _insideRenderPass = false; /////////// execute /////////// @@ -122,20 +127,21 @@ void CommandBufferValidator::end() { } void CommandBufferValidator::beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, uint32_t stencil, CommandBuffer *const *secondaryCBs, uint32_t secondaryCBCount) { - CCASSERT(isInited(), "alread destroyed?"); - CCASSERT(renderPass && static_cast(renderPass)->isInited(), "already destroyed?"); - CCASSERT(fbo && static_cast(fbo)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(renderPass && static_cast(renderPass)->isInited()); + CC_ASSERT(fbo && static_cast(fbo)->isInited()); - CCASSERT(_type == CommandBufferType::PRIMARY, "Command 'endRenderPass' must be recorded in primary command buffers."); - CCASSERT(!_insideRenderPass, "Already inside a render pass?"); + // Command 'endRenderPass' must be recorded in primary command buffers. + CC_ASSERT(_type == CommandBufferType::PRIMARY); + CC_ASSERT(!_insideRenderPass); for (size_t i = 0; i < renderPass->getColorAttachments().size(); ++i) { const auto &desc = renderPass->getColorAttachments()[i]; const auto *tex = fbo->getColorTextures()[i]; - CCASSERT(tex->getFormat() == desc.format, "attachment format mismatch"); + CC_ASSERT(tex->getFormat() == desc.format); } if (fbo->getDepthStencilTexture()) { - CCASSERT(fbo->getDepthStencilTexture()->getFormat() == renderPass->getDepthStencilAttachment().format, "attachment format mismatch"); + CC_ASSERT(fbo->getDepthStencilTexture()->getFormat() == renderPass->getDepthStencilAttachment().format); } _insideRenderPass = true; @@ -175,7 +181,7 @@ void CommandBufferValidator::beginRenderPass(RenderPass *renderPass, Framebuffer } void CommandBufferValidator::nextSubpass() { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); ++_curSubpass; @@ -185,10 +191,11 @@ void CommandBufferValidator::nextSubpass() { } void CommandBufferValidator::endRenderPass() { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); - CCASSERT(_type == CommandBufferType::PRIMARY, "Command 'endRenderPass' must be recorded in primary command buffers."); - CCASSERT(_insideRenderPass, "No render pass to end?"); + // Command 'endRenderPass' must be recorded in primary command buffers. + CC_ASSERT(_type == CommandBufferType::PRIMARY); + CC_ASSERT(_insideRenderPass); _insideRenderPass = false; if (DeviceValidator::getInstance()->isRecording()) { @@ -201,13 +208,14 @@ void CommandBufferValidator::endRenderPass() { } void CommandBufferValidator::execute(CommandBuffer *const *cmdBuffs, uint32_t count) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); if (!count) return; // be more lenient on this for now - CCASSERT(_type == CommandBufferType::PRIMARY, "Command 'execute' must be recorded in primary command buffers."); + // Command 'execute' must be recorded in primary command buffers. + CC_ASSERT(_type == CommandBufferType::PRIMARY); for (uint32_t i = 0U; i < count; ++i) { - CCASSERT(cmdBuffs[i] && static_cast(cmdBuffs[i])->isInited(), "already destroyed?"); + CC_ASSERT(cmdBuffs[i] && static_cast(cmdBuffs[i])->isInited()); } /////////// execute /////////// @@ -223,8 +231,8 @@ void CommandBufferValidator::execute(CommandBuffer *const *cmdBuffs, uint32_t co } void CommandBufferValidator::bindPipelineState(PipelineState *pso) { - CCASSERT(isInited(), "alread destroyed?"); - CCASSERT(pso && static_cast(pso)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(pso && static_cast(pso)->isInited()); _curStates.pipelineState = pso; @@ -234,11 +242,11 @@ void CommandBufferValidator::bindPipelineState(PipelineState *pso) { } void CommandBufferValidator::bindDescriptorSet(uint32_t set, DescriptorSet *descriptorSet, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets) { - CCASSERT(isInited(), "alread destroyed?"); - CCASSERT(descriptorSet && static_cast(descriptorSet)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(descriptorSet && static_cast(descriptorSet)->isInited()); - CCASSERT(set < DeviceValidator::getInstance()->bindingMappingInfo().setIndices.size(), "invalid set index"); - //CCASSERT(descriptorSet->getLayout()->getDynamicBindings().size() == dynamicOffsetCount, "wrong number of dynamic offsets"); // be more lenient on this + CC_ASSERT(set < DeviceValidator::getInstance()->bindingMappingInfo().setIndices.size()); + //CC_ASSERT(descriptorSet->getLayout()->getDynamicBindings().size() == dynamicOffsetCount); // be more lenient on this _curStates.descriptorSets[set] = descriptorSet; _curStates.dynamicOffsets[set].assign(dynamicOffsets, dynamicOffsets + dynamicOffsetCount); @@ -249,8 +257,8 @@ void CommandBufferValidator::bindDescriptorSet(uint32_t set, DescriptorSet *desc } void CommandBufferValidator::bindInputAssembler(InputAssembler *ia) { - CCASSERT(isInited(), "alread destroyed?"); - CCASSERT(ia && static_cast(ia)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(ia && static_cast(ia)->isInited()); _curStates.inputAssembler = ia; @@ -260,7 +268,7 @@ void CommandBufferValidator::bindInputAssembler(InputAssembler *ia) { } void CommandBufferValidator::setViewport(const Viewport &vp) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); _curStates.viewport = vp; @@ -270,7 +278,7 @@ void CommandBufferValidator::setViewport(const Viewport &vp) { } void CommandBufferValidator::setScissor(const Rect &rect) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); _curStates.scissor = rect; @@ -280,7 +288,7 @@ void CommandBufferValidator::setScissor(const Rect &rect) { } void CommandBufferValidator::setLineWidth(float width) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); _curStates.lineWidth = width; @@ -290,7 +298,7 @@ void CommandBufferValidator::setLineWidth(float width) { } void CommandBufferValidator::setDepthBias(float constant, float clamp, float slope) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); _curStates.depthBiasConstant = constant; _curStates.depthBiasClamp = clamp; @@ -302,7 +310,7 @@ void CommandBufferValidator::setDepthBias(float constant, float clamp, float slo } void CommandBufferValidator::setBlendConstants(const Color &constants) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); _curStates.blendConstant = constants; @@ -312,7 +320,7 @@ void CommandBufferValidator::setBlendConstants(const Color &constants) { } void CommandBufferValidator::setDepthBound(float minBounds, float maxBounds) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); _curStates.depthMinBounds = minBounds; _curStates.depthMaxBounds = maxBounds; @@ -323,7 +331,7 @@ void CommandBufferValidator::setDepthBound(float minBounds, float maxBounds) { } void CommandBufferValidator::setStencilWriteMask(StencilFace face, uint32_t mask) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); if (hasFlag(face, StencilFace::FRONT)) { _curStates.stencilStatesFront.writeMask = mask; @@ -338,7 +346,7 @@ void CommandBufferValidator::setStencilWriteMask(StencilFace face, uint32_t mask } void CommandBufferValidator::setStencilCompareMask(StencilFace face, uint32_t ref, uint32_t mask) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); if (hasFlag(face, StencilFace::FRONT)) { _curStates.stencilStatesFront.reference = ref; @@ -355,9 +363,10 @@ void CommandBufferValidator::setStencilCompareMask(StencilFace face, uint32_t re } void CommandBufferValidator::draw(const DrawInfo &info) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); - CCASSERT(_insideRenderPass, "Command 'draw' must be recorded inside render passes."); + // Command 'draw' must be recorded inside render passes. + CC_ASSERT(_insideRenderPass); if (DeviceValidator::getInstance()->isRecording()) { _recorder.recordDrawcall(_curStates); @@ -368,7 +377,7 @@ void CommandBufferValidator::draw(const DrawInfo &info) { if (!_curStates.descriptorSets[i]) continue; // there may be inactive sets const auto &dsBindings = _curStates.descriptorSets[i]->getLayout()->getBindings(); const auto &psoBindings = psoLayouts[i]->getBindings(); - CCASSERT(psoBindings.size() == dsBindings.size(), "Descriptor set layout mismatch"); + CC_ASSERT(psoBindings.size() == dsBindings.size()); } /////////// execute /////////// @@ -377,11 +386,13 @@ void CommandBufferValidator::draw(const DrawInfo &info) { } void CommandBufferValidator::updateBuffer(Buffer *buff, const void *data, uint32_t size) { - CCASSERT(isInited(), "alread destroyed?"); - CCASSERT(buff && static_cast(buff)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(buff && static_cast(buff)->isInited()); - CCASSERT(_type == CommandBufferType::PRIMARY, "Command 'updateBuffer' must be recorded in primary command buffers."); - CCASSERT(!_insideRenderPass, "Command 'updateBuffer' must be recorded outside render passes."); + // Command 'updateBuffer' must be recorded in primary command buffers. + CC_ASSERT(_type == CommandBufferType::PRIMARY); + // Command 'updateBuffer' must be recorded outside render passes. + CC_ASSERT(!_insideRenderPass); auto *bufferValidator = static_cast(buff); bufferValidator->sanityCheck(data, size); @@ -392,11 +403,13 @@ void CommandBufferValidator::updateBuffer(Buffer *buff, const void *data, uint32 } void CommandBufferValidator::copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) { - CCASSERT(isInited(), "alread destroyed?"); - CCASSERT(texture && static_cast(texture)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(texture && static_cast(texture)->isInited()); - CCASSERT(_type == CommandBufferType::PRIMARY, "Command 'copyBuffersToTexture' must be recorded in primary command buffers."); - CCASSERT(!_insideRenderPass, "Command 'copyBuffersToTexture' must be recorded outside render passes."); + // Command 'copyBuffersToTexture' must be recorded in primary command buffers. + CC_ASSERT(_type == CommandBufferType::PRIMARY); + // Command 'copyBuffersToTexture' must be recorded outside render passes. + CC_ASSERT(!_insideRenderPass); auto *textureValidator = static_cast(texture); textureValidator->sanityCheck(); @@ -407,24 +420,26 @@ void CommandBufferValidator::copyBuffersToTexture(const uint8_t *const *buffers, } void CommandBufferValidator::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) { - CCASSERT(isInited(), "alread destroyed?"); - CCASSERT(srcTexture && static_cast(srcTexture)->isInited(), "already destroyed?"); - CCASSERT(dstTexture && static_cast(dstTexture)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(srcTexture && static_cast(srcTexture)->isInited()); + CC_ASSERT(dstTexture && static_cast(dstTexture)->isInited()); + // Blit on multisampled texture is not allowed. + CC_ASSERT(srcTexture->getInfo().samples == SampleCount::ONE); + // blit on multisampled texture is not allowed. + CC_ASSERT(dstTexture->getInfo().samples == SampleCount::ONE); - CCASSERT(srcTexture->getInfo().samples == SampleCount::ONE, "blit on multisampled texture is not allowed"); - CCASSERT(dstTexture->getInfo().samples == SampleCount::ONE, "blit on multisampled texture is not allowed"); - - CCASSERT(!_insideRenderPass, "Command 'blitTexture' must be recorded outside render passes."); + // Command 'blitTexture' must be recorded outside render passes. + CC_ASSERT(!_insideRenderPass); for (uint32_t i = 0; i < count; ++i) { const auto ®ion = regions[i]; - CCASSERT(region.srcOffset.x + region.srcExtent.width <= srcTexture->getInfo().width, "Invalid src region"); - CCASSERT(region.srcOffset.y + region.srcExtent.height <= srcTexture->getInfo().height, "Invalid src region"); - CCASSERT(region.srcOffset.z + region.srcExtent.depth <= srcTexture->getInfo().depth, "Invalid src region"); + CC_ASSERT(region.srcOffset.x + region.srcExtent.width <= srcTexture->getInfo().width); + CC_ASSERT(region.srcOffset.y + region.srcExtent.height <= srcTexture->getInfo().height); + CC_ASSERT(region.srcOffset.z + region.srcExtent.depth <= srcTexture->getInfo().depth); - CCASSERT(region.dstOffset.x + region.dstExtent.width <= dstTexture->getInfo().width, "Invalid dst region"); - CCASSERT(region.dstOffset.y + region.dstExtent.height <= dstTexture->getInfo().height, "Invalid dst region"); - CCASSERT(region.dstOffset.z + region.dstExtent.depth <= dstTexture->getInfo().depth, "Invalid dst region"); + CC_ASSERT(region.dstOffset.x + region.dstExtent.width <= dstTexture->getInfo().width); + CC_ASSERT(region.dstOffset.y + region.dstExtent.height <= dstTexture->getInfo().height); + CC_ASSERT(region.dstOffset.z + region.dstExtent.depth <= dstTexture->getInfo().depth); } /////////// execute /////////// @@ -438,9 +453,10 @@ void CommandBufferValidator::blitTexture(Texture *srcTexture, Texture *dstTextur } void CommandBufferValidator::dispatch(const DispatchInfo &info) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); - CCASSERT(!_insideRenderPass, "Command 'dispatch' must be recorded outside render passes."); + // Command 'dispatch' must be recorded outside render passes. + CC_ASSERT(!_insideRenderPass); /////////// execute /////////// @@ -451,10 +467,10 @@ void CommandBufferValidator::dispatch(const DispatchInfo &info) { } void CommandBufferValidator::pipelineBarrier(const GeneralBarrier *barrier, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); for (uint32_t i = 0U; i < textureBarrierCount; ++i) { - CCASSERT(textures[i] && static_cast(textures[i])->isInited(), "already destroyed?"); + CC_ASSERT(textures[i] && static_cast(textures[i])->isInited()); } /////////// execute /////////// @@ -474,32 +490,32 @@ void CommandBufferValidator::pipelineBarrier(const GeneralBarrier *barrier, cons } void CommandBufferValidator::beginQuery(QueryPool *queryPool, uint32_t id) { - CCASSERT(isInited(), "already destroyed?"); - CCASSERT(static_cast(queryPool)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(static_cast(queryPool)->isInited()); QueryPool *actorQueryPool = static_cast(queryPool)->getActor(); _actor->beginQuery(actorQueryPool, id); } void CommandBufferValidator::endQuery(QueryPool *queryPool, uint32_t id) { - CCASSERT(isInited(), "already destroyed?"); - CCASSERT(static_cast(queryPool)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(static_cast(queryPool)->isInited()); QueryPool *actorQueryPool = static_cast(queryPool)->getActor(); _actor->endQuery(actorQueryPool, id); } void CommandBufferValidator::resetQueryPool(QueryPool *queryPool) { - CCASSERT(isInited(), "already destroyed?"); - CCASSERT(static_cast(queryPool)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(static_cast(queryPool)->isInited()); QueryPool *actorQueryPool = static_cast(queryPool)->getActor(); _actor->resetQueryPool(actorQueryPool); } void CommandBufferValidator::completeQueryPool(QueryPool *queryPool) { - CCASSERT(isInited(), "already destroyed?"); - CCASSERT(static_cast(queryPool)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(static_cast(queryPool)->isInited()); QueryPool *actorQueryPool = static_cast(queryPool)->getActor(); _actor->completeQueryPool(actorQueryPool); diff --git a/native/cocos/renderer/gfx-validator/DescriptorSetLayoutValidator.cpp b/native/cocos/renderer/gfx-validator/DescriptorSetLayoutValidator.cpp index 175dd47956..ad65a77538 100644 --- a/native/cocos/renderer/gfx-validator/DescriptorSetLayoutValidator.cpp +++ b/native/cocos/renderer/gfx-validator/DescriptorSetLayoutValidator.cpp @@ -45,7 +45,8 @@ DescriptorSetLayoutValidator::~DescriptorSetLayoutValidator() { } void DescriptorSetLayoutValidator::doInit(const DescriptorSetLayoutInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + // Initialize twice? + CC_ASSERT(!isInited()); _inited = true; DescriptorSetLayoutBindingList bindings{info.bindings}; @@ -68,13 +69,13 @@ void DescriptorSetLayoutValidator::doInit(const DescriptorSetLayoutInfo &info) { _typeCounts.resize(DESCRIPTOR_TYPE_ORDERS[utils::getBitPosition(toNumber(DescriptorType::INPUT_ATTACHMENT))] + 1); uint32_t lastType{0}; for (const auto &binding : bindings) { - CCASSERT(binding.binding != INVALID_BINDING, "Invalid binding"); - CCASSERT(binding.descriptorType != DescriptorType::UNKNOWN, "Invalid binding type"); - CCASSERT(math::IsPowerOfTwo(toNumber(binding.descriptorType)), "Invalid binding type"); - CCASSERT(binding.count, "Invalid binding count"); - CCASSERT(binding.stageFlags != ShaderStageFlagBit::NONE, "Invalid binding stage flags"); + CC_ASSERT(binding.binding != INVALID_BINDING); + CC_ASSERT(binding.descriptorType != DescriptorType::UNKNOWN); + CC_ASSERT(math::IsPowerOfTwo(toNumber(binding.descriptorType))); + CC_ASSERT(binding.count); + CC_ASSERT(binding.stageFlags != ShaderStageFlagBit::NONE); for (const Sampler *sampler : binding.immutableSamplers) { - CCASSERT(sampler, "Invalid immutable sampler"); + CC_ASSERT(sampler); } /** * Descriptors should be defined strictly in the following order, @@ -88,7 +89,7 @@ void DescriptorSetLayoutValidator::doInit(const DescriptorSetLayoutInfo &info) { * * SubpassInput */ uint32_t type{DESCRIPTOR_TYPE_ORDERS[utils::getBitPosition(toNumber(binding.descriptorType))]}; - CCASSERT(lastType <= type, "Illegal binding order"); + CC_ASSERT(lastType <= type); lastType = type; ++_typeCounts[type]; } @@ -99,7 +100,7 @@ void DescriptorSetLayoutValidator::doInit(const DescriptorSetLayoutInfo &info) { } void DescriptorSetLayoutValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/DescriptorSetValidator.cpp b/native/cocos/renderer/gfx-validator/DescriptorSetValidator.cpp index 68c8d5a947..9f78674b5e 100644 --- a/native/cocos/renderer/gfx-validator/DescriptorSetValidator.cpp +++ b/native/cocos/renderer/gfx-validator/DescriptorSetValidator.cpp @@ -47,9 +47,9 @@ DescriptorSetValidator::~DescriptorSetValidator() { } void DescriptorSetValidator::doInit(const DescriptorSetInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; - CCASSERT(info.layout && static_cast(info.layout)->isInited(), "already destroyed?"); + CC_ASSERT(info.layout && static_cast(info.layout)->isInited()); /////////// execute /////////// @@ -60,7 +60,8 @@ void DescriptorSetValidator::doInit(const DescriptorSetInfo &info) { } void DescriptorSetValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + // Destroy twice. + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// @@ -69,7 +70,7 @@ void DescriptorSetValidator::doDestroy() { } void DescriptorSetValidator::update() { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); const auto descriptorCount = _textures.size(); @@ -92,8 +93,8 @@ void DescriptorSetValidator::update() { } } - CCASSERT(_referenceStamp < DeviceValidator::getInstance()->currentFrame(), - "DescriptorSet can not be updated after bound to CommandBuffer"); + // DescriptorSet can not be updated after bound to CommandBuffer. + CC_ASSERT(_referenceStamp < DeviceValidator::getInstance()->currentFrame()); /////////// execute /////////// @@ -108,24 +109,25 @@ void DescriptorSetValidator::updateReferenceStamp() { } void DescriptorSetValidator::bindBuffer(uint32_t binding, Buffer *buffer, uint32_t index) { - CCASSERT(isInited(), "alread destroyed?"); - CCASSERT(buffer && static_cast(buffer)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(buffer && static_cast(buffer)->isInited()); const ccstd::vector & bindingIndices = _layout->getBindingIndices(); const DescriptorSetLayoutBindingList &bindings = _layout->getBindings(); - CCASSERT(binding < bindingIndices.size() && bindingIndices[binding] < bindings.size(), "Illegal binding"); + CC_ASSERT(binding < bindingIndices.size() && bindingIndices[binding] < bindings.size()); const DescriptorSetLayoutBinding &info = bindings[bindingIndices[binding]]; - CCASSERT(hasAnyFlags(info.descriptorType, DESCRIPTOR_BUFFER_TYPE), "Setting binding is not DESCRIPTOR_BUFFER_TYPE"); + CC_ASSERT(hasAnyFlags(info.descriptorType, DESCRIPTOR_BUFFER_TYPE)); if (hasAnyFlags(info.descriptorType, DESCRIPTOR_DYNAMIC_TYPE)) { - CCASSERT(buffer->isBufferView(), "Should bind buffer views for dynamic descriptors"); + // Should bind buffer views for dynamic descriptors. + CC_ASSERT(buffer->isBufferView()); } if (hasAnyFlags(info.descriptorType, DescriptorType::UNIFORM_BUFFER | DescriptorType::DYNAMIC_UNIFORM_BUFFER)) { - CCASSERT(hasFlag(buffer->getUsage(), BufferUsageBit::UNIFORM), "Input is not a uniform buffer"); + CC_ASSERT(hasFlag(buffer->getUsage(), BufferUsageBit::UNIFORM)); } else if (hasAnyFlags(info.descriptorType, DescriptorType::STORAGE_BUFFER | DescriptorType::DYNAMIC_STORAGE_BUFFER)) { - CCASSERT(hasFlag(buffer->getUsage(), BufferUsageBit::STORAGE), "Input is not a storage buffer"); + CC_ASSERT(hasFlag(buffer->getUsage(), BufferUsageBit::STORAGE)); } /////////// execute /////////// @@ -136,22 +138,22 @@ void DescriptorSetValidator::bindBuffer(uint32_t binding, Buffer *buffer, uint32 } void DescriptorSetValidator::bindTexture(uint32_t binding, Texture *texture, uint32_t index) { - CCASSERT(isInited(), "alread destroyed?"); - CCASSERT(texture && static_cast(texture)->isInited(), "already destroyed?"); + CC_ASSERT(isInited()); + CC_ASSERT(texture && static_cast(texture)->isInited()); const ccstd::vector & bindingIndices = _layout->getBindingIndices(); const DescriptorSetLayoutBindingList &bindings = _layout->getBindings(); - CCASSERT(binding < bindingIndices.size() && bindingIndices[binding] < bindings.size(), "Illegal binding"); + CC_ASSERT(binding < bindingIndices.size() && bindingIndices[binding] < bindings.size()); const DescriptorSetLayoutBinding &info = bindings[bindingIndices[binding]]; - CCASSERT(hasAnyFlags(info.descriptorType, DESCRIPTOR_TEXTURE_TYPE), "Setting binding is not DESCRIPTOR_TEXTURE_TYPE"); + CC_ASSERT(hasAnyFlags(info.descriptorType, DESCRIPTOR_TEXTURE_TYPE)); if (hasFlag(info.descriptorType, DescriptorType::INPUT_ATTACHMENT)) { - CCASSERT(hasFlag(texture->getInfo().usage, TextureUsageBit::INPUT_ATTACHMENT), "Input is not an input attachment"); + CC_ASSERT(hasFlag(texture->getInfo().usage, TextureUsageBit::INPUT_ATTACHMENT)); } else if (hasFlag(info.descriptorType, DescriptorType::STORAGE_IMAGE)) { - CCASSERT(hasFlag(texture->getInfo().usage, TextureUsageBit::STORAGE), "Input is not a storage image"); + CC_ASSERT(hasFlag(texture->getInfo().usage, TextureUsageBit::STORAGE)); } else { - CCASSERT(hasFlag(texture->getInfo().usage, TextureUsageBit::SAMPLED), "Input is not a sampled texture"); + CC_ASSERT(hasFlag(texture->getInfo().usage, TextureUsageBit::SAMPLED)); } /////////// execute /////////// @@ -162,14 +164,14 @@ void DescriptorSetValidator::bindTexture(uint32_t binding, Texture *texture, uin } void DescriptorSetValidator::bindSampler(uint32_t binding, Sampler *sampler, uint32_t index) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); const ccstd::vector & bindingIndices = _layout->getBindingIndices(); const DescriptorSetLayoutBindingList &bindings = _layout->getBindings(); - CCASSERT(binding < bindingIndices.size() && bindingIndices[binding] < bindings.size(), "Illegal binding"); + CC_ASSERT(binding < bindingIndices.size() && bindingIndices[binding] < bindings.size()); const DescriptorSetLayoutBinding &info = bindings[bindingIndices[binding]]; - CCASSERT(hasAnyFlags(info.descriptorType, DESCRIPTOR_TEXTURE_TYPE), "Setting binding is not DESCRIPTOR_TEXTURE_TYPE"); + CC_ASSERT(hasAnyFlags(info.descriptorType, DESCRIPTOR_TEXTURE_TYPE)); /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/DeviceValidator.cpp b/native/cocos/renderer/gfx-validator/DeviceValidator.cpp index 24c73aed37..f0b521b30b 100644 --- a/native/cocos/renderer/gfx-validator/DeviceValidator.cpp +++ b/native/cocos/renderer/gfx-validator/DeviceValidator.cpp @@ -66,13 +66,13 @@ DeviceValidator::~DeviceValidator() { bool DeviceValidator::doInit(const DeviceInfo &info) { uint32_t flexibleSet{info.bindingMappingInfo.setIndices.back()}; - CCASSERT(!info.bindingMappingInfo.maxBlockCounts[flexibleSet], "flexible set limits should be zero"); - CCASSERT(!info.bindingMappingInfo.maxSamplerTextureCounts[flexibleSet], "flexible set limits should be zero"); - CCASSERT(!info.bindingMappingInfo.maxSamplerCounts[flexibleSet], "flexible set limits should be zero"); - CCASSERT(!info.bindingMappingInfo.maxTextureCounts[flexibleSet], "flexible set limits should be zero"); - CCASSERT(!info.bindingMappingInfo.maxBufferCounts[flexibleSet], "flexible set limits should be zero"); - CCASSERT(!info.bindingMappingInfo.maxImageCounts[flexibleSet], "flexible set limits should be zero"); - CCASSERT(!info.bindingMappingInfo.maxSubpassInputCounts[flexibleSet], "flexible set limits should be zero"); + CC_ASSERT(!info.bindingMappingInfo.maxBlockCounts[flexibleSet]); // Flexible set limits should be zero. + CC_ASSERT(!info.bindingMappingInfo.maxSamplerTextureCounts[flexibleSet]); // Flexible set limits should be zero. + CC_ASSERT(!info.bindingMappingInfo.maxSamplerCounts[flexibleSet]); // Flexible set limits should be zero. + CC_ASSERT(!info.bindingMappingInfo.maxTextureCounts[flexibleSet]); // Flexible set limits should be zero. + CC_ASSERT(!info.bindingMappingInfo.maxBufferCounts[flexibleSet]); // Flexible set limits should be zero. + CC_ASSERT(!info.bindingMappingInfo.maxImageCounts[flexibleSet]); // Flexible set limits should be zero. + CC_ASSERT(!info.bindingMappingInfo.maxSubpassInputCounts[flexibleSet]); // Flexible set limits should be zero. if (!_actor->initialize(info)) { return false; @@ -269,10 +269,12 @@ Sampler *DeviceValidator::getSampler(const SamplerInfo &info) { GeneralBarrier *DeviceValidator::getGeneralBarrier(const GeneralBarrierInfo &info) { if (info.prevAccesses > AccessFlagBit::PRESENT) { - CCASSERT(math::IsPowerOfTwo(toNumber(info.prevAccesses)), "Write access should appear on its own"); + // Write access should appear on its own. + CC_ASSERT(math::IsPowerOfTwo(toNumber(info.prevAccesses))); } if (info.nextAccesses > AccessFlagBit::PRESENT) { - CCASSERT(math::IsPowerOfTwo(toNumber(info.nextAccesses)), "Write access should appear on its own"); + // Write access should appear on its own. + CC_ASSERT(math::IsPowerOfTwo(toNumber(info.nextAccesses))); } /////////// execute /////////// @@ -282,10 +284,12 @@ GeneralBarrier *DeviceValidator::getGeneralBarrier(const GeneralBarrierInfo &inf TextureBarrier *DeviceValidator::getTextureBarrier(const TextureBarrierInfo &info) { if (info.prevAccesses > AccessFlagBit::PRESENT) { - CCASSERT(math::IsPowerOfTwo(toNumber(info.prevAccesses)), "Write access should appear on its own"); + // Write access should appear on its own. + CC_ASSERT(math::IsPowerOfTwo(toNumber(info.prevAccesses))); } if (info.nextAccesses > AccessFlagBit::PRESENT) { - CCASSERT(math::IsPowerOfTwo(toNumber(info.nextAccesses)), "Write access should appear on its own"); + // Write access should appear on its own. + CC_ASSERT(math::IsPowerOfTwo(toNumber(info.nextAccesses))); } /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/FramebufferValidator.cpp b/native/cocos/renderer/gfx-validator/FramebufferValidator.cpp index 55f08754f1..5eb1f7a9e3 100644 --- a/native/cocos/renderer/gfx-validator/FramebufferValidator.cpp +++ b/native/cocos/renderer/gfx-validator/FramebufferValidator.cpp @@ -46,27 +46,27 @@ FramebufferValidator::~FramebufferValidator() { } void FramebufferValidator::doInit(const FramebufferInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; - CCASSERT(info.renderPass && static_cast(info.renderPass)->isInited(), "already destroyed?"); - CCASSERT(!info.colorTextures.empty() || info.depthStencilTexture, "no attachments?"); - CCASSERT(info.colorTextures.size() == info.renderPass->getColorAttachments().size(), "attachment count mismatch"); + CC_ASSERT(info.renderPass && static_cast(info.renderPass)->isInited()); + CC_ASSERT(!info.colorTextures.empty() || info.depthStencilTexture); + CC_ASSERT(info.colorTextures.size() == info.renderPass->getColorAttachments().size()); if (info.renderPass->getDepthStencilAttachment().format != Format::UNKNOWN) { - CCASSERT(info.depthStencilTexture, "missing depth stencil attachment"); + CC_ASSERT(info.depthStencilTexture); } for (uint32_t i = 0U; i < info.colorTextures.size(); ++i) { const auto &desc = info.renderPass->getColorAttachments()[i]; const auto *tex = info.colorTextures[i]; - CCASSERT(tex && static_cast(tex)->isInited(), "already destroyed?"); - CCASSERT(hasAnyFlags(tex->getInfo().usage, TextureUsageBit::COLOR_ATTACHMENT | TextureUsageBit::DEPTH_STENCIL_ATTACHMENT), "Input is not an attachment"); - CCASSERT(tex->getFormat() == desc.format, "attachment format mismatch"); + CC_ASSERT(tex && static_cast(tex)->isInited()); + CC_ASSERT(hasAnyFlags(tex->getInfo().usage, TextureUsageBit::COLOR_ATTACHMENT | TextureUsageBit::DEPTH_STENCIL_ATTACHMENT)); + CC_ASSERT(tex->getFormat() == desc.format); } if (info.depthStencilTexture) { - CCASSERT(static_cast(info.depthStencilTexture)->isInited(), "already destroyed?"); - CCASSERT(hasFlag(info.depthStencilTexture->getInfo().usage, TextureUsageBit::DEPTH_STENCIL_ATTACHMENT), "Input is not a depth stencil attachment"); - CCASSERT(info.depthStencilTexture->getFormat() == info.renderPass->getDepthStencilAttachment().format, "attachment format mismatch"); + CC_ASSERT(static_cast(info.depthStencilTexture)->isInited()); + CC_ASSERT(hasFlag(info.depthStencilTexture->getInfo().usage, TextureUsageBit::DEPTH_STENCIL_ATTACHMENT)); + CC_ASSERT(info.depthStencilTexture->getFormat() == info.renderPass->getDepthStencilAttachment().format); } /////////// execute /////////// @@ -86,7 +86,8 @@ void FramebufferValidator::doInit(const FramebufferInfo &info) { } void FramebufferValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + // Destroy twice? + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/InputAssemblerValidator.cpp b/native/cocos/renderer/gfx-validator/InputAssemblerValidator.cpp index f0db607d58..7b9cbdbc5d 100644 --- a/native/cocos/renderer/gfx-validator/InputAssemblerValidator.cpp +++ b/native/cocos/renderer/gfx-validator/InputAssemblerValidator.cpp @@ -44,25 +44,26 @@ InputAssemblerValidator::~InputAssemblerValidator() { } void InputAssemblerValidator::doInit(const InputAssemblerInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; // vertex attributes validations for (auto const &attribute : info.attributes) { - CCASSERT(hasFlag(DeviceValidator::getInstance()->getFormatFeatures(attribute.format), FormatFeature::VERTEX_ATTRIBUTE), "Format not supported for the specified features"); + // Format not supported for the specified features. + CC_ASSERT(hasFlag(DeviceValidator::getInstance()->getFormatFeatures(attribute.format), FormatFeature::VERTEX_ATTRIBUTE)); } for (auto *vertexBuffer : info.vertexBuffers) { - CCASSERT(vertexBuffer && static_cast(vertexBuffer)->isInited(), "already destroyed?"); - CCASSERT(hasFlag(vertexBuffer->getUsage(), BufferUsageBit::VERTEX), "Input is not a vertex buffer"); + CC_ASSERT(vertexBuffer && static_cast(vertexBuffer)->isInited()); + CC_ASSERT(hasFlag(vertexBuffer->getUsage(), BufferUsageBit::VERTEX)); } if (info.indexBuffer) { - CCASSERT(static_cast(info.indexBuffer)->isInited(), "already destroyed?"); - CCASSERT(hasFlag(info.indexBuffer->getUsage(), BufferUsageBit::INDEX), "Input is not an index buffer"); + CC_ASSERT(static_cast(info.indexBuffer)->isInited()); + CC_ASSERT(hasFlag(info.indexBuffer->getUsage(), BufferUsageBit::INDEX)); } if (info.indirectBuffer) { - CCASSERT(static_cast(info.indirectBuffer)->isInited(), "already destroyed?"); - CCASSERT(hasFlag(info.indirectBuffer->getUsage(), BufferUsageBit::INDIRECT), "Input is not an indirect buffer"); + CC_ASSERT(static_cast(info.indirectBuffer)->isInited()); + CC_ASSERT(hasFlag(info.indirectBuffer->getUsage(), BufferUsageBit::INDIRECT)); } /////////// execute /////////// @@ -82,7 +83,7 @@ void InputAssemblerValidator::doInit(const InputAssemblerInfo &info) { } void InputAssemblerValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/PipelineLayoutValidator.cpp b/native/cocos/renderer/gfx-validator/PipelineLayoutValidator.cpp index 8c87dd8fa3..5764015867 100644 --- a/native/cocos/renderer/gfx-validator/PipelineLayoutValidator.cpp +++ b/native/cocos/renderer/gfx-validator/PipelineLayoutValidator.cpp @@ -45,22 +45,22 @@ PipelineLayoutValidator::~PipelineLayoutValidator() { } void PipelineLayoutValidator::doInit(const PipelineLayoutInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; const auto &bindingMappings{DeviceValidator::getInstance()->bindingMappingInfo()}; for (uint32_t i = 0; i < info.setLayouts.size(); ++i) { auto *layout{static_cast(info.setLayouts[i])}; - CCASSERT(layout && layout->isInited(), "already destroyed?"); + CC_ASSERT(layout && layout->isInited()); // check against limits specified in BindingMappingInfo if (bindingMappings.setIndices.back() == i) continue; // flexible set - CCASSERT(layout->_typeCounts[0] <= bindingMappings.maxBlockCounts[i], "Exceeds descriptor type limit"); - CCASSERT(layout->_typeCounts[1] <= bindingMappings.maxSamplerTextureCounts[i], "Exceeds descriptor type limit"); - CCASSERT(layout->_typeCounts[2] <= bindingMappings.maxSamplerCounts[i], "Exceeds descriptor type limit"); - CCASSERT(layout->_typeCounts[3] <= bindingMappings.maxTextureCounts[i], "Exceeds descriptor type limit"); - CCASSERT(layout->_typeCounts[4] <= bindingMappings.maxBufferCounts[i], "Exceeds descriptor type limit"); - CCASSERT(layout->_typeCounts[5] <= bindingMappings.maxImageCounts[i], "Exceeds descriptor type limit"); - CCASSERT(layout->_typeCounts[6] <= bindingMappings.maxSubpassInputCounts[i], "Exceeds descriptor type limit"); + CC_ASSERT(layout->_typeCounts[0] <= bindingMappings.maxBlockCounts[i]); + CC_ASSERT(layout->_typeCounts[1] <= bindingMappings.maxSamplerTextureCounts[i]); + CC_ASSERT(layout->_typeCounts[2] <= bindingMappings.maxSamplerCounts[i]); + CC_ASSERT(layout->_typeCounts[3] <= bindingMappings.maxTextureCounts[i]); + CC_ASSERT(layout->_typeCounts[4] <= bindingMappings.maxBufferCounts[i]); + CC_ASSERT(layout->_typeCounts[5] <= bindingMappings.maxImageCounts[i]); + CC_ASSERT(layout->_typeCounts[6] <= bindingMappings.maxSubpassInputCounts[i]); } /////////// execute /////////// @@ -75,7 +75,7 @@ void PipelineLayoutValidator::doInit(const PipelineLayoutInfo &info) { } void PipelineLayoutValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/PipelineStateValidator.cpp b/native/cocos/renderer/gfx-validator/PipelineStateValidator.cpp index 5b2f7ff438..4d558f2047 100644 --- a/native/cocos/renderer/gfx-validator/PipelineStateValidator.cpp +++ b/native/cocos/renderer/gfx-validator/PipelineStateValidator.cpp @@ -46,11 +46,11 @@ PipelineStateValidator::~PipelineStateValidator() { } void PipelineStateValidator::doInit(const PipelineStateInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; - CCASSERT(info.shader && static_cast(info.shader)->isInited(), "already destroyed?"); - CCASSERT(info.pipelineLayout && static_cast(info.pipelineLayout)->isInited(), "already destroyed?"); - CCASSERT(!info.renderPass || static_cast(info.renderPass)->isInited(), "already destroyed?"); + CC_ASSERT(info.shader && static_cast(info.shader)->isInited()); + CC_ASSERT(info.pipelineLayout && static_cast(info.pipelineLayout)->isInited()); + CC_ASSERT(!info.renderPass || static_cast(info.renderPass)->isInited()); /////////// execute /////////// @@ -63,7 +63,7 @@ void PipelineStateValidator::doInit(const PipelineStateInfo &info) { } void PipelineStateValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/QueryPoolValidator.cpp b/native/cocos/renderer/gfx-validator/QueryPoolValidator.cpp index 508f9eb245..69c437aabb 100644 --- a/native/cocos/renderer/gfx-validator/QueryPoolValidator.cpp +++ b/native/cocos/renderer/gfx-validator/QueryPoolValidator.cpp @@ -44,7 +44,7 @@ QueryPoolValidator::~QueryPoolValidator() { } void QueryPoolValidator::doInit(const QueryPoolInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; /////////// execute /////////// @@ -53,7 +53,7 @@ void QueryPoolValidator::doInit(const QueryPoolInfo &info) { } void QueryPoolValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/QueueValidator.cpp b/native/cocos/renderer/gfx-validator/QueueValidator.cpp index 8fe6c5eff5..f01089ea4c 100644 --- a/native/cocos/renderer/gfx-validator/QueueValidator.cpp +++ b/native/cocos/renderer/gfx-validator/QueueValidator.cpp @@ -42,7 +42,7 @@ QueueValidator::~QueueValidator() { } void QueueValidator::doInit(const QueueInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; /////////// execute /////////// @@ -51,7 +51,7 @@ void QueueValidator::doInit(const QueueInfo &info) { } void QueueValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// @@ -60,13 +60,14 @@ void QueueValidator::doDestroy() { } void QueueValidator::submit(CommandBuffer *const *cmdBuffs, uint32_t count) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); if (!count) return; for (uint32_t i = 0U; i < count; ++i) { auto *cmdBuff = static_cast(cmdBuffs[i]); - CCASSERT(cmdBuff && cmdBuff->isInited(), "alread destroyed?"); - CCASSERT(cmdBuff->isCommandsFlushed(), "command buffers must be flushed before submit"); + CC_ASSERT(cmdBuff && cmdBuff->isInited()); + // Command buffers must be flushed before submit. + CC_ASSERT(cmdBuff->isCommandsFlushed()); } /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/RenderPassValidator.cpp b/native/cocos/renderer/gfx-validator/RenderPassValidator.cpp index 0eddaed770..718967e576 100644 --- a/native/cocos/renderer/gfx-validator/RenderPassValidator.cpp +++ b/native/cocos/renderer/gfx-validator/RenderPassValidator.cpp @@ -43,24 +43,25 @@ RenderPassValidator::~RenderPassValidator() { } void RenderPassValidator::doInit(const RenderPassInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; bool hasDepth = info.depthStencilAttachment.format != Format::UNKNOWN; if (!hasDepth) { for (const auto &subpass : info.subpasses) { - CCASSERT(subpass.depthStencil == INVALID_BINDING || subpass.depthStencil < info.colorAttachments.size(), - "Invalid depth stencil attachment index"); + CC_ASSERT(subpass.depthStencil == INVALID_BINDING || subpass.depthStencil < info.colorAttachments.size()); } } for (auto &attachment : _colorAttachments) { if (attachment.loadOp == LoadOp::LOAD && attachment.barrier->getInfo().prevAccesses == AccessFlagBit::NONE) { - CCASSERT(false, "Attachment missing beginAccesses for LoadOp::LOAD"); + // Attachment missing beginAccesses for LoadOp::LOAD. + CC_ASSERT(false); } } if ((_depthStencilAttachment.depthLoadOp == LoadOp::LOAD || _depthStencilAttachment.stencilLoadOp == LoadOp::LOAD) && _depthStencilAttachment.barrier->getInfo().prevAccesses == AccessFlagBit::NONE) { - CCASSERT(false, "Attachment missing beginAccesses for LoadOp::LOAD"); + // Attachment missing beginAccesses for LoadOp::LOAD. + CC_ASSERT(false); } /////////// execute /////////// @@ -69,7 +70,7 @@ void RenderPassValidator::doInit(const RenderPassInfo &info) { } void RenderPassValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/ShaderValidator.cpp b/native/cocos/renderer/gfx-validator/ShaderValidator.cpp index a2eb2f1255..f7c0db8d4e 100644 --- a/native/cocos/renderer/gfx-validator/ShaderValidator.cpp +++ b/native/cocos/renderer/gfx-validator/ShaderValidator.cpp @@ -43,7 +43,7 @@ ShaderValidator::~ShaderValidator() { } void ShaderValidator::doInit(const ShaderInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; /////////// execute /////////// @@ -52,7 +52,7 @@ void ShaderValidator::doInit(const ShaderInfo &info) { } void ShaderValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// diff --git a/native/cocos/renderer/gfx-validator/SwapchainValidator.cpp b/native/cocos/renderer/gfx-validator/SwapchainValidator.cpp index a8660600fe..777829c4c8 100644 --- a/native/cocos/renderer/gfx-validator/SwapchainValidator.cpp +++ b/native/cocos/renderer/gfx-validator/SwapchainValidator.cpp @@ -44,7 +44,7 @@ SwapchainValidator::~SwapchainValidator() { } void SwapchainValidator::doInit(const SwapchainInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; /////////// execute /////////// @@ -75,7 +75,7 @@ void SwapchainValidator::doInit(const SwapchainInfo &info) { } void SwapchainValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// @@ -86,7 +86,7 @@ void SwapchainValidator::doDestroy() { } void SwapchainValidator::doResize(uint32_t width, uint32_t height, SurfaceTransform transform) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); _actor->resize(width, height, transform); @@ -98,13 +98,13 @@ void SwapchainValidator::doResize(uint32_t width, uint32_t height, SurfaceTransf } void SwapchainValidator::doDestroySurface() { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); _actor->destroySurface(); } void SwapchainValidator::doCreateSurface(void *windowHandle) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); _actor->createSurface(windowHandle); } diff --git a/native/cocos/renderer/gfx-validator/TextureValidator.cpp b/native/cocos/renderer/gfx-validator/TextureValidator.cpp index ba439b7203..d632e2d487 100644 --- a/native/cocos/renderer/gfx-validator/TextureValidator.cpp +++ b/native/cocos/renderer/gfx-validator/TextureValidator.cpp @@ -54,24 +54,24 @@ TextureValidator::~TextureValidator() { } void TextureValidator::doInit(const TextureInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; - CCASSERT(info.width && info.height && info.depth, "zero-sized texture?"); + CC_ASSERT(info.width && info.height && info.depth); FormatFeature ff = FormatFeature::NONE; if (hasAnyFlags(info.usage, TextureUsageBit::COLOR_ATTACHMENT | TextureUsageBit::DEPTH_STENCIL_ATTACHMENT)) ff |= FormatFeature::RENDER_TARGET; if (hasAnyFlags(info.usage, TextureUsageBit::SAMPLED)) ff |= FormatFeature::SAMPLED_TEXTURE; if (hasAnyFlags(info.usage, TextureUsageBit::STORAGE)) ff |= FormatFeature::STORAGE_TEXTURE; if (ff != FormatFeature::NONE) { - CCASSERT(hasAllFlags(DeviceValidator::getInstance()->getFormatFeatures(info.format), ff), "Format not supported for the specified features"); + CC_ASSERT(hasAllFlags(DeviceValidator::getInstance()->getFormatFeatures(info.format), ff)); } if (hasFlag(info.flags, TextureFlagBit::GEN_MIPMAP)) { - CCASSERT(info.levelCount > 1, "Generating mipmaps with level count 1?"); + CC_ASSERT(info.levelCount > 1); bool isCompressed = GFX_FORMAT_INFOS[static_cast(info.format)].isCompressed; - CCASSERT(!isCompressed, "Generating mipmaps for compressed image?"); + CC_ASSERT(!isCompressed); } /////////// execute /////////// @@ -80,10 +80,10 @@ void TextureValidator::doInit(const TextureInfo &info) { } void TextureValidator::doInit(const TextureViewInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; _isTextureView = true; - CCASSERT(info.texture && static_cast(info.texture)->isInited(), "alread destroyed?"); + CC_ASSERT(info.texture && static_cast(info.texture)->isInited()); /////////// execute /////////// @@ -94,16 +94,16 @@ void TextureValidator::doInit(const TextureViewInfo &info) { } void TextureValidator::doInit(const SwapchainTextureInfo &info) { - CCASSERT(!isInited(), "initializing twice?"); + CC_ASSERT(!isInited()); _inited = true; CC_UNUSED_PARAM(info); // workaround tidy issue - CCASSERT(info.swapchain && static_cast(info.swapchain)->isInited(), "alread destroyed?"); + CC_ASSERT(info.swapchain && static_cast(info.swapchain)->isInited()); // the actor is already initialized } void TextureValidator::doDestroy() { - CCASSERT(isInited(), "destroying twice?"); + CC_ASSERT(isInited()); _inited = false; /////////// execute /////////// @@ -112,9 +112,10 @@ void TextureValidator::doDestroy() { } void TextureValidator::doResize(uint32_t width, uint32_t height, uint32_t /*size*/) { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); - CCASSERT(!_isTextureView, "Cannot resize texture views"); + // Cannot resize texture views. + CC_ASSERT(!_isTextureView); /////////// execute /////////// @@ -122,7 +123,7 @@ void TextureValidator::doResize(uint32_t width, uint32_t height, uint32_t /*size } void TextureValidator::sanityCheck() { - CCASSERT(isInited(), "alread destroyed?"); + CC_ASSERT(isInited()); uint64_t cur = DeviceValidator::getInstance()->currentFrame(); diff --git a/native/cocos/renderer/gfx-validator/ValidationUtils.h b/native/cocos/renderer/gfx-validator/ValidationUtils.h index 05701b264d..a0f0bbd9c4 100644 --- a/native/cocos/renderer/gfx-validator/ValidationUtils.h +++ b/native/cocos/renderer/gfx-validator/ValidationUtils.h @@ -157,7 +157,7 @@ DeviceResourceTracker::push(T *resource) { template void DeviceResourceTracker::erase(Resource *resource) { - CCASSERT(!resources.empty(), "Deleted twice?"); + CC_ASSERT(!resources.empty()); resources.erase(std::remove_if(resources.begin(), resources.end(), [resource](const auto &record) { return record.resource == resource; })); @@ -170,7 +170,7 @@ void DeviceResourceTracker::checkEmpty() { // and look up the resource initialization stacktrace in `resources[i].initStack`. // Note: capturing stacktrace is a painfully time-consuming process, // so better to uncomment the exact type of resource that is leaking rather than toggle them all at once. - CCASSERT(resources.empty(), "Resource leaked"); + CC_ASSERT(resources.empty()); // Resource leaked. } //template <> struct RecordStacktrace : std::true_type {}; diff --git a/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.cpp b/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.cpp index a21849cc19..5fc1723ab9 100644 --- a/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.cpp @@ -215,7 +215,7 @@ void CCVKCommandBuffer::bindPipelineState(PipelineState *pso) { } void CCVKCommandBuffer::bindDescriptorSet(uint32_t set, DescriptorSet *descriptorSet, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets) { - CCASSERT(_curGPUDescriptorSets.size() > set, "Invalid set index"); + CC_ASSERT(_curGPUDescriptorSets.size() > set); CCVKGPUDescriptorSet *gpuDescriptorSet = static_cast(descriptorSet)->gpuDescriptorSet(); @@ -575,7 +575,7 @@ void CCVKCommandBuffer::bindDescriptorSets(VkPipelineBindPoint bindPoint) { _curVkDescriptorSets[i] = pipelineLayout->setLayouts[i]->defaultDescriptorSet; } uint32_t count = dynamicOffsetOffsets[i + 1] - dynamicOffsetOffsets[i]; - //CCASSERT(_curDynamicOffsetCounts[i] >= count, "missing dynamic offsets?"); + // CC_ASSERT(_curDynamicOffsetCounts[i] >= count); count = std::min(count, utils::toUint(_curDynamicOffsetsArray[i].size())); if (count > 0) memcpy(&_curDynamicOffsets[dynamicOffsetOffsets[i]], _curDynamicOffsetsArray[i].data(), count * sizeof(uint32_t)); } diff --git a/native/cocos/renderer/gfx-vulkan/VKCommands.cpp b/native/cocos/renderer/gfx-vulkan/VKCommands.cpp index e7db4843c2..03fda93cfe 100644 --- a/native/cocos/renderer/gfx-vulkan/VKCommands.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKCommands.cpp @@ -72,7 +72,7 @@ void insertVkDynamicStates(ccstd::vector *out, const ccstd::vect out->push_back(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); break; default: { - CCASSERT(false, "Unsupported DynamicStateFlagBit, convert to VkDynamicState failed."); + CC_ASSERT(false); break; } } diff --git a/native/cocos/renderer/gfx-vulkan/VKDevice.cpp b/native/cocos/renderer/gfx-vulkan/VKDevice.cpp index 2434e24a04..057680f18f 100644 --- a/native/cocos/renderer/gfx-vulkan/VKDevice.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKDevice.cpp @@ -540,8 +540,8 @@ void CCVKDevice::doDestroy() { VmaStats stats; vmaCalculateStats(_gpuDevice->memoryAllocator, &stats); CC_LOG_INFO("Total device memory leaked: %d bytes.", stats.total.usedBytes); - CCASSERT(!_memoryStatus.bufferSize, "Buffer memory leaked"); - CCASSERT(!_memoryStatus.textureSize, "Texture memory leaked"); + CC_ASSERT(!_memoryStatus.bufferSize); // Buffer memory leaked. + CC_ASSERT(!_memoryStatus.textureSize); // Texture memory leaked. vmaDestroyAllocator(_gpuDevice->memoryAllocator); _gpuDevice->memoryAllocator = VK_NULL_HANDLE; @@ -626,7 +626,7 @@ void CCVKDevice::acquire(Swapchain *const *swapchains, uint32_t count) { VkSemaphore acquireSemaphore = _gpuSemaphorePool->alloc(); VkResult res = vkAcquireNextImageKHR(_gpuDevice->vkDevice, vkSwapchains[i], ~0ULL, acquireSemaphore, VK_NULL_HANDLE, &vkSwapchainIndices[i]); - CCASSERT(res == VK_SUCCESS || res == VK_SUBOPTIMAL_KHR, "acquire surface failed"); + CC_ASSERT(res == VK_SUCCESS || res == VK_SUBOPTIMAL_KHR); gpuSwapchains[i]->curImageIndex = vkSwapchainIndices[i]; queue->gpuQueue()->lastSignaledSemaphores.push_back(acquireSemaphore); @@ -885,7 +885,7 @@ void CCVKDevice::getQueryPoolResults(QueryPool *queryPool) { CC_PROFILE(CCVKDeviceGetQueryPoolResults); auto *vkQueryPool = static_cast(queryPool); auto queryCount = static_cast(vkQueryPool->_ids.size()); - CCASSERT(queryCount <= vkQueryPool->getMaxQueryObjects(), "Too many query commands."); + CC_ASSERT(queryCount <= vkQueryPool->getMaxQueryObjects()); const bool bWait = queryPool->getForceWait(); uint32_t width = bWait ? 1U : 2U; @@ -903,7 +903,7 @@ void CCVKDevice::getQueryPoolResults(QueryPool *queryPool) { results.data(), stride, VK_QUERY_RESULT_64_BIT | flag); - CCASSERT(result == VK_SUCCESS || result == VK_NOT_READY, "Unexpected error code."); + CC_ASSERT(result == VK_SUCCESS || result == VK_NOT_READY); } ccstd::unordered_map mapResults; diff --git a/native/cocos/renderer/gfx-vulkan/VKGPUContext.cpp b/native/cocos/renderer/gfx-vulkan/VKGPUContext.cpp index e1e6cb67ed..1cf9e20b26 100644 --- a/native/cocos/renderer/gfx-vulkan/VKGPUContext.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKGPUContext.cpp @@ -43,7 +43,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL debugUtilsMessengerCallback(VkDebugUtilsMessageSe void * /*userData*/) { if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { CC_LOG_ERROR("%s: %s", callbackData->pMessageIdName, callbackData->pMessage); - CCASSERT(DISABLE_VALIDATION_ASSERTIONS, "Validation Error"); + CC_ASSERT(DISABLE_VALIDATION_ASSERTIONS); return VK_FALSE; } if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) { @@ -72,7 +72,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL debugReportCallback(VkDebugReportFlagsEXT flags, void * /*userData*/) { if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) { CC_LOG_ERROR("%s: %s", layerPrefix, message); - CCASSERT(DISABLE_VALIDATION_ASSERTIONS, "Validation Error"); + CC_ASSERT(DISABLE_VALIDATION_ASSERTIONS); return VK_FALSE; } if (flags & (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT)) { diff --git a/native/cocos/renderer/gfx-vulkan/VKGPUObjects.h b/native/cocos/renderer/gfx-vulkan/VKGPUObjects.h index 83007ccde7..0648f4efe9 100644 --- a/native/cocos/renderer/gfx-vulkan/VKGPUObjects.h +++ b/native/cocos/renderer/gfx-vulkan/VKGPUObjects.h @@ -597,7 +597,7 @@ public: break; } } - CCASSERT(found, "wrong descriptor set layout to yield?"); + CC_ASSERT(found); // Wrong descriptor set layout to yield? _fleaMarkets[backBufferIndex].push_back(set); } @@ -695,7 +695,7 @@ public: void yield(CCVKGPUCommandBuffer *gpuCommandBuffer) { if (gpuCommandBuffer->vkCommandBuffer) { uint32_t hash = getHash(gpuCommandBuffer->queueFamilyIndex); - CCASSERT(_pools.count(hash), "wrong command pool to yield?"); + CC_ASSERT(_pools.count(hash)); // Wrong command pool to yield? CommandBufferPool &pool = _pools[hash]; pool.usedCommandBuffers[gpuCommandBuffer->level].push(gpuCommandBuffer->vkCommandBuffer); @@ -758,7 +758,7 @@ public: void alloc(CCVKGPUBuffer *gpuBuffer) { alloc(gpuBuffer, 1U); } void alloc(CCVKGPUBuffer *gpuBuffer, uint32_t alignment) { - CCASSERT(gpuBuffer->size <= CHUNK_SIZE, "required size exceeds single chunk size"); + CC_ASSERT(gpuBuffer->size <= CHUNK_SIZE); size_t bufferCount = _pool.size(); Buffer * buffer = nullptr; diff --git a/native/cocos/renderer/gfx-vulkan/VKStd.h b/native/cocos/renderer/gfx-vulkan/VKStd.h index 0762035e73..c294f21334 100644 --- a/native/cocos/renderer/gfx-vulkan/VKStd.h +++ b/native/cocos/renderer/gfx-vulkan/VKStd.h @@ -47,7 +47,7 @@ VkResult err = x; \ if (err) { \ CC_LOG_ERROR("%s returned Vulkan error: %d", #x, err); \ - CCASSERT(false, "Vulkan Error"); \ + CC_ASSERT(false); \ } \ } while (0) diff --git a/native/cocos/renderer/gfx-vulkan/VKSwapchain.cpp b/native/cocos/renderer/gfx-vulkan/VKSwapchain.cpp index c10320d08a..d4b8129001 100644 --- a/native/cocos/renderer/gfx-vulkan/VKSwapchain.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKSwapchain.cpp @@ -75,7 +75,7 @@ void CCVKSwapchain::doInit(const SwapchainInfo &info) { return !_gpuSwapchain->queueFamilyPresentables[i]; }), indices.end()); - CCASSERT(!_gpuSwapchain->queueFamilyPresentables.empty(), "no presentable queue found!"); + CC_ASSERT(!_gpuSwapchain->queueFamilyPresentables.empty()); cmdFuncCCVKGetDeviceQueue(CCVKDevice::getInstance(), queue->gpuQueue()); } @@ -124,7 +124,7 @@ void CCVKSwapchain::doInit(const SwapchainInfo &info) { case VK_FORMAT_R8G8B8A8_UNORM: colorFmt = Format::RGBA8; break; case VK_FORMAT_R8G8B8A8_SRGB: colorFmt = Format::SRGB8_A8; break; case VK_FORMAT_R5G6B5_UNORM_PACK16: colorFmt = Format::R5G6B5; break; - default: CCASSERT(0, "assumption broken: new default surface format"); break; + default: CC_ASSERT(false); break; } } } diff --git a/native/cocos/renderer/gfx-vulkan/VKUtils.cpp b/native/cocos/renderer/gfx-vulkan/VKUtils.cpp index 6465f5f0f9..595aff2bda 100644 --- a/native/cocos/renderer/gfx-vulkan/VKUtils.cpp +++ b/native/cocos/renderer/gfx-vulkan/VKUtils.cpp @@ -35,7 +35,7 @@ VkQueryType mapVkQueryType(QueryType type) { case QueryType::PIPELINE_STATISTICS: return VK_QUERY_TYPE_PIPELINE_STATISTICS; case QueryType::TIMESTAMP: return VK_QUERY_TYPE_TIMESTAMP; default: { - CCASSERT(false, "Unsupported query type, convert to VkQueryType failed."); + CC_ASSERT(false); return VK_QUERY_TYPE_OCCLUSION; } } @@ -163,7 +163,7 @@ VkFormat mapVkFormat(Format format, const CCVKGPUDevice *gpuDevice) { case Format::ASTC_SRGBA_12X12: return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; default: { - CCASSERT(false, "Unsupported Format, convert to VkFormat failed."); + CC_ASSERT(false); return VK_FORMAT_B8G8R8A8_UNORM; } } @@ -175,7 +175,7 @@ VkAttachmentLoadOp mapVkLoadOp(LoadOp loadOp) { case LoadOp::LOAD: return VK_ATTACHMENT_LOAD_OP_LOAD; case LoadOp::DISCARD: return VK_ATTACHMENT_LOAD_OP_DONT_CARE; default: { - CCASSERT(false, "Unsupported LoadOp, convert to VkLoadOp failed."); + CC_ASSERT(false); return VK_ATTACHMENT_LOAD_OP_LOAD; } } @@ -186,7 +186,7 @@ VkAttachmentStoreOp mapVkStoreOp(StoreOp storeOp) { case StoreOp::STORE: return VK_ATTACHMENT_STORE_OP_STORE; case StoreOp::DISCARD: return VK_ATTACHMENT_STORE_OP_DONT_CARE; default: { - CCASSERT(false, "Unsupported StoreOp, convert to VkStoreOp failed."); + CC_ASSERT(false); return VK_ATTACHMENT_STORE_OP_STORE; } } @@ -213,7 +213,7 @@ VkImageType mapVkImageType(TextureType type) { case TextureType::TEX2D_ARRAY: return VK_IMAGE_TYPE_2D; case TextureType::TEX3D: return VK_IMAGE_TYPE_3D; default: { - CCASSERT(false, "Unsupported TextureType, convert to VkImageType failed."); + CC_ASSERT(false); return VK_IMAGE_TYPE_2D; } } @@ -269,7 +269,7 @@ VkImageViewType mapVkImageViewType(TextureType viewType) { case TextureType::TEX3D: return VK_IMAGE_VIEW_TYPE_3D; case TextureType::CUBE: return VK_IMAGE_VIEW_TYPE_CUBE; default: { - CCASSERT(false, "Unsupported TextureViewType, convert to VkImageViewType failed."); + CC_ASSERT(false); return VK_IMAGE_VIEW_TYPE_2D; } } @@ -280,7 +280,7 @@ VkCommandBufferLevel mapVkCommandBufferLevel(CommandBufferType type) { case CommandBufferType::PRIMARY: return VK_COMMAND_BUFFER_LEVEL_PRIMARY; case CommandBufferType::SECONDARY: return VK_COMMAND_BUFFER_LEVEL_SECONDARY; default: { - CCASSERT(false, "Unsupported CommandBufferType, convert to VkCommandBufferLevel failed."); + CC_ASSERT(false); return VK_COMMAND_BUFFER_LEVEL_SECONDARY; } } @@ -298,7 +298,7 @@ VkDescriptorType mapVkDescriptorType(DescriptorType type) { case DescriptorType::STORAGE_IMAGE: return VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; case DescriptorType::INPUT_ATTACHMENT: return VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; default: { - CCASSERT(false, "Unsupported DescriptorType, convert to VkDescriptorType failed."); + CC_ASSERT(false); return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; } } @@ -322,7 +322,7 @@ VkShaderStageFlagBits mapVkShaderStageFlagBits(ShaderStageFlagBit stage) { case ShaderStageFlagBit::FRAGMENT: return VK_SHADER_STAGE_FRAGMENT_BIT; case ShaderStageFlagBit::COMPUTE: return VK_SHADER_STAGE_COMPUTE_BIT; default: { - CCASSERT(false, "Unsupported ShaderStageFlagBit, convert to VkShaderStageFlagBits failed."); + CC_ASSERT(false); return VK_SHADER_STAGE_VERTEX_BIT; } } diff --git a/native/cocos/renderer/pipeline/ClusterLightCulling.cpp b/native/cocos/renderer/pipeline/ClusterLightCulling.cpp index 2ea6c2e5a7..21d13e01c0 100644 --- a/native/cocos/renderer/pipeline/ClusterLightCulling.cpp +++ b/native/cocos/renderer/pipeline/ClusterLightCulling.cpp @@ -82,7 +82,7 @@ void ClusterLightCulling::initialize(gfx::Device *dev) { } else { clusterZThreads = 1; } - CCASSERT(CLUSTERS_X_THREADS * CLUSTERS_Y_THREADS * clusterZThreads <= maxInvocations, "maxInvocations is too small"); + CC_ASSERT(CLUSTERS_X_THREADS * CLUSTERS_Y_THREADS * clusterZThreads <= maxInvocations); // maxInvocations is too small CC_LOG_INFO(" work group size: %dx%dx%d", CLUSTERS_X_THREADS, CLUSTERS_Y_THREADS, clusterZThreads); _constantsBuffer = _device->createBuffer({ diff --git a/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp b/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp index 62014e7cfa..de5ce29cd2 100644 --- a/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp +++ b/native/cocos/renderer/pipeline/deferred/ReflectionComp.cpp @@ -77,7 +77,7 @@ void ReflectionComp::init(gfx::Device *dev, uint groupSizeX, uint groupSizeY) { _sampler = _device->getSampler(samplerInfo); uint maxInvocations = _device->getCapabilities().maxComputeWorkGroupInvocations; - CCASSERT(_groupSizeX * _groupSizeY <= maxInvocations, "maxInvocations is too small"); + CC_ASSERT(_groupSizeX * _groupSizeY <= maxInvocations); // maxInvocations is too small CC_LOG_INFO(" work group size: %dx%d", _groupSizeX, _groupSizeY); gfx::DescriptorSetLayoutInfo layoutInfo = {pipeline::localDescriptorSetLayout.bindings}; diff --git a/native/cocos/scene/Octree.cpp b/native/cocos/scene/Octree.cpp index bfd590a05a..e8418d5500 100644 --- a/native/cocos/scene/Octree.cpp +++ b/native/cocos/scene/Octree.cpp @@ -361,7 +361,7 @@ void Octree::resize(const Vec3 &minPos, const Vec3 &maxPos, uint32_t maxDepth) { } void Octree::insert(Model *model) { - CCASSERT(model, "Octree insert: model is nullptr."); + CC_ASSERT(model); if (!model->getWorldBounds()) { return; @@ -381,7 +381,7 @@ void Octree::insert(Model *model) { } void Octree::remove(Model *model) { - CCASSERT(model, "Octree remove: model is nullptr."); + CC_ASSERT(model); OctreeNode *node = model->getOctreeNode(); if (node) { diff --git a/native/cocos/scene/Pass.cpp b/native/cocos/scene/Pass.cpp index 184a2639c0..cce6f1ec5c 100644 --- a/native/cocos/scene/Pass.cpp +++ b/native/cocos/scene/Pass.cpp @@ -307,7 +307,8 @@ void Pass::resetUniform(const ccstd::string &name) { const auto &floatArr = cc::get>(value); auto iter = type2writer.find(type); if (iter != type2writer.end()) { - iter->second(block.data, floatArr.data(), static_cast(ofs)); + CC_ASSERT(floatArr.size() == 2); + iter->second(block.data, toMaterialProperty(type, floatArr), static_cast(ofs)); } } } diff --git a/native/tools/simulator/libsimulator/lib/PlayerProtocol.cpp b/native/tools/simulator/libsimulator/lib/PlayerProtocol.cpp index 986411ffaa..536d474135 100755 --- a/native/tools/simulator/libsimulator/lib/PlayerProtocol.cpp +++ b/native/tools/simulator/libsimulator/lib/PlayerProtocol.cpp @@ -33,7 +33,7 @@ PlayerProtocol *PlayerProtocol::_instance = nullptr; PlayerProtocol::PlayerProtocol() { - CCASSERT(_instance == nullptr, "CAN NOT CREATE MORE PLAYER INSTANCE"); + CC_ASSERT(_instance == nullptr); // Can not create more player instance. _instance = this; } diff --git a/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.cpp b/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.cpp index 27e899b1fd..63d95f4fd6 100755 --- a/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.cpp +++ b/native/tools/simulator/libsimulator/lib/network/CCHTTPRequest.cpp @@ -75,7 +75,7 @@ bool HTTPRequest::initWithListener(LUA_FUNCTION listener, const char *url, int m #endif bool HTTPRequest::initWithUrl(const char *url, int method) { - CCASSERT(url, "HTTPRequest::initWithUrl() - invalid url"); + CC_ASSERT(url); _curl = curl_easy_init(); curl_easy_setopt(_curl, CURLOPT_URL, url); curl_easy_setopt(_curl, CURLOPT_USERAGENT, "libcurl"); @@ -104,7 +104,7 @@ HTTPRequest::~HTTPRequest(void) { } void HTTPRequest::setRequestUrl(const char *url) { - CCASSERT(url, "HTTPRequest::setRequestUrl() - invalid url"); + CC_ASSERT(url); _url = url; curl_easy_setopt(_curl, CURLOPT_URL, _url.c_str()); } @@ -114,20 +114,20 @@ const string HTTPRequest::getRequestUrl(void) { } void HTTPRequest::addRequestHeader(const char *header) { - CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::addRequestHeader() - request not idle"); - CCASSERT(header, "HTTPRequest::addRequestHeader() - invalid header"); + CC_ASSERT(_state == kCCHTTPRequestStateIdle); + CC_ASSERT(header); _headers.push_back(string(header)); } void HTTPRequest::addPOSTValue(const char *key, const char *value) { - CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::addPOSTValue() - request not idle"); - CCASSERT(key, "HTTPRequest::addPOSTValue() - invalid key"); + CC_ASSERT(_state == kCCHTTPRequestStateIdle); + CC_ASSERT(key); _postFields[string(key)] = string(value ? value : ""); } void HTTPRequest::setPOSTData(const char *data) { - CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setPOSTData() - request not idle"); - CCASSERT(data, "HTTPRequest::setPOSTData() - invalid post data"); + CC_ASSERT(_state == kCCHTTPRequestStateIdle); + CC_ASSERT(data); _postFields.clear(); curl_easy_setopt(_curl, CURLOPT_POST, 1L); curl_easy_setopt(_curl, CURLOPT_COPYPOSTFIELDS, data); @@ -151,17 +151,17 @@ void HTTPRequest::addFormContents(const char *name, const char *value) { } void HTTPRequest::setCookieString(const char *cookie) { - CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setAcceptEncoding() - request not idle"); + CC_ASSERT(_state == kCCHTTPRequestStateIdle); curl_easy_setopt(_curl, CURLOPT_COOKIE, cookie ? cookie : ""); } const string HTTPRequest::getCookieString(void) { - CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseData() - request not completed"); + CC_ASSERT(_state == kCCHTTPRequestStateCompleted); return _responseCookies; } void HTTPRequest::setAcceptEncoding(int acceptEncoding) { - CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setAcceptEncoding() - request not idle"); + CC_ASSERT(_state == kCCHTTPRequestStateIdle); switch (acceptEncoding) { case kCCHTTPRequestAcceptEncodingGzip: curl_easy_setopt(_curl, CURLOPT_ACCEPT_ENCODING, "gzip"); @@ -177,13 +177,13 @@ void HTTPRequest::setAcceptEncoding(int acceptEncoding) { } void HTTPRequest::setTimeout(int timeout) { - CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::setTimeout() - request not idle"); + CC_ASSERT(_state == kCCHTTPRequestStateIdle); curl_easy_setopt(_curl, CURLOPT_CONNECTTIMEOUT, timeout); curl_easy_setopt(_curl, CURLOPT_TIMEOUT, timeout); } bool HTTPRequest::start(void) { - CCASSERT(_state == kCCHTTPRequestStateIdle, "HTTPRequest::start() - request not idle"); + CC_ASSERT(_state == kCCHTTPRequestStateIdle); _state = kCCHTTPRequestStateInProgress; _curlState = kCCHTTPRequestCURLStateBusy; @@ -236,12 +236,12 @@ int HTTPRequest::getState(void) { } int HTTPRequest::getResponseStatusCode(void) { - CCASSERT(_state == kCCHTTPRequestStateCompleted, "Request not completed"); + CC_ASSERT(_state == kCCHTTPRequestStateCompleted); return _responseCode; } const HTTPRequestHeaders &HTTPRequest::getResponseHeaders(void) { - CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseHeaders() - request not completed"); + CC_ASSERT(_state == kCCHTTPRequestStateCompleted); return _responseHeaders; } @@ -254,12 +254,12 @@ const string HTTPRequest::getResponseHeadersString() { } const string HTTPRequest::getResponseString(void) { - CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseString() - request not completed"); + CC_ASSERT(_state == kCCHTTPRequestStateCompleted); return string(_responseBuffer ? static_cast(_responseBuffer) : ""); } void *HTTPRequest::getResponseData(void) { - CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseData() - request not completed"); + CC_ASSERT(_state == kCCHTTPRequestStateCompleted); void *buff = malloc(_responseDataLength); memcpy(buff, _responseBuffer, _responseDataLength); return buff; @@ -267,7 +267,7 @@ void *HTTPRequest::getResponseData(void) { #if CC_LUA_ENGINE_ENABLED > 0 LUA_STRING HTTPRequest::getResponseDataLua(void) { - CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::getResponseDataLua() - request not completed"); + CC_ASSERT(_state == kCCHTTPRequestStateCompleted); LuaStack *stack = LuaEngine::getInstance()->getLuaStack(); stack->clean(); stack->pushString(static_cast(_responseBuffer), (int)_responseDataLength); @@ -276,15 +276,15 @@ LUA_STRING HTTPRequest::getResponseDataLua(void) { #endif int HTTPRequest::getResponseDataLength(void) { - CCASSERT(_state == kCCHTTPRequestStateCompleted, "Request not completed"); + CC_ASSERT(_state == kCCHTTPRequestStateCompleted); return (int)_responseDataLength; } size_t HTTPRequest::saveResponseData(const char *filename) { - CCASSERT(_state == kCCHTTPRequestStateCompleted, "HTTPRequest::saveResponseData() - request not completed"); + CC_ASSERT(_state == kCCHTTPRequestStateCompleted); FILE *fp = fopen(filename, "wb"); - CCASSERT(fp, "HTTPRequest::saveResponseData() - open file failure"); + CC_ASSERT(fp); size_t writedBytes = _responseDataLength; if (writedBytes > 0) { diff --git a/native/tools/simulator/libsimulator/lib/platform/mac/PlayerTaskServiceMac.mm b/native/tools/simulator/libsimulator/lib/platform/mac/PlayerTaskServiceMac.mm index 716d897b78..73d89d9370 100755 --- a/native/tools/simulator/libsimulator/lib/platform/mac/PlayerTaskServiceMac.mm +++ b/native/tools/simulator/libsimulator/lib/platform/mac/PlayerTaskServiceMac.mm @@ -246,7 +246,7 @@ PlayerTask *PlayerTaskServiceMac::createTask(const std::string &name, const std::string &executePath, const std::string &commandLineArguments) { - CCASSERT(_tasks.find(name) == _tasks.end(), "Task already exists."); + CC_ASSERT(_tasks.find(name) == _tasks.end()); // Make sure task doesn't exist. PlayerTaskMac *task = PlayerTaskMac::create(name, executePath, commandLineArguments); _tasks.insert(name, task); return task; diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp index 444f0b56eb..508e973f39 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerTaskServiceWin.cpp @@ -243,7 +243,7 @@ PlayerTaskServiceWin::~PlayerTaskServiceWin() { PlayerTask *PlayerTaskServiceWin::createTask(const std::string &name, const std::string &executePath, const std::string &commandLineArguments) { - CCASSERT(_tasks.find(name) == _tasks.end(), "Task already exists."); + CC_ASSERT(_tasks.find(name) == _tasks.end()); // Make sure task doesn't exist. PlayerTaskWin *task = PlayerTaskWin::create(name, executePath, commandLineArguments); _tasks.insert(name, task); return task; diff --git a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.cpp b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.cpp index 8d7122ab09..551ade3d6f 100755 --- a/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.cpp +++ b/native/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.cpp @@ -82,7 +82,7 @@ PlayerTaskServiceProtocol *PlayerWin::getTaskService() // services void PlayerWin::initServices() { - CCASSERT(_menuService == nullptr, "CAN'T INITIALIZATION SERVICES MORE THAN ONCE"); + CC_ASSERT(_menuService == nullptr); // Can't initialize services again. _menuService = new PlayerMenuServiceWin(_hwnd); _messageBoxService = new PlayerMessageBoxServiceWin(_hwnd); _fileDialogService = new PlayerFileDialogServiceWin(_hwnd);