diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 09:24:14 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 09:24:14 +0300 |
commit | 41d4a1986548e66a652221e4a68c52900474eeff (patch) | |
tree | 26acf937ea0b762977f89adcc4e74a3ec9ecee62 /source/blender/imbuf | |
parent | 108045faa01849115c54190ebed788faf36dcb56 (diff) |
ClangFormat: format '#if 0' code in source/
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/intern/allocimbuf.c | 3 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/BlockDXT.h | 24 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/ColorBlock.cpp | 136 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/PixelFormat.h | 22 | ||||
-rw-r--r-- | source/blender/imbuf/intern/filter.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/jpeg.c | 7 | ||||
-rw-r--r-- | source/blender/imbuf/intern/png.c | 12 |
7 files changed, 113 insertions, 93 deletions
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 2c253f7f0e6..eaf3d58270a 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -587,7 +587,7 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1) static void imbuf_cache_destructor(void *data) { - ImBuf *ibuf = (ImBuf *) data; + ImBuf *ibuf = (ImBuf *)data; imb_freerectImBuf(ibuf); imb_freerectfloatImBuf(ibuf); @@ -598,7 +598,6 @@ static void imbuf_cache_destructor(void *data) ibuf->c_handle = NULL; } - static MEM_CacheLimiterC **get_imbuf_cache_limiter(void) { static MEM_CacheLimiterC *c = NULL; diff --git a/source/blender/imbuf/intern/dds/BlockDXT.h b/source/blender/imbuf/intern/dds/BlockDXT.h index c13fa42dcdc..b167fba71a2 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.h +++ b/source/blender/imbuf/intern/dds/BlockDXT.h @@ -138,22 +138,22 @@ struct AlphaBlockDXT5 { struct { uint64 alpha0 : 8; // 8 uint64 alpha1 : 8; // 16 - uint64 bits0 : 3; // 3 - 19 + uint64 bits0 : 3; // 3 - 19 uint64 bits1 : 3; // 6 - 22 uint64 bits2 : 3; // 9 - 25 - uint64 bits3 : 3; // 12 - 28 - uint64 bits4 : 3; // 15 - 31 - uint64 bits5 : 3; // 18 - 34 - uint64 bits6 : 3; // 21 - 37 - uint64 bits7 : 3; // 24 - 40 - uint64 bits8 : 3; // 27 - 43 + uint64 bits3 : 3; // 12 - 28 + uint64 bits4 : 3; // 15 - 31 + uint64 bits5 : 3; // 18 - 34 + uint64 bits6 : 3; // 21 - 37 + uint64 bits7 : 3; // 24 - 40 + uint64 bits8 : 3; // 27 - 43 uint64 bits9 : 3; // 30 - 46 uint64 bitsA : 3; // 33 - 49 - uint64 bitsB : 3; // 36 - 52 - uint64 bitsC : 3; // 39 - 55 - uint64 bitsD : 3; // 42 - 58 - uint64 bitsE : 3; // 45 - 61 - uint64 bitsF : 3; // 48 - 64 + uint64 bitsB : 3; // 36 - 52 + uint64 bitsC : 3; // 39 - 55 + uint64 bitsD : 3; // 42 - 58 + uint64 bitsE : 3; // 45 - 61 + uint64 bitsF : 3; // 48 - 64 }; uint64 u; }; diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index 73397cd036e..c392ef351ff 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -32,17 +32,18 @@ #include <Common.h> #if 0 - // Get approximate luminance. - inline static uint colorLuminance(Color32 c) - { - return c.r + c.g + c.b; - } +// Get approximate luminance. +inline static uint colorLuminance(Color32 c) +{ + return c.r + c.g + c.b; +} - // Get the euclidean distance between the given colors. - inline static uint colorDistance(Color32 c0, Color32 c1) - { - return (c0.r - c1.r) * (c0.r - c1.r) + (c0.g - c1.g) * (c0.g - c1.g) + (c0.b - c1.b) * (c0.b - c1.b); - } +// Get the euclidean distance between the given colors. +inline static uint colorDistance(Color32 c0, Color32 c1) +{ + return (c0.r - c1.r) * (c0.r - c1.r) + (c0.g - c1.g) * (c0.g - c1.g) + + (c0.b - c1.b) * (c0.b - c1.b); +} #endif /// Default constructor. @@ -173,18 +174,16 @@ bool ColorBlock::isSingleColorNoAlpha() const { Color32 c; int i; - for (i = 0; i < 16; i++) - { - if (m_color[i].a != 0) c = m_color[i]; + for (i = 0; i < 16; i++) { + if (m_color[i].a != 0) + c = m_color[i]; } Color32 mask(0xFF, 0xFF, 0xFF, 0x00); uint u = c.u & mask.u; - for (; i < 16; i++) - { - if (u != (m_color[i].u & mask.u)) - { + for (; i < 16; i++) { + if (u != (m_color[i].u & mask.u)) { return false; } } @@ -200,16 +199,15 @@ uint ColorBlock::countUniqueColors() const uint count = 0; // @@ This does not have to be o(n^2) - for (int i = 0; i < 16; i++) - { + for (int i = 0; i < 16; i++) { bool unique = true; for (int j = 0; j < i; j++) { - if ( m_color[i] != m_color[j] ) { + if (m_color[i] != m_color[j]) { unique = false; } } - if ( unique ) { + if (unique) { count++; } } @@ -255,9 +253,9 @@ void ColorBlock::diameterRange(Color32 *start, Color32 *end) const uint best_dist = 0; for (int i = 0; i < 16; i++) { - for (int j = i+1; j < 16; j++) { + for (int j = i + 1; j < 16; j++) { uint dist = colorDistance(m_color[i], m_color[j]); - if ( dist > best_dist ) { + if (dist > best_dist) { best_dist = dist; c0 = m_color[i]; c1 = m_color[j]; @@ -277,8 +275,7 @@ void ColorBlock::luminanceRange(Color32 *start, Color32 *end) const maxLuminance = minLuminance = colorLuminance(m_color[0]); - for (uint i = 1; i < 16; i++) - { + for (uint i = 1; i < 16; i++) { uint luminance = colorLuminance(m_color[i]); if (luminance > maxLuminance) { @@ -301,14 +298,25 @@ void ColorBlock::boundsRange(Color32 *start, Color32 *end) const Color32 minColor(255, 255, 255); Color32 maxColor(0, 0, 0); - for (uint i = 0; i < 16; i++) - { - if (m_color[i].r < minColor.r) { minColor.r = m_color[i].r; } - if (m_color[i].g < minColor.g) { minColor.g = m_color[i].g; } - if (m_color[i].b < minColor.b) { minColor.b = m_color[i].b; } - if (m_color[i].r > maxColor.r) { maxColor.r = m_color[i].r; } - if (m_color[i].g > maxColor.g) { maxColor.g = m_color[i].g; } - if (m_color[i].b > maxColor.b) { maxColor.b = m_color[i].b; } + for (uint i = 0; i < 16; i++) { + if (m_color[i].r < minColor.r) { + minColor.r = m_color[i].r; + } + if (m_color[i].g < minColor.g) { + minColor.g = m_color[i].g; + } + if (m_color[i].b < minColor.b) { + minColor.b = m_color[i].b; + } + if (m_color[i].r > maxColor.r) { + maxColor.r = m_color[i].r; + } + if (m_color[i].g > maxColor.g) { + maxColor.g = m_color[i].g; + } + if (m_color[i].b > maxColor.b) { + maxColor.b = m_color[i].b; + } } // Offset range by 1/16 of the extents @@ -335,16 +343,31 @@ void ColorBlock::boundsRangeAlpha(Color32 *start, Color32 *end) const Color32 minColor(255, 255, 255, 255); Color32 maxColor(0, 0, 0, 0); - for (uint i = 0; i < 16; i++) - { - if (m_color[i].r < minColor.r) { minColor.r = m_color[i].r; } - if (m_color[i].g < minColor.g) { minColor.g = m_color[i].g; } - if (m_color[i].b < minColor.b) { minColor.b = m_color[i].b; } - if (m_color[i].a < minColor.a) { minColor.a = m_color[i].a; } - if (m_color[i].r > maxColor.r) { maxColor.r = m_color[i].r; } - if (m_color[i].g > maxColor.g) { maxColor.g = m_color[i].g; } - if (m_color[i].b > maxColor.b) { maxColor.b = m_color[i].b; } - if (m_color[i].a > maxColor.a) { maxColor.a = m_color[i].a; } + for (uint i = 0; i < 16; i++) { + if (m_color[i].r < minColor.r) { + minColor.r = m_color[i].r; + } + if (m_color[i].g < minColor.g) { + minColor.g = m_color[i].g; + } + if (m_color[i].b < minColor.b) { + minColor.b = m_color[i].b; + } + if (m_color[i].a < minColor.a) { + minColor.a = m_color[i].a; + } + if (m_color[i].r > maxColor.r) { + maxColor.r = m_color[i].r; + } + if (m_color[i].g > maxColor.g) { + maxColor.g = m_color[i].g; + } + if (m_color[i].b > maxColor.b) { + maxColor.b = m_color[i].b; + } + if (m_color[i].a > maxColor.a) { + maxColor.a = m_color[i].a; + } } // Offset range by 1/16 of the extents @@ -374,19 +397,19 @@ void ColorBlock::boundsRangeAlpha(Color32 *start, Color32 *end) const void ColorBlock::sortColorsByAbsoluteValue() { // Dummy selection sort. - for ( uint a = 0; a < 16; a++ ) { + for (uint a = 0; a < 16; a++) { uint max = a; Color16 cmax(m_color[a]); - for ( uint b = a+1; b < 16; b++ ) { + for (uint b = a + 1; b < 16; b++) { Color16 cb(m_color[b]); - if ( cb.u > cmax.u ) { + if (cb.u > cmax.u) { max = b; cmax = cb; } } - swap( m_color[a], m_color[max] ); + swap(m_color[a], m_color[max]); } } #endif @@ -402,16 +425,15 @@ void ColorBlock::computeRange(Vector3::Arg axis, Color32 *start, Color32 *end) c float min, max; min = max = dot(Vector3(m_color[0].r, m_color[0].g, m_color[0].b), axis); - for (uint i = 1; i < 16; i++) - { + for (uint i = 1; i < 16; i++) { const Vector3 vec(m_color[i].r, m_color[i].g, m_color[i].b); float val = dot(vec, axis); - if ( val < min ) { + if (val < min) { mini = i; min = val; } - else if ( val > max ) { + else if (val > max) { maxi = i; max = val; } @@ -424,7 +446,7 @@ void ColorBlock::computeRange(Vector3::Arg axis, Color32 *start, Color32 *end) c #if 0 /// Sort colors in the given axis. -void ColorBlock::sortColors(const Vector3 & axis) +void ColorBlock::sortColors(const Vector3 &axis) { float luma_array[16]; @@ -434,15 +456,15 @@ void ColorBlock::sortColors(const Vector3 & axis) } // Dummy selection sort. - for ( uint a = 0; a < 16; a++ ) { + for (uint a = 0; a < 16; a++) { uint min = a; - for ( uint b = a+1; b < 16; b++ ) { - if ( luma_array[b] < luma_array[min] ) { + for (uint b = a + 1; b < 16; b++) { + if (luma_array[b] < luma_array[min]) { min = b; } } - swap( luma_array[a], luma_array[min] ); - swap( m_color[a], m_color[min] ); + swap(luma_array[a], luma_array[min]); + swap(m_color[a], m_color[min]); } } #endif diff --git a/source/blender/imbuf/intern/dds/PixelFormat.h b/source/blender/imbuf/intern/dds/PixelFormat.h index 07912b86f47..ba487afdfc1 100644 --- a/source/blender/imbuf/intern/dds/PixelFormat.h +++ b/source/blender/imbuf/intern/dds/PixelFormat.h @@ -112,17 +112,17 @@ inline float quantizeCeil(float f, int inbits, int outbits) } #if 0 - inline float quantizeRound(float f, int bits) - { - float scale = float(1 << bits); - return fround(f * scale) / scale; - } - - inline float quantizeFloor(float f, int bits) - { - float scale = float(1 << bits); - return floor(f * scale) / scale; - } +inline float quantizeRound(float f, int bits) +{ + float scale = float(1 << bits); + return fround(f * scale) / scale; +} + +inline float quantizeFloor(float f, int bits) +{ + float scale = float(1 << bits); + return floor(f * scale) / scale; +} #endif } // namespace PixelFormat diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 2d7e90db34e..32b1c6b280e 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -438,7 +438,7 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) k = 0; for (i = -n; i <= n; i++) for (j = -n; j <= n; j++) - weight[k++] = sqrt((float) i * i + j * j); + weight[k++] = sqrt((float)i * i + j * j); #endif weight[0] = 1; diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 6743fe536b1..a09f83e9b92 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -96,8 +96,8 @@ static void jpeg_error(j_common_ptr cinfo) #if 0 typedef struct { - unsigned char *buffer; - int filled; + unsigned char *buffer; + int filled; } buffer_struct; #endif @@ -572,7 +572,8 @@ static int init_jpeg(FILE *outfile, struct jpeg_compress_struct *cinfo, struct I /* just write RGBA as RGB, * unsupported feature only confuses other s/w */ - if (ibuf->planes == 32) cinfo->in_color_space = JCS_UNKNOWN; + if (ibuf->planes == 32) + cinfo->in_color_space = JCS_UNKNOWN; #endif switch (cinfo->in_color_space) { case JCS_RGB: diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 27cf30c71ba..bff2ac62fdf 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -389,13 +389,11 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) } #if 0 - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH | - PNG_ALL_FILTERS); + png_set_filter(png_ptr, + 0, + PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | + PNG_FILTER_UP | PNG_FILTER_VALUE_UP | PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | + PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH | PNG_ALL_FILTERS); #endif png_set_compression_level(png_ptr, compression); |