From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- modules/etc/image_etc.cpp | 1 - modules/etc/register_types.cpp | 2 -- modules/etc/texture_loader_pkm.cpp | 4 ---- 3 files changed, 7 deletions(-) (limited to 'modules/etc') diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index 223830f445..6bf4a7ef47 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -219,7 +219,6 @@ static void _compress_etc2(Image *p_img, float p_lossy_quality, Image::UsedChann } void _register_etc_compress_func() { - Image::_image_compress_etc1_func = _compress_etc1; Image::_image_compress_etc2_func = _compress_etc2; } diff --git a/modules/etc/register_types.cpp b/modules/etc/register_types.cpp index 26809e0de9..0972857808 100644 --- a/modules/etc/register_types.cpp +++ b/modules/etc/register_types.cpp @@ -36,7 +36,6 @@ static Ref resource_loader_pkm; void register_etc_types() { - resource_loader_pkm.instance(); ResourceLoader::add_resource_format_loader(resource_loader_pkm); @@ -44,7 +43,6 @@ void register_etc_types() { } void unregister_etc_types() { - ResourceLoader::remove_resource_format_loader(resource_loader_pkm); resource_loader_pkm.unref(); } diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index bfb2098dff..78768c5ba9 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -43,7 +43,6 @@ struct ETC1Header { }; RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { - if (r_error) *r_error = ERR_CANT_OPEN; @@ -96,17 +95,14 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, } void ResourceFormatPKM::get_recognized_extensions(List *p_extensions) const { - p_extensions->push_back("pkm"); } bool ResourceFormatPKM::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatPKM::get_resource_type(const String &p_path) const { - if (p_path.get_extension().to_lower() == "pkm") return "ImageTexture"; return ""; -- cgit v1.2.3 From 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 16:41:43 +0200 Subject: Style: Enforce braces around if blocks and loops Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html --- modules/etc/image_etc.cpp | 10 ++++++---- modules/etc/texture_loader_pkm.cpp | 15 ++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'modules/etc') diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index 6bf4a7ef47..9b6d8a2d35 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -127,8 +127,9 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f Ref img = p_img->duplicate(); - if (img->get_format() != Image::FORMAT_RGBA8) + if (img->get_format() != Image::FORMAT_RGBA8) { img->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert + } if (img->has_mipmaps()) { if (next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh) { @@ -165,12 +166,13 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f int encoding_time = 0; float effort = 0.0; //default, reasonable time - if (p_lossy_quality > 0.75) + if (p_lossy_quality > 0.75) { effort = 0.4; - else if (p_lossy_quality > 0.85) + } else if (p_lossy_quality > 0.85) { effort = 0.6; - else if (p_lossy_quality > 0.95) + } else if (p_lossy_quality > 0.95) { effort = 0.8; + } Etc::ErrorMetric error_metric = Etc::ErrorMetric::RGBX; // NOTE: we can experiment with other error metrics Etc::Image::Format etc2comp_etc_format = _image_format_to_etc2comp_format(etc_format); diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index 78768c5ba9..c40e9612a8 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -43,17 +43,20 @@ struct ETC1Header { }; RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { - if (r_error) + if (r_error) { *r_error = ERR_CANT_OPEN; + } Error err; FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); - if (!f) + if (!f) { return RES(); + } FileAccessRef fref(f); - if (r_error) + if (r_error) { *r_error = ERR_FILE_CORRUPT; + } ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open PKM texture file '" + p_path + "'."); @@ -86,8 +89,9 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Ref texture = memnew(ImageTexture); texture->create_from_image(img); - if (r_error) + if (r_error) { *r_error = OK; + } f->close(); memdelete(f); @@ -103,7 +107,8 @@ bool ResourceFormatPKM::handles_type(const String &p_type) const { } String ResourceFormatPKM::get_resource_type(const String &p_path) const { - if (p_path.get_extension().to_lower() == "pkm") + if (p_path.get_extension().to_lower() == "pkm") { return "ImageTexture"; + } return ""; } -- cgit v1.2.3