eepp: Added QOI image format support (inherited from SOIL2).

ecode:
Fixed a crash while unloading documents that were still loading.
Fixed an incorrect un-initialization of the thread pool when consumed by the UISceneNode.
This commit is contained in:
Martín Lucas Golini
2023-03-11 22:55:17 -03:00
parent f7faa6240e
commit 26c1e4dfe8
8 changed files with 26 additions and 14 deletions

View File

@@ -61,7 +61,8 @@ class EE_API Image {
SAVE_TYPE_BMP = 1,
SAVE_TYPE_PNG = 2,
SAVE_TYPE_DDS = 3,
SAVE_TYPE_JPG = 4
SAVE_TYPE_JPG = 4,
SAVE_TYPE_QOI = 5
};
class FormatConfiguration {

View File

@@ -265,6 +265,8 @@ std::string Image::saveTypeToExtension( const Int32& Format ) {
return "dds";
case Image::SaveType::SAVE_TYPE_JPG:
return "jpg";
case Image::SaveType::SAVE_TYPE_QOI:
return "qoi";
case Image::SaveType::SAVE_TYPE_UNKNOWN:
default:
break;
@@ -286,6 +288,8 @@ Image::SaveType Image::extensionToSaveType( const std::string& Extension ) {
saveType = SaveType::SAVE_TYPE_DDS;
else if ( Extension == "jpg" || Extension == "jpeg" )
saveType = SaveType::SAVE_TYPE_JPG;
else if ( Extension == "qoi" )
saveType = SaveType::SAVE_TYPE_QOI;
return saveType;
}
@@ -362,7 +366,7 @@ bool Image::isImageExtension( const std::string& path ) {
const std::string ext( FileSystem::fileExtension( path ) );
return ( ext == "png" || ext == "tga" || ext == "bmp" || ext == "jpg" || ext == "gif" ||
ext == "jpeg" || ext == "dds" || ext == "psd" || ext == "hdr" || ext == "pic" ||
ext == "pvr" || ext == "pkm" || ext == "svg" );
ext == "pvr" || ext == "pkm" || ext == "svg" || ext == "qoi" );
}
std::string Image::getLastFailureReason() {

View File

@@ -38,6 +38,11 @@ TokenizedLine SyntaxHighlighter::tokenizeLine( const size_t& line, const Uint64&
}
const std::vector<SyntaxToken>& SyntaxHighlighter::getLine( const size_t& index ) {
if ( mDoc->getSyntaxDefinition().getPatterns().empty() ) {
static std::vector<SyntaxToken> noHighlightVector = { { "normal", 0 } };
noHighlightVector[0].len = mDoc->line( index ).size();
return noHighlightVector;
}
const auto& it = mLines.find( index );
if ( it == mLines.end() ||
( index < mDoc->linesCount() && mDoc->line( index ).getHash() != it->second.hash ) ) {

View File

@@ -138,7 +138,7 @@ TextDocument::LoadStatus TextDocument::loadFromStream( IOStream& file, std::stri
}
}
while ( consume ) {
while ( consume && mLoading ) {
lineBuffer += ptrGetLine( bufferPtr, consume, position );
bufferPtr += position;
consume -= position;
@@ -200,10 +200,8 @@ TextDocument::LoadStatus TextDocument::loadFromStream( IOStream& file, std::stri
clock.getElapsedTime().asMilliseconds() );
bool wasInterrupted = !mLoading;
if ( wasInterrupted ) {
mLines.clear();
mLines.push_back( String( "\n" ) );
}
if ( wasInterrupted )
reset();
mLoading = false;
return wasInterrupted ? LoadStatus::Interrupted
: ( file.isOpen() ? LoadStatus::Loaded : LoadStatus::Failed );

View File

@@ -152,7 +152,8 @@ void TextureAtlasNew::windowClose( const Event* ) {
}
static bool isValidExtension( const std::string& ext ) {
return ext == "png" || ext == "bmp" || ext == "dds" || ext == "tga" || ext == "jpg";
return ext == "png" || ext == "bmp" || ext == "dds" || ext == "tga" || ext == "jpg" ||
ext == "qoi";
}
void TextureAtlasNew::textureAtlasSave( const Event* Event ) {

View File

@@ -66,6 +66,11 @@ UISceneNode::~UISceneNode() {
for ( auto& font : mFontFaces ) {
FontManager::instance()->remove( font );
}
// UISceneNode can now destroy the ThreadPool shared to him. If that's the case,
// We need to ensure that the childs are destroyed before the thread pool,
// since its childs could be consuming it and need to uninitialize gracefully.
childDeleteAll();
}
void UISceneNode::resizeNode( EE::Window::Window* ) {

View File

@@ -22,11 +22,9 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
parser, "output-file", "Texture atlas file output path. Extension must be: \".eta\"",
{ 'o', "output-file" }, "", args::Options::Required | args::Options::Single );
std::unordered_map<std::string, Image::SaveType> saveTypeFormat{
{ "PNG", Image::SaveType::SAVE_TYPE_PNG },
{ "DDS", Image::SaveType::SAVE_TYPE_DDS },
{ "TGA", Image::SaveType::SAVE_TYPE_TGA },
{ "BMP", Image::SaveType::SAVE_TYPE_BMP },
{ "JPG", Image::SaveType::SAVE_TYPE_JPG } };
{ "PNG", Image::SaveType::SAVE_TYPE_PNG }, { "DDS", Image::SaveType::SAVE_TYPE_DDS },
{ "TGA", Image::SaveType::SAVE_TYPE_TGA }, { "BMP", Image::SaveType::SAVE_TYPE_BMP },
{ "JPG", Image::SaveType::SAVE_TYPE_JPG }, { "QOI", Image::SaveType::SAVE_TYPE_QOI } };
args::MapFlag<std::string, Image::SaveType> saveType(
parser, "image-format", "Output image format.", { 'f', "image-format" }, saveTypeFormat,
Image::SaveType::SAVE_TYPE_PNG, args::Options::Single );