Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-08-07 13:39:50 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-08-07 14:38:06 +0300
commitdbf4f52fe0b7644ab607a6edd66facc6f1736693 (patch)
tree51d003842c620ddeb7258ebd863fd60eed972e7d /source/blender/imbuf/intern/dds
parentc889d93c80c52603a501b6b76f6e251b7a6112d2 (diff)
Cleanup: ImBuf, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/imbuf` module. No functional changes.
Diffstat (limited to 'source/blender/imbuf/intern/dds')
-rw-r--r--source/blender/imbuf/intern/dds/BlockDXT.cpp50
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp115
-rw-r--r--source/blender/imbuf/intern/dds/FlipDXT.cpp2
3 files changed, 77 insertions, 90 deletions
diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp
index 9fd6d71e091..1fbe7b46963 100644
--- a/source/blender/imbuf/intern/dds/BlockDXT.cpp
+++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp
@@ -97,21 +97,20 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
return 4;
}
- else {
- // Three-color block: derive the other color.
- color_array[2].r = (color_array[0].r + color_array[1].r) / 2;
- color_array[2].g = (color_array[0].g + color_array[1].g) / 2;
- color_array[2].b = (color_array[0].b + color_array[1].b) / 2;
- color_array[2].a = 0xFF;
- // Set all components to 0 to match DXT specs.
- color_array[3].r = 0x00; // color_array[2].r;
- color_array[3].g = 0x00; // color_array[2].g;
- color_array[3].b = 0x00; // color_array[2].b;
- color_array[3].a = 0x00;
+ // Three-color block: derive the other color.
+ color_array[2].r = (color_array[0].r + color_array[1].r) / 2;
+ color_array[2].g = (color_array[0].g + color_array[1].g) / 2;
+ color_array[2].b = (color_array[0].b + color_array[1].b) / 2;
+ color_array[2].a = 0xFF;
- return 3;
- }
+ // Set all components to 0 to match DXT specs.
+ color_array[3].r = 0x00; // color_array[2].r;
+ color_array[3].g = 0x00; // color_array[2].g;
+ color_array[3].b = 0x00; // color_array[2].b;
+ color_array[3].a = 0x00;
+
+ return 3;
}
uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
@@ -143,21 +142,20 @@ uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
return 4;
}
- else {
- // Three-color block: derive the other color.
- color_array[2].r = ((col0.r + col1.r) * 33) / 8;
- color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 128) / 256;
- color_array[2].b = ((col0.b + col1.b) * 33) / 8;
- color_array[2].a = 0xFF;
- // Set all components to 0 to match DXT specs.
- color_array[3].r = 0x00; // color_array[2].r;
- color_array[3].g = 0x00; // color_array[2].g;
- color_array[3].b = 0x00; // color_array[2].b;
- color_array[3].a = 0x00;
+ // Three-color block: derive the other color.
+ color_array[2].r = ((col0.r + col1.r) * 33) / 8;
+ color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 128) / 256;
+ color_array[2].b = ((col0.b + col1.b) * 33) / 8;
+ color_array[2].a = 0xFF;
- return 3;
- }
+ // Set all components to 0 to match DXT specs.
+ color_array[3].r = 0x00; // color_array[2].r;
+ color_array[3].g = 0x00; // color_array[2].g;
+ color_array[3].b = 0x00; // color_array[2].b;
+ color_array[3].a = 0x00;
+
+ return 3;
}
// Evaluate palette assuming 3 color block.
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index 9730153819e..92dd475813a 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -864,9 +864,8 @@ uint DDSHeader::d3d9Format() const
if (pf.flags & DDPF_FOURCC) {
return pf.fourcc;
}
- else {
- return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
- }
+
+ return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask);
}
DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem, size), header()
@@ -923,33 +922,32 @@ bool DirectDrawSurface::isSupported() const
return false;
}
- else {
- if (header.pf.flags & DDPF_FOURCC) {
- if (header.pf.fourcc != FOURCC_DXT1 && header.pf.fourcc != FOURCC_DXT2 &&
- header.pf.fourcc != FOURCC_DXT3 && header.pf.fourcc != FOURCC_DXT4 &&
- header.pf.fourcc != FOURCC_DXT5 && header.pf.fourcc != FOURCC_RXGB &&
- header.pf.fourcc != FOURCC_ATI1 && header.pf.fourcc != FOURCC_ATI2) {
- // Unknown fourcc code.
- return false;
- }
- }
- else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE)) {
- // All RGB and luminance formats are supported now.
- }
- else {
- return false;
- }
- if (isTextureCube() &&
- (header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) != DDSCAPS2_CUBEMAP_ALL_FACES) {
- // Cubemaps must contain all faces.
+ if (header.pf.flags & DDPF_FOURCC) {
+ if (header.pf.fourcc != FOURCC_DXT1 && header.pf.fourcc != FOURCC_DXT2 &&
+ header.pf.fourcc != FOURCC_DXT3 && header.pf.fourcc != FOURCC_DXT4 &&
+ header.pf.fourcc != FOURCC_DXT5 && header.pf.fourcc != FOURCC_RXGB &&
+ header.pf.fourcc != FOURCC_ATI1 && header.pf.fourcc != FOURCC_ATI2) {
+ // Unknown fourcc code.
return false;
}
+ }
+ else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE)) {
+ // All RGB and luminance formats are supported now.
+ }
+ else {
+ return false;
+ }
- if (isTexture3D()) {
- // @@ 3D textures not supported yet.
- return false;
- }
+ if (isTextureCube() &&
+ (header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) != DDSCAPS2_CUBEMAP_ALL_FACES) {
+ // Cubemaps must contain all faces.
+ return false;
+ }
+
+ if (isTexture3D()) {
+ // @@ 3D textures not supported yet.
+ return false;
}
return true;
@@ -963,23 +961,21 @@ bool DirectDrawSurface::hasAlpha() const
header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM ||
header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM;
}
- else {
- if (header.pf.flags & DDPF_RGB) {
- return header.pf.amask != 0;
- }
- else if (header.pf.flags & DDPF_FOURCC) {
- if (header.pf.fourcc == FOURCC_RXGB || header.pf.fourcc == FOURCC_ATI1 ||
- header.pf.fourcc == FOURCC_ATI2 || header.pf.flags & DDPF_NORMAL) {
- return false;
- }
- else {
- // @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?)
- return true;
- }
+
+ if (header.pf.flags & DDPF_RGB) {
+ return header.pf.amask != 0;
+ }
+ if (header.pf.flags & DDPF_FOURCC) {
+ if (header.pf.fourcc == FOURCC_RXGB || header.pf.fourcc == FOURCC_ATI1 ||
+ header.pf.fourcc == FOURCC_ATI2 || header.pf.flags & DDPF_NORMAL) {
+ return false;
}
- return false;
+ // @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?)
+ return true;
}
+
+ return false;
}
uint DirectDrawSurface::mipmapCount() const
@@ -987,9 +983,8 @@ uint DirectDrawSurface::mipmapCount() const
if (header.flags & DDSD_MIPMAPCOUNT) {
return header.mipmapcount;
}
- else {
- return 1;
- }
+
+ return 1;
}
uint DirectDrawSurface::fourCC() const
@@ -1002,9 +997,8 @@ uint DirectDrawSurface::width() const
if (header.flags & DDSD_WIDTH) {
return header.width;
}
- else {
- return 1;
- }
+
+ return 1;
}
uint DirectDrawSurface::height() const
@@ -1012,9 +1006,8 @@ uint DirectDrawSurface::height() const
if (header.flags & DDSD_HEIGHT) {
return header.height;
}
- else {
- return 1;
- }
+
+ return 1;
}
uint DirectDrawSurface::depth() const
@@ -1022,9 +1015,8 @@ uint DirectDrawSurface::depth() const
if (header.flags & DDSD_DEPTH) {
return header.depth;
}
- else {
- return 1;
- }
+
+ return 1;
}
bool DirectDrawSurface::isTexture1D() const
@@ -1040,9 +1032,8 @@ bool DirectDrawSurface::isTexture2D() const
if (header.hasDX10Header()) {
return header.header10.resourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE2D;
}
- else {
- return !isTexture3D() && !isTextureCube();
- }
+
+ return !isTexture3D() && !isTextureCube();
}
bool DirectDrawSurface::isTexture3D() const
@@ -1050,9 +1041,8 @@ bool DirectDrawSurface::isTexture3D() const
if (header.hasDX10Header()) {
return header.header10.resourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE3D;
}
- else {
- return (header.caps.caps2 & DDSCAPS2_VOLUME) != 0;
- }
+
+ return (header.caps.caps2 & DDSCAPS2_VOLUME) != 0;
}
bool DirectDrawSurface::isTextureCube() const
@@ -1355,16 +1345,15 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
h = (h + 3) / 4;
return blockSize() * w * h;
}
- else if (header.pf.flags & DDPF_RGB || (header.pf.flags & DDPF_LUMINANCE)) {
+ if (header.pf.flags & DDPF_RGB || (header.pf.flags & DDPF_LUMINANCE)) {
uint pitch = computePitch(
w, header.pf.bitcount, 8); // Assuming 8 bit alignment, which is the same D3DX expects.
return pitch * h * d;
}
- else {
- printf("DDS: mipmap format not supported\n");
- return (0);
- }
+
+ printf("DDS: mipmap format not supported\n");
+ return (0);
}
uint DirectDrawSurface::faceSize() const
diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp
index f5c937654b3..f46f50eb2b9 100644
--- a/source/blender/imbuf/intern/dds/FlipDXT.cpp
+++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp
@@ -217,7 +217,7 @@ int FlipDXTCImage(
// no flip to do, and we're done.
break;
}
- else if (mip_height == 2) {
+ if (mip_height == 2) {
// flip the first 2 lines in each block.
for (unsigned int i = 0; i < blocks_per_row; i++) {
half_block_function(data + i * block_bytes);