From d840165a324b5c218ca3a4882f030986855c8383 Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Tue, 6 Apr 2021 22:05:56 -0700 Subject: Add `etcpak` library for faster ETC/ETC2/S3TC imports. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `etc` module was renamed to `etcpak` and modified to use the new library. - PKM importer is removed in the process, it's obsolete. - Old library `etc2comp` is removed. - S3TC compression no longer done via `squish` (but decompression still is). - Slight modifications to etcpak sources for MinGW compatibility, to fix LLVM `-Wc++11-narrowing` errors, and to allow using vendored or system libpng. Co-authored-by: RĂ©mi Verschelde --- thirdparty/etcpak/BlockData.hpp | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 thirdparty/etcpak/BlockData.hpp (limited to 'thirdparty/etcpak/BlockData.hpp') diff --git a/thirdparty/etcpak/BlockData.hpp b/thirdparty/etcpak/BlockData.hpp new file mode 100644 index 0000000000..209e35b4e6 --- /dev/null +++ b/thirdparty/etcpak/BlockData.hpp @@ -0,0 +1,56 @@ +#ifndef __BLOCKDATA_HPP__ +#define __BLOCKDATA_HPP__ + +#include +#include +#include +#include +#include +#include +#include + +#include "Bitmap.hpp" +#include "ForceInline.hpp" +#include "Vector.hpp" + +class BlockData +{ +public: + enum Type + { + Etc1, + Etc2_RGB, + Etc2_RGBA, + Dxt1, + Dxt5 + }; + + BlockData( const char* fn ); + BlockData( const char* fn, const v2i& size, bool mipmap, Type type ); + BlockData( const v2i& size, bool mipmap, Type type ); + ~BlockData(); + + BitmapPtr Decode(); + + void Process( const uint32_t* src, uint32_t blocks, size_t offset, size_t width, Channels type, bool dither ); + void ProcessRGBA( const uint32_t* src, uint32_t blocks, size_t offset, size_t width ); + + const v2i& Size() const { return m_size; } + +private: + etcpak_no_inline BitmapPtr DecodeRGB(); + etcpak_no_inline BitmapPtr DecodeRGBA(); + etcpak_no_inline BitmapPtr DecodeDxt1(); + etcpak_no_inline BitmapPtr DecodeDxt5(); + + uint8_t* m_data; + v2i m_size; + size_t m_dataOffset; + FILE* m_file; + size_t m_maplen; + Type m_type; +}; + +typedef std::shared_ptr BlockDataPtr; + +#endif -- cgit v1.2.3