[DEV] update new ememory::SharedPtr
This commit is contained in:
parent
87316c738a
commit
27e440c4a3
@ -7,7 +7,7 @@
|
|||||||
#include <egami/Image.h>
|
#include <egami/Image.h>
|
||||||
#include <egami/debug.h>
|
#include <egami/debug.h>
|
||||||
#include <egami/ImagePrivate.h>
|
#include <egami/ImagePrivate.h>
|
||||||
#include <memory>
|
#include <ememory/memory.h>
|
||||||
|
|
||||||
std::ostream& egami::operator <<(std::ostream& _os, const enum egami::colorType _type) {
|
std::ostream& egami::operator <<(std::ostream& _os, const enum egami::colorType _type) {
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
@ -47,6 +47,10 @@ egami::Image::Image() :
|
|||||||
EGAMI_WARNING("Chek this code, the caller can not use it corectly ... (NEW API)");
|
EGAMI_WARNING("Chek this code, the caller can not use it corectly ... (NEW API)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
egami::Image::~Image() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
egami::Image::Image(const ivec2& _size, enum colorType _type) :
|
egami::Image::Image(const ivec2& _size, enum colorType _type) :
|
||||||
m_data(nullptr) {
|
m_data(nullptr) {
|
||||||
configure(_size, _type);
|
configure(_size, _type);
|
||||||
@ -58,29 +62,29 @@ void egami::Image::configure(const ivec2& _size, enum colorType _type) {
|
|||||||
m_data = nullptr;
|
m_data = nullptr;
|
||||||
break;
|
break;
|
||||||
case egami::colorType::RGBA8:
|
case egami::colorType::RGBA8:
|
||||||
//m_data = std::make_shared<egami::ImagePrivate>(new egami::ImageTemplate<etk::Color<uint8_t>>(_size));
|
//m_data = ememory::makeShared<egami::ImagePrivate>(new egami::ImageTemplate<etk::Color<uint8_t>>(_size));
|
||||||
m_data = std::shared_ptr<egami::ImagePrivate>(new egami::ImageTemplate<etk::Color<uint8_t>>(_size));
|
m_data = ememory::makeShared<egami::ImageTemplate<etk::Color<uint8_t>>>(_size);
|
||||||
break;
|
break;
|
||||||
case egami::colorType::RGB8:
|
case egami::colorType::RGB8:
|
||||||
m_data = std::shared_ptr<egami::ImagePrivate>(new egami::ImageTemplate<etk::Color<uint8_t, 3>>(_size));
|
m_data = ememory::makeShared<egami::ImageTemplate<etk::Color<uint8_t, 3>>>(_size);
|
||||||
break;
|
break;
|
||||||
case egami::colorType::RGBAf:
|
case egami::colorType::RGBAf:
|
||||||
m_data = std::shared_ptr<egami::ImagePrivate>(new egami::ImageTemplate<etk::Color<float>>(_size));
|
m_data = ememory::makeShared<egami::ImageTemplate<etk::Color<float>>>(_size);
|
||||||
break;
|
break;
|
||||||
case egami::colorType::RGBf:
|
case egami::colorType::RGBf:
|
||||||
m_data = std::shared_ptr<egami::ImagePrivate>(new egami::ImageTemplate<etk::Color<float, 3>>(_size));
|
m_data = ememory::makeShared<egami::ImageTemplate<etk::Color<float, 3>>>(_size);
|
||||||
break;
|
break;
|
||||||
case egami::colorType::unsignedInt16:
|
case egami::colorType::unsignedInt16:
|
||||||
m_data = std::shared_ptr<egami::ImagePrivate>(new egami::ImageTemplate<etk::Color<uint16_t, 1>>(_size));
|
m_data = ememory::makeShared<egami::ImageTemplate<etk::Color<uint16_t, 1>>>(_size);
|
||||||
break;
|
break;
|
||||||
case egami::colorType::unsignedInt32:
|
case egami::colorType::unsignedInt32:
|
||||||
m_data = std::shared_ptr<egami::ImagePrivate>(new egami::ImageTemplate<etk::Color<uint32_t, 1>>(_size));
|
m_data = ememory::makeShared<egami::ImageTemplate<etk::Color<uint32_t, 1>>>(_size);
|
||||||
break;
|
break;
|
||||||
case egami::colorType::float32:
|
case egami::colorType::float32:
|
||||||
m_data = std::shared_ptr<egami::ImagePrivate>(new egami::ImageTemplate<etk::Color<float, 1>>(_size));
|
m_data = ememory::makeShared<egami::ImageTemplate<etk::Color<float, 1>>>(_size);
|
||||||
break;
|
break;
|
||||||
case egami::colorType::float64:
|
case egami::colorType::float64:
|
||||||
m_data = std::shared_ptr<egami::ImagePrivate>(new egami::ImageTemplate<etk::Color<double, 1>>(_size));
|
m_data = ememory::makeShared<egami::ImageTemplate<etk::Color<double, 1>>>(_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <etk/math/Vector2D.h>
|
#include <etk/math/Vector2D.h>
|
||||||
#include <etk/Color.h>
|
#include <etk/Color.h>
|
||||||
#include <etk/stdTools.h>
|
#include <etk/stdTools.h>
|
||||||
#include <memory>
|
#include <ememory/memory.h>
|
||||||
|
|
||||||
namespace egami {
|
namespace egami {
|
||||||
enum class colorType {
|
enum class colorType {
|
||||||
@ -26,11 +26,47 @@ namespace egami {
|
|||||||
float64,
|
float64,
|
||||||
};
|
};
|
||||||
std::ostream& operator <<(std::ostream& _os, const enum egami::colorType _obj);
|
std::ostream& operator <<(std::ostream& _os, const enum egami::colorType _obj);
|
||||||
class ImagePrivate;
|
|
||||||
|
class ImagePrivate {
|
||||||
|
public:
|
||||||
|
ImagePrivate() {};
|
||||||
|
virtual ~ImagePrivate() {};
|
||||||
|
virtual void* getTextureDataPointer() {
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
virtual const ivec2& getSize() const = 0;
|
||||||
|
virtual int32_t getWidth() const {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
virtual int32_t getHeight() const {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
virtual enum colorType getType() const {
|
||||||
|
return egami::colorType::RGBA8;
|
||||||
|
};
|
||||||
|
virtual void clear() = 0;
|
||||||
|
virtual void resize(const ivec2& _size, const etk::Color<uint8_t, 4>& _color, const ivec2& _startPos) = 0;
|
||||||
|
virtual void resize(const ivec2& _size, const etk::Color<float, 4>& _color, const ivec2& _startPos) = 0;
|
||||||
|
virtual void resize(const ivec2& _size, const etk::Color<uint16_t, 1>& _color, const ivec2& _startPos) = 0;
|
||||||
|
virtual void resize(const ivec2& _size, const etk::Color<uint32_t, 1>& _color, const ivec2& _startPos) = 0;
|
||||||
|
virtual void resize(const ivec2& _size, const etk::Color<float, 1>& _color, const ivec2& _startPos) = 0;
|
||||||
|
virtual void resize(const ivec2& _size, const etk::Color<double, 1>& _color, const ivec2& _startPos) = 0;
|
||||||
|
virtual void resize(const ivec2& _size, const ivec2& _startPos) = 0;
|
||||||
|
virtual void set(const ivec2& _pos, const etk::Color<>& _newColor) = 0;
|
||||||
|
virtual void set(const ivec2& _pos, const etk::Color<float>& _newColor) = 0;
|
||||||
|
virtual void set(const ivec2& _pos, const etk::Color<uint16_t, 1>& _newColor) = 0;
|
||||||
|
virtual void set(const ivec2& _pos, const etk::Color<uint32_t, 1>& _newColor) = 0;
|
||||||
|
virtual void set(const ivec2& _pos, const etk::Color<float, 1>& _newColor) = 0;
|
||||||
|
virtual void set(const ivec2& _pos, const etk::Color<double, 1>& _newColor) = 0;
|
||||||
|
virtual etk::Color<> get(const ivec2& _pos) const = 0;
|
||||||
|
virtual void set(const std::vector<etk::Color<float,4>>& _data, const ivec2& _size) = 0;
|
||||||
|
virtual void set(const std::vector<etk::Color<uint8_t,4>>& _data, const ivec2& _size) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class Image {
|
class Image {
|
||||||
private:
|
private:
|
||||||
// TODO : Change this in a unique_ptr ...
|
// TODO : Change this in a unique_ptr ...
|
||||||
std::shared_ptr<ImagePrivate> m_data; //!< data of the image
|
ememory::SharedPtr<ImagePrivate> m_data; //!< data of the image
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief contructor that create an empty image (no valid data)
|
* @brief contructor that create an empty image (no valid data)
|
||||||
@ -39,6 +75,7 @@ namespace egami {
|
|||||||
Image();
|
Image();
|
||||||
Image(const ivec2& _size,
|
Image(const ivec2& _size,
|
||||||
enum colorType _type = egami::colorType::undefined);
|
enum colorType _type = egami::colorType::undefined);
|
||||||
|
~Image();
|
||||||
// TODO : IMplement move operator ... and copy operator...
|
// TODO : IMplement move operator ... and copy operator...
|
||||||
public:
|
public:
|
||||||
void configure(const ivec2& _size=ivec2(32,32),
|
void configure(const ivec2& _size=ivec2(32,32),
|
||||||
@ -99,4 +136,3 @@ namespace egami {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,35 +9,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <etk/math/Vector2D.h>
|
#include <etk/math/Vector2D.h>
|
||||||
#include <etk/Color.h>
|
#include <etk/Color.h>
|
||||||
|
#include <egami/debug.h>
|
||||||
|
|
||||||
namespace egami {
|
namespace egami {
|
||||||
class ImagePrivate {
|
|
||||||
public:
|
|
||||||
ImagePrivate() {};
|
|
||||||
virtual ~ImagePrivate() {};
|
|
||||||
virtual void* getTextureDataPointer() { return nullptr; };
|
|
||||||
virtual const ivec2& getSize()=0;
|
|
||||||
virtual int32_t getWidth() const { return 0; };
|
|
||||||
virtual int32_t getHeight() const { return 0; };
|
|
||||||
virtual enum colorType getType() { return egami::colorType::RGBA8; };
|
|
||||||
virtual void clear() = 0;
|
|
||||||
virtual void resize(const ivec2& _size, const etk::Color<uint8_t, 4>& _color, const ivec2& _startPos) = 0;
|
|
||||||
virtual void resize(const ivec2& _size, const etk::Color<float, 4>& _color, const ivec2& _startPos) = 0;
|
|
||||||
virtual void resize(const ivec2& _size, const etk::Color<uint16_t, 1>& _color, const ivec2& _startPos) = 0;
|
|
||||||
virtual void resize(const ivec2& _size, const etk::Color<uint32_t, 1>& _color, const ivec2& _startPos) = 0;
|
|
||||||
virtual void resize(const ivec2& _size, const etk::Color<float, 1>& _color, const ivec2& _startPos) = 0;
|
|
||||||
virtual void resize(const ivec2& _size, const etk::Color<double, 1>& _color, const ivec2& _startPos) = 0;
|
|
||||||
virtual void resize(const ivec2& _size, const ivec2& _startPos) = 0;
|
|
||||||
virtual void set(const ivec2& _pos, const etk::Color<>& _newColor) = 0;
|
|
||||||
virtual void set(const ivec2& _pos, const etk::Color<float>& _newColor) = 0;
|
|
||||||
virtual void set(const ivec2& _pos, const etk::Color<uint16_t, 1>& _newColor) = 0;
|
|
||||||
virtual void set(const ivec2& _pos, const etk::Color<uint32_t, 1>& _newColor) = 0;
|
|
||||||
virtual void set(const ivec2& _pos, const etk::Color<float, 1>& _newColor) = 0;
|
|
||||||
virtual void set(const ivec2& _pos, const etk::Color<double, 1>& _newColor) = 0;
|
|
||||||
virtual etk::Color<> get(const ivec2& _pos) const = 0;
|
|
||||||
virtual void set(const std::vector<etk::Color<float,4>>& _data, const ivec2& _size) = 0;
|
|
||||||
virtual void set(const std::vector<etk::Color<uint8_t,4>>& _data, const ivec2& _size) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T = etk::Color<>>
|
template<typename T = etk::Color<>>
|
||||||
class ImageTemplate : public ImagePrivate {
|
class ImageTemplate : public ImagePrivate {
|
||||||
@ -65,8 +39,10 @@ namespace egami {
|
|||||||
void* getTextureDataPointer() {
|
void* getTextureDataPointer() {
|
||||||
return &m_data[0];
|
return &m_data[0];
|
||||||
};
|
};
|
||||||
enum colorType getType();
|
enum colorType getType() const;
|
||||||
const ivec2& getSize() { return m_size; };
|
const ivec2& getSize() {
|
||||||
|
return m_size;
|
||||||
|
};
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
// -- basic tools :
|
// -- basic tools :
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
@ -249,28 +225,28 @@ namespace egami {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <> enum colorType ImageTemplate<etk::Color<uint8_t>>::getType() {
|
template <> enum colorType ImageTemplate<etk::Color<uint8_t>>::getType() const {
|
||||||
return egami::colorType::RGBA8;
|
return egami::colorType::RGBA8;
|
||||||
}
|
}
|
||||||
template <> enum colorType ImageTemplate<etk::Color<uint8_t, 3>>::getType() {
|
template <> enum colorType ImageTemplate<etk::Color<uint8_t, 3>>::getType() const {
|
||||||
return egami::colorType::RGB8;
|
return egami::colorType::RGB8;
|
||||||
}
|
}
|
||||||
template <> enum colorType ImageTemplate<etk::Color<float>>::getType() {
|
template <> enum colorType ImageTemplate<etk::Color<float>>::getType() const {
|
||||||
return egami::colorType::RGBAf;
|
return egami::colorType::RGBAf;
|
||||||
}
|
}
|
||||||
template <> enum colorType ImageTemplate<etk::Color<float, 3>>::getType() {
|
template <> enum colorType ImageTemplate<etk::Color<float, 3>>::getType() const {
|
||||||
return egami::colorType::RGBf;
|
return egami::colorType::RGBf;
|
||||||
}
|
}
|
||||||
template <> enum colorType ImageTemplate<etk::Color<uint16_t, 1>>::getType() {
|
template <> enum colorType ImageTemplate<etk::Color<uint16_t, 1>>::getType() const {
|
||||||
return egami::colorType::unsignedInt16;
|
return egami::colorType::unsignedInt16;
|
||||||
}
|
}
|
||||||
template <> enum colorType ImageTemplate<etk::Color<uint32_t, 1>>::getType() {
|
template <> enum colorType ImageTemplate<etk::Color<uint32_t, 1>>::getType() const {
|
||||||
return egami::colorType::unsignedInt32;
|
return egami::colorType::unsignedInt32;
|
||||||
}
|
}
|
||||||
template <> enum colorType ImageTemplate<etk::Color<float, 1>>::getType() {
|
template <> enum colorType ImageTemplate<etk::Color<float, 1>>::getType() const {
|
||||||
return egami::colorType::float32;
|
return egami::colorType::float32;
|
||||||
}
|
}
|
||||||
template <> enum colorType ImageTemplate<etk::Color<double, 1>>::getType() {
|
template <> enum colorType ImageTemplate<etk::Color<double, 1>>::getType() const {
|
||||||
return egami::colorType::float64;
|
return egami::colorType::float64;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user