[DEBUG] try to find the problem of opening png file

This commit is contained in:
Edouard DUPIN 2016-04-22 23:46:19 +02:00
parent 06842eeafb
commit f471429ac3
5 changed files with 39 additions and 21 deletions

View File

@ -248,8 +248,8 @@ void ewol::compositing::Image::printPart(const vec2& _size,
void ewol::compositing::Image::setSource(const std::string& _newFile, const vec2& _size) { void ewol::compositing::Image::setSource(const std::string& _newFile, const vec2& _size) {
clear(); clear();
std::shared_ptr<ewol::resource::TextureFile> resource(m_resource); std::shared_ptr<ewol::resource::TextureFile> resource = m_resource;
std::shared_ptr<ewol::resource::ImageDF> resourceDF(m_resourceDF); std::shared_ptr<ewol::resource::ImageDF> resourceDF = m_resourceDF;
m_filename = _newFile; m_filename = _newFile;
m_requestSize = _size; m_requestSize = _size;
m_resource.reset(); m_resource.reset();
@ -284,7 +284,8 @@ void ewol::compositing::Image::setSource(const std::string& _newFile, const vec2
} }
bool ewol::compositing::Image::hasSources() { bool ewol::compositing::Image::hasSources() {
return (m_resource != nullptr || m_resourceDF != nullptr); return m_resource != nullptr
|| m_resourceDF != nullptr;
} }

View File

@ -26,18 +26,19 @@ void ewol::resource::TextureFile::init() {
ewol::resource::Texture::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<std::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
ewol::resource::Texture::init(_genName); ewol::resource::Texture::init(_genName);
EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpfileName=" << _tmpfileName << " size=" << _size); EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpFilename=" << _tmpFilename << " size=" << _size);
if (egami::load(m_data, _tmpfileName, _size) == false) { if (egami::load(m_data, _tmpFilename, _size) == false) {
EWOL_ERROR("ERROR when loading the image : " << _tmpfileName); EWOL_ERROR("ERROR when loading the image : " << _tmpFilename);
} }
//egami::store(m_data, "tmpResult.bmp");
ivec2 tmp = m_data.getSize(); ivec2 tmp = m_data.getSize();
m_realImageSize = vec2(tmp.x(), tmp.y()); m_realImageSize = vec2(tmp.x(), tmp.y());
#ifdef GENERATE_DISTANCE_FIELD_MODE #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) + ".bmp");
egami::generateDistanceFieldFile(_tmpfileName, std::string(_tmpfileName, 0, _tmpfileName.size()-4) + ".edf"); egami::generateDistanceFieldFile(_tmpFilename, std::string(_tmpFilename, 0, _tmpFilename.size()-4) + ".edf");
#endif #endif
flush(); flush();
} }
@ -84,7 +85,7 @@ std::shared_ptr<ewol::resource::TextureFile> ewol::resource::TextureFile::create
_size.setY(-1); _size.setY(-1);
//EWOL_ERROR("Error Request the image size.y() =0 ???"); //EWOL_ERROR("Error Request the image size.y() =0 ???");
} }
std::string TmpFilename = _filename; std::string tmpFilename = _filename;
if (etk::end_with(_filename, ".svg") == false) { if (etk::end_with(_filename, ".svg") == false) {
_size = ewol::resource::TextureFile::sizeAuto; _size = ewol::resource::TextureFile::sizeAuto;
} }
@ -99,35 +100,35 @@ std::shared_ptr<ewol::resource::TextureFile> ewol::resource::TextureFile::create
#endif #endif
if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) { if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) {
if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) { if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) {
TmpFilename += ":"; tmpFilename += ":";
TmpFilename += etk::to_string(_size.x()); tmpFilename += etk::to_string(_size.x());
TmpFilename += "x"; tmpFilename += "x";
TmpFilename += etk::to_string(_size.y()); 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<ewol::resource::TextureFile> object = nullptr; std::shared_ptr<ewol::resource::TextureFile> object = nullptr;
std::shared_ptr<gale::Resource> object2 = getManager().localKeep(TmpFilename); std::shared_ptr<gale::Resource> object2 = getManager().localKeep(tmpFilename);
if (object2 != nullptr) { if (object2 != nullptr) {
object = std::dynamic_pointer_cast<ewol::resource::TextureFile>(object2); object = std::dynamic_pointer_cast<ewol::resource::TextureFile>(object2);
if (object == nullptr) { 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; return nullptr;
} }
} }
if (object != nullptr) { if (object != nullptr) {
return object; return object;
} }
EWOL_INFO("CREATE: TextureFile: '" << TmpFilename << "' size=" << _size); EWOL_INFO("CREATE: TextureFile: '" << tmpFilename << "' size=" << _size);
// need to crate a new one ... // need to crate a new one ...
object = std::shared_ptr<ewol::resource::TextureFile>(new ewol::resource::TextureFile()); object = std::shared_ptr<ewol::resource::TextureFile>(new ewol::resource::TextureFile());
if (object == nullptr) { if (object == nullptr) {
EWOL_ERROR("allocation error of a resource : " << _filename); EWOL_ERROR("allocation error of a resource : " << _filename);
return nullptr; return nullptr;
} }
object->init(TmpFilename, _filename, _size); object->init(tmpFilename, _filename, _size);
getManager().localAdd(object); getManager().localAdd(object);
return object; return object;
} }

View File

@ -51,6 +51,7 @@ ewol::resource::Texture::~Texture() {
//#include <egami/wrapperBMP.h> //#include <egami/wrapperBMP.h>
bool ewol::resource::Texture::updateContext() { bool ewol::resource::Texture::updateContext() {
EWOL_INFO("updateContext [START]");
std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock); std::unique_lock<std::recursive_mutex> lock(m_mutex, std::defer_lock);
if (lock.try_lock() == false) { if (lock.try_lock() == false) {
//Lock error ==> try later ... //Lock error ==> try later ...
@ -60,7 +61,7 @@ bool ewol::resource::Texture::updateContext() {
// Request a new texture at openGl : // Request a new texture at openGl :
glGenTextures(1, &m_texId); 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 : // in all case we set the texture properties :
// TODO : check error ??? // TODO : check error ???
glBindTexture(GL_TEXTURE_2D, m_texId); glBindTexture(GL_TEXTURE_2D, m_texId);
@ -73,7 +74,7 @@ bool ewol::resource::Texture::updateContext() {
//--- Mode linear //--- Mode linear
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" <<m_texId); EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" << m_texId << " type=" << m_data.getType());
//egami::storeBMP("~/bbb_image.bmp", m_data); //egami::storeBMP("~/bbb_image.bmp", m_data);
glTexImage2D(GL_TEXTURE_2D, // Target glTexImage2D(GL_TEXTURE_2D, // Target
0, // Level 0, // Level
@ -86,6 +87,7 @@ bool ewol::resource::Texture::updateContext() {
m_data.getTextureDataPointer() ); m_data.getTextureDataPointer() );
// now the data is loaded // now the data is loaded
m_loaded = true; m_loaded = true;
EWOL_INFO("updateContext [STOP]");
return true; return true;
} }
@ -108,6 +110,7 @@ void ewol::resource::Texture::removeContextToLate() {
void ewol::resource::Texture::flush() { void ewol::resource::Texture::flush() {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std::unique_lock<std::recursive_mutex> lock(m_mutex);
// request to the manager to be call at the next update ... // request to the manager to be call at the next update ...
EWOL_INFO("Request UPDATE of Element");
getManager().update(std::dynamic_pointer_cast<gale::Resource>(shared_from_this())); getManager().update(std::dynamic_pointer_cast<gale::Resource>(shared_from_this()));
} }

View File

@ -60,6 +60,18 @@ void appl::MainWindows::init() {
if (m_subWidget == nullptr) { if (m_subWidget == nullptr) {
APPL_CRITICAL("Can not get subWidget pointer"); 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) { void appl::MainWindows::onCallbackThemeChange(const bool& _value) {

View File

@ -37,6 +37,7 @@ namespace appl {
void onCallbackThemeChange(const bool& _value); void onCallbackThemeChange(const bool& _value);
void onCallbackWidgetChange(int32_t _increment); void onCallbackWidgetChange(int32_t _increment);
void updateProperty(); void updateProperty();
void onCallbackShortCut(const std::string& _value);
}; };
}; };