[DEV] set object manager thread safe, set MacOs texture correct size and remove store of all texture

This commit is contained in:
Edouard DUPIN 2016-09-21 21:35:13 +02:00
parent e6cab1e0cb
commit f91a2f6009
4 changed files with 22 additions and 7 deletions

View File

@ -23,6 +23,7 @@ ewol::object::Manager::Manager(ewol::Context& _context) :
}
ewol::object::Manager::~Manager() {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_workerList.clear();
bool hasError = false;
if (m_eObjectList.size()!=0) {
@ -36,6 +37,7 @@ ewol::object::Manager::~Manager() {
}
void ewol::object::Manager::displayListObject() {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
EWOL_INFO("List loaded object : ");
for (auto &it : m_eObjectList) {
ewol::ObjectShared element = it.lock();
@ -46,6 +48,7 @@ void ewol::object::Manager::displayListObject() {
}
void ewol::object::Manager::unInit() {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
EWOL_DEBUG(" == > Un-Init Object-Manager");
if (m_workerList.size() > 0) {
EWOL_DEBUG(" == > Remove all workers");
@ -64,6 +67,7 @@ void ewol::object::Manager::unInit() {
}
void ewol::object::Manager::add(const ewol::ObjectShared& _object) {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (_object == nullptr) {
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() {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
return m_eObjectList.size();
}
// clean all Object that request an autoRemove ...
void ewol::object::Manager::cleanInternalRemoved() {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
size_t nbObject = m_eObjectList.size();
EWOL_VERBOSE("Clean Object List (if needed) : " << m_eObjectList.size() << " elements");
auto it(m_eObjectList.begin());
@ -92,6 +98,7 @@ void ewol::object::Manager::cleanInternalRemoved() {
}
ewol::ObjectShared ewol::object::Manager::get(const std::string& _name) {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
if (_name == "") {
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) {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
return ewol::object::Manager::get(_name);
}
void ewol::object::Manager::workerAdd(const ewol::ObjectShared& _worker) {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_workerList.push_back(_worker);
}
void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
auto it(m_workerList.begin());
while (it != m_workerList.end()) {
if (*it == _worker) {
@ -127,6 +137,7 @@ void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) {
}
void ewol::object::Manager::timeCall(int64_t _localTime) {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
int64_t previousTime = m_lastPeriodicCallTime;
m_lastPeriodicCallTime = _localTime;
if (periodicCall.size() <= 0) {
@ -138,9 +149,11 @@ void ewol::object::Manager::timeCall(int64_t _localTime) {
}
void ewol::object::Manager::timeCallResume(int64_t _localTime) {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
m_lastPeriodicCallTime = _localTime;
}
bool ewol::object::Manager::timeCallHave() {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
return periodicCall.size() > 0;
}

View File

@ -14,6 +14,8 @@ namespace ewol {
class Context;
namespace object {
class Manager : public esignal::Interface {
protected:
std::recursive_mutex m_mutex;
private:
std::vector<ewol::ObjectWeak> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
Context& m_context;

View File

@ -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
* @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) {
_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) {
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()));
#endif
if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) {

View File

@ -100,7 +100,7 @@ bool ewol::resource::Texture::updateContext() {
break;
}
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
0, // Level
typeObject, // Format internal