From 3d47b9da34f742af2101f78686443be9600f7c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 3 Apr 2017 22:41:37 -0700 Subject: [PATCH] Cleanup. --- include/bimg/bimg.h | 26 +++++++++++++++++++++++++- include/bimg/encode.h | 4 ++-- scripts/texturec.lua | 2 +- src/image_encode.cpp | 26 +++++++++++--------------- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/include/bimg/bimg.h b/include/bimg/bimg.h index 0ab4d23..0fec44d 100644 --- a/include/bimg/bimg.h +++ b/include/bimg/bimg.h @@ -8,11 +8,12 @@ #include // uint32_t #include // NULL +#include namespace bx { struct AllocatorI; - struct Error; + class Error; struct ReaderSeekerI; struct WriterI; @@ -272,6 +273,29 @@ namespace bimg /// bool imageConvert(TextureFormat::Enum _dstFormat, TextureFormat::Enum _srcFormat); + /// + void imageConvert( + void* _dst + , uint32_t _bpp + , bx::PackFn _pack + , const void* _src + , bx::UnpackFn _unpack + , uint32_t _size + ); + + /// + void imageConvert( + void* _dst + , uint32_t _dstBpp + , bx::PackFn _pack + , const void* _src + , uint32_t _srcBpp + , bx::UnpackFn _unpack + , uint32_t _width + , uint32_t _height + , uint32_t _srcPitch + ); + /// bool imageConvert( void* _dst diff --git a/include/bimg/encode.h b/include/bimg/encode.h index e91288e..db74eb9 100644 --- a/include/bimg/encode.h +++ b/include/bimg/encode.h @@ -11,10 +11,10 @@ namespace bimg { /// - bool imageEncodeFromRgba8(void* _dst, const void* _src, uint32_t _width, uint32_t _height, uint8_t _format); + bool imageEncodeFromRgba8(void* _dst, const void* _src, uint32_t _width, uint32_t _height, TextureFormat::Enum _format); /// - bool imageEncodeFromRgba32f(bx::AllocatorI* _allocator, void* _dst, const void* _src, uint32_t _width, uint32_t _height, uint8_t _format); + bool imageEncodeFromRgba32f(bx::AllocatorI* _allocator, void* _dst, const void* _src, uint32_t _width, uint32_t _height, TextureFormat::Enum _format); /// void imageRgba32f11to01(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src); diff --git a/scripts/texturec.lua b/scripts/texturec.lua index 4a785ac..02f6bb6 100644 --- a/scripts/texturec.lua +++ b/scripts/texturec.lua @@ -7,7 +7,7 @@ project "texturec" kind "ConsoleApp" includedirs { - path.join(BX_DIR, "include"), + path.join(BX_DIR, "include"), path.join(BIMG_DIR, "include"), path.join(BIMG_DIR, "3rdparty"), path.join(BIMG_DIR, "3rdparty/nvtt"), diff --git a/src/image_encode.cpp b/src/image_encode.cpp index e5b5986..e06e5f9 100644 --- a/src/image_encode.cpp +++ b/src/image_encode.cpp @@ -14,11 +14,9 @@ namespace bimg { - bool imageEncodeFromRgba8(void* _dst, const void* _src, uint32_t _width, uint32_t _height, uint8_t _format) + bool imageEncodeFromRgba8(void* _dst, const void* _src, uint32_t _width, uint32_t _height, TextureFormat::Enum _format) { - TextureFormat::Enum format = TextureFormat::Enum(_format); - - switch (format) + switch (_format) { case TextureFormat::BC1: case TextureFormat::BC2: @@ -26,11 +24,11 @@ namespace bimg case TextureFormat::BC4: case TextureFormat::BC5: squish::CompressImage( (const uint8_t*)_src, _width, _height, _dst - , format == TextureFormat::BC2 ? squish::kDxt3 - : format == TextureFormat::BC3 ? squish::kDxt5 - : format == TextureFormat::BC4 ? squish::kBc4 - : format == TextureFormat::BC5 ? squish::kBc5 - : squish::kDxt1 + , _format == TextureFormat::BC2 ? squish::kDxt3 + : _format == TextureFormat::BC3 ? squish::kDxt5 + : _format == TextureFormat::BC4 ? squish::kBc4 + : _format == TextureFormat::BC5 ? squish::kBc5 + : squish::kDxt1 ); return true; @@ -108,16 +106,14 @@ namespace bimg break; } - return imageConvert(_dst, format, _src, TextureFormat::RGBA8, _width, _height); + return imageConvert(_dst, _format, _src, TextureFormat::RGBA8, _width, _height); } - bool imageEncodeFromRgba32f(bx::AllocatorI* _allocator, void* _dst, const void* _src, uint32_t _width, uint32_t _height, uint8_t _format) + bool imageEncodeFromRgba32f(bx::AllocatorI* _allocator, void* _dst, const void* _src, uint32_t _width, uint32_t _height, TextureFormat::Enum _format) { - TextureFormat::Enum format = TextureFormat::Enum(_format); - const uint8_t* src = (const uint8_t*)_src; - switch (format) + switch (_format) { case TextureFormat::RGBA8: { @@ -164,7 +160,7 @@ namespace bimg break; } - return imageConvert(_dst, format, _src, TextureFormat::RGBA32F, _width, _height); + return imageConvert(_dst, _format, _src, TextureFormat::RGBA32F, _width, _height); } void imageRgba32f11to01(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)