diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-05-14 23:09:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 23:09:03 +0200 |
commit | 00949f0c5fcc6a4f8382a4a97d5591fd9ec380f8 (patch) | |
tree | 2b1c31f45add24085b64425ce440f577424c16a1 /modules/tinyexr | |
parent | 5046f666a1181675b39f156c38346525dc1c444e (diff) | |
parent | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (diff) |
Merge pull request #38738 from akien-mga/cause-we-never-go-out-of-style
Style: Remove new line at block start, enforce line between functions, enforce braces in if and loop blocks
Diffstat (limited to 'modules/tinyexr')
-rw-r--r-- | modules/tinyexr/image_loader_tinyexr.cpp | 10 | ||||
-rw-r--r-- | modules/tinyexr/image_loader_tinyexr.h | 1 | ||||
-rw-r--r-- | modules/tinyexr/image_saver_tinyexr.cpp | 5 | ||||
-rw-r--r-- | modules/tinyexr/register_types.cpp | 2 |
4 files changed, 2 insertions, 16 deletions
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp index 1c0f3cd03e..9e7266b95a 100644 --- a/modules/tinyexr/image_loader_tinyexr.cpp +++ b/modules/tinyexr/image_loader_tinyexr.cpp @@ -36,7 +36,6 @@ #include "thirdparty/tinyexr/tinyexr.h" Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) { - Vector<uint8_t> src_image; int src_image_len = f->get_len(); ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT); @@ -62,7 +61,6 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f int ret = ParseEXRVersionFromMemory(&exr_version, w, src_image_len); if (ret != TINYEXR_SUCCESS) { - return ERR_FILE_CORRUPT; } @@ -141,12 +139,10 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f int output_channels = 0; if (idxA != -1) { - imgdata.resize(exr_image.width * exr_image.height * 8); //RGBA16 format = Image::FORMAT_RGBAH; output_channels = 4; } else { - imgdata.resize(exr_image.width * exr_image.height * 6); //RGB16 format = Image::FORMAT_RGBH; output_channels = 3; @@ -185,7 +181,6 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f // Assume `out_rgba` have enough memory allocated. for (int tile_index = 0; tile_index < num_tiles; tile_index++) { - const EXRTile &tile = exr_tiles[tile_index]; int tw = tile.width; @@ -215,11 +210,11 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f uint16_t *row_w = first_row_w + (y * exr_image.width * output_channels); for (int x = 0; x < tw; x++) { - Color color(*r_channel++, *g_channel++, *b_channel++); - if (p_force_linear) + if (p_force_linear) { color = color.to_linear(); + } *row_w++ = Math::make_half_float(color.r); *row_w++ = Math::make_half_float(color.g); @@ -242,7 +237,6 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f } void ImageLoaderTinyEXR::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("exr"); } diff --git a/modules/tinyexr/image_loader_tinyexr.h b/modules/tinyexr/image_loader_tinyexr.h index af95989254..ff040b0915 100644 --- a/modules/tinyexr/image_loader_tinyexr.h +++ b/modules/tinyexr/image_loader_tinyexr.h @@ -34,7 +34,6 @@ #include "core/io/image_loader.h" class ImageLoaderTinyEXR : public ImageFormatLoader { - public: virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale); virtual void get_recognized_extensions(List<String> *p_extensions) const; diff --git a/modules/tinyexr/image_saver_tinyexr.cpp b/modules/tinyexr/image_saver_tinyexr.cpp index bc30f4e4fd..420619bd5f 100644 --- a/modules/tinyexr/image_saver_tinyexr.cpp +++ b/modules/tinyexr/image_saver_tinyexr.cpp @@ -140,7 +140,6 @@ static int get_channel_count(Image::Format p_format) { } Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale) { - Image::Format format = p_img->get_format(); if (!is_supported_format(format)) { @@ -192,7 +191,6 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale) const uint8_t *src_r = src_data.ptr(); for (int channel_index = 0; channel_index < channel_count; ++channel_index) { - // De-interleave channels PackedByteArray &dst = channels[channel_index]; @@ -201,7 +199,6 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale) uint8_t *dst_w = dst.ptrw(); if (src_pixel_type == SRC_FLOAT && target_pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - // Note: we don't save mipmaps CRASH_COND(src_data.size() < pixel_count * channel_count * target_pixel_type_size); @@ -213,7 +210,6 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale) } } else if (src_pixel_type == SRC_HALF && target_pixel_type == TINYEXR_PIXELTYPE_HALF) { - CRASH_COND(src_data.size() < pixel_count * channel_count * target_pixel_type_size); const uint16_t *src_rp = (uint16_t *)src_r; @@ -224,7 +220,6 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale) } } else if (src_pixel_type == SRC_BYTE && target_pixel_type == TINYEXR_PIXELTYPE_HALF) { - CRASH_COND(src_data.size() < pixel_count * channel_count); const uint8_t *src_rp = (uint8_t *)src_r; diff --git a/modules/tinyexr/register_types.cpp b/modules/tinyexr/register_types.cpp index af05a411e1..9d0fb8729e 100644 --- a/modules/tinyexr/register_types.cpp +++ b/modules/tinyexr/register_types.cpp @@ -36,7 +36,6 @@ static ImageLoaderTinyEXR *image_loader_tinyexr = nullptr; void register_tinyexr_types() { - image_loader_tinyexr = memnew(ImageLoaderTinyEXR); ImageLoader::add_image_format_loader(image_loader_tinyexr); @@ -44,7 +43,6 @@ void register_tinyexr_types() { } void unregister_tinyexr_types() { - memdelete(image_loader_tinyexr); Image::save_exr_func = nullptr; |