[DEV] set object manager thread safe, set MacOs texture correct size and remove store of all texture
This commit is contained in:
parent
e6cab1e0cb
commit
f91a2f6009
@ -23,6 +23,7 @@ ewol::object::Manager::Manager(ewol::Context& _context) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
ewol::object::Manager::~Manager() {
|
ewol::object::Manager::~Manager() {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_workerList.clear();
|
m_workerList.clear();
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
if (m_eObjectList.size()!=0) {
|
if (m_eObjectList.size()!=0) {
|
||||||
@ -36,6 +37,7 @@ ewol::object::Manager::~Manager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::displayListObject() {
|
void ewol::object::Manager::displayListObject() {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
EWOL_INFO("List loaded object : ");
|
EWOL_INFO("List loaded object : ");
|
||||||
for (auto &it : m_eObjectList) {
|
for (auto &it : m_eObjectList) {
|
||||||
ewol::ObjectShared element = it.lock();
|
ewol::ObjectShared element = it.lock();
|
||||||
@ -46,6 +48,7 @@ void ewol::object::Manager::displayListObject() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::unInit() {
|
void ewol::object::Manager::unInit() {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
EWOL_DEBUG(" == > Un-Init Object-Manager");
|
EWOL_DEBUG(" == > Un-Init Object-Manager");
|
||||||
if (m_workerList.size() > 0) {
|
if (m_workerList.size() > 0) {
|
||||||
EWOL_DEBUG(" == > Remove all workers");
|
EWOL_DEBUG(" == > Remove all workers");
|
||||||
@ -64,6 +67,7 @@ void ewol::object::Manager::unInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::add(const ewol::ObjectShared& _object) {
|
void ewol::object::Manager::add(const ewol::ObjectShared& _object) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (_object == nullptr) {
|
if (_object == nullptr) {
|
||||||
EWOL_ERROR("try to add an inexistant Object in manager");
|
EWOL_ERROR("try to add an inexistant Object in manager");
|
||||||
}
|
}
|
||||||
@ -71,11 +75,13 @@ void ewol::object::Manager::add(const ewol::ObjectShared& _object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t ewol::object::Manager::getNumberObject() {
|
int32_t ewol::object::Manager::getNumberObject() {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
return m_eObjectList.size();
|
return m_eObjectList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean all Object that request an autoRemove ...
|
// clean all Object that request an autoRemove ...
|
||||||
void ewol::object::Manager::cleanInternalRemoved() {
|
void ewol::object::Manager::cleanInternalRemoved() {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
size_t nbObject = m_eObjectList.size();
|
size_t nbObject = m_eObjectList.size();
|
||||||
EWOL_VERBOSE("Clean Object List (if needed) : " << m_eObjectList.size() << " elements");
|
EWOL_VERBOSE("Clean Object List (if needed) : " << m_eObjectList.size() << " elements");
|
||||||
auto it(m_eObjectList.begin());
|
auto it(m_eObjectList.begin());
|
||||||
@ -92,6 +98,7 @@ void ewol::object::Manager::cleanInternalRemoved() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ewol::ObjectShared ewol::object::Manager::get(const std::string& _name) {
|
ewol::ObjectShared ewol::object::Manager::get(const std::string& _name) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
if (_name == "") {
|
if (_name == "") {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -107,15 +114,18 @@ ewol::ObjectShared ewol::object::Manager::get(const std::string& _name) {
|
|||||||
|
|
||||||
|
|
||||||
ewol::ObjectShared ewol::object::Manager::getObjectNamed(const std::string& _name) {
|
ewol::ObjectShared ewol::object::Manager::getObjectNamed(const std::string& _name) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
return ewol::object::Manager::get(_name);
|
return ewol::object::Manager::get(_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::object::Manager::workerAdd(const ewol::ObjectShared& _worker) {
|
void ewol::object::Manager::workerAdd(const ewol::ObjectShared& _worker) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_workerList.push_back(_worker);
|
m_workerList.push_back(_worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) {
|
void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
auto it(m_workerList.begin());
|
auto it(m_workerList.begin());
|
||||||
while (it != m_workerList.end()) {
|
while (it != m_workerList.end()) {
|
||||||
if (*it == _worker) {
|
if (*it == _worker) {
|
||||||
@ -127,6 +137,7 @@ void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::timeCall(int64_t _localTime) {
|
void ewol::object::Manager::timeCall(int64_t _localTime) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
int64_t previousTime = m_lastPeriodicCallTime;
|
int64_t previousTime = m_lastPeriodicCallTime;
|
||||||
m_lastPeriodicCallTime = _localTime;
|
m_lastPeriodicCallTime = _localTime;
|
||||||
if (periodicCall.size() <= 0) {
|
if (periodicCall.size() <= 0) {
|
||||||
@ -138,9 +149,11 @@ void ewol::object::Manager::timeCall(int64_t _localTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ewol::object::Manager::timeCallResume(int64_t _localTime) {
|
void ewol::object::Manager::timeCallResume(int64_t _localTime) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_lastPeriodicCallTime = _localTime;
|
m_lastPeriodicCallTime = _localTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ewol::object::Manager::timeCallHave() {
|
bool ewol::object::Manager::timeCallHave() {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
return periodicCall.size() > 0;
|
return periodicCall.size() > 0;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ namespace ewol {
|
|||||||
class Context;
|
class Context;
|
||||||
namespace object {
|
namespace object {
|
||||||
class Manager : public esignal::Interface {
|
class Manager : public esignal::Interface {
|
||||||
|
protected:
|
||||||
|
std::recursive_mutex m_mutex;
|
||||||
private:
|
private:
|
||||||
std::vector<ewol::ObjectWeak> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
|
std::vector<ewol::ObjectWeak> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
|
||||||
Context& m_context;
|
Context& m_context;
|
||||||
|
@ -43,7 +43,9 @@ void ewol::resource::TextureFile::init(std::string _genName, const std::string&
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __TARGET_OS__Android
|
#if defined(__TARGET_OS__Android) \
|
||||||
|
|| defined(__TARGET_OS__MacOs) \
|
||||||
|
|| defined(__TARGET_OS__IOs)
|
||||||
/**
|
/**
|
||||||
* @brief get the next power 2 if the input
|
* @brief get the next power 2 if the input
|
||||||
* @param[in] _value Value that we want the next power of 2
|
* @param[in] _value Value that we want the next power of 2
|
||||||
@ -88,13 +90,11 @@ ememory::SharedPtr<ewol::resource::TextureFile> ewol::resource::TextureFile::cre
|
|||||||
if (etk::end_with(_filename, ".svg") == false) {
|
if (etk::end_with(_filename, ".svg") == false) {
|
||||||
_size = ewol::resource::TextureFile::sizeAuto;
|
_size = ewol::resource::TextureFile::sizeAuto;
|
||||||
}
|
}
|
||||||
#ifdef __TARGET_OS__MacOs
|
|
||||||
EWOL_ERROR("TODO : remove this strange hack");
|
|
||||||
_size = ivec2(64,64);
|
|
||||||
#endif
|
|
||||||
if (_size.x()>0 && _size.y()>0) {
|
if (_size.x()>0 && _size.y()>0) {
|
||||||
EWOL_VERBOSE(" == > specific size : " << _size);
|
EWOL_VERBOSE(" == > specific size : " << _size);
|
||||||
#ifdef __TARGET_OS__Android
|
#if defined(__TARGET_OS__Android) \
|
||||||
|
|| defined(__TARGET_OS__MacOs) \
|
||||||
|
|| defined(__TARGET_OS__IOs)
|
||||||
_size.setValue(nextP2(_size.x()), nextP2(_size.y()));
|
_size.setValue(nextP2(_size.x()), nextP2(_size.y()));
|
||||||
#endif
|
#endif
|
||||||
if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) {
|
if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) {
|
||||||
|
@ -100,7 +100,7 @@ bool ewol::resource::Texture::updateContext() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" << m_texId << " type=" << m_data.getType());
|
EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" << m_texId << " type=" << m_data.getType());
|
||||||
egami::store(m_data, std::string("~/texture_") + etk::to_string(getId()) + ".bmp");
|
//egami::store(m_data, std::string("~/texture_") + etk::to_string(getId()) + ".bmp");
|
||||||
glTexImage2D(GL_TEXTURE_2D, // Target
|
glTexImage2D(GL_TEXTURE_2D, // Target
|
||||||
0, // Level
|
0, // Level
|
||||||
typeObject, // Format internal
|
typeObject, // Format internal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user