memory refactor Texture and ImageData

This commit is contained in:
MihailRis
2024-06-30 21:24:46 +03:00
parent ce9c5b97c7
commit c0dca31e98
14 changed files with 191 additions and 160 deletions
+7 -4
View File
@@ -3,6 +3,8 @@
#include "../../typedefs.hpp"
#include <memory>
enum class ImageFormat {
rgb888,
rgba8888
@@ -12,10 +14,11 @@ class ImageData {
ImageFormat format;
uint width;
uint height;
void* data;
std::unique_ptr<ubyte[]> data;
public:
ImageData(ImageFormat format, uint width, uint height);
ImageData(ImageFormat format, uint width, uint height, void* data);
ImageData(ImageFormat format, uint width, uint height, std::unique_ptr<ubyte[]> data);
ImageData(ImageFormat format, uint width, uint height, const ubyte* data);
~ImageData();
void flipX();
@@ -27,8 +30,8 @@ public:
void extrude(int x, int y, int w, int h);
void fixAlphaColor();
void* getData() const {
return data;
ubyte* getData() const {
return data.get();
}
ImageFormat getFormat() const {