From f8db8a3faa30b71dca33ced38be16d3f93f43e8a Mon Sep 17 00:00:00 2001 From: Rémi Verschelde Date: Sun, 19 Mar 2017 00:36:26 +0100 Subject: Bring that Whole New World to the Old Continent too Applies the clang-format style to the 2.1 branch as done for master in 5dbf1809c6e3e905b94b8764e99491e608122261. --- modules/etc1/image_etc.cpp | 160 +++++++++++++++++++-------------------------- 1 file changed, 69 insertions(+), 91 deletions(-) (limited to 'modules/etc1/image_etc.cpp') diff --git a/modules/etc1/image_etc.cpp b/modules/etc1/image_etc.cpp index fdca19046..b3ceb60ed 100644 --- a/modules/etc1/image_etc.cpp +++ b/modules/etc1/image_etc.cpp @@ -28,174 +28,152 @@ /*************************************************************************/ #include "image_etc.h" #include "image.h" -#include "rg_etc1.h" -#include "print_string.h" #include "os/copymem.h" +#include "print_string.h" +#include "rg_etc1.h" static void _decompress_etc(Image *p_img) { - ERR_FAIL_COND(p_img->get_format()!=Image::FORMAT_ETC); + ERR_FAIL_COND(p_img->get_format() != Image::FORMAT_ETC); int imgw = p_img->get_width(); int imgh = p_img->get_height(); - DVector src=p_img->get_data(); + DVector src = p_img->get_data(); DVector dst; DVector::Read r = src.read(); - int mmc=p_img->get_mipmaps(); + int mmc = p_img->get_mipmaps(); + for (int i = 0; i <= mmc; i++) { - for(int i=0;i<=mmc;i++) { - - dst.resize(dst.size()+imgw*imgh*3); - const uint8_t *srcbr=&r[p_img->get_mipmap_offset(i)]; + dst.resize(dst.size() + imgw * imgh * 3); + const uint8_t *srcbr = &r[p_img->get_mipmap_offset(i)]; DVector::Write w = dst.write(); - uint8_t *wptr = &w[dst.size()-imgw*imgh*3]; - - int bw=MAX(imgw/4,1); - int bh=MAX(imgh/4,1); - - for(int y=0;y::Read(); + r = DVector::Read(); //print_line("Re Creating ETC into regular image: w "+itos(p_img->get_width())+" h "+itos(p_img->get_height())+" mm "+itos(p_img->get_mipmaps())); - *p_img=Image(p_img->get_width(),p_img->get_height(),p_img->get_mipmaps(),Image::FORMAT_RGB,dst); + *p_img = Image(p_img->get_width(), p_img->get_height(), p_img->get_mipmaps(), Image::FORMAT_RGB, dst); if (p_img->get_mipmaps()) - p_img->generate_mipmaps(-1,true); - - + p_img->generate_mipmaps(-1, true); } static void _compress_etc(Image *p_img) { Image img = *p_img; - int imgw=img.get_width(),imgh=img.get_height(); + int imgw = img.get_width(), imgh = img.get_height(); - ERR_FAIL_COND( nearest_power_of_2(imgw)!=imgw || nearest_power_of_2(imgh)!=imgh ); + ERR_FAIL_COND(nearest_power_of_2(imgw) != imgw || nearest_power_of_2(imgh) != imgh); - if (img.get_format()!=Image::FORMAT_RGB) + if (img.get_format() != Image::FORMAT_RGB) img.convert(Image::FORMAT_RGB); - - int mmc=img.get_mipmaps(); - if (mmc==0) + int mmc = img.get_mipmaps(); + if (mmc == 0) img.generate_mipmaps(); // force mipmaps, so it works on most hardware - DVector res_data; DVector dst_data; DVector::Read r = img.get_data().read(); - int mc=0; - + int mc = 0; rg_etc1::etc1_pack_params pp; - pp.m_quality=rg_etc1::cLowQuality; - for(int i=0;i<=mmc;i++) { + pp.m_quality = rg_etc1::cLowQuality; + for (int i = 0; i <= mmc; i++) { - - int bw=MAX(imgw/4,1); - int bh=MAX(imgh/4,1); + int bw = MAX(imgw / 4, 1); + int bh = MAX(imgh / 4, 1); const uint8_t *src = &r[img.get_mipmap_offset(i)]; - int mmsize = MAX(bw,1)*MAX(bh,1)*8; - dst_data.resize(dst_data.size()+mmsize); - DVector::Write w=dst_data.write(); - uint8_t *dst = &w[dst_data.size()-mmsize]; - + int mmsize = MAX(bw, 1) * MAX(bh, 1) * 8; + dst_data.resize(dst_data.size() + mmsize); + DVector::Write w = dst_data.write(); + uint8_t *dst = &w[dst_data.size() - mmsize]; -// print_line("bh: "+itos(bh)+" bw: "+itos(bw)); + // print_line("bh: "+itos(bh)+" bw: "+itos(bw)); - for(int y=0;yget_width(),p_img->get_height(),mc-1,Image::FORMAT_ETC,dst_data); - - + *p_img = Image(p_img->get_width(), p_img->get_height(), mc - 1, Image::FORMAT_ETC, dst_data); } void _register_etc1_compress_func() { rg_etc1::pack_etc1_block_init(); - Image::_image_compress_etc_func=_compress_etc; - Image::_image_decompress_etc=_decompress_etc; - - + Image::_image_compress_etc_func = _compress_etc; + Image::_image_decompress_etc = _decompress_etc; } -- cgit v1.2.3-70-g09d2