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. --- drivers/png/image_loader_png.cpp | 6 ------ drivers/png/png_driver_common.cpp | 3 --- drivers/png/resource_saver_png.cpp | 6 ------ 3 files changed, 15 deletions(-) (limited to 'drivers/png') diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index 4cb93a821c..8af58a7ed7 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -37,7 +37,6 @@ #include Error ImageLoaderPNG::load_image(Ref p_image, FileAccess *f, bool p_force_linear, float p_scale) { - const size_t buffer_size = f->get_len(); Vector file_buffer; Error err = file_buffer.resize(buffer_size); @@ -55,12 +54,10 @@ Error ImageLoaderPNG::load_image(Ref p_image, FileAccess *f, bool p_force } void ImageLoaderPNG::get_recognized_extensions(List *p_extensions) const { - p_extensions->push_back("png"); } Ref ImageLoaderPNG::load_mem_png(const uint8_t *p_png, int p_size) { - Ref img; img.instance(); @@ -71,7 +68,6 @@ Ref ImageLoaderPNG::load_mem_png(const uint8_t *p_png, int p_size) { } Ref ImageLoaderPNG::lossless_unpack_png(const Vector &p_data) { - const int len = p_data.size(); ERR_FAIL_COND_V(len < 4, Ref()); const uint8_t *r = p_data.ptr(); @@ -80,7 +76,6 @@ Ref ImageLoaderPNG::lossless_unpack_png(const Vector &p_data) { } Vector ImageLoaderPNG::lossless_pack_png(const Ref &p_image) { - Vector out_buffer; // add Godot's own "PNG " prefix @@ -104,7 +99,6 @@ Vector ImageLoaderPNG::lossless_pack_png(const Ref &p_image) { } ImageLoaderPNG::ImageLoaderPNG() { - Image::_png_mem_loader_func = load_mem_png; Image::lossless_unpacker = lossless_unpack_png; Image::lossless_packer = lossless_pack_png; diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp index 3f9c824e93..68faff30fc 100644 --- a/drivers/png/png_driver_common.cpp +++ b/drivers/png/png_driver_common.cpp @@ -59,7 +59,6 @@ static bool check_error(const png_image &image) { } Error png_to_image(const uint8_t *p_source, size_t p_size, Ref p_image) { - png_image png_img; zeromem(&png_img, sizeof(png_img)); png_img.version = PNG_IMAGE_VERSION; @@ -121,7 +120,6 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref p_image) { } Error image_to_png(const Ref &p_image, Vector &p_buffer) { - Ref source_image = p_image->duplicate(); if (source_image->is_compressed()) @@ -179,7 +177,6 @@ Error image_to_png(const Ref &p_image, Vector &p_buffer) { ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message); } if (!success) { - // buffer was big enough, must be some other error ERR_FAIL_COND_V(compressed_size <= png_size_estimate, FAILED); diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index 2380c2685f..3a0b319a45 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -36,7 +36,6 @@ #include "scene/resources/texture.h" Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { - Ref texture = p_resource; ERR_FAIL_COND_V_MSG(!texture.is_valid(), ERR_INVALID_PARAMETER, "Can't save invalid texture as PNG."); @@ -50,7 +49,6 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32 }; Error ResourceSaverPNG::save_image(const String &p_path, const Ref &p_img) { - Vector buffer; Error err = PNGDriverCommon::image_to_png(p_img, buffer); ERR_FAIL_COND_V_MSG(err, err, "Can't convert image to PNG."); @@ -72,7 +70,6 @@ Error ResourceSaverPNG::save_image(const String &p_path, const Ref &p_img } Vector ResourceSaverPNG::save_image_to_buffer(const Ref &p_img) { - Vector buffer; Error err = PNGDriverCommon::image_to_png(p_img, buffer); ERR_FAIL_COND_V_MSG(err, Vector(), "Can't convert image to PNG."); @@ -80,19 +77,16 @@ Vector ResourceSaverPNG::save_image_to_buffer(const Ref &p_img) } bool ResourceSaverPNG::recognize(const RES &p_resource) const { - return (p_resource.is_valid() && p_resource->is_class("ImageTexture")); } void ResourceSaverPNG::get_recognized_extensions(const RES &p_resource, List *p_extensions) const { - if (Object::cast_to(*p_resource)) { p_extensions->push_back("png"); } } ResourceSaverPNG::ResourceSaverPNG() { - Image::save_png_func = &save_image; Image::save_png_buffer_func = &save_image_to_buffer; }; -- cgit v1.2.3