diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-04-13 01:09:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-13 01:09:38 +0200 |
commit | 8793a464d312c5a48490fbec03c26f2835318063 (patch) | |
tree | 8be39ad26992b0bc10ee69fef5f0c5cadb6a0760 /thirdparty/etcpak/Bitmap.hpp | |
parent | 075f358fcddbb3df8417ef85baabdf3684a4efd2 (diff) | |
parent | d840165a324b5c218ca3a4882f030986855c8383 (diff) |
Merge pull request #47370 from fire/etcpak
Add thirdparty library etcpak for faster imports.
Diffstat (limited to 'thirdparty/etcpak/Bitmap.hpp')
-rw-r--r-- | thirdparty/etcpak/Bitmap.hpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/thirdparty/etcpak/Bitmap.hpp b/thirdparty/etcpak/Bitmap.hpp new file mode 100644 index 0000000000..fae8c936ed --- /dev/null +++ b/thirdparty/etcpak/Bitmap.hpp @@ -0,0 +1,50 @@ +#ifndef __DARKRL__BITMAP_HPP__ +#define __DARKRL__BITMAP_HPP__ + +#include <future> +#include <memory> +#include <mutex> +#include <stdint.h> + +#include "Semaphore.hpp" +#include "Vector.hpp" + +enum class Channels +{ + RGB, + Alpha +}; + +class Bitmap +{ +public: + Bitmap( const char* fn, unsigned int lines, bool bgr ); + Bitmap( const v2i& size ); + virtual ~Bitmap(); + + void Write( const char* fn ); + + uint32_t* Data() { if( m_load.valid() ) m_load.wait(); return m_data; } + const uint32_t* Data() const { if( m_load.valid() ) m_load.wait(); return m_data; } + const v2i& Size() const { return m_size; } + bool Alpha() const { return m_alpha; } + + const uint32_t* NextBlock( unsigned int& lines, bool& done ); + +protected: + Bitmap( const Bitmap& src, unsigned int lines ); + + uint32_t* m_data; + uint32_t* m_block; + unsigned int m_lines; + unsigned int m_linesLeft; + v2i m_size; + bool m_alpha; + Semaphore m_sema; + std::mutex m_lock; + std::future<void> m_load; +}; + +typedef std::shared_ptr<Bitmap> BitmapPtr; + +#endif |