From f471429ac38b76db01f7e4b73dd2e7b23c6c4dea Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 22 Apr 2016 23:46:19 +0200 Subject: [PATCH] [DEBUG] try to find the problem of opening png file --- ewol/compositing/Image.cpp | 7 +++--- ewol/resource/Image.cpp | 33 +++++++++++++------------- ewol/resource/Texture.cpp | 7 ++++-- tools/visual_test/appl/MainWindows.cpp | 12 ++++++++++ tools/visual_test/appl/MainWindows.h | 1 + 5 files changed, 39 insertions(+), 21 deletions(-) diff --git a/ewol/compositing/Image.cpp b/ewol/compositing/Image.cpp index c62cd812..d62273f3 100644 --- a/ewol/compositing/Image.cpp +++ b/ewol/compositing/Image.cpp @@ -248,8 +248,8 @@ void ewol::compositing::Image::printPart(const vec2& _size, void ewol::compositing::Image::setSource(const std::string& _newFile, const vec2& _size) { clear(); - std::shared_ptr resource(m_resource); - std::shared_ptr resourceDF(m_resourceDF); + std::shared_ptr resource = m_resource; + std::shared_ptr resourceDF = m_resourceDF; m_filename = _newFile; m_requestSize = _size; m_resource.reset(); @@ -284,7 +284,8 @@ void ewol::compositing::Image::setSource(const std::string& _newFile, const vec2 } bool ewol::compositing::Image::hasSources() { - return (m_resource != nullptr || m_resourceDF != nullptr); + return m_resource != nullptr + || m_resourceDF != nullptr; } diff --git a/ewol/resource/Image.cpp b/ewol/resource/Image.cpp index 27ffc63d..2a345f49 100644 --- a/ewol/resource/Image.cpp +++ b/ewol/resource/Image.cpp @@ -26,18 +26,19 @@ void ewol::resource::TextureFile::init() { ewol::resource::Texture::init(); } -void ewol::resource::TextureFile::init(std::string _genName, const std::string& _tmpfileName, const ivec2& _size) { +void ewol::resource::TextureFile::init(std::string _genName, const std::string& _tmpFilename, const ivec2& _size) { std::unique_lock lock(m_mutex); ewol::resource::Texture::init(_genName); - EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpfileName=" << _tmpfileName << " size=" << _size); - if (egami::load(m_data, _tmpfileName, _size) == false) { - EWOL_ERROR("ERROR when loading the image : " << _tmpfileName); + EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpFilename=" << _tmpFilename << " size=" << _size); + if (egami::load(m_data, _tmpFilename, _size) == false) { + EWOL_ERROR("ERROR when loading the image : " << _tmpFilename); } + //egami::store(m_data, "tmpResult.bmp"); ivec2 tmp = m_data.getSize(); m_realImageSize = vec2(tmp.x(), tmp.y()); #ifdef GENERATE_DISTANCE_FIELD_MODE - //egami::generateDistanceFieldFile(_tmpfileName, std::string(_tmpfileName, 0, _tmpfileName.size()-4) + ".bmp"); - egami::generateDistanceFieldFile(_tmpfileName, std::string(_tmpfileName, 0, _tmpfileName.size()-4) + ".edf"); + //egami::generateDistanceFieldFile(_tmpFilename, std::string(_tmpFilename, 0, _tmpFilename.size()-4) + ".bmp"); + egami::generateDistanceFieldFile(_tmpFilename, std::string(_tmpFilename, 0, _tmpFilename.size()-4) + ".edf"); #endif flush(); } @@ -84,7 +85,7 @@ std::shared_ptr ewol::resource::TextureFile::create _size.setY(-1); //EWOL_ERROR("Error Request the image size.y() =0 ???"); } - std::string TmpFilename = _filename; + std::string tmpFilename = _filename; if (etk::end_with(_filename, ".svg") == false) { _size = ewol::resource::TextureFile::sizeAuto; } @@ -99,35 +100,35 @@ std::shared_ptr ewol::resource::TextureFile::create #endif if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) { if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) { - TmpFilename += ":"; - TmpFilename += etk::to_string(_size.x()); - TmpFilename += "x"; - TmpFilename += etk::to_string(_size.y()); + tmpFilename += ":"; + tmpFilename += etk::to_string(_size.x()); + tmpFilename += "x"; + tmpFilename += etk::to_string(_size.y()); } } } - EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size); + EWOL_VERBOSE("KEEP: TextureFile: '" << tmpFilename << "' new size=" << _size); std::shared_ptr object = nullptr; - std::shared_ptr object2 = getManager().localKeep(TmpFilename); + std::shared_ptr object2 = getManager().localKeep(tmpFilename); if (object2 != nullptr) { object = std::dynamic_pointer_cast(object2); if (object == nullptr) { - EWOL_CRITICAL("Request resource file : '" << TmpFilename << "' With the wrong type (dynamic cast error)"); + EWOL_CRITICAL("Request resource file : '" << tmpFilename << "' With the wrong type (dynamic cast error)"); return nullptr; } } if (object != nullptr) { return object; } - EWOL_INFO("CREATE: TextureFile: '" << TmpFilename << "' size=" << _size); + EWOL_INFO("CREATE: TextureFile: '" << tmpFilename << "' size=" << _size); // need to crate a new one ... object = std::shared_ptr(new ewol::resource::TextureFile()); if (object == nullptr) { EWOL_ERROR("allocation error of a resource : " << _filename); return nullptr; } - object->init(TmpFilename, _filename, _size); + object->init(tmpFilename, _filename, _size); getManager().localAdd(object); return object; } diff --git a/ewol/resource/Texture.cpp b/ewol/resource/Texture.cpp index b3ec7c10..835377a2 100644 --- a/ewol/resource/Texture.cpp +++ b/ewol/resource/Texture.cpp @@ -51,6 +51,7 @@ ewol::resource::Texture::~Texture() { //#include bool ewol::resource::Texture::updateContext() { + EWOL_INFO("updateContext [START]"); std::unique_lock lock(m_mutex, std::defer_lock); if (lock.try_lock() == false) { //Lock error ==> try later ... @@ -60,7 +61,7 @@ bool ewol::resource::Texture::updateContext() { // Request a new texture at openGl : glGenTextures(1, &m_texId); } - EWOL_VERBOSE("load the image:" << m_name); + EWOL_INFO("load the image:" << m_name); // in all case we set the texture properties : // TODO : check error ??? glBindTexture(GL_TEXTURE_2D, m_texId); @@ -73,7 +74,7 @@ bool ewol::resource::Texture::updateContext() { //--- Mode linear glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" < lock(m_mutex); // request to the manager to be call at the next update ... + EWOL_INFO("Request UPDATE of Element"); getManager().update(std::dynamic_pointer_cast(shared_from_this())); } diff --git a/tools/visual_test/appl/MainWindows.cpp b/tools/visual_test/appl/MainWindows.cpp index e4a8f260..bd920373 100644 --- a/tools/visual_test/appl/MainWindows.cpp +++ b/tools/visual_test/appl/MainWindows.cpp @@ -60,6 +60,18 @@ void appl::MainWindows::init() { if (m_subWidget == nullptr) { APPL_CRITICAL("Can not get subWidget pointer"); } + shortCutAdd("F12", "menu:reloade-shader"); + signalShortcut.connect(shared_from_this(), &appl::MainWindows::onCallbackShortCut); +} + +void appl::MainWindows::onCallbackShortCut(const std::string& _value) { + APPL_WARNING("Event from ShortCut : " << _value); + if (_value == "menu:reloade-shader") { + ewol::getContext().getResourcesManager().reLoadResources(); + ewol::getContext().forceRedrawAll(); + } else { + APPL_ERROR("Event from Menu UNKNOW : '" << _value << "'"); + } } void appl::MainWindows::onCallbackThemeChange(const bool& _value) { diff --git a/tools/visual_test/appl/MainWindows.h b/tools/visual_test/appl/MainWindows.h index da7a1689..8477d69a 100644 --- a/tools/visual_test/appl/MainWindows.h +++ b/tools/visual_test/appl/MainWindows.h @@ -37,6 +37,7 @@ namespace appl { void onCallbackThemeChange(const bool& _value); void onCallbackWidgetChange(int32_t _increment); void updateProperty(); + void onCallbackShortCut(const std::string& _value); }; };