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/webp | |
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/webp')
-rw-r--r-- | modules/webp/image_loader_webp.cpp | 12 | ||||
-rw-r--r-- | modules/webp/image_loader_webp.h | 1 | ||||
-rw-r--r-- | modules/webp/register_types.cpp | 2 |
3 files changed, 3 insertions, 12 deletions
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp index 6c778d2809..d5c80e7909 100644 --- a/modules/webp/image_loader_webp.cpp +++ b/modules/webp/image_loader_webp.cpp @@ -39,14 +39,14 @@ #include <webp/encode.h> static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quality) { - ERR_FAIL_COND_V(p_image.is_null() || p_image->empty(), Vector<uint8_t>()); Ref<Image> img = p_image->duplicate(); - if (img->detect_alpha()) + if (img->detect_alpha()) { img->convert(Image::FORMAT_RGBA8); - else + } else { img->convert(Image::FORMAT_RGB8); + } Size2 s(img->get_width(), img->get_height()); Vector<uint8_t> data = img->get_data(); @@ -55,7 +55,6 @@ static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quali uint8_t *dst_buff = nullptr; size_t dst_size = 0; if (img->get_format() == Image::FORMAT_RGB8) { - dst_size = WebPEncodeRGB(r, s.width, s.height, 3 * s.width, CLAMP(p_quality * 100.0, 0, 100.0), &dst_buff); } else { dst_size = WebPEncodeRGBA(r, s.width, s.height, 4 * s.width, CLAMP(p_quality * 100.0, 0, 100.0), &dst_buff); @@ -76,7 +75,6 @@ static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quali } static Ref<Image> _webp_lossy_unpack(const Vector<uint8_t> &p_buffer) { - int size = p_buffer.size() - 4; ERR_FAIL_COND_V(size <= 0, Ref<Image>()); const uint8_t *r = p_buffer.ptr(); @@ -113,7 +111,6 @@ static Ref<Image> _webp_lossy_unpack(const Vector<uint8_t> &p_buffer) { } Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p_buffer_len) { - ERR_FAIL_NULL_V(p_image, ERR_INVALID_PARAMETER); WebPBitstreamFeatures features; @@ -141,7 +138,6 @@ Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p } static Ref<Image> _webp_mem_loader_func(const uint8_t *p_png, int p_size) { - Ref<Image> img; img.instance(); Error err = webp_load_image_from_buffer(img.ptr(), p_png, p_size); @@ -150,7 +146,6 @@ static Ref<Image> _webp_mem_loader_func(const uint8_t *p_png, int p_size) { } Error ImageLoaderWEBP::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); @@ -168,7 +163,6 @@ Error ImageLoaderWEBP::load_image(Ref<Image> p_image, FileAccess *f, bool p_forc } void ImageLoaderWEBP::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("webp"); } diff --git a/modules/webp/image_loader_webp.h b/modules/webp/image_loader_webp.h index 9206ca2525..49a7407600 100644 --- a/modules/webp/image_loader_webp.h +++ b/modules/webp/image_loader_webp.h @@ -34,7 +34,6 @@ #include "core/io/image_loader.h" class ImageLoaderWEBP : 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/webp/register_types.cpp b/modules/webp/register_types.cpp index fe945b01d4..0788b06309 100644 --- a/modules/webp/register_types.cpp +++ b/modules/webp/register_types.cpp @@ -35,12 +35,10 @@ static ImageLoaderWEBP *image_loader_webp = nullptr; void register_webp_types() { - image_loader_webp = memnew(ImageLoaderWEBP); ImageLoader::add_image_format_loader(image_loader_webp); } void unregister_webp_types() { - memdelete(image_loader_webp); } |