Cleanup: Compositor, Clang-Tidy else-after-return fixes

This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/compositor` module.

No functional changes.
This commit is contained in:
Sybren A. Stüvel
2020-08-07 12:32:45 +02:00
parent fb18e48a84
commit f453ee7d3a
19 changed files with 124 additions and 144 deletions

View File

@@ -36,7 +36,6 @@ int CompositorContext::getFramenumber() const
if (this->m_rd) {
return this->m_rd->cfra;
}
else {
return -1; /* this should never happen */
}
return -1; /* this should never happen */
}

View File

@@ -416,19 +416,19 @@ NodeOperation *Converter::convertDataType(NodeOperationOutput *from, NodeOperati
if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) {
return new ConvertValueToColorOperation();
}
else if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) {
if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) {
return new ConvertValueToVectorOperation();
}
else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) {
if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) {
return new ConvertColorToValueOperation();
}
else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) {
if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) {
return new ConvertColorToVectorOperation();
}
else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) {
if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) {
return new ConvertVectorToValueOperation();
}
else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) {
if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) {
return new ConvertVectorToColorOperation();
}

View File

@@ -136,10 +136,9 @@ float MemoryBuffer::getMaximumValue(rcti *rect)
delete temp;
return result;
}
else {
BLI_assert(0);
return 0.0f;
}
BLI_assert(0);
return 0.0f;
}
MemoryBuffer::~MemoryBuffer()

View File

@@ -145,9 +145,8 @@ NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex)
if (input && input->isConnected()) {
return &input->getLink()->getOperation();
}
else {
return NULL;
}
return NULL;
}
void NodeOperation::getConnectedInputSockets(Inputs *sockets)
@@ -168,30 +167,29 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input,
BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax);
return false;
}
else {
rcti tempOutput;
bool first = true;
for (int i = 0; i < getNumberOfInputSockets(); i++) {
NodeOperation *inputOperation = this->getInputOperation(i);
if (inputOperation &&
inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) {
if (first) {
output->xmin = tempOutput.xmin;
output->ymin = tempOutput.ymin;
output->xmax = tempOutput.xmax;
output->ymax = tempOutput.ymax;
first = false;
}
else {
output->xmin = min(output->xmin, tempOutput.xmin);
output->ymin = min(output->ymin, tempOutput.ymin);
output->xmax = max(output->xmax, tempOutput.xmax);
output->ymax = max(output->ymax, tempOutput.ymax);
}
rcti tempOutput;
bool first = true;
for (int i = 0; i < getNumberOfInputSockets(); i++) {
NodeOperation *inputOperation = this->getInputOperation(i);
if (inputOperation &&
inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) {
if (first) {
output->xmin = tempOutput.xmin;
output->ymin = tempOutput.ymin;
output->xmax = tempOutput.xmax;
output->ymax = tempOutput.ymax;
first = false;
}
else {
output->xmin = min(output->xmin, tempOutput.xmin);
output->ymin = min(output->ymin, tempOutput.ymin);
output->xmax = max(output->xmax, tempOutput.xmax);
output->ymax = max(output->ymax, tempOutput.ymax);
}
}
return !first;
}
return !first;
}
/*****************
@@ -210,9 +208,8 @@ SocketReader *NodeOperationInput::getReader()
if (isConnected()) {
return &m_link->getOperation();
}
else {
return NULL;
}
return NULL;
}
void NodeOperationInput::determineResolution(unsigned int resolution[2],

View File

@@ -105,9 +105,9 @@ static int extrapolate9(float *E0,
}
return 1;
}
else {
return 0;
}
return 0;
#undef PEQ
#undef PCPY
}

View File

@@ -39,9 +39,8 @@ float ConvertDepthToRadiusOperation::determineFocalDistance()
this->m_cam_lens = camera->lens;
return BKE_camera_object_dof_distance(this->m_cameraObject);
}
else {
return 10.0f;
}
return 10.0f;
}
void ConvertDepthToRadiusOperation::initExecution()

View File

@@ -73,14 +73,13 @@ bool DenoiseOperation::determineDependingAreaOfInterest(rcti * /*input*/,
if (isCached()) {
return false;
}
else {
rcti newInput;
newInput.xmax = this->getWidth();
newInput.xmin = 0;
newInput.ymax = this->getHeight();
newInput.ymin = 0;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
rcti newInput;
newInput.xmax = this->getWidth();
newInput.xmin = 0;
newInput.ymax = this->getHeight();
newInput.ymin = 0;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void DenoiseOperation::generateDenoise(float *data,

View File

@@ -74,13 +74,12 @@ bool DisplaceOperation::read_displacement(
r_v = 0.0f;
return false;
}
else {
float col[4];
m_inputVectorProgram->readSampled(col, x, y, COM_PS_BILINEAR);
r_u = origin[0] - col[0] * xscale;
r_v = origin[1] - col[1] * yscale;
return true;
}
float col[4];
m_inputVectorProgram->readSampled(col, x, y, COM_PS_BILINEAR);
r_u = origin[0] - col[0] * xscale;
r_v = origin[1] - col[1] * yscale;
return true;
}
void DisplaceOperation::pixelTransform(const float xy[2], float r_uv[2], float r_deriv[2][2])

View File

@@ -1330,9 +1330,8 @@ bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti * /*input*/,
newInput.ymin = 0;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
else {
return false;
}
return false;
}
void DoubleEdgeMaskOperation::initExecution()

View File

@@ -47,18 +47,17 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
}
else {
if (this->m_iirgaus) {
return false;
}
else {
newInput.xmin = 0;
newInput.ymin = 0;
newInput.xmax = this->getWidth();
newInput.ymax = this->getHeight();
}
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
if (this->m_iirgaus) {
return false;
}
newInput.xmin = 0;
newInput.ymin = 0;
newInput.xmax = this->getWidth();
newInput.ymax = this->getHeight();
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void FastGaussianBlurOperation::initExecution()
@@ -282,12 +281,12 @@ bool FastGaussianBlurValueOperation::determineDependingAreaOfInterest(
if (this->m_iirgaus) {
return false;
}
else {
newInput.xmin = 0;
newInput.ymin = 0;
newInput.xmax = this->getWidth();
newInput.ymax = this->getHeight();
}
newInput.xmin = 0;
newInput.ymin = 0;
newInput.xmax = this->getWidth();
newInput.ymax = this->getHeight();
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}

View File

@@ -176,23 +176,22 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
}
else {
if (this->m_sizeavailable && this->m_gausstab != NULL) {
newInput.xmin = 0;
newInput.ymin = 0;
newInput.xmax = this->getWidth();
newInput.ymax = this->getHeight();
}
else {
int addx = this->m_radx;
int addy = this->m_rady;
newInput.xmax = input->xmax + addx;
newInput.xmin = input->xmin - addx;
newInput.ymax = input->ymax + addy;
newInput.ymin = input->ymin - addy;
}
return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
if (this->m_sizeavailable && this->m_gausstab != NULL) {
newInput.xmin = 0;
newInput.ymin = 0;
newInput.xmax = this->getWidth();
newInput.ymax = this->getHeight();
}
else {
int addx = this->m_radx;
int addy = this->m_rady;
newInput.xmax = input->xmax + addx;
newInput.xmin = input->xmin - addx;
newInput.ymax = input->ymax + addy;
newInput.ymin = input->ymin - addy;
}
return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
// reference image
@@ -351,13 +350,12 @@ bool GaussianBlurReferenceOperation::determineDependingAreaOfInterest(
if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
return true;
}
else {
int addx = this->m_data.sizex + 2;
int addy = this->m_data.sizey + 2;
newInput.xmax = input->xmax + addx;
newInput.xmin = input->xmin - addx;
newInput.ymax = input->ymax + addy;
newInput.ymin = input->ymin - addy;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
int addx = this->m_data.sizex + 2;
int addy = this->m_data.sizey + 2;
newInput.xmax = input->xmax + addx;
newInput.xmin = input->xmin - addx;
newInput.ymax = input->ymax + addy;
newInput.ymin = input->ymin - addy;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}

View File

@@ -58,12 +58,11 @@ bool GlareBaseOperation::determineDependingAreaOfInterest(rcti * /*input*/,
if (isCached()) {
return false;
}
else {
rcti newInput;
newInput.xmax = this->getWidth();
newInput.xmin = 0;
newInput.ymax = this->getHeight();
newInput.ymin = 0;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
rcti newInput;
newInput.xmax = this->getWidth();
newInput.xmin = 0;
newInput.ymax = this->getHeight();
newInput.ymin = 0;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}

View File

@@ -28,9 +28,8 @@ static float smoothMask(float x, float y)
if ((t = 1.0f - sqrtf(x * x + y * y)) > 0.0f) {
return t;
}
else {
return 0.0f;
}
return 0.0f;
}
void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)

View File

@@ -272,14 +272,13 @@ bool InpaintSimpleOperation::determineDependingAreaOfInterest(rcti * /*input*/,
if (this->m_cached_buffer_ready) {
return false;
}
else {
rcti newInput;
newInput.xmax = getWidth();
newInput.xmin = 0;
newInput.ymax = getHeight();
newInput.ymin = 0;
rcti newInput;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
newInput.xmax = getWidth();
newInput.xmin = 0;
newInput.ymax = getHeight();
newInput.ymin = 0;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}

View File

@@ -87,14 +87,13 @@ bool MapUVOperation::read_uv(float x, float y, float &r_u, float &r_v, float &r_
r_alpha = 0.0f;
return false;
}
else {
float vector[3];
m_inputUVProgram->readSampled(vector, x, y, COM_PS_BILINEAR);
r_u = vector[0] * m_inputColorProgram->getWidth();
r_v = vector[1] * m_inputColorProgram->getHeight();
r_alpha = vector[2];
return true;
}
float vector[3];
m_inputUVProgram->readSampled(vector, x, y, COM_PS_BILINEAR);
r_u = vector[0] * m_inputColorProgram->getWidth();
r_v = vector[1] * m_inputColorProgram->getHeight();
r_alpha = vector[2];
return true;
}
void MapUVOperation::pixelTransform(const float xy[2],

View File

@@ -129,9 +129,8 @@ static float *init_buffer(unsigned int width, unsigned int height, DataType data
int size = get_datatype_size(datatype);
return (float *)MEM_callocN(width * height * size * sizeof(float), "OutputFile buffer");
}
else {
return NULL;
}
return NULL;
}
static void write_buffer_rect(rcti *rect,

View File

@@ -124,9 +124,8 @@ bool ScreenLensDistortionOperation::get_delta(float r_sq,
distort_uv(uv, t, delta);
return true;
}
else {
return false;
}
return false;
}
void ScreenLensDistortionOperation::accumulate(MemoryBuffer *buffer,

View File

@@ -115,9 +115,8 @@ bool VectorBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/,
newInput.ymin = 0;
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
else {
return false;
}
return false;
}
void VectorBlurOperation::generateVectorBlur(float *data,

View File

@@ -199,7 +199,6 @@ CompositorPriority ViewerOperation::getRenderPriority() const
if (this->isActiveViewerOutput()) {
return COM_PRIORITY_HIGH;
}
else {
return COM_PRIORITY_LOW;
}
return COM_PRIORITY_LOW;
}