diff --git a/cocos/base/CCUserDefault.cpp b/cocos/base/CCUserDefault.cpp index e78078ea70..394fd5ca67 100644 --- a/cocos/base/CCUserDefault.cpp +++ b/cocos/base/CCUserDefault.cpp @@ -297,8 +297,7 @@ void UserDefault::setStringForKey(const char* pKey, const std::string & value) if ((_realSize + obs.length() + sizeof(udflen_t)) < _curMapSize) { // increase entities count - auto count = yasio::endian::ntohv(*(udflen_t*)_rwmmap->data()); - *(udflen_t*)_rwmmap->data() = yasio::endian::htonv(count + 1); + yasio::obstream::swrite_i(_rwmmap->data(), 1 + yasio::ibstream::sread_i(_rwmmap->data())); // append entity ::memcpy(_rwmmap->data() + sizeof(udflen_t) + _realSize, obs.data(), obs.length()); diff --git a/cocos/renderer/CCTexture2D.cpp b/cocos/renderer/CCTexture2D.cpp index 3afda7ba49..3a6b8cecb2 100644 --- a/cocos/renderer/CCTexture2D.cpp +++ b/cocos/renderer/CCTexture2D.cpp @@ -281,8 +281,8 @@ bool Texture2D::updateWithImage(Image* image, backend::PixelFormat format, int i case PixelFormat::ASTC4: case PixelFormat::ASTC8: renderFormat = imagePixelFormat; + default: break; - default:; } //override renderFormat, since some render format is not supported by metal switch (renderFormat) @@ -326,16 +326,14 @@ bool Texture2D::updateWithImage(Image* image, backend::PixelFormat format, int i } else if (image->isCompressed()) { -#ifndef CC_USE_METAL switch (imagePixelFormat) { - case PixelFormat::ETC: case PixelFormat::ASTC4: case PixelFormat::ASTC8: + case PixelFormat::ETC: renderFormat = imagePixelFormat; - break; default:; } -#endif + if (renderFormat != image->getPixelFormat()) { CCLOG("cocos2d: WARNING: This image is compressed and we can't convert it for now"); diff --git a/cocos/renderer/backend/metal/TextureMTL.mm b/cocos/renderer/backend/metal/TextureMTL.mm index 5512f9d0af..4a0c5bbb5f 100644 --- a/cocos/renderer/backend/metal/TextureMTL.mm +++ b/cocos/renderer/backend/metal/TextureMTL.mm @@ -140,30 +140,6 @@ namespace return bytesPerRow; } - std::size_t getBytesPerRowASTC(MTLPixelFormat pixleFormat, std::size_t width) - { - std::size_t bytesPerRow = 0; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - uint32_t bytesPerBlock = 0; - switch (pixleFormat) { - case MTLPixelFormatASTC_4x4_sRGB: - case MTLPixelFormatASTC_4x4_LDR: - case MTLPixelFormatASTC_4x4_HDR: - bytesPerBlock = 4; - break; - case MTLPixelFormatASTC_8x8_sRGB: - case MTLPixelFormatASTC_8x8_LDR: - case MTLPixelFormatASTC_8x8_HDR: - bytesPerBlock = 8; - break; - default: - CCASSERT(false, "Not supported ASTC format!"); - } - bytesPerRow = width * bytesPerBlock; -#endif - return bytesPerRow; - } - std::size_t getBytesPerRowS3TC(MTLPixelFormat pixleFormat, std::size_t width) { std::size_t bytesPerRow = 0; @@ -200,10 +176,6 @@ namespace { bytesPerRow = getBytesPerRowETC(pixelFormat, width); } - else if (textureFormat == PixelFormat::ASTC4 || textureFormat == PixelFormat::ASTC8) - { - bytesPerRow = getBytesPerRowASTC(pixelFormat, width); - } else if(textureFormat >= PixelFormat::S3TC_DXT1 && textureFormat <= PixelFormat::S3TC_DXT5) { diff --git a/cocos/renderer/backend/metal/Utils.mm b/cocos/renderer/backend/metal/Utils.mm index eb49aa25da..0974d4f330 100644 --- a/cocos/renderer/backend/metal/Utils.mm +++ b/cocos/renderer/backend/metal/Utils.mm @@ -123,10 +123,6 @@ MTLPixelFormat Utils::toMTLPixelFormat(PixelFormat textureFormat) return MTLPixelFormatPVRTC_RGB_2BPP; case PixelFormat::ETC: return MTLPixelFormatETC2_RGB8; - case PixelFormat::ASTC4: - return MTLPixelFormatASTC_4x4_LDR; - case PixelFormat::ASTC8: - return MTLPixelFormatASTC_8x8_LDR; #else case PixelFormat::S3TC_DXT1: return MTLPixelFormatBC1_RGBA;