diff options
Diffstat (limited to 'source/core/slang-deflate-compression-system.cpp')
| -rw-r--r-- | source/core/slang-deflate-compression-system.cpp | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/source/core/slang-deflate-compression-system.cpp b/source/core/slang-deflate-compression-system.cpp index 4f1390240..1cbea01f0 100644 --- a/source/core/slang-deflate-compression-system.cpp +++ b/source/core/slang-deflate-compression-system.cpp @@ -3,13 +3,13 @@ #include "slang-com-helper.h" #include "slang-com-ptr.h" -// We don't want compress #define to clash +// We don't want compress #define to clash #define MINIZ_NO_ZLIB_COMPATIBLE_NAMES 1 -#include <miniz.h> - #include "slang-blob.h" +#include <miniz.h> + namespace Slang { @@ -18,7 +18,7 @@ namespace Slang class DeflateCompressionSystemImpl : public RefObject, public ICompressionSystem { public: - // ISlangUnknown + // ISlangUnknown // override ref counting, as singleton SLANG_IUNKNOWN_QUERY_INTERFACE @@ -26,28 +26,45 @@ public: SLANG_NO_THROW uint32_t SLANG_MCALL release() SLANG_OVERRIDE { return 1; } // ICompressionSystem - virtual SLANG_NO_THROW CompressionSystemType SLANG_MCALL getSystemType() SLANG_OVERRIDE { return CompressionSystemType::Deflate; } - virtual SLANG_NO_THROW SlangResult SLANG_MCALL compress(const CompressionStyle* style, const void* src, size_t srcSizeInBytes, ISlangBlob** outBlob) SLANG_OVERRIDE; - virtual SLANG_NO_THROW SlangResult SLANG_MCALL decompress(const void* compressed, size_t compressedSizeInBytes, size_t decompressedSizeInBytes, void* outDecompressed) SLANG_OVERRIDE; + virtual SLANG_NO_THROW CompressionSystemType SLANG_MCALL getSystemType() SLANG_OVERRIDE + { + return CompressionSystemType::Deflate; + } + virtual SLANG_NO_THROW SlangResult SLANG_MCALL compress( + const CompressionStyle* style, + const void* src, + size_t srcSizeInBytes, + ISlangBlob** outBlob) SLANG_OVERRIDE; + virtual SLANG_NO_THROW SlangResult SLANG_MCALL decompress( + const void* compressed, + size_t compressedSizeInBytes, + size_t decompressedSizeInBytes, + void* outDecompressed) SLANG_OVERRIDE; protected: - ICompressionSystem* getInterface(const Guid& guid); }; ICompressionSystem* DeflateCompressionSystemImpl::getInterface(const Guid& guid) { - return (guid == ISlangUnknown::getTypeGuid() || guid == ICompressionSystem::getTypeGuid()) ? static_cast<ICompressionSystem*>(this) : nullptr; + return (guid == ISlangUnknown::getTypeGuid() || guid == ICompressionSystem::getTypeGuid()) + ? static_cast<ICompressionSystem*>(this) + : nullptr; } -SlangResult DeflateCompressionSystemImpl::compress(const CompressionStyle* style, const void* src, size_t srcSizeInBytes, ISlangBlob** outBlob) +SlangResult DeflateCompressionSystemImpl::compress( + const CompressionStyle* style, + const void* src, + size_t srcSizeInBytes, + ISlangBlob** outBlob) { SLANG_UNUSED(style); size_t compressedSizeInBytes; const int flags = 0; - void* compressed = tdefl_compress_mem_to_heap(src, srcSizeInBytes, &compressedSizeInBytes, flags); + void* compressed = + tdefl_compress_mem_to_heap(src, srcSizeInBytes, &compressedSizeInBytes, flags); if (!compressed) { @@ -62,11 +79,20 @@ SlangResult DeflateCompressionSystemImpl::compress(const CompressionStyle* style return SLANG_OK; } -SlangResult DeflateCompressionSystemImpl::decompress(const void* compressed, size_t compressedSizeInBytes, size_t decompressedSizeInBytes, void* outDecompressed) +SlangResult DeflateCompressionSystemImpl::decompress( + const void* compressed, + size_t compressedSizeInBytes, + size_t decompressedSizeInBytes, + void* outDecompressed) { const int flags = TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF; - size_t size = tinfl_decompress_mem_to_mem(outDecompressed, decompressedSizeInBytes, compressed ,compressedSizeInBytes, flags); + size_t size = tinfl_decompress_mem_to_mem( + outDecompressed, + decompressedSizeInBytes, + compressed, + compressedSizeInBytes, + flags); if (size == TINFL_DECOMPRESS_MEM_TO_MEM_FAILED) { return SLANG_FAIL; @@ -75,7 +101,7 @@ SlangResult DeflateCompressionSystemImpl::decompress(const void* compressed, siz return SLANG_OK; } -/* static */ICompressionSystem* DeflateCompressionSystem::getSingleton() +/* static */ ICompressionSystem* DeflateCompressionSystem::getSingleton() { static DeflateCompressionSystemImpl impl; return &impl; |
