[DEV] update to the new ETK allocator wrapper
This commit is contained in:
parent
0f14d7341a
commit
3be9f44264
@ -545,18 +545,18 @@ extern "C" {
|
||||
s_applicationInit = NULL;
|
||||
gale::Application* localApplication = NULL;
|
||||
// call the basic init of all application (that call us ...)
|
||||
main(0,NULL);
|
||||
main(0, NULL);
|
||||
localApplication = s_applicationInit;
|
||||
s_applicationInit = NULL;
|
||||
if (org_gale_GaleConstants_GALE_APPL_TYPE_ACTIVITY == _typeApplication) {
|
||||
tmpContext = new AndroidContext(localApplication, _env, _classBase, _objCallback, AndroidContext::appl_application);
|
||||
tmpContext = ETK_NEW(AndroidContext, localApplication, _env, _classBase, _objCallback, AndroidContext::appl_application);
|
||||
} else if (org_gale_GaleConstants_GALE_APPL_TYPE_WALLPAPER == _typeApplication) {
|
||||
tmpContext = new AndroidContext(localApplication, _env, _classBase, _objCallback, AndroidContext::appl_wallpaper);
|
||||
tmpContext = ETK_NEW(AndroidContext, localApplication, _env, _classBase, _objCallback, AndroidContext::appl_wallpaper);
|
||||
} else {
|
||||
GALE_CRITICAL(" try to create an instance with no apply type: " << _typeApplication);
|
||||
return -1;
|
||||
}
|
||||
if (nullptr == tmpContext) {
|
||||
if (tmpContext == nullptr) {
|
||||
GALE_ERROR("Can not allocate the main context instance _id=" << (s_listInstance.size()-1));
|
||||
return -1;
|
||||
}
|
||||
@ -572,24 +572,24 @@ extern "C" {
|
||||
GALE_DEBUG("** remove JVM Pointer **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0) {
|
||||
|| _id < 0) {
|
||||
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
return;
|
||||
}
|
||||
if (nullptr == s_listInstance[_id]) {
|
||||
if (s_listInstance[_id] == nullptr) {
|
||||
GALE_ERROR("the requested instance _id=" << (int32_t)_id << " is already removed ...");
|
||||
return;
|
||||
}
|
||||
s_listInstance[_id]->unInit(_env);
|
||||
delete(s_listInstance[_id]);
|
||||
ETK_DELETE(AndroidContext, s_listInstance[_id]);
|
||||
s_listInstance[_id]=nullptr;
|
||||
}
|
||||
void Java_org_gale_Gale_EWtouchEvent(JNIEnv* _env, jobject _thiz, jint _id) {
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
GALE_DEBUG(" == > Touch Event");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
|| _id < 0
|
||||
|| s_listInstance[_id] == nullptr) {
|
||||
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
// TODO : generate error in java to stop the current instance
|
||||
return;
|
||||
@ -603,8 +603,8 @@ extern "C" {
|
||||
GALE_DEBUG("** Activity on Create **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
|| _id < 0
|
||||
|| s_listInstance[_id] == nullptr) {
|
||||
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
// TODO : generate error in java to stop the current instance
|
||||
return;
|
||||
@ -619,8 +619,8 @@ extern "C" {
|
||||
GALE_DEBUG("** Activity on Start **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
|| _id < 0
|
||||
|| s_listInstance[_id]== nullptr) {
|
||||
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
// TODO : generate error in java to stop the current instance
|
||||
return;
|
||||
@ -634,8 +634,8 @@ extern "C" {
|
||||
GALE_DEBUG("** Activity on Re-Start **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
|| _id < 0
|
||||
|| s_listInstance[_id] == nullptr) {
|
||||
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
// TODO : generate error in java to stop the current instance
|
||||
return;
|
||||
@ -648,8 +648,8 @@ extern "C" {
|
||||
GALE_DEBUG("** Activity on resume **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
|| _id < 0
|
||||
|| s_listInstance[_id] == nullptr) {
|
||||
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
// TODO : generate error in java to stop the current instance
|
||||
return;
|
||||
@ -662,8 +662,8 @@ extern "C" {
|
||||
GALE_DEBUG("** Activity on pause **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
|| _id < 0
|
||||
|| s_listInstance[_id] == nullptr) {
|
||||
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
// TODO : generate error in java to stop the current instance
|
||||
return;
|
||||
@ -678,8 +678,8 @@ extern "C" {
|
||||
GALE_DEBUG("** Activity on Stop **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
|| _id < 0
|
||||
|| s_listInstance[_id] == nullptr) {
|
||||
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
// TODO : generate error in java to stop the current instance
|
||||
return;
|
||||
@ -692,8 +692,8 @@ extern "C" {
|
||||
GALE_DEBUG("** Activity on Destroy **");
|
||||
GALE_DEBUG("*******************************************");
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
|| _id < 0
|
||||
|| s_listInstance[_id] == nullptr) {
|
||||
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
// TODO : generate error in java to stop the current instance
|
||||
return;
|
||||
@ -715,8 +715,8 @@ extern "C" {
|
||||
jfloat _y) {
|
||||
ethread::UniqueLock lock(g_interfaceMutex);
|
||||
if( _id >= (int32_t)s_listInstance.size()
|
||||
|| _id<0
|
||||
|| nullptr == s_listInstance[_id] ) {
|
||||
|| _id < 0
|
||||
|| s_listInstance[_id] == nullptr) {
|
||||
GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
// TODO : generate error in java to stop the current instance
|
||||
return;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <echrono/Time.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
#include <etk/Allocator.hpp>
|
||||
ETK_DECLARE_TYPE(gale::Context);
|
||||
|
||||
/**
|
||||
@ -621,6 +622,13 @@ bool gale::Context::OS_Draw(bool _displayEveryTime) {
|
||||
m_simulationFile.filePuts(etk::toString(_displayEveryTime));
|
||||
m_simulationFile.filePuts("\n");
|
||||
}
|
||||
{
|
||||
static int32_t countMemeCheck = 0;
|
||||
if (countMemeCheck++ >= 10*16) {
|
||||
countMemeCheck = 0;
|
||||
ETK_MEM_SHOW_LOG(true);
|
||||
}
|
||||
}
|
||||
//GALE_VERBOSE("Call draw");
|
||||
echrono::Steady currentTime = echrono::Steady::now();
|
||||
//echrono::Time currentTime2 = echrono::Time::now();
|
||||
|
@ -251,9 +251,9 @@ int gale::run(gale::Application* _application, int _argc, const char *_argv[]) {
|
||||
void IOs::createInterface() {
|
||||
etk::init(l_argc, l_argv);
|
||||
GALE_INFO("Create new interface");
|
||||
interface = new MacOSInterface(l_application, l_argc, l_argv);
|
||||
interface = ETK_NEW(MacOSInterface, l_application, l_argc, l_argv);
|
||||
l_application = nullptr;
|
||||
if (nullptr == interface) {
|
||||
if (interface == nullptr) {
|
||||
GALE_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
|
||||
return;
|
||||
}
|
||||
@ -263,7 +263,7 @@ void IOs::releaseInterface() {
|
||||
if (interface != nullptr) {
|
||||
GALE_INFO("Remove interface");
|
||||
}
|
||||
delete(interface);
|
||||
ETK_DELETE(MacOSInterface, interface);
|
||||
interface = nullptr;
|
||||
}
|
||||
|
||||
|
@ -1295,12 +1295,13 @@ class X11Interface : public gale::Context {
|
||||
GALE_CRITICAL("Unknow thys type of bitDepth : " << depth);
|
||||
return;
|
||||
}
|
||||
char* tmpVal = new char[4*dataImage.getWidth()*dataImage.getHeight()];
|
||||
etk::Vector<char> tmpVal;
|
||||
tmpVal.resize(4*dataImage.getWidth()*dataImage.getHeight(), 0);
|
||||
if (tmpVal == NULL) {
|
||||
GALE_CRITICAL("Allocation error ...");
|
||||
return;
|
||||
}
|
||||
char* tmpPointer = tmpVal;
|
||||
char* tmpPointer = &tmpVal[0];
|
||||
switch(depth) {
|
||||
case 16:
|
||||
for(ivec2 pos(0,0); pos.y()<dataImage.getHeight(); pos.setY(pos.y()+1)) {
|
||||
@ -1349,7 +1350,7 @@ class X11Interface : public gale::Context {
|
||||
depth,
|
||||
ZPixmap,
|
||||
0,
|
||||
(char*)tmpVal,
|
||||
(char*)&tmpVal[0],
|
||||
dataImage.getWidth(),
|
||||
dataImage.getHeight(),
|
||||
32,
|
||||
@ -1420,7 +1421,6 @@ class X11Interface : public gale::Context {
|
||||
|
||||
myImage->data = nullptr;
|
||||
XDestroyImage(myImage);
|
||||
delete[] tmpVal;
|
||||
#endif
|
||||
}
|
||||
/****************************************************************************************/
|
||||
|
@ -1401,12 +1401,9 @@ class WAYLANDInterface : public gale::Context {
|
||||
GALE_CRITICAL("Unknow thys type of bitDepth : " << depth);
|
||||
return;
|
||||
}
|
||||
char* tmpVal = new char[4*dataImage.getWidth()*dataImage.getHeight()];
|
||||
if (nullptr == tmpVal) {
|
||||
GALE_CRITICAL("Allocation error ...");
|
||||
return;
|
||||
}
|
||||
char* tmpPointer = tmpVal;
|
||||
etk::Vector<char> tmpVal
|
||||
tmpVal.resize(4*dataImage.getWidth()*dataImage.getHeight(), 0);
|
||||
char* tmpPointer = &tmpVal[0];
|
||||
switch(depth) {
|
||||
case 16:
|
||||
for(ivec2 pos(0,0); pos.y()<dataImage.getHeight(); pos.setY(pos.y()+1)) {
|
||||
@ -1522,7 +1519,6 @@ class WAYLANDInterface : public gale::Context {
|
||||
|
||||
myImage->data = nullptr;
|
||||
XDestroyImage(myImage);
|
||||
delete[] tmpVal;
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
@ -747,8 +747,9 @@ bool gale::openGL::deleteBuffers(etk::Vector<uint32_t>& _buffers) {
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
//glDeleteBuffers(_buffers.size(), &_buffers[0]);
|
||||
//CHECK_GL_ERROR("glDeleteBuffers", __LINE__);
|
||||
// TODO: Check if we are in the correct thread
|
||||
glDeleteBuffers(_buffers.size(), &_buffers[0]);
|
||||
CHECK_GL_ERROR("glDeleteBuffers", __LINE__);
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
@ -860,8 +861,9 @@ void gale::openGL::shader::remove(int64_t& _shader) {
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
//glDeleteShader(GLuint(_shader));
|
||||
//CHECK_GL_ERROR("glDeleteShader", __LINE__);
|
||||
// TODO: Check if we are in the correct thread
|
||||
glDeleteShader(GLuint(_shader));
|
||||
CHECK_GL_ERROR("glDeleteShader", __LINE__);
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
@ -926,8 +928,9 @@ void gale::openGL::program::remove(int64_t& _prog) {
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
if (s_simulationMode == false) {
|
||||
#endif
|
||||
//glDeleteProgram(GLuint(_prog));
|
||||
//CHECK_GL_ERROR("glDeleteProgram", __LINE__);
|
||||
// TODO: Check if we are in the correct thread
|
||||
glDeleteProgram(GLuint(_prog));
|
||||
CHECK_GL_ERROR("glDeleteProgram", __LINE__);
|
||||
#ifdef GALE_BUILD_SIMULATION
|
||||
}
|
||||
#endif
|
||||
|
@ -341,11 +341,11 @@ void gale::resource::Program::reload() {
|
||||
}
|
||||
// remove previous data ...
|
||||
if (m_fileData != nullptr) {
|
||||
delete[] m_fileData;
|
||||
del ete[] m_fileData;
|
||||
m_fileData = 0;
|
||||
}
|
||||
// allocate data
|
||||
m_fileData = new char[fileSize+5];
|
||||
m_fileData = ne w char[fileSize+5];
|
||||
if (m_fileData == nullptr) {
|
||||
GALE_ERROR("Error Memory allocation size=" << fileSize);
|
||||
return;
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#define DECLARE_RESOURCE_FACTORY(className) \
|
||||
template<typename ... GALE_TYPE> static ememory::SharedPtr<className> create( GALE_TYPE&& ... _all ) { \
|
||||
ememory::SharedPtr<className> resource(new className()); \
|
||||
ememory::SharedPtr<className> resource(ETK_NEW(className)); \
|
||||
if (resource == nullptr) { \
|
||||
GALE_ERROR("Factory resource error"); \
|
||||
return nullptr; \
|
||||
@ -43,7 +43,7 @@
|
||||
} \
|
||||
return resource; \
|
||||
} \
|
||||
resource = ememory::SharedPtr<className>(new className()); \
|
||||
resource = ememory::SharedPtr<className>(ETK_NEW(className)); \
|
||||
if (resource == nullptr) { \
|
||||
GALE_ERROR("allocation error of a resource : " << _name); \
|
||||
return nullptr; \
|
||||
@ -70,7 +70,7 @@
|
||||
if (resource != nullptr) { \
|
||||
return resource; \
|
||||
} \
|
||||
resource = ememory::SharedPtr<className>(new className()); \
|
||||
resource = ememory::SharedPtr<className>(ETK_NEW(className)); \
|
||||
if (resource == nullptr) { \
|
||||
GALE_ERROR("allocation error of a resource : " << uniqueName); \
|
||||
return nullptr; \
|
||||
@ -150,7 +150,7 @@ namespace gale {
|
||||
protected:
|
||||
/**
|
||||
* @brief Add a type of the list of Object.
|
||||
* @param[in] _type new type to add.
|
||||
* @param[in] _type Type to add.
|
||||
*/
|
||||
void addResourceType(const char* _type);
|
||||
protected:
|
||||
@ -165,7 +165,7 @@ namespace gale {
|
||||
};
|
||||
/**
|
||||
* @brief get the resource name
|
||||
* @param[in] _name The new name
|
||||
* @param[in] _name The name to set.
|
||||
*/
|
||||
void setName(const etk::String& _name) {
|
||||
m_name = _name;
|
||||
|
@ -45,7 +45,7 @@ gale::resource::Texture::Texture() :
|
||||
m_size(0,0),
|
||||
m_dataType(gale::resource::Texture::dataType::int16),
|
||||
m_dataColorSpace(gale::resource::Texture::color::mono) {
|
||||
addResourceType("gale::compositing::Texture");
|
||||
addResourceType("gale::resource::Texture");
|
||||
}
|
||||
|
||||
gale::resource::Texture::~Texture() {
|
||||
@ -58,7 +58,7 @@ bool gale::resource::Texture::updateContext() {
|
||||
//Lock error ==> try later ...
|
||||
return false;
|
||||
}
|
||||
if (false == m_loaded) {
|
||||
if (m_loaded == false) {
|
||||
// Request a new texture at openGl :
|
||||
glGenTextures(1, &m_texId);
|
||||
}
|
||||
@ -94,7 +94,8 @@ void gale::resource::Texture::removeContext() {
|
||||
if (true == m_loaded) {
|
||||
// Request remove texture ...
|
||||
GALE_INFO("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;
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class MainApplication : public gale::Application {
|
||||
* @return std IO
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
return gale::run(new MainApplication(), _argc, _argv);
|
||||
return gale::run(ETK_NEW(appl::MainApplication)(), _argc, _argv);
|
||||
}
|
||||
//! [gale_declare_main]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user