[DEV] update to the new ETK allocator wrapper
This commit is contained in:
parent
b8a2210d0d
commit
dd8daa7e3d
@ -27,7 +27,7 @@ int32_t ewol::run(ewol::context::Application* _application,
|
||||
int32_t _argc,
|
||||
const char* _argv[]) {
|
||||
etranslate::init(_argc, _argv);
|
||||
return gale::run(new ewol::Context(_application), _argc, _argv);
|
||||
return gale::run(ETK_NEW(ewol::Context, _application), _argc, _argv);
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ exit_on_error:
|
||||
|
||||
#define DECLARE_FACTORY(className) \
|
||||
template<class ... EWOL_FACTORY_CREATE_TYPE> static ememory::SharedPtr<className> create(const EWOL_FACTORY_CREATE_TYPE& ... _all) { \
|
||||
ememory::SharedPtr<className> object(new className()); \
|
||||
ememory::SharedPtr<className> object(ETK_NEW(className)); \
|
||||
if (object == nullptr) { \
|
||||
EWOL_ERROR("Factory error"); \
|
||||
return nullptr; \
|
||||
@ -75,7 +75,7 @@ exit_on_error:
|
||||
return object; \
|
||||
} \
|
||||
static ememory::SharedPtr<className> createXml(const exml::Element& _node) { \
|
||||
ememory::SharedPtr<className> object(new className()); \
|
||||
ememory::SharedPtr<className> object(ETK_NEW(className)); \
|
||||
if (object == nullptr) { \
|
||||
EWOL_ERROR("Factory error"); \
|
||||
return nullptr; \
|
||||
@ -102,7 +102,7 @@ exit_on_error:
|
||||
if (object != nullptr) { \
|
||||
return object; \
|
||||
} \
|
||||
object = ememory::SharedPtr<className>(new className()); \
|
||||
object = ememory::SharedPtr<className>(ETK_NEW(className)); \
|
||||
if (object == nullptr) { \
|
||||
EWOL_ERROR("Factory error"); \
|
||||
return nullptr; \
|
||||
|
@ -53,7 +53,6 @@ void ewol::resource::freeTypeUnInit() {
|
||||
ewol::resource::FontFreeType::FontFreeType() {
|
||||
addResourceType("ewol::FontFreeType");
|
||||
m_init = false;
|
||||
m_FileBuffer = nullptr;
|
||||
m_FileSize = 0;
|
||||
}
|
||||
|
||||
@ -75,17 +74,17 @@ void ewol::resource::FontFreeType::init(const etk::String& _fontName) {
|
||||
return;
|
||||
}
|
||||
// allocate data
|
||||
m_FileBuffer = new FT_Byte[m_FileSize];
|
||||
if (m_FileBuffer == nullptr) {
|
||||
m_FileBuffer.resize(m_FileSize, 0);
|
||||
if (m_FileBuffer.size() != m_FileSize) {
|
||||
EWOL_ERROR("Error Memory allocation size=" << _fontName);
|
||||
return;
|
||||
}
|
||||
// load data from the file :
|
||||
myfile.fileRead(m_FileBuffer, 1, m_FileSize);
|
||||
myfile.fileRead(&m_FileBuffer[0], 1, m_FileSize);
|
||||
// close the file:
|
||||
myfile.fileClose();
|
||||
// load Face ...
|
||||
int32_t error = FT_New_Memory_Face( library, m_FileBuffer, m_FileSize, 0, &m_fftFace );
|
||||
int32_t error = FT_New_Memory_Face(library, &m_FileBuffer[0], m_FileSize, 0, &m_fftFace );
|
||||
if( FT_Err_Unknown_File_Format == error) {
|
||||
EWOL_ERROR("... the font file could be opened and read, but it appears ... that its font format is unsupported");
|
||||
} else if (0 != error) {
|
||||
@ -101,17 +100,14 @@ void ewol::resource::FontFreeType::init(const etk::String& _fontName) {
|
||||
ewol::resource::FontFreeType::~FontFreeType() {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
// clean the tmp memory
|
||||
if (nullptr != m_FileBuffer) {
|
||||
delete[] m_FileBuffer;
|
||||
m_FileBuffer = nullptr;
|
||||
}
|
||||
m_FileBuffer.clear();
|
||||
// must be deleted fftFace
|
||||
FT_Done_Face( m_fftFace );
|
||||
FT_Done_Face(m_fftFace);
|
||||
}
|
||||
|
||||
vec2 ewol::resource::FontFreeType::getSize(int32_t _fontSize, const etk::String& _unicodeString) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if(false == m_init) {
|
||||
if (m_init == false) {
|
||||
return vec2(0,0);
|
||||
}
|
||||
// TODO : ...
|
||||
|
@ -19,7 +19,7 @@ namespace ewol {
|
||||
// show : http://www.freetype.org/freetype2/docs/tutorial/step2.html
|
||||
class FontFreeType : public ewol::resource::FontBase {
|
||||
private:
|
||||
FT_Byte* m_FileBuffer;
|
||||
etk::Vector<FT_Byte> m_FileBuffer;
|
||||
int32_t m_FileSize;
|
||||
FT_Face m_fftFace;
|
||||
bool m_init;
|
||||
|
@ -156,7 +156,7 @@ static int32_t nextP2(int32_t _value) {
|
||||
ememory::SharedPtr<ewol::resource::ImageDF> ewol::resource::ImageDF::create(const etk::String& _filename, ivec2 _size) {
|
||||
EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size);
|
||||
if (_filename == "") {
|
||||
ememory::SharedPtr<ewol::resource::ImageDF> object(new ewol::resource::ImageDF());
|
||||
ememory::SharedPtr<ewol::resource::ImageDF> object(ETK_NEW(ewol::resource::ImageDF));
|
||||
if (object == nullptr) {
|
||||
EWOL_ERROR("allocation error of a resource : ??TEX??");
|
||||
return nullptr;
|
||||
@ -208,7 +208,7 @@ ememory::SharedPtr<ewol::resource::ImageDF> ewol::resource::ImageDF::create(cons
|
||||
}
|
||||
EWOL_INFO("CREATE: ImageDF: '" << TmpFilename << "' size=" << _size);
|
||||
// need to crate a new one ...
|
||||
object = ememory::SharedPtr<ewol::resource::ImageDF>(new ewol::resource::ImageDF());
|
||||
object = ememory::SharedPtr<ewol::resource::ImageDF>(ETK_NEW(ewol::resource::ImageDF));
|
||||
if (object == nullptr) {
|
||||
EWOL_ERROR("allocation error of a resource : " << _filename);
|
||||
return nullptr;
|
||||
|
@ -274,7 +274,8 @@ void ewol::resource::Texture::removeContext() {
|
||||
if (m_loaded == true) {
|
||||
// Request remove texture ...
|
||||
EWOL_DEBUG("TEXTURE: Rm [" << getId() << "] texId=" << m_texId);
|
||||
//glDeleteTextures(1, &m_texId);
|
||||
// TODO: Check if we are in the correct thread
|
||||
glDeleteTextures(1, &m_texId);
|
||||
m_loaded = false;
|
||||
}
|
||||
}
|
||||
@ -311,7 +312,7 @@ void ewol::resource::Texture::set(egami::Image _image) {
|
||||
m_realImageSize = vec2(tmp.x(), tmp.y());
|
||||
vec2 compatibilityHWSize = vec2(nextP2(tmp.x()), nextP2(tmp.y()));
|
||||
if (m_realImageSize != compatibilityHWSize) {
|
||||
EWOL_ERROR("RESIZE Image for HArwareCompatibility:" << m_realImageSize << " => " << compatibilityHWSize);
|
||||
EWOL_VERBOSE("RESIZE Image for HArwareCompatibility:" << m_realImageSize << " => " << compatibilityHWSize);
|
||||
m_data.resize(ivec2(compatibilityHWSize.x(),compatibilityHWSize.y()));
|
||||
}
|
||||
flush();
|
||||
|
@ -61,7 +61,7 @@ void ewol::resource::TextureFile::init(etk::String _genName, const etk::String&
|
||||
ememory::SharedPtr<ewol::resource::TextureFile> ewol::resource::TextureFile::create(const etk::String& _filename, ivec2 _size, ivec2 _sizeRegister) {
|
||||
EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size << " sizeRegister=" << _sizeRegister);
|
||||
if (_filename == "") {
|
||||
ememory::SharedPtr<ewol::resource::TextureFile> object(new ewol::resource::TextureFile());
|
||||
ememory::SharedPtr<ewol::resource::TextureFile> object(ETK_NEW(ewol::resource::TextureFile));
|
||||
if (object == nullptr) {
|
||||
EWOL_ERROR("allocation error of a resource : ??TEX??");
|
||||
return nullptr;
|
||||
@ -110,7 +110,7 @@ ememory::SharedPtr<ewol::resource::TextureFile> ewol::resource::TextureFile::cre
|
||||
}
|
||||
EWOL_INFO("CREATE: TextureFile: '" << tmpFilename << "' size=" << _size);
|
||||
// need to crate a new one ...
|
||||
object = ememory::SharedPtr<ewol::resource::TextureFile>(new ewol::resource::TextureFile());
|
||||
object = ememory::SharedPtr<ewol::resource::TextureFile>(ETK_NEW(ewol::resource::TextureFile));
|
||||
if (object == nullptr) {
|
||||
EWOL_ERROR("allocation error of a resource : " << _filename);
|
||||
return nullptr;
|
||||
|
@ -124,29 +124,29 @@ void ewol::widget::Image::onRegenerateDisplay() {
|
||||
}
|
||||
|
||||
void ewol::widget::Image::calculateMinMaxSize() {
|
||||
EWOL_WARNING("calculate min size: border=" << propertyBorder << " size=" << propertyImageSize << " min-size=" << propertyMinSize);
|
||||
EWOL_DEBUG("calculate min size: border=" << propertyBorder << " size=" << propertyImageSize << " min-size=" << propertyMinSize);
|
||||
vec2 imageBoder = propertyBorder->getPixel()*2.0f;
|
||||
vec2 imageSize = propertyImageSize->getPixel();
|
||||
vec2 size = propertyMinSize->getPixel();
|
||||
EWOL_WARNING(" ==> border=" << imageBoder << " size=" << imageSize << " min-size=" << size);
|
||||
EWOL_DEBUG(" ==> border=" << imageBoder << " size=" << imageSize << " min-size=" << size);
|
||||
if (imageSize != vec2(0,0)) {
|
||||
m_minSize = imageBoder+imageSize;
|
||||
m_maxSize = m_minSize;
|
||||
} else {
|
||||
vec2 imageSizeReal = m_compositing.getRealSize();
|
||||
EWOL_WARNING(" Real Size = " << imageSizeReal);
|
||||
EWOL_VERBOSE(" Real Size = " << imageSizeReal);
|
||||
vec2 min1 = imageBoder+propertyMinSize->getPixel();
|
||||
m_minSize = imageBoder+imageSizeReal;
|
||||
EWOL_WARNING(" set max : " << m_minSize << " min1=" << min1);
|
||||
EWOL_VERBOSE(" set max : " << m_minSize << " min1=" << min1);
|
||||
m_minSize.setMax(min1);
|
||||
EWOL_WARNING(" result : " << m_minSize);
|
||||
EWOL_VERBOSE(" result : " << m_minSize);
|
||||
m_maxSize = imageBoder+propertyMaxSize->getPixel();
|
||||
m_minSize.setMin(m_maxSize);
|
||||
}
|
||||
m_imageRenderSize = m_minSize;
|
||||
m_minSize.setMax(size);
|
||||
m_maxSize.setMax(m_minSize);
|
||||
EWOL_ERROR("set widget min=" << m_minSize << " max=" << m_maxSize << " with real Image size=" << m_imageRenderSize << " img size=" << imageSize << " " << propertyImageSize);
|
||||
EWOL_DEBUG("set widget min=" << m_minSize << " max=" << m_maxSize << " with real Image size=" << m_imageRenderSize << " img size=" << imageSize << " " << propertyImageSize);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ ewol::widget::Joystick::~Joystick() {
|
||||
}
|
||||
|
||||
void ewol::widget::Joystick::onRegenerateDisplay() {
|
||||
if (true == needRedraw()) {
|
||||
if (needRedraw() == true) {
|
||||
// clean the object list ...
|
||||
|
||||
/*
|
||||
@ -58,11 +58,11 @@ void ewol::widget::Joystick::onRegenerateDisplay() {
|
||||
// set background
|
||||
if (true == m_displayBackground) {
|
||||
if (m_background == "") {
|
||||
tmpOObjects = new ewol::OObject2DColored;
|
||||
tmpOObjects = ne w ewol::OObject2DColored;
|
||||
tmpOObjects->setColor(m_colorBg);
|
||||
tmpOObjects->Disc( m_size.x/2, m_size.y/2, m_size.x/2-1);
|
||||
} else {
|
||||
tmpOOtexBg = new ewol::OObject2DTextured(m_background, m_size.x, m_size.y);
|
||||
tmpOOtexBg = n ew ewol::OObject2DTextured(m_background, m_size.x, m_size.y);
|
||||
tmpOOtexBg->rectangle(0, 0, m_size.x, m_size.y);
|
||||
}
|
||||
}
|
||||
@ -70,13 +70,13 @@ void ewol::widget::Joystick::onRegenerateDisplay() {
|
||||
float sizeElement = m_size.x*m_ratio;
|
||||
if (m_foreground == "") {
|
||||
if (nullptr == tmpOObjects) {
|
||||
tmpOObjects = new ewol::OObject2DColored;
|
||||
tmpOObjects = ne w ewol::OObject2DColored;
|
||||
}
|
||||
tmpOObjects->setColor(m_colorFg);
|
||||
tmpOObjects->Disc( ((m_displayPos.x+1.0)/2.0)*(m_size.x-2*sizeElement) + sizeElement,
|
||||
((m_displayPos.y+1.0)/2.0)*(m_size.y-2*sizeElement) + sizeElement, sizeElement);
|
||||
} else {
|
||||
tmpOOtexFg = new ewol::OObject2DTextured(m_foreground,sizeElement*2, sizeElement*2);
|
||||
tmpOOtexFg = ne w ewol::OObject2DTextured(m_foreground,sizeElement*2, sizeElement*2);
|
||||
tmpOOtexFg->rectangle(((m_displayPos.x+1.0)/2.0)*(m_size.x-2*sizeElement),
|
||||
((m_displayPos.y+1.0)/2.0)*(m_size.y-2*sizeElement), sizeElement*2, sizeElement*2);
|
||||
}
|
||||
@ -123,7 +123,7 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) {
|
||||
// clip if needed ...
|
||||
if (m_distance > 1.0) {
|
||||
m_distance = 1.0;
|
||||
// regenerate new display position :
|
||||
// regenerate n ew display position :
|
||||
m_displayPos.x = cos(m_angle)*m_distance;
|
||||
m_displayPos.y = sin(m_angle)*m_distance;
|
||||
}
|
||||
@ -158,19 +158,19 @@ bool ewol::widget::Joystick::onEventInput(const ewol::event::Input& _event) {
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::Joystick::ratio(float newRatio) {
|
||||
if (newRatio > 1) {
|
||||
newRatio = 1;
|
||||
void ewol::widget::Joystick::ratio(float _newRatio) {
|
||||
if (_newRatio > 1) {
|
||||
_newRatio = 1;
|
||||
}
|
||||
m_ratio = newRatio;
|
||||
m_ratio = _newRatio;
|
||||
EWOL_INFO("Set default Joystick ratio at " << m_ratio);
|
||||
}
|
||||
|
||||
|
||||
void ewol::widget::Joystick::background(etk::String imageNameInData, bool display) {
|
||||
void ewol::widget::Joystick::background(etk::String _imageNameInData, bool _display) {
|
||||
// TODO : check if it existed
|
||||
m_background = imageNameInData;
|
||||
m_displayBackground = display;
|
||||
m_background = _imageNameInData;
|
||||
m_displayBackground = _display;
|
||||
EWOL_INFO("Set default Joystick background at " << m_background << " display it=" << m_displayBackground);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ ewol::widget::List::List() {
|
||||
ewol::widget::List::~List() {
|
||||
//clean all the object
|
||||
for (size_t iii=0; iii<m_listOObject.size(); iii++) {
|
||||
delete(m_listOObject[iii]);
|
||||
ETK_DELETE(ewol::Compositing, m_listOObject[iii]);
|
||||
m_listOObject[iii] = nullptr;
|
||||
}
|
||||
m_listOObject.clear();
|
||||
@ -71,11 +71,12 @@ void ewol::widget::List::calculateMinMaxSize() {
|
||||
}
|
||||
|
||||
void ewol::widget::List::addOObject(ewol::Compositing* _newObject, int32_t _pos) {
|
||||
if (nullptr == _newObject) {
|
||||
if (_newObject == nullptr) {
|
||||
EWOL_ERROR("Try to add an empty object in the Widget generic display system");
|
||||
return;
|
||||
}
|
||||
if (_pos < 0 || (size_t)_pos >= m_listOObject.size() ) {
|
||||
if ( _pos < 0
|
||||
|| (size_t)_pos >= m_listOObject.size() ) {
|
||||
m_listOObject.pushBack(_newObject);
|
||||
} else {
|
||||
m_listOObject.insert(m_listOObject.begin()+_pos, _newObject);
|
||||
@ -84,7 +85,7 @@ void ewol::widget::List::addOObject(ewol::Compositing* _newObject, int32_t _pos)
|
||||
|
||||
void ewol::widget::List::clearOObjectList() {
|
||||
for (size_t iii=0; iii<m_listOObject.size(); iii++) {
|
||||
delete(m_listOObject[iii]);
|
||||
ETK_DELETE(ewol::Compositing, m_listOObject[iii]);
|
||||
m_listOObject[iii] = nullptr;
|
||||
}
|
||||
m_listOObject.clear();
|
||||
@ -92,7 +93,7 @@ void ewol::widget::List::clearOObjectList() {
|
||||
|
||||
void ewol::widget::List::onDraw() {
|
||||
for (size_t iii=0; iii<m_listOObject.size(); iii++) {
|
||||
if (nullptr != m_listOObject[iii]) {
|
||||
if (m_listOObject[iii] != nullptr) {
|
||||
m_listOObject[iii]->draw();
|
||||
}
|
||||
}
|
||||
@ -100,8 +101,7 @@ void ewol::widget::List::onDraw() {
|
||||
}
|
||||
|
||||
void ewol::widget::List::onRegenerateDisplay() {
|
||||
if (true == needRedraw()) {
|
||||
|
||||
if (needRedraw() == true) {
|
||||
// clean the object list ...
|
||||
clearOObjectList();
|
||||
//EWOL_DEBUG("OnRegenerateDisplay(" << m_size.x << "," << m_size.y << ")");
|
||||
@ -128,7 +128,7 @@ void ewol::widget::List::onRegenerateDisplay() {
|
||||
|
||||
etk::Vector<int32_t> listSizeColomn;
|
||||
|
||||
ewol::compositing::Drawing * BGOObjects = new ewol::compositing::Drawing();
|
||||
ewol::compositing::Drawing * BGOObjects = ETK_NEW(ewol::compositing::Drawing);
|
||||
etk::Color<> basicBG = getBasicBG();
|
||||
BGOObjects->setColor(basicBG);
|
||||
BGOObjects->setPos(vec3(0, 0, 0) );
|
||||
@ -170,7 +170,7 @@ void ewol::widget::List::onRegenerateDisplay() {
|
||||
etk::Color<> bg;
|
||||
getElement(jjj, iii, myTextToWrite, fg, bg);
|
||||
|
||||
ewol::compositing::Text * tmpText = new ewol::compositing::Text();
|
||||
ewol::compositing::Text * tmpText = ETK_NEW(ewol::compositing::Text);
|
||||
if (nullptr != tmpText) {
|
||||
// get font size :
|
||||
int32_t tmpFontHeight = tmpText->calculateSize(char32_t('A')).y();
|
||||
|
@ -62,7 +62,7 @@ ewol::widget::ListFileSystem::~ListFileSystem() {
|
||||
void ewol::widget::ListFileSystem::clearList() {
|
||||
for (auto &it : m_list) {
|
||||
if (it != nullptr) {
|
||||
delete(it);
|
||||
ETK_DELETE(etk::FSNode, it);
|
||||
it = nullptr;
|
||||
}
|
||||
}
|
||||
@ -79,7 +79,7 @@ void ewol::widget::ListFileSystem::regenerateView() {
|
||||
m_list.clear();
|
||||
m_originScrooled.setValue(0,0);
|
||||
etk::FSNode tmpFolder(*propertyPath);
|
||||
// get the new list :
|
||||
// get the list:
|
||||
m_list = tmpFolder.folderGetSubList(*propertyShowHidden, *propertyShowFolder, *propertyShowFile, *propertyFilter);
|
||||
// request a redraw ...
|
||||
markToRedraw();
|
||||
|
@ -63,5 +63,5 @@ class MainApplication : public ewol::context::Application {
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
// second possibility
|
||||
return ewol::run(new MainApplication(), _argc, _argv);
|
||||
return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv);
|
||||
}
|
@ -95,7 +95,7 @@ namespace appl {
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
// second possibility
|
||||
return ewol::run(new appl::MainApplication(), _argc, _argv);
|
||||
return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv);
|
||||
}
|
||||
//! [ewol_sample_HW_main_main]
|
||||
|
||||
|
@ -62,5 +62,5 @@ class MainApplication : public ewol::context::Application {
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
// second possibility
|
||||
return ewol::run(new MainApplication(), _argc, _argv);
|
||||
return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv);
|
||||
}
|
@ -10,8 +10,8 @@
|
||||
#define NAME "Application"
|
||||
|
||||
TEST(TestEwolApplication, Creation) {
|
||||
ewol::context::Application* tmpAppl = new ewol::context::Application();
|
||||
ewol::context::Application* tmpAppl = ETK_NEW(ewol::context::Application);
|
||||
EXPECT_NE(tmpAppl, nullptr);
|
||||
delete tmpAppl;
|
||||
ETK_DELETE(ewol::context::Application, tmpAppl);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class MainApplication : public ewol::context::Application {
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
// second possibility
|
||||
return ewol::run(new MainApplication(), _argc, _argv);
|
||||
return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv);
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,7 +90,7 @@ class MainApplication : public ewol::context::Application {
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
// second possibility
|
||||
return ewol::run(new MainApplication(), _argc, _argv);
|
||||
return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user