Cleanup: style, use braces for compositor

This commit is contained in:
Campbell Barton 2019-04-23 11:21:22 +10:00
parent 64b4b719eb
commit 3302fbaeb1
66 changed files with 795 additions and 403 deletions

View File

@ -130,8 +130,9 @@ Node *Converter::convert(bNode *b_node)
Node *node = NULL;
/* ignore undefined nodes with missing or invalid node data */
if (!nodeIsRegistered(b_node))
if (!nodeIsRegistered(b_node)) {
return NULL;
}
switch (b_node->type) {
case CMP_NODE_COMPOSITE:
@ -514,8 +515,9 @@ void Converter::convertResolution(NodeOperationBuilder &builder,
TranslateOperation *translateOperation = new TranslateOperation();
translateOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
translateOperation->getInputSocket(2)->setResizeMode(COM_SC_NO_RESIZE);
if (!first)
if (!first) {
first = translateOperation;
}
SetValueOperation *xop = new SetValueOperation();
xop->setValue(addX);
builder.addLink(xop->getOutputSocket(), translateOperation->getInputSocket(1));

View File

@ -53,19 +53,23 @@ DebugInfo::GroupStateMap DebugInfo::m_group_states;
std::string DebugInfo::node_name(const Node *node)
{
NodeNameMap::const_iterator it = m_node_names.find(node);
if (it != m_node_names.end())
if (it != m_node_names.end()) {
return it->second;
else
}
else {
return "";
}
}
std::string DebugInfo::operation_name(const NodeOperation *op)
{
OpNameMap::const_iterator it = m_op_names.find(op);
if (it != m_op_names.end())
if (it != m_op_names.end()) {
return it->second;
else
}
else {
return "";
}
}
void DebugInfo::convert_started()
@ -79,8 +83,9 @@ void DebugInfo::execute_started(const ExecutionSystem *system)
m_group_states.clear();
for (ExecutionSystem::Groups::const_iterator it = system->m_groups.begin();
it != system->m_groups.end();
++it)
++it) {
m_group_states[*it] = EG_WAIT;
}
}
void DebugInfo::node_added(const Node *node)
@ -145,10 +150,12 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
}
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %p\r\n", operation);
if (group)
if (group) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p_%p\"", operation, group);
else
}
else {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p\"", operation);
}
len += snprintf(str + len,
maxlen > len ? maxlen - len : 0,
" [fillcolor=%s,style=filled,shape=record,label=\"{",
@ -368,8 +375,9 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
/* operations not included in any group */
for (int j = 0; j < totops; ++j) {
NodeOperation *operation = system->m_operations[j];
if (op_groups.find(operation) != op_groups.end())
if (op_groups.find(operation) != op_groups.end()) {
continue;
}
op_groups[operation].push_back(std::string(""));
@ -407,8 +415,9 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
NodeOperationInput *to = *it;
NodeOperationOutput *from = to->getLink();
if (!from)
if (!from) {
continue;
}
std::string color;
switch (from->getDataType()) {

View File

@ -96,8 +96,9 @@ bool ExecutionGroup::canContainOperation(NodeOperation *operation)
bool ExecutionGroup::addOperation(NodeOperation *operation)
{
if (!canContainOperation(operation))
if (!canContainOperation(operation)) {
return false;
}
if (!operation->isReadBufferOperation() && !operation->isWriteBufferOperation()) {
m_complex = operation->isComplex();
@ -342,8 +343,9 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
startEvaluated = true;
numberEvaluated++;
if (bTree->update_draw)
if (bTree->update_draw) {
bTree->update_draw(bTree->udh);
}
}
else if (state == COM_ES_SCHEDULED) {
finished = false;
@ -401,8 +403,9 @@ MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *mem
void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers)
{
if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED)
if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) {
this->m_chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED;
}
atomic_add_and_fetch_u(&this->m_chunksFinished, 1);
if (memoryBuffers) {

View File

@ -158,10 +158,12 @@ class MemoryBuffer {
case COM_MB_CLIP:
break;
case COM_MB_EXTEND:
if (x < 0)
if (x < 0) {
x = 0;
if (x >= w)
}
if (x >= w) {
x = w;
}
break;
case COM_MB_REPEAT:
x = (x >= 0.0f ? (x % w) : (x % w) + w);
@ -172,10 +174,12 @@ class MemoryBuffer {
case COM_MB_CLIP:
break;
case COM_MB_EXTEND:
if (y < 0)
if (y < 0) {
y = 0;
if (y >= h)
}
if (y >= h) {
y = h;
}
break;
case COM_MB_REPEAT:
y = (y >= 0.0f ? (y % h) : (y % h) + h);
@ -197,10 +201,12 @@ class MemoryBuffer {
case COM_MB_CLIP:
break;
case COM_MB_EXTEND:
if (x < 0)
if (x < 0) {
x = 0.0f;
if (x >= w)
}
if (x >= w) {
x = w;
}
break;
case COM_MB_REPEAT:
x = fmodf(x, w);
@ -211,10 +217,12 @@ class MemoryBuffer {
case COM_MB_CLIP:
break;
case COM_MB_EXTEND:
if (y < 0)
if (y < 0) {
y = 0.0f;
if (y >= h)
}
if (y >= h) {
y = h;
}
break;
case COM_MB_REPEAT:
y = fmodf(y, h);

View File

@ -48,10 +48,12 @@ Node::Node(bNode *editorNode, bool create_sockets)
bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
while (input != NULL) {
DataType dt = COM_DT_VALUE;
if (input->type == SOCK_RGBA)
if (input->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
if (input->type == SOCK_VECTOR)
}
if (input->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
}
this->addInputSocket(dt, input);
input = input->next;
@ -59,10 +61,12 @@ Node::Node(bNode *editorNode, bool create_sockets)
bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first;
while (output != NULL) {
DataType dt = COM_DT_VALUE;
if (output->type == SOCK_RGBA)
if (output->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
if (output->type == SOCK_VECTOR)
}
if (output->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
}
this->addOutputSocket(dt, output);
output = output->next;

View File

@ -60,8 +60,9 @@ bNodeSocket *NodeGraph::find_b_node_input(bNode *b_group_node, const char *ident
{
for (bNodeSocket *b_sock = (bNodeSocket *)b_group_node->inputs.first; b_sock;
b_sock = b_sock->next) {
if (STREQ(b_sock->identifier, identifier))
if (STREQ(b_sock->identifier, identifier)) {
return b_sock;
}
}
return NULL;
}
@ -70,8 +71,9 @@ bNodeSocket *NodeGraph::find_b_node_output(bNode *b_group_node, const char *iden
{
for (bNodeSocket *b_sock = (bNodeSocket *)b_group_node->outputs.first; b_sock;
b_sock = b_sock->next) {
if (STREQ(b_sock->identifier, identifier))
if (STREQ(b_sock->identifier, identifier)) {
return b_sock;
}
}
return NULL;
}
@ -149,8 +151,9 @@ void NodeGraph::add_bNode(const CompositorContext &context,
else {
/* regular nodes, handled in Converter */
Node *node = Converter::convert(b_node);
if (node)
if (node) {
add_node(node, b_ntree, key, is_active_group);
}
}
}
@ -186,24 +189,28 @@ NodeOutput *NodeGraph::find_output(const NodeRange &node_range, bNodeSocket *b_s
void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink)
{
/// \note: ignore invalid links
if (!(b_nodelink->flag & NODE_LINK_VALID))
if (!(b_nodelink->flag & NODE_LINK_VALID)) {
return;
if ((b_nodelink->fromsock->flag & SOCK_UNAVAIL) || (b_nodelink->tosock->flag & SOCK_UNAVAIL))
}
if ((b_nodelink->fromsock->flag & SOCK_UNAVAIL) || (b_nodelink->tosock->flag & SOCK_UNAVAIL)) {
return;
}
/* Note: a DNA input socket can have multiple NodeInput in the compositor tree! (proxies)
* The output then gets linked to each one of them.
*/
NodeOutput *output = find_output(node_range, b_nodelink->fromsock);
if (!output)
if (!output) {
return;
}
NodeInputs inputs = find_inputs(node_range, b_nodelink->tosock);
for (NodeInputs::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
NodeInput *input = *it;
if (input->isLinked())
if (input->isLinked()) {
continue;
}
add_link(output, input);
}
}
@ -232,8 +239,9 @@ void NodeGraph::add_proxies_skip(bNodeTree *b_ntree,
/* look for first input with matching datatype for each output */
for (input = (bNodeSocket *)b_node->inputs.first; input; input = input->next) {
if (input->type == output->type)
if (input->type == output->type) {
break;
}
}
if (input) {
@ -305,11 +313,13 @@ void NodeGraph::add_proxies_group(const CompositorContext &context,
/* create proxy nodes for group input/output nodes */
for (bNode *b_node_io = (bNode *)b_group_tree->nodes.first; b_node_io;
b_node_io = b_node_io->next) {
if (b_node_io->type == NODE_GROUP_INPUT)
if (b_node_io->type == NODE_GROUP_INPUT) {
add_proxies_group_inputs(b_node, b_node_io);
}
if (b_node_io->type == NODE_GROUP_OUTPUT && (b_node_io->flag & NODE_DO_OUTPUT))
if (b_node_io->type == NODE_GROUP_OUTPUT && (b_node_io->flag & NODE_DO_OUTPUT)) {
add_proxies_group_outputs(b_node, b_node_io, context.isGroupnodeBufferEnabled());
}
}
add_bNodeTree(context, nodes_start, b_group_tree, key);

View File

@ -142,10 +142,12 @@ SocketReader *NodeOperation::getInputSocketReader(unsigned int inputSocketIndex)
NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex)
{
NodeOperationInput *input = getInputSocket(inputSocketIndex);
if (input && input->isConnected())
if (input && input->isConnected()) {
return &input->getLink()->getOperation();
else
}
else {
return NULL;
}
}
void NodeOperation::getConnectedInputSockets(Inputs *sockets)
@ -216,8 +218,9 @@ SocketReader *NodeOperationInput::getReader()
void NodeOperationInput::determineResolution(unsigned int resolution[2],
unsigned int preferredResolution[2])
{
if (m_link)
if (m_link) {
m_link->determineResolution(resolution, preferredResolution);
}
}
/******************

View File

@ -365,8 +365,9 @@ class NodeOperation : public SocketReader {
inline void updateDraw()
{
if (this->m_btree->update_draw)
if (this->m_btree->update_draw) {
this->m_btree->update_draw(this->m_btree->udh);
}
}
protected:

View File

@ -70,8 +70,9 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
* so multiple operations can use the same node input.
*/
OpInputInverseMap inverse_input_map;
for (InputSocketMap::const_iterator it = m_input_map.begin(); it != m_input_map.end(); ++it)
for (InputSocketMap::const_iterator it = m_input_map.begin(); it != m_input_map.end(); ++it) {
inverse_input_map[it->second].push_back(it->first);
}
for (NodeGraph::Links::const_iterator it = m_graph.links().begin(); it != m_graph.links().end();
++it) {
@ -153,8 +154,9 @@ void NodeOperationBuilder::mapOutputSocket(NodeOutput *node_socket,
void NodeOperationBuilder::addLink(NodeOperationOutput *from, NodeOperationInput *to)
{
if (to->isConnected())
if (to->isConnected()) {
return;
}
m_links.push_back(Link(from, to));
@ -202,14 +204,17 @@ PreviewOperation *NodeOperationBuilder::make_preview_operation() const
{
BLI_assert(m_current_node);
if (!(m_current_node->getbNode()->flag & NODE_PREVIEW))
if (!(m_current_node->getbNode()->flag & NODE_PREVIEW)) {
return NULL;
}
/* previews only in the active group */
if (!m_current_node->isInActiveGroup())
if (!m_current_node->isInActiveGroup()) {
return NULL;
}
/* do not calculate previews of hidden nodes */
if (m_current_node->getbNode()->flag & NODE_HIDDEN)
if (m_current_node->getbNode()->flag & NODE_HIDDEN) {
return NULL;
}
bNodeInstanceHash *previews = m_context->getPreviewHash();
if (previews) {
@ -275,11 +280,13 @@ void NodeOperationBuilder::add_datatype_conversions()
/* proxy operations can skip data type conversion */
NodeOperation *from_op = &link.from()->getOperation();
NodeOperation *to_op = &link.to()->getOperation();
if (!(from_op->useDatatypeConversion() || to_op->useDatatypeConversion()))
if (!(from_op->useDatatypeConversion() || to_op->useDatatypeConversion())) {
continue;
}
if (link.from()->getDataType() != link.to()->getDataType())
if (link.from()->getDataType() != link.to()->getDataType()) {
convert_links.push_back(link);
}
}
for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
const Link &link = *it;
@ -305,8 +312,9 @@ void NodeOperationBuilder::add_operation_input_constants()
NodeOperation *op = *it;
for (int k = 0; k < op->getNumberOfInputSockets(); ++k) {
NodeOperationInput *input = op->getInputSocket(k);
if (!input->isConnected())
if (!input->isConnected()) {
pending_inputs.push_back(input);
}
}
}
for (Inputs::const_iterator it = pending_inputs.begin(); it != pending_inputs.end(); ++it) {
@ -321,10 +329,12 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
switch (input->getDataType()) {
case COM_DT_VALUE: {
float value;
if (node_input && node_input->getbNodeSocket())
if (node_input && node_input->getbNodeSocket()) {
value = node_input->getEditorValueFloat();
else
}
else {
value = 0.0f;
}
SetValueOperation *op = new SetValueOperation();
op->setValue(value);
@ -334,10 +344,12 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
}
case COM_DT_COLOR: {
float value[4];
if (node_input && node_input->getbNodeSocket())
if (node_input && node_input->getbNodeSocket()) {
node_input->getEditorValueColor(value);
else
}
else {
zero_v4(value);
}
SetColorOperation *op = new SetColorOperation();
op->setChannels(value);
@ -347,10 +359,12 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
}
case COM_DT_VECTOR: {
float value[3];
if (node_input && node_input->getbNodeSocket())
if (node_input && node_input->getbNodeSocket()) {
node_input->getEditorValueVector(value);
else
}
else {
zero_v3(value);
}
SetVectorOperation *op = new SetVectorOperation();
op->setVector(value);
@ -387,8 +401,9 @@ void NodeOperationBuilder::resolve_proxies()
/* we may not have a final proxy input link,
* in that case it just gets dropped
*/
if (from)
if (from) {
addLink(from, to);
}
}
}
@ -426,8 +441,9 @@ void NodeOperationBuilder::determineResolutions()
if (link.to()->getResizeMode() != COM_SC_NO_RESIZE) {
NodeOperation &from_op = link.from()->getOperation();
NodeOperation &to_op = link.to()->getOperation();
if (from_op.getWidth() != to_op.getWidth() || from_op.getHeight() != to_op.getHeight())
if (from_op.getWidth() != to_op.getWidth() || from_op.getHeight() != to_op.getHeight()) {
convert_links.push_back(link);
}
}
}
for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
@ -443,8 +459,9 @@ NodeOperationBuilder::OpInputs NodeOperationBuilder::cache_output_links(
OpInputs inputs;
for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
const Link &link = *it;
if (link.from() == output)
if (link.from() == output) {
inputs.push_back(link.to());
}
}
return inputs;
}
@ -456,8 +473,9 @@ WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation
const Link &link = *it;
if (link.from() == output) {
NodeOperation &op = link.to()->getOperation();
if (op.isWriteBufferOperation())
if (op.isWriteBufferOperation()) {
return (WriteBufferOperation *)(&op);
}
}
}
return NULL;
@ -466,8 +484,9 @@ WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation
void NodeOperationBuilder::add_input_buffers(NodeOperation * /*operation*/,
NodeOperationInput *input)
{
if (!input->isConnected())
if (!input->isConnected()) {
return;
}
NodeOperationOutput *output = input->getLink();
if (output->getOperation().isReadBufferOperation()) {
@ -505,8 +524,9 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
{
/* cache connected sockets, so we can safely remove links first before replacing them */
OpInputs targets = cache_output_links(output);
if (targets.empty())
if (targets.empty()) {
return;
}
WriteBufferOperation *writeOperation = NULL;
for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
@ -537,8 +557,9 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
/* add readbuffer op for every former connected input */
for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
NodeOperationInput *target = *it;
if (&target->getOperation() == writeOperation)
if (&target->getOperation() == writeOperation) {
continue; /* skip existing write op links */
}
ReadBufferOperation *readoperation = new ReadBufferOperation(
operation->getOutputSocket()->getDataType());
@ -557,20 +578,24 @@ void NodeOperationBuilder::add_complex_operation_buffers()
* will invalidate iterators over the main m_operations
*/
Operations complex_ops;
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
if ((*it)->isComplex())
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
if ((*it)->isComplex()) {
complex_ops.push_back(*it);
}
}
for (Operations::const_iterator it = complex_ops.begin(); it != complex_ops.end(); ++it) {
NodeOperation *op = *it;
DebugInfo::operation_read_write_buffer(op);
for (int index = 0; index < op->getNumberOfInputSockets(); index++)
for (int index = 0; index < op->getNumberOfInputSockets(); index++) {
add_input_buffers(op, op->getInputSocket(index));
}
for (int index = 0; index < op->getNumberOfOutputSockets(); index++)
for (int index = 0; index < op->getNumberOfOutputSockets(); index++) {
add_output_buffers(op, op->getOutputSocket(index));
}
}
}
@ -578,14 +603,16 @@ typedef std::set<NodeOperation *> Tags;
static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *op)
{
if (reachable.find(op) != reachable.end())
if (reachable.find(op) != reachable.end()) {
return;
}
reachable.insert(op);
for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
NodeOperationInput *input = op->getInputSocket(i);
if (input->isConnected())
if (input->isConnected()) {
find_reachable_operations_recursive(reachable, &input->getLink()->getOperation());
}
}
/* associated write-buffer operations are executed as well */
@ -603,8 +630,9 @@ void NodeOperationBuilder::prune_operations()
NodeOperation *op = *it;
/* output operations are primary executed operations */
if (op->isOutputOperation(m_context->isRendering()))
if (op->isOutputOperation(m_context->isRendering())) {
find_reachable_operations_recursive(reachable, op);
}
}
/* delete unreachable operations */
@ -612,10 +640,12 @@ void NodeOperationBuilder::prune_operations()
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
NodeOperation *op = *it;
if (reachable.find(op) != reachable.end())
if (reachable.find(op) != reachable.end()) {
reachable_ops.push_back(op);
else
}
else {
delete op;
}
}
/* finally replace the operations list with the pruned list */
m_operations = reachable_ops;
@ -626,14 +656,16 @@ static void sort_operations_recursive(NodeOperationBuilder::Operations &sorted,
Tags &visited,
NodeOperation *op)
{
if (visited.find(op) != visited.end())
if (visited.find(op) != visited.end()) {
return;
}
visited.insert(op);
for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
NodeOperationInput *input = op->getInputSocket(i);
if (input->isConnected())
if (input->isConnected()) {
sort_operations_recursive(sorted, visited, &input->getLink()->getOperation());
}
}
sorted.push_back(op);
@ -645,26 +677,30 @@ void NodeOperationBuilder::sort_operations()
sorted.reserve(m_operations.size());
Tags visited;
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
sort_operations_recursive(sorted, visited, *it);
}
m_operations = sorted;
}
static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group)
{
if (visited.find(op) != visited.end())
if (visited.find(op) != visited.end()) {
return;
}
visited.insert(op);
if (!group->addOperation(op))
if (!group->addOperation(op)) {
return;
}
/* add all eligible input ops to the group */
for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
NodeOperationInput *input = op->getInputSocket(i);
if (input->isConnected())
if (input->isConnected()) {
add_group_operations_recursive(visited, &input->getLink()->getOperation(), group);
}
}
}

View File

@ -133,8 +133,9 @@ cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
if (error == CL_SUCCESS)
if (error == CL_SUCCESS) {
cleanup->push_back(clBuffer);
}
error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer);
if (error != CL_SUCCESS) {
@ -263,8 +264,9 @@ cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname,
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
else {
if (clKernelsToCleanUp)
if (clKernelsToCleanUp) {
clKernelsToCleanUp->push_back(kernel);
}
}
return kernel;
}

View File

@ -44,8 +44,9 @@ void SingleThreadedOperation::deinitExecution()
}
void *SingleThreadedOperation::initializeTileData(rcti *rect)
{
if (this->m_cachedInstance)
if (this->m_cachedInstance) {
return this->m_cachedInstance;
}
lockMutex();
if (this->m_cachedInstance == NULL) {

View File

@ -239,8 +239,9 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
g_program = NULL;
if (clewInit() !=
CLEW_SUCCESS) /* this will check for errors and skip if already initialized */
CLEW_SUCCESS) { /* this will check for errors and skip if already initialized */
return;
}
if (clCreateContextFromType) {
cl_uint numberOfPlatforms = 0;
@ -251,8 +252,9 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
else if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
}
if (G.f & G_DEBUG)
if (G.f & G_DEBUG) {
printf("%u number of platforms\n", numberOfPlatforms);
}
cl_platform_id *platforms = (cl_platform_id *)MEM_mallocN(
sizeof(cl_platform_id) * numberOfPlatforms, __func__);
error = clGetPlatformIDs(numberOfPlatforms, platforms, 0);
@ -261,8 +263,9 @@ void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
cl_platform_id platform = platforms[indexPlatform];
cl_uint numberOfDevices = 0;
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices);
if (numberOfDevices <= 0)
if (numberOfDevices <= 0) {
continue;
}
cl_device_id *cldevices = (cl_device_id *)MEM_mallocN(
sizeof(cl_device_id) * numberOfDevices, __func__);

View File

@ -49,10 +49,12 @@ void CompositorNode::convertToOperations(NodeConverter &converter,
converter.addOperation(compositorOperation);
converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0));
/* only use alpha link if "use alpha" is enabled */
if (ignore_alpha)
if (ignore_alpha) {
converter.addInputValue(compositorOperation->getInputSocket(1), 1.0f);
else
}
else {
converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1));
}
converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2));
converter.addNodeInputPreview(imageSocket);

View File

@ -109,10 +109,12 @@ void DefocusNode::convertToOperations(NodeConverter &converter,
#endif
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
if (data->preview)
if (data->preview) {
operation->setQuality(COM_QUALITY_LOW);
else
}
else {
operation->setQuality(context.getQuality());
}
operation->setMaxBlur(data->maxblur);
operation->setThreshold(data->bthresh);
converter.addOperation(operation);

View File

@ -30,10 +30,12 @@ void DisplaceNode::convertToOperations(NodeConverter &converter,
const CompositorContext &context) const
{
NodeOperation *operation;
if (context.getQuality() == COM_QUALITY_LOW)
if (context.getQuality() == COM_QUALITY_LOW) {
operation = new DisplaceSimpleOperation();
else
}
else {
operation = new DisplaceOperation();
}
converter.addOperation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));

View File

@ -118,8 +118,9 @@ void ImageNode::convertToOperations(NodeConverter &converter,
* check if the view name exists in the image */
view = BLI_findstringindex(
&image->rr->views, context.getViewName(), offsetof(RenderView, name));
if (view == -1)
if (view == -1) {
view = 0;
}
}
else {
view = view_image - 1;
@ -195,8 +196,9 @@ void ImageNode::convertToOperations(NodeConverter &converter,
}
/* incase we can't load the layer */
if (operation == NULL)
if (operation == NULL) {
converter.setInvalidOutput(getOutputSocket(index));
}
}
}
}
@ -204,8 +206,9 @@ void ImageNode::convertToOperations(NodeConverter &converter,
/* without this, multilayer that fail to load will crash blender [#32490] */
if (is_multilayer_ok == false) {
for (int i = 0; i < getNumberOfOutputSockets(); ++i)
for (int i = 0; i < getNumberOfOutputSockets(); ++i) {
converter.setInvalidOutput(getOutputSocket(i));
}
}
}
else {

View File

@ -302,8 +302,9 @@ void KeyingNode::convertToOperations(NodeConverter &converter,
}
/* apply blur on matte if needed */
if (keying_data->blur_post)
if (keying_data->blur_post) {
postprocessedMatte = setupPostBlur(converter, postprocessedMatte, keying_data->blur_post);
}
/* matte dilate/erode */
if (keying_data->dilate_distance != 0) {
@ -342,6 +343,7 @@ void KeyingNode::convertToOperations(NodeConverter &converter,
converter.mapOutputSocket(outputImage, postprocessedImage);
converter.mapOutputSocket(outputMatte, postprocessedMatte);
if (edgesMatte)
if (edgesMatte) {
converter.mapOutputSocket(outputEdges, edgesMatte);
}
}

View File

@ -44,10 +44,12 @@ void LensDistortionNode::convertToOperations(NodeConverter &converter,
operation->setFit(data->fit);
operation->setJitter(data->jit);
if (!getInputSocket(1)->isLinked())
if (!getInputSocket(1)->isLinked()) {
operation->setDistortion(getInputSocket(1)->getEditorValueFloat());
if (!getInputSocket(2)->isLinked())
}
if (!getInputSocket(2)->isLinked()) {
operation->setDispersion(getInputSocket(2)->getEditorValueFloat());
}
converter.addOperation(operation);

View File

@ -51,11 +51,13 @@ void MovieClipNode::convertToOperations(NodeConverter &converter,
ImBuf *ibuf = NULL;
if (movieClip) {
if (cacheFrame)
if (cacheFrame) {
ibuf = BKE_movieclip_get_ibuf(movieClip, movieClipUser);
else
}
else {
ibuf = BKE_movieclip_get_ibuf_flag(
movieClip, movieClipUser, movieClip->flag, MOVIECLIP_CACHE_SKIP);
}
}
// always connect the output image

View File

@ -46,8 +46,9 @@ void RenderLayersNode::testSocketLink(NodeConverter &converter,
converter.mapOutputSocket(output, operation->getOutputSocket());
converter.addOperation(operation);
if (is_preview) /* only for image socket */
if (is_preview) { /* only for image socket */
converter.addPreview(operation->getOutputSocket());
}
}
void RenderLayersNode::testRenderLink(NodeConverter &converter,

View File

@ -45,10 +45,12 @@ void SeparateColorNode::convertToOperations(NodeConverter &converter,
operation->setChannel(0);
converter.addOperation(operation);
if (color_conv)
if (color_conv) {
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
else
}
else {
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
}
converter.mapOutputSocket(outputRSocket, operation->getOutputSocket(0));
}
@ -57,10 +59,12 @@ void SeparateColorNode::convertToOperations(NodeConverter &converter,
operation->setChannel(1);
converter.addOperation(operation);
if (color_conv)
if (color_conv) {
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
else
}
else {
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
}
converter.mapOutputSocket(outputGSocket, operation->getOutputSocket(0));
}
@ -69,10 +73,12 @@ void SeparateColorNode::convertToOperations(NodeConverter &converter,
operation->setChannel(2);
converter.addOperation(operation);
if (color_conv)
if (color_conv) {
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
else
}
else {
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
}
converter.mapOutputSocket(outputBSocket, operation->getOutputSocket(0));
}
@ -81,10 +87,12 @@ void SeparateColorNode::convertToOperations(NodeConverter &converter,
operation->setChannel(3);
converter.addOperation(operation);
if (color_conv)
if (color_conv) {
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
else
}
else {
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
}
converter.mapOutputSocket(outputASocket, operation->getOutputSocket(0));
}
}

View File

@ -34,17 +34,21 @@ SocketProxyNode::SocketProxyNode(bNode *editorNode,
DataType dt;
dt = COM_DT_VALUE;
if (editorInput->type == SOCK_RGBA)
if (editorInput->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
if (editorInput->type == SOCK_VECTOR)
}
if (editorInput->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
}
this->addInputSocket(dt, editorInput);
dt = COM_DT_VALUE;
if (editorOutput->type == SOCK_RGBA)
if (editorOutput->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
if (editorOutput->type == SOCK_VECTOR)
}
if (editorOutput->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
}
this->addOutputSocket(dt, editorOutput);
}
@ -63,17 +67,21 @@ SocketBufferNode::SocketBufferNode(bNode *editorNode,
DataType dt;
dt = COM_DT_VALUE;
if (editorInput->type == SOCK_RGBA)
if (editorInput->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
if (editorInput->type == SOCK_VECTOR)
}
if (editorInput->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
}
this->addInputSocket(dt, editorInput);
dt = COM_DT_VALUE;
if (editorOutput->type == SOCK_RGBA)
if (editorOutput->type == SOCK_RGBA) {
dt = COM_DT_COLOR;
if (editorOutput->type == SOCK_VECTOR)
}
if (editorOutput->type == SOCK_VECTOR) {
dt = COM_DT_VECTOR;
}
this->addOutputSocket(dt, editorOutput);
}

View File

@ -69,6 +69,7 @@ void SplitViewerNode::convertToOperations(NodeConverter &converter,
converter.addPreview(splitViewerOperation->getOutputSocket());
if (do_output)
if (do_output) {
converter.registerViewer(viewerOperation);
}
}

View File

@ -29,10 +29,12 @@ void SwitchNode::convertToOperations(NodeConverter &converter,
bool condition = this->getbNode()->custom1;
NodeOperationOutput *result;
if (!condition)
if (!condition) {
result = converter.addInputProxy(getInputSocket(0), false);
else
}
else {
result = converter.addInputProxy(getInputSocket(1), false);
}
converter.mapOutputSocket(getOutputSocket(0), result);
}

View File

@ -68,14 +68,17 @@ void ViewerNode::convertToOperations(NodeConverter &converter,
converter.addOperation(viewerOperation);
converter.mapInputSocket(imageSocket, viewerOperation->getInputSocket(0));
/* only use alpha link if "use alpha" is enabled */
if (ignore_alpha)
if (ignore_alpha) {
converter.addInputValue(viewerOperation->getInputSocket(1), 1.0f);
else
}
else {
converter.mapInputSocket(alphaSocket, viewerOperation->getInputSocket(1));
}
converter.mapInputSocket(depthSocket, viewerOperation->getInputSocket(2));
converter.addNodeInputPreview(imageSocket);
if (do_output)
if (do_output) {
converter.registerViewer(viewerOperation);
}
}

View File

@ -56,39 +56,55 @@ static int extrapolate9(float *E0,
*DST = *SRC; \
} while (0)
if ((!PEQ(B, H)) && (!PEQ(D, F))) {
if (PEQ(D, B))
if (PEQ(D, B)) {
PCPY(E0, D);
else
}
else {
PCPY(E0, E);
if ((PEQ(D, B) && !PEQ(E, C)) || (PEQ(B, F) && !PEQ(E, A)))
}
if ((PEQ(D, B) && !PEQ(E, C)) || (PEQ(B, F) && !PEQ(E, A))) {
PCPY(E1, B);
else
}
else {
PCPY(E1, E);
if (PEQ(B, F))
}
if (PEQ(B, F)) {
PCPY(E2, F);
else
}
else {
PCPY(E2, E);
if ((PEQ(D, B) && !PEQ(E, G)) || (PEQ(D, H) && !PEQ(E, A)))
}
if ((PEQ(D, B) && !PEQ(E, G)) || (PEQ(D, H) && !PEQ(E, A))) {
PCPY(E3, D);
else
}
else {
PCPY(E3, E);
}
PCPY(E4, E);
if ((PEQ(B, F) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, C)))
if ((PEQ(B, F) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, C))) {
PCPY(E5, F);
else
}
else {
PCPY(E5, E);
if (PEQ(D, H))
}
if (PEQ(D, H)) {
PCPY(E6, D);
else
}
else {
PCPY(E6, E);
if ((PEQ(D, H) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, G)))
}
if ((PEQ(D, H) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, G))) {
PCPY(E7, H);
else
}
else {
PCPY(E7, E);
if (PEQ(H, F))
}
if (PEQ(H, F)) {
PCPY(E8, F);
else
}
else {
PCPY(E8, E);
}
return 1;
}
else {

View File

@ -81,8 +81,9 @@ float *BlurBaseOperation::make_gausstab(float rad, int size)
}
sum = 1.0f / sum;
for (i = 0; i < n; i++)
for (i = 0; i < n; i++) {
gausstab[i] *= sum;
}
return gausstab;
}

View File

@ -58,10 +58,12 @@ void ChangeHSVOperation::executePixelSampled(float output[4],
this->m_valueOperation->readSampled(value, x, y, sampler);
output[0] = inputColor1[0] + (hue[0] - 0.5f);
if (output[0] > 1.0f)
if (output[0] > 1.0f) {
output[0] -= 1.0f;
else if (output[0] < 0.0f)
}
else if (output[0] < 0.0f) {
output[0] += 1.0f;
}
output[1] = inputColor1[1] * saturation[0];
output[2] = inputColor1[2] * value[0];
output[3] = inputColor1[3];

View File

@ -24,8 +24,9 @@ inline float colorbalance_cdl(float in, float offset, float power, float slope)
float x = in * slope + offset;
/* prevent NaN */
if (x < 0.0f)
if (x < 0.0f) {
x = 0.0f;
}
return powf(x, power);
}

View File

@ -28,8 +28,9 @@ inline float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float g
float x = (((linearrgb_to_srgb(in) - 1.0f) * lift_lgg) + 1.0f) * gain;
/* prevent NaN */
if (x < 0.0f)
if (x < 0.0f) {
x = 0.0f;
}
return powf(srgb_to_linearrgb(x), gamma_inv);
}

View File

@ -54,8 +54,9 @@ CompositorOperation::CompositorOperation() : NodeOperation()
void CompositorOperation::initExecution()
{
if (!this->m_active)
if (!this->m_active) {
return;
}
// When initializing the tree during initial load the width and height can be zero.
this->m_imageInput = getInputSocketReader(0);
@ -73,8 +74,9 @@ void CompositorOperation::initExecution()
void CompositorOperation::deinitExecution()
{
if (!this->m_active)
if (!this->m_active) {
return;
}
if (!isBreaked()) {
Render *re = RE_GetSceneRender(this->m_scene);
@ -136,8 +138,9 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
float *buffer = this->m_outputBuffer;
float *zbuffer = this->m_depthBuffer;
if (!buffer)
if (!buffer) {
return;
}
int x1 = rect->xmin;
int y1 = rect->ymin;
int x2 = rect->xmax;

View File

@ -56,8 +56,9 @@ void ConvertDepthToRadiusOperation::initExecution()
this->m_inputOperation = this->getInputSocketReader(0);
float focalDistance = determineFocalDistance();
if (focalDistance == 0.0f)
if (focalDistance == 0.0f) {
focalDistance = 1e10f; /* if the dof is 0.0 then set it to be far away */
}
this->m_inverseFocalDistance = 1.0f / focalDistance;
this->m_aspect = (this->getWidth() > this->getHeight()) ?
(this->getHeight() / (float)this->getWidth()) :
@ -95,8 +96,9 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
radius = 0.5f * fabsf(this->m_aperture *
(this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.0f));
// 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem
if (radius < 0.0f)
if (radius < 0.0f) {
radius = 0.0f;
}
if (radius > this->m_maxRadius) {
radius = this->m_maxRadius;
}

View File

@ -41,14 +41,18 @@ void CropBaseOperation::updateArea()
local_settings.y1 = height * local_settings.fac_y1;
local_settings.y2 = height * local_settings.fac_y2;
}
if (width <= local_settings.x1 + 1)
if (width <= local_settings.x1 + 1) {
local_settings.x1 = width - 1;
if (height <= local_settings.y1 + 1)
}
if (height <= local_settings.y1 + 1) {
local_settings.y1 = height - 1;
if (width <= local_settings.x2 + 1)
}
if (width <= local_settings.x2 + 1) {
local_settings.x2 = width - 1;
if (height <= local_settings.y2 + 1)
}
if (height <= local_settings.y2 + 1) {
local_settings.y2 = height - 1;
}
this->m_xmax = max(local_settings.x1, local_settings.x2) + 1;
this->m_xmin = min(local_settings.x1, local_settings.x2);

View File

@ -1340,8 +1340,9 @@ void DoubleEdgeMaskOperation::initExecution()
void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect)
{
if (this->m_cachedInstance)
if (this->m_cachedInstance) {
return this->m_cachedInstance;
}
lockMutex();
if (this->m_cachedInstance == NULL) {

View File

@ -89,17 +89,20 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
this->m_sy = this->m_data.sizey * this->m_size / 2.0f;
if ((this->m_sx == this->m_sy) && (this->m_sx > 0.0f)) {
for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c) {
IIR_gauss(copy, this->m_sx, c, 3);
}
}
else {
if (this->m_sx > 0.0f) {
for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c) {
IIR_gauss(copy, this->m_sx, c, 1);
}
}
if (this->m_sy > 0.0f) {
for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c) {
IIR_gauss(copy, this->m_sy, c, 2);
}
}
}
this->m_iirgaus = copy;
@ -123,27 +126,34 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
const unsigned int num_channels = src->get_num_channels();
// <0.5 not valid, though can have a possibly useful sort of sharpening effect
if (sigma < 0.5f)
if (sigma < 0.5f) {
return;
}
if ((xy < 1) || (xy > 3))
if ((xy < 1) || (xy > 3)) {
xy = 3;
}
// XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels,
// so just skipping blur along faulty direction if src's def is below that limit!
if (src_width < 3)
if (src_width < 3) {
xy &= ~1;
if (src_height < 3)
}
if (src_height < 3) {
xy &= ~2;
if (xy < 1)
}
if (xy < 1) {
return;
}
// see "Recursive Gabor Filtering" by Young/VanVliet
// all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200
if (sigma >= 3.556f)
if (sigma >= 3.556f) {
q = 0.9804f * (sigma - 3.556f) + 2.5091f;
else // sigma >= 0.5
}
else { // sigma >= 0.5
q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f;
}
q2 = q * q;
sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q);
// no gabor filtering here, so no complex multiplies, just the regular coefs.

View File

@ -98,8 +98,9 @@ void GaussianBokehBlurOperation::updateGauss()
if (sum > 0.0f) {
/* normalize */
float norm = 1.0f / sum;
for (j = n - 1; j >= 0; j--)
for (j = n - 1; j >= 0; j--) {
ddgauss[j] *= norm;
}
}
else {
int center = m_rady * ddwidth + m_radx;
@ -233,19 +234,23 @@ void GaussianBlurReferenceOperation::initExecution()
/* horizontal */
m_filtersizex = (float)this->m_data.sizex;
int imgx = getWidth() / 2;
if (m_filtersizex > imgx)
if (m_filtersizex > imgx) {
m_filtersizex = imgx;
else if (m_filtersizex < 1)
}
else if (m_filtersizex < 1) {
m_filtersizex = 1;
}
m_radx = (float)m_filtersizex;
/* vertical */
m_filtersizey = (float)this->m_data.sizey;
int imgy = getHeight() / 2;
if (m_filtersizey > imgy)
if (m_filtersizey > imgy) {
m_filtersizey = imgy;
else if (m_filtersizey < 1)
}
else if (m_filtersizey < 1) {
m_filtersizey = 1;
}
m_rady = (float)m_filtersizey;
updateGauss();
}
@ -277,14 +282,18 @@ void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y,
float refSize = tempSize[0];
int refradx = (int)(refSize * m_radx);
int refrady = (int)(refSize * m_rady);
if (refradx > m_filtersizex)
if (refradx > m_filtersizex) {
refradx = m_filtersizex;
else if (refradx < 1)
}
else if (refradx < 1) {
refradx = 1;
if (refrady > m_filtersizey)
}
if (refrady > m_filtersizey) {
refrady = m_filtersizey;
else if (refrady < 1)
}
else if (refrady < 1) {
refrady = 1;
}
if (refradx == 1 && refrady == 1) {
memorybuffer->readNoCheck(output, x, y);

View File

@ -30,8 +30,9 @@ static unsigned int nextPow2(unsigned int x, unsigned int *L2)
{
unsigned int pw, x_notpow2 = x & (x - 1);
*L2 = 0;
while (x >>= 1)
while (x >>= 1) {
++(*L2);
}
pw = 1 << (*L2);
if (x_notpow2) {
(*L2)++;
@ -46,8 +47,9 @@ static unsigned int nextPow2(unsigned int x, unsigned int *L2)
// use: r = revbin_upd(r, h) where h = N>>1
static unsigned int revbin_upd(unsigned int r, unsigned int h)
{
while (!((r ^= h) & h))
while (!((r ^= h) & h)) {
h >>= 1;
}
return r;
}
//------------------------------------------------------------------------------
@ -115,8 +117,9 @@ static void FHT(fREAL *data, unsigned int M, unsigned int inverse)
if (inverse) {
fREAL sc = (fREAL)1 / (fREAL)len;
for (k = 0; k < len; ++k)
for (k = 0; k < len; ++k) {
data[k] *= sc;
}
}
}
//------------------------------------------------------------------------------
@ -133,25 +136,29 @@ static void FHT2D(
// rows (forward transform skips 0 pad data)
maxy = inverse ? Ny : nzp;
for (j = 0; j < maxy; ++j)
for (j = 0; j < maxy; ++j) {
FHT(&data[Nx * j], Mx, inverse);
}
// transpose data
if (Nx == Ny) { // square
for (j = 0; j < Ny; ++j)
for (j = 0; j < Ny; ++j) {
for (i = j + 1; i < Nx; ++i) {
unsigned int op = i + (j << Mx), np = j + (i << My);
SWAP(fREAL, data[op], data[np]);
}
}
}
else { // rectangular
unsigned int k, Nym = Ny - 1, stm = 1 << (Mx + My);
for (i = 0; stm > 0; i++) {
#define PRED(k) (((k & Nym) << Mx) + (k >> My))
for (j = PRED(i); j > i; j = PRED(j))
for (j = PRED(i); j > i; j = PRED(j)) {
;
if (j < i)
}
if (j < i) {
continue;
}
for (k = i, j = PRED(i); j != i; k = j, j = PRED(j), stm--) {
SWAP(fREAL, data[j], data[k]);
}
@ -164,8 +171,9 @@ static void FHT2D(
SWAP(unsigned int, Mx, My);
// now columns == transposed rows
for (j = 0; j < Ny; ++j)
for (j = 0; j < Ny; ++j) {
FHT(&data[Nx * j], Mx, inverse);
}
// finalize
for (j = 0; j <= (Ny >> 1); j++) {
@ -280,19 +288,24 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
wt[0] = wt[1] = wt[2] = 0.0f;
for (y = 0; y < kernelHeight; y++) {
colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
for (x = 0; x < kernelWidth; x++)
for (x = 0; x < kernelWidth; x++) {
add_v3_v3(wt, colp[x]);
}
}
if (wt[0] != 0.0f)
if (wt[0] != 0.0f) {
wt[0] = 1.0f / wt[0];
if (wt[1] != 0.0f)
}
if (wt[1] != 0.0f) {
wt[1] = 1.0f / wt[1];
if (wt[2] != 0.0f)
}
if (wt[2] != 0.0f) {
wt[2] = 1.0f / wt[2];
}
for (y = 0; y < kernelHeight; y++) {
colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
for (x = 0; x < kernelWidth; x++)
for (x = 0; x < kernelWidth; x++) {
mul_v3_v3(colp[x], wt);
}
}
// copy image data, unpacking interleaved RGBA into separate channels
@ -304,11 +317,13 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
xbsz = (w2 + 1) - kernelWidth;
ybsz = (h2 + 1) - kernelHeight;
nxb = imageWidth / xbsz;
if (imageWidth % xbsz)
if (imageWidth % xbsz) {
nxb++;
}
nyb = imageHeight / ybsz;
if (imageHeight % ybsz)
if (imageHeight % ybsz) {
nyb++;
}
for (ybl = 0; ybl < nyb; ybl++) {
for (xbl = 0; xbl < nxb; xbl++) {
@ -322,8 +337,9 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
for (y = 0; y < kernelHeight; y++) {
fp = &data1ch[y * w2];
colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
for (x = 0; x < kernelWidth; x++)
for (x = 0; x < kernelWidth; x++) {
fp[x] = colp[x][ch];
}
}
}
@ -331,22 +347,25 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
memset(data2, 0, w2 * h2 * sizeof(fREAL));
for (y = 0; y < ybsz; y++) {
int yy = ybl * ybsz + y;
if (yy >= imageHeight)
if (yy >= imageHeight) {
continue;
}
fp = &data2[y * w2];
colp = (fRGB *)&imageBuffer[yy * imageWidth * COM_NUM_CHANNELS_COLOR];
for (x = 0; x < xbsz; x++) {
int xx = xbl * xbsz + x;
if (xx >= imageWidth)
if (xx >= imageWidth) {
continue;
}
fp[x] = colp[xx][ch];
}
}
// forward FHT
// zero pad data start is different for each == height+1
if (!in2done)
if (!in2done) {
FHT2D(data1ch, log2_w, log2_h, kernelHeight + 1, 0);
}
FHT2D(data2, log2_w, log2_h, kernelHeight + 1, 0);
// FHT2D transposed data, row/col now swapped
@ -358,14 +377,16 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
// overlap-add result
for (y = 0; y < (int)h2; y++) {
const int yy = ybl * ybsz + y - hh;
if ((yy < 0) || (yy >= imageHeight))
if ((yy < 0) || (yy >= imageHeight)) {
continue;
}
fp = &data2[y * w2];
colp = (fRGB *)&rdst->getBuffer()[yy * imageWidth * COM_NUM_CHANNELS_COLOR];
for (x = 0; x < (int)w2; x++) {
const int xx = xbl * xbsz + x - hw;
if ((xx < 0) || (xx >= imageWidth))
if ((xx < 0) || (xx >= imageWidth)) {
continue;
}
colp[xx][ch] += fp[x];
}
}

View File

@ -48,41 +48,54 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
bool breaked = false;
FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 0, 3);
if (!breaked)
if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 1, 3);
if (isBreaked())
}
if (isBreaked()) {
breaked = true;
if (!breaked)
}
if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 2, 3);
}
MemoryBuffer *tbuf2 = tbuf1->duplicate();
if (isBreaked())
if (isBreaked()) {
breaked = true;
if (!breaked)
}
if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 0, 3);
if (isBreaked())
}
if (isBreaked()) {
breaked = true;
if (!breaked)
}
if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 1, 3);
if (isBreaked())
}
if (isBreaked()) {
breaked = true;
if (!breaked)
}
if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3);
}
ofs = (settings->iter & 1) ? 0.5f : 0.0f;
for (x = 0; x < (settings->iter * 4); x++) {
y = x & 3;
cm[x][0] = cm[x][1] = cm[x][2] = 1;
if (y == 1)
if (y == 1) {
fRGB_rgbmult(cm[x], 1.0f, cmo, cmo);
if (y == 2)
}
if (y == 2) {
fRGB_rgbmult(cm[x], cmo, cmo, 1.0f);
if (y == 3)
}
if (y == 3) {
fRGB_rgbmult(cm[x], cmo, 1.0f, cmo);
}
scalef[x] = 2.1f * (1.0f - (x + ofs) / (float)(settings->iter * 4));
if (x & 1)
if (x & 1) {
scalef[x] = -0.99f / scalef[x];
}
}
sc = 2.13;
@ -104,8 +117,9 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
gbuf->writePixel(x, y, c);
}
if (isBreaked())
if (isBreaked()) {
breaked = true;
}
}
memset(tbuf1->getBuffer(),
@ -128,8 +142,9 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
}
tbuf1->addPixel(x, y, tc);
}
if (isBreaked())
if (isBreaked()) {
breaked = true;
}
}
memcpy(gbuf->getBuffer(),
tbuf1->getBuffer(),

View File

@ -54,10 +54,12 @@ void GlareStreaksOperation::generateGlare(float *data,
for (x = 0; x < tsrc->getWidth(); ++x, tdstcol += 4) {
// first pass no offset, always same for every pass, exact copy,
// otherwise results in uneven brightness, only need once
if (n == 0)
if (n == 0) {
tsrc->read(c1, x, y);
else
}
else {
c1[0] = c1[1] = c1[2] = 0;
}
tsrc->readBilinear(c2, x + vxp, y + vyp);
tsrc->readBilinear(c3, x + vxp * 2.0f, y + vyp * 2.0f);
tsrc->readBilinear(c4, x + vxp * 3.0f, y + vyp * 3.0f);

View File

@ -66,12 +66,14 @@ ImBuf *BaseImageOperation::getImBuf()
ImBuf *ibuf;
ImageUser iuser = *this->m_imageUser;
if (this->m_image == NULL)
if (this->m_image == NULL) {
return NULL;
}
/* local changes to the original ImageUser */
if (BKE_image_is_multilayer(this->m_image) == false)
if (BKE_image_is_multilayer(this->m_image) == false) {
iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
}
ibuf = BKE_image_acquire_ibuf(this->m_image, &iuser, NULL);
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
@ -194,8 +196,9 @@ void ImageDepthOperation::executePixelSampled(float output[4],
output[0] = 0.0f;
}
else {
if (x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight())
if (x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight()) {
output[0] = 0.0f;
}
else {
int offset = y * this->m_width + x;
output[0] = this->m_depthBuffer[offset];

View File

@ -125,10 +125,12 @@ void InpaintSimpleOperation::calc_manhatten_distance()
/* no need to clamp here */
if (this->get_pixel(i, j)[3] < 1.0f) {
r = width + height;
if (i > 0)
if (i > 0) {
r = min_ii(r, m[j * width + i - 1] + 1);
if (j > 0)
}
if (j > 0) {
r = min_ii(r, m[(j - 1) * width + i] + 1);
}
}
m[j * width + i] = r;
}
@ -138,10 +140,12 @@ void InpaintSimpleOperation::calc_manhatten_distance()
for (int i = width - 1; i >= 0; i--) {
int r = m[j * width + i];
if (i + 1 < width)
if (i + 1 < width) {
r = min_ii(r, m[j * width + i + 1] + 1);
if (j + 1 < height)
}
if (j + 1 < height) {
r = min_ii(r, m[(j + 1) * width + i] + 1);
}
m[j * width + i] = r;

View File

@ -54,10 +54,12 @@ void InvertOperation::executePixelSampled(float output[4], float x, float y, Pix
copy_v3_v3(output, inputColor);
}
if (this->m_alpha)
if (this->m_alpha) {
output[3] = (1.0f - inputColor[3]) * value + inputColor[3] * invertedValue;
else
}
else {
output[3] = inputColor[3];
}
}
void InvertOperation::deinitExecution()

View File

@ -90,21 +90,26 @@ void KeyingClipOperation::executePixel(float output[4], int x, int y, void *data
}
if (this->m_isEdgeMatte) {
if (ok)
if (ok) {
output[0] = 0.0f;
else
}
else {
output[0] = 1.0f;
}
}
else {
output[0] = value;
if (ok) {
if (output[0] < this->m_clipBlack)
if (output[0] < this->m_clipBlack) {
output[0] = 0.0f;
else if (output[0] >= this->m_clipWhite)
}
else if (output[0] >= this->m_clipWhite) {
output[0] = 1.0f;
else
}
else {
output[0] = (output[0] - this->m_clipBlack) / (this->m_clipWhite - this->m_clipBlack);
}
}
}
}

View File

@ -52,14 +52,17 @@ void KeyingScreenOperation::deinitExecution()
if (this->m_cachedTriangulation) {
TriangulationData *triangulation = this->m_cachedTriangulation;
if (triangulation->triangulated_points)
if (triangulation->triangulated_points) {
MEM_freeN(triangulation->triangulated_points);
}
if (triangulation->triangles)
if (triangulation->triangles) {
MEM_freeN(triangulation->triangles);
}
if (triangulation->triangles_AABB)
if (triangulation->triangles_AABB) {
MEM_freeN(triangulation->triangles_AABB);
}
MEM_freeN(this->m_cachedTriangulation);
@ -86,13 +89,15 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
if (this->m_trackingObject[0]) {
MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->m_trackingObject);
if (!object)
if (!object) {
return NULL;
}
tracksbase = BKE_tracking_object_get_tracks(tracking, object);
}
else
else {
tracksbase = BKE_tracking_get_active_tracks(tracking);
}
/* count sites */
for (track = (MovieTrackingTrack *)tracksbase->first, sites_total = 0; track;
@ -100,8 +105,9 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame);
float pos[2];
if (marker->flag & MARKER_DISABLED)
if (marker->flag & MARKER_DISABLED) {
continue;
}
add_v2_v2v2(pos, marker->pos, track->offset);
@ -112,14 +118,16 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
sites_total++;
}
if (!sites_total)
if (!sites_total) {
return NULL;
}
BKE_movieclip_user_set_frame(&user, clip_frame);
ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, &user);
if (!ibuf)
if (!ibuf) {
return NULL;
}
triangulation = (TriangulationData *)MEM_callocN(sizeof(TriangulationData),
"keying screen triangulation data");
@ -133,8 +141,9 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
int j;
float pos[2];
if (marker->flag & MARKER_DISABLED)
if (marker->flag & MARKER_DISABLED) {
continue;
}
add_v2_v2v2(pos, marker->pos, track->offset);
@ -225,8 +234,9 @@ void *KeyingScreenOperation::initializeTileData(rcti *rect)
int chunk_size = 20;
int i;
if (this->m_movieClip == NULL)
if (this->m_movieClip == NULL) {
return NULL;
}
if (!this->m_cachedTriangulation) {
lockMutex();
@ -238,8 +248,9 @@ void *KeyingScreenOperation::initializeTileData(rcti *rect)
triangulation = this->m_cachedTriangulation;
if (!triangulation)
if (!triangulation) {
return NULL;
}
tile_data = (TileData *)MEM_callocN(sizeof(TileData), "keying screen tile data");

View File

@ -73,10 +73,12 @@ void MapRangeOperation::executePixelSampled(float output[4],
value = (value - source_min) / (source_max - source_min);
value = dest_min + value * (dest_max - dest_min);
}
else if (value > BLENDER_ZMAX)
else if (value > BLENDER_ZMAX) {
value = dest_max;
else
}
else {
value = dest_min;
}
if (this->m_useClamp) {
if (dest_max > dest_min) {

View File

@ -64,10 +64,12 @@ void MapUVOperation::executePixelSampled(float output[4],
float dv = len_v2(deriv[1]);
float factor = 1.0f - threshold * (du / m_inputColorProgram->getWidth() +
dv / m_inputColorProgram->getHeight());
if (factor < 0.0f)
if (factor < 0.0f) {
alpha = 0.0f;
else
}
else {
alpha *= factor;
}
/* "premul" */
if (alpha < 1.0f) {

View File

@ -39,12 +39,16 @@ void MapValueOperation::executePixelSampled(float output[4],
this->m_inputOperation->readSampled(src, x, y, sampler);
TexMapping *texmap = this->m_settings;
float value = (src[0] + texmap->loc[0]) * texmap->size[0];
if (texmap->flag & TEXMAP_CLIP_MIN)
if (value < texmap->min[0])
if (texmap->flag & TEXMAP_CLIP_MIN) {
if (value < texmap->min[0]) {
value = texmap->min[0];
if (texmap->flag & TEXMAP_CLIP_MAX)
if (value > texmap->max[0])
}
}
if (texmap->flag & TEXMAP_CLIP_MAX) {
if (value > texmap->max[0]) {
value = texmap->max[0];
}
}
output[0] = value;
}

View File

@ -124,10 +124,12 @@ void MathDivideOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue2[0] == 0) /* We don't want to divide by zero. */
if (inputValue2[0] == 0) { /* We don't want to divide by zero. */
output[0] = 0.0;
else
}
else {
output[0] = inputValue1[0] / inputValue2[0];
}
clampIfNeeded(output);
}
@ -191,10 +193,12 @@ void MathArcSineOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
if (inputValue1[0] <= 1 && inputValue1[0] >= -1) {
output[0] = asin(inputValue1[0]);
else
}
else {
output[0] = 0.0;
}
clampIfNeeded(output);
}
@ -210,10 +214,12 @@ void MathArcCosineOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
if (inputValue1[0] <= 1 && inputValue1[0] >= -1) {
output[0] = acos(inputValue1[0]);
else
}
else {
output[0] = 0.0;
}
clampIfNeeded(output);
}
@ -273,10 +279,12 @@ void MathLogarithmOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue1[0] > 0 && inputValue2[0] > 0)
if (inputValue1[0] > 0 && inputValue2[0] > 0) {
output[0] = log(inputValue1[0]) / log(inputValue2[0]);
else
}
else {
output[0] = 0.0;
}
clampIfNeeded(output);
}
@ -372,10 +380,12 @@ void MathModuloOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
if (inputValue2[0] == 0)
if (inputValue2[0] == 0) {
output[0] = 0.0;
else
}
else {
output[0] = fmod(inputValue1[0], inputValue2[0]);
}
clampIfNeeded(output);
}
@ -461,10 +471,12 @@ void MathSqrtOperation::executePixelSampled(float output[4],
this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
if (inputValue1[0] > 0)
if (inputValue1[0] > 0) {
output[0] = sqrt(inputValue1[0]);
else
}
else {
output[0] = 0.0f;
}
clampIfNeeded(output);
}

View File

@ -185,42 +185,54 @@ void MixBurnOperation::executePixelSampled(float output[4], float x, float y, Pi
float valuem = 1.0f - value;
tmp = valuem + value * inputColor2[0];
if (tmp <= 0.0f)
if (tmp <= 0.0f) {
output[0] = 0.0f;
}
else {
tmp = 1.0f - (1.0f - inputColor1[0]) / tmp;
if (tmp < 0.0f)
if (tmp < 0.0f) {
output[0] = 0.0f;
else if (tmp > 1.0f)
}
else if (tmp > 1.0f) {
output[0] = 1.0f;
else
}
else {
output[0] = tmp;
}
}
tmp = valuem + value * inputColor2[1];
if (tmp <= 0.0f)
if (tmp <= 0.0f) {
output[1] = 0.0f;
}
else {
tmp = 1.0f - (1.0f - inputColor1[1]) / tmp;
if (tmp < 0.0f)
if (tmp < 0.0f) {
output[1] = 0.0f;
else if (tmp > 1.0f)
}
else if (tmp > 1.0f) {
output[1] = 1.0f;
else
}
else {
output[1] = tmp;
}
}
tmp = valuem + value * inputColor2[2];
if (tmp <= 0.0f)
if (tmp <= 0.0f) {
output[2] = 0.0f;
}
else {
tmp = 1.0f - (1.0f - inputColor1[2]) / tmp;
if (tmp < 0.0f)
if (tmp < 0.0f) {
output[2] = 0.0f;
else if (tmp > 1.0f)
}
else if (tmp > 1.0f) {
output[2] = 1.0f;
else
}
else {
output[2] = tmp;
}
}
output[3] = inputColor1[3];
@ -365,18 +377,24 @@ void MixDivideOperation::executePixelSampled(float output[4],
}
float valuem = 1.0f - value;
if (inputColor2[0] != 0.0f)
if (inputColor2[0] != 0.0f) {
output[0] = valuem * (inputColor1[0]) + value * (inputColor1[0]) / inputColor2[0];
else
}
else {
output[0] = 0.0f;
if (inputColor2[1] != 0.0f)
}
if (inputColor2[1] != 0.0f) {
output[1] = valuem * (inputColor1[1]) + value * (inputColor1[1]) / inputColor2[1];
else
}
else {
output[1] = 0.0f;
if (inputColor2[2] != 0.0f)
}
if (inputColor2[2] != 0.0f) {
output[2] = valuem * (inputColor1[2]) + value * (inputColor1[2]) / inputColor2[2];
else
}
else {
output[2] = 0.0f;
}
output[3] = inputColor1[3];
@ -411,48 +429,60 @@ void MixDodgeOperation::executePixelSampled(float output[4],
if (inputColor1[0] != 0.0f) {
tmp = 1.0f - value * inputColor2[0];
if (tmp <= 0.0f)
if (tmp <= 0.0f) {
output[0] = 1.0f;
}
else {
tmp = inputColor1[0] / tmp;
if (tmp > 1.0f)
if (tmp > 1.0f) {
output[0] = 1.0f;
else
}
else {
output[0] = tmp;
}
}
}
else
else {
output[0] = 0.0f;
}
if (inputColor1[1] != 0.0f) {
tmp = 1.0f - value * inputColor2[1];
if (tmp <= 0.0f)
if (tmp <= 0.0f) {
output[1] = 1.0f;
}
else {
tmp = inputColor1[1] / tmp;
if (tmp > 1.0f)
if (tmp > 1.0f) {
output[1] = 1.0f;
else
}
else {
output[1] = tmp;
}
}
}
else
else {
output[1] = 0.0f;
}
if (inputColor1[2] != 0.0f) {
tmp = 1.0f - value * inputColor2[2];
if (tmp <= 0.0f)
if (tmp <= 0.0f) {
output[2] = 1.0f;
}
else {
tmp = inputColor1[2] / tmp;
if (tmp > 1.0f)
if (tmp > 1.0f) {
output[2] = 1.0f;
else
}
else {
output[2] = tmp;
}
}
}
else
else {
output[2] = 0.0f;
}
output[3] = inputColor1[3];
@ -482,12 +512,15 @@ void MixGlareOperation::executePixelSampled(float output[4],
value = inputValue[0];
float mf = 2.0f - 2.0f * fabsf(value - 0.5f);
if (inputColor1[0] < 0.0f)
if (inputColor1[0] < 0.0f) {
inputColor1[0] = 0.0f;
if (inputColor1[1] < 0.0f)
}
if (inputColor1[1] < 0.0f) {
inputColor1[1] = 0.0f;
if (inputColor1[2] < 0.0f)
}
if (inputColor1[2] < 0.0f) {
inputColor1[2] = 0.0f;
}
output[0] = mf * max(inputColor1[0] + value * (inputColor2[0] - inputColor1[0]), 0.0f);
output[1] = mf * max(inputColor1[1] + value * (inputColor2[1] - inputColor1[1]), 0.0f);
@ -565,20 +598,26 @@ void MixLightenOperation::executePixelSampled(float output[4],
}
float tmp;
tmp = value * inputColor2[0];
if (tmp > inputColor1[0])
if (tmp > inputColor1[0]) {
output[0] = tmp;
else
}
else {
output[0] = inputColor1[0];
}
tmp = value * inputColor2[1];
if (tmp > inputColor1[1])
if (tmp > inputColor1[1]) {
output[1] = tmp;
else
}
else {
output[1] = inputColor1[1];
}
tmp = value * inputColor2[2];
if (tmp > inputColor1[2])
if (tmp > inputColor1[2]) {
output[2] = tmp;
else
}
else {
output[2] = inputColor1[2];
}
output[3] = inputColor1[3];
clampIfNeeded(output);
@ -608,18 +647,24 @@ void MixLinearLightOperation::executePixelSampled(float output[4],
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}
if (inputColor2[0] > 0.5f)
if (inputColor2[0] > 0.5f) {
output[0] = inputColor1[0] + value * (2.0f * (inputColor2[0] - 0.5f));
else
}
else {
output[0] = inputColor1[0] + value * (2.0f * (inputColor2[0]) - 1.0f);
if (inputColor2[1] > 0.5f)
}
if (inputColor2[1] > 0.5f) {
output[1] = inputColor1[1] + value * (2.0f * (inputColor2[1] - 0.5f));
else
}
else {
output[1] = inputColor1[1] + value * (2.0f * (inputColor2[1]) - 1.0f);
if (inputColor2[2] > 0.5f)
}
if (inputColor2[2] > 0.5f) {
output[2] = inputColor1[2] + value * (2.0f * (inputColor2[2] - 0.5f));
else
}
else {
output[2] = inputColor1[2] + value * (2.0f * (inputColor2[2]) - 1.0f);
}
output[3] = inputColor1[3];

View File

@ -42,11 +42,13 @@ void MovieClipBaseOperation::initExecution()
BKE_movieclip_user_set_frame(this->m_movieClipUser, this->m_framenumber);
ImBuf *ibuf;
if (this->m_cacheFrame)
if (this->m_cacheFrame) {
ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, this->m_movieClipUser);
else
}
else {
ibuf = BKE_movieclip_get_ibuf_flag(
this->m_movieClip, this->m_movieClipUser, this->m_movieClip->flag, MOVIECLIP_CACHE_SKIP);
}
if (ibuf) {
this->m_movieClipBuffer = ibuf;

View File

@ -72,8 +72,9 @@ void MultilayerColorOperation::executePixelSampled(float output[4],
int yi = y;
int xi = x;
if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() ||
(unsigned int)yi >= this->getHeight())
(unsigned int)yi >= this->getHeight()) {
zero_v4(output);
}
else {
int offset = (yi * this->getWidth() + xi) * 3;
copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
@ -94,8 +95,9 @@ void MultilayerValueOperation::executePixelSampled(float output[4],
int yi = y;
int xi = x;
if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() ||
(unsigned int)yi >= this->getHeight())
(unsigned int)yi >= this->getHeight()) {
output[0] = 0.0f;
}
else {
float result = this->m_imageFloatBuffer[yi * this->getWidth() + xi];
output[0] = result;
@ -115,8 +117,9 @@ void MultilayerVectorOperation::executePixelSampled(float output[4],
int yi = y;
int xi = x;
if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() ||
(unsigned int)yi >= this->getHeight())
(unsigned int)yi >= this->getHeight()) {
output[0] = 0.0f;
}
else {
int offset = (yi * this->getWidth() + xi) * 3;
copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);

View File

@ -42,10 +42,12 @@ void NormalizeOperation::executePixel(float output[4], int x, int y, void *data)
output[0] = (output[0] - minmult->x) * minmult->y;
/* clamp infinities */
if (output[0] > 1.0f)
if (output[0] > 1.0f) {
output[0] = 1.0f;
else if (output[0] < 0.0f)
}
else if (output[0] < 0.0f) {
output[0] = 0.0f;
}
}
void NormalizeOperation::deinitExecution()
@ -62,8 +64,9 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti * /*input*/,
rcti *output)
{
rcti imageInput;
if (this->m_cachedInstance)
if (this->m_cachedInstance) {
return false;
}
NodeOperation *operation = getInputOperation(0);
imageInput.xmax = operation->getWidth();

View File

@ -26,22 +26,22 @@
const sampler_t SAMPLER_NEAREST = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
const sampler_t SAMPLER_NEAREST_CLAMP = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
__constant const int2 zero = {0,0};
__constant const int zero = {0,0};
// KERNEL --- BOKEH BLUR ---
__kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only image2d_t inputImage,
__read_only image2d_t bokehImage, __write_only image2d_t output,
int2 offsetInput, int2 offsetOutput, int radius, int step, int2 dimension, int2 offset)
int offsetInput, int offsetOutput, int radius, int step, int dimension, int offset)
{
int2 coords = {get_global_id(0), get_global_id(1)};
int coords = {get_global_id(0), get_global_id(1)};
coords += offset;
float tempBoundingBox;
float4 color = {0.0f,0.0f,0.0f,0.0f};
float4 multiplyer = {0.0f,0.0f,0.0f,0.0f};
float4 bokeh;
float color = {0.0f,0.0f,0.0f,0.0f};
float multiplyer = {0.0f,0.0f,0.0f,0.0f};
float bokeh;
const float radius2 = radius*2.0f;
const int2 realCoordinate = coords + offsetOutput;
int2 imageCoordinates = realCoordinate - offsetInput;
const int realCoordinate = coords + offsetOutput;
int imageCoordinates = realCoordinate - offsetInput;
tempBoundingBox = read_imagef(boundingBox, SAMPLER_NEAREST, coords).s0;

View File

@ -66,14 +66,16 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filenam
exrhandle = IMB_exr_get_handle_name(filename);
if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
return exrhandle;
}
IMB_exr_clear_channels(exrhandle);
for (srv = (SceneRenderView *)this->m_rd->views.first; srv; srv = srv->next) {
if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false)
if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false) {
continue;
}
IMB_exr_add_view(exrhandle, srv->name);
add_exr_channels(exrhandle, NULL, this->m_datatype, srv->name, width, false, NULL);
@ -166,20 +168,22 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename
/* get a new global handle */
exrhandle = IMB_exr_get_handle_name(filename);
if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
return exrhandle;
}
IMB_exr_clear_channels(exrhandle);
/* check renderdata for amount of views */
for (srv = (SceneRenderView *)this->m_rd->views.first; srv; srv = srv->next) {
if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false)
if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false) {
continue;
}
IMB_exr_add_view(exrhandle, srv->name);
for (unsigned int i = 0; i < this->m_layers.size(); ++i)
for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
add_exr_channels(exrhandle,
this->m_layers[i].name,
this->m_layers[i].datatype,
@ -187,6 +191,7 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename
width,
this->m_exr_half_float,
NULL);
}
}
BLI_make_existing_file(filename);
@ -224,7 +229,7 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution()
exrhandle = this->get_handle(filename);
for (unsigned int i = 0; i < this->m_layers.size(); ++i)
for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
add_exr_channels(exrhandle,
this->m_layers[i].name,
this->m_layers[i].datatype,
@ -232,6 +237,7 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution()
width,
this->m_exr_half_float,
this->m_layers[i].outputBuffer);
}
for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
/* memory can only be freed after we write all views to the file */
@ -284,13 +290,15 @@ void *OutputStereoOperation::get_handle(const char *filename)
exrhandle = IMB_exr_get_handle_name(filename);
if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
return exrhandle;
}
IMB_exr_clear_channels(exrhandle);
for (i = 0; i < 2; i++)
for (i = 0; i < 2; i++) {
IMB_exr_add_view(exrhandle, names[i]);
}
return exrhandle;
}
@ -359,8 +367,9 @@ void OutputStereoOperation::deinitExecution()
BKE_imbuf_write(ibuf[2], filename, this->m_format);
/* imbuf knows which rects are not part of ibuf */
for (i = 0; i < 3; i++)
for (i = 0; i < 3; i++) {
IMB_freeImBuf(ibuf[i]);
}
IMB_exr_close(exrhandle);
}

View File

@ -86,8 +86,9 @@ void free_exr_channels(void *exrhandle,
for (srv = (SceneRenderView *)rd->views.first; srv; srv = srv->next) {
float *rect = NULL;
if (BKE_scene_multiview_is_render_view_active(rd, srv) == false)
if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
continue;
}
/* the pointer is stored in the first channel of each datatype */
switch (datatype) {
@ -103,8 +104,9 @@ void free_exr_channels(void *exrhandle,
default:
break;
}
if (rect)
if (rect) {
MEM_freeN(rect);
}
}
}
@ -129,8 +131,9 @@ 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
else {
return NULL;
}
}
static void write_buffer_rect(rcti *rect,
@ -143,8 +146,9 @@ static void write_buffer_rect(rcti *rect,
float color[4];
int i, size = get_datatype_size(datatype);
if (!buffer)
if (!buffer) {
return;
}
int x1 = rect->xmin;
int y1 = rect->ymin;
int x2 = rect->xmax;
@ -158,12 +162,14 @@ static void write_buffer_rect(rcti *rect,
for (x = x1; x < x2 && (!breaked); x++) {
reader->readSampled(color, x, y, COM_PS_NEAREST);
for (i = 0; i < size; ++i)
for (i = 0; i < size; ++i) {
buffer[offset + i] = color[i];
}
offset += size;
if (tree->test_break && tree->test_break(tree->tbh))
if (tree->test_break && tree->test_break(tree->tbh)) {
breaked = true;
}
}
offset += (width - (x2 - x1)) * size;
}
@ -240,10 +246,12 @@ void OutputSingleLayerOperation::deinitExecution()
true,
suffix);
if (0 == BKE_imbuf_write(ibuf, filename, this->m_format))
if (0 == BKE_imbuf_write(ibuf, filename, this->m_format)) {
printf("Cannot save Node File Output to %s\n", filename);
else
}
else {
printf("Saved: %s\n", filename);
}
IMB_freeImBuf(ibuf);
}
@ -304,13 +312,14 @@ void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int /*
{
for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
OutputOpenExrLayer &layer = this->m_layers[i];
if (layer.imageInput)
if (layer.imageInput) {
write_buffer_rect(rect,
this->m_tree,
layer.imageInput,
layer.outputBuffer,
this->getWidth(),
layer.datatype);
}
}
}
@ -336,8 +345,9 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
OutputOpenExrLayer &layer = this->m_layers[i];
if (!layer.imageInput)
if (!layer.imageInput) {
continue; /* skip unconnected sockets */
}
add_exr_channels(exrhandle,
this->m_layers[i].name,

View File

@ -43,13 +43,16 @@ static bool check_corners(float corners[4][2])
sub_v2_v2v2(v2, corners[next], corners[i]);
cur_cross = cross_v2v2(v1, v2);
if (fabsf(cur_cross) <= FLT_EPSILON)
if (fabsf(cur_cross) <= FLT_EPSILON) {
return false;
}
if (cross == 0.0f)
if (cross == 0.0f) {
cross = cur_cross;
else if (cross * cur_cross < 0.0f)
}
else if (cross * cur_cross < 0.0f) {
return false;
}
}
return true;
@ -205,9 +208,11 @@ void *PlaneCornerPinWarpImageOperation::initializeTileData(rcti *rect)
bool PlaneCornerPinWarpImageOperation::determineDependingAreaOfInterest(
rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
for (int i = 0; i < 4; ++i)
if (getInputOperation(i + 1)->determineDependingAreaOfInterest(input, readOperation, output))
for (int i = 0; i < 4; ++i) {
if (getInputOperation(i + 1)->determineDependingAreaOfInterest(input, readOperation, output)) {
return true;
}
}
/* XXX this is bad, but unavoidable with the current design:
* we don't know the actual corners and matrix at this point,

View File

@ -46,8 +46,9 @@ void PlaneTrackCommon::readCornersFromTrack(float corners[4][2], float frame)
MovieTracking *tracking;
MovieTrackingObject *object;
if (!this->m_movieClip)
if (!this->m_movieClip) {
return;
}
tracking = &this->m_movieClip->tracking;

View File

@ -97,8 +97,9 @@ bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(
void ProjectorLensDistortionOperation::updateDispersion()
{
if (this->m_dispersionAvailable)
if (this->m_dispersionAvailable) {
return;
}
this->lockMutex();
if (!this->m_dispersionAvailable) {
float result[4];

View File

@ -47,8 +47,9 @@ void RenderLayersProg::initExecution()
Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
RenderResult *rr = NULL;
if (re)
if (re) {
rr = RE_AcquireResultRead(re);
}
if (rr) {
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, getLayerId());
@ -74,12 +75,15 @@ void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelS
int ix = x, iy = y;
if (ix < 0 || iy < 0 || ix >= width || iy >= height) {
if (this->m_elementsize == 1)
if (this->m_elementsize == 1) {
output[0] = 0.0f;
else if (this->m_elementsize == 3)
}
else if (this->m_elementsize == 3) {
zero_v3(output);
else
}
else {
zero_v4(output);
}
return;
}
@ -87,12 +91,15 @@ void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelS
case COM_PS_NEAREST: {
offset = (iy * width + ix) * this->m_elementsize;
if (this->m_elementsize == 1)
if (this->m_elementsize == 1) {
output[0] = this->m_inputBuffer[offset];
else if (this->m_elementsize == 3)
}
else if (this->m_elementsize == 3) {
copy_v3_v3(output, &this->m_inputBuffer[offset]);
else
}
else {
copy_v4_v4(output, &this->m_inputBuffer[offset]);
}
break;
}
@ -185,8 +192,9 @@ void RenderLayersProg::determineResolution(unsigned int resolution[2],
resolution[0] = 0;
resolution[1] = 0;
if (re)
if (re) {
rr = RE_AcquireResultRead(re);
}
if (rr) {
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&sce->view_layers, getLayerId());
@ -199,8 +207,9 @@ void RenderLayersProg::determineResolution(unsigned int resolution[2],
}
}
if (re)
if (re) {
RE_ReleaseResult(re);
}
}
/* ******** Render Layers AO Operation ******** */

View File

@ -125,8 +125,9 @@ bool ScreenLensDistortionOperation::get_delta(float r_sq,
distort_uv(uv, t, delta);
return true;
}
else
else {
return false;
}
}
void ScreenLensDistortionOperation::accumulate(MemoryBuffer *buffer,
@ -182,12 +183,15 @@ void ScreenLensDistortionOperation::executePixel(float output[4], int x, int y,
accumulate(buffer, 0, 1, uv_dot, uv, delta, sum, count);
accumulate(buffer, 1, 2, uv_dot, uv, delta, sum, count);
if (count[0])
if (count[0]) {
output[0] = 2.0f * sum[0] / (float)count[0];
if (count[1])
}
if (count[1]) {
output[1] = 2.0f * sum[1] / (float)count[1];
if (count[2])
}
if (count[2]) {
output[2] = 2.0f * sum[2] / (float)count[2];
}
/* set alpha */
output[3] = 1.0f;

View File

@ -132,10 +132,12 @@ void TextureBaseOperation::executePixelSampled(float output[4],
retval = multitex_ext(
this->m_texture, vec, NULL, NULL, 0, &texres, thread_id, m_pool, m_sceneColorManage, false);
if (texres.talpha)
if (texres.talpha) {
output[3] = texres.ta;
else
}
else {
output[3] = texres.tin;
}
if ((retval & TEX_RGB)) {
output[0] = texres.tr;

View File

@ -52,8 +52,9 @@ void TrackPositionOperation::initExecution()
zero_v2(this->m_markerPos);
zero_v2(this->m_relativePos);
if (!this->m_movieClip)
if (!this->m_movieClip) {
return;
}
tracking = &this->m_movieClip->tracking;
@ -121,10 +122,12 @@ void TrackPositionOperation::executePixelSampled(float output[4],
{
output[0] = this->m_markerPos[this->m_axis] - this->m_relativePos[this->m_axis];
if (this->m_axis == 0)
if (this->m_axis == 0) {
output[0] *= this->m_width;
else
}
else {
output[0] *= this->m_height;
}
}
void TrackPositionOperation::determineResolution(unsigned int resolution[2],

View File

@ -178,10 +178,12 @@ void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop)
void zbuf_free_span(ZSpan *zspan)
{
if (zspan) {
if (zspan->span1)
if (zspan->span1) {
MEM_freeN(zspan->span1);
if (zspan->span2)
}
if (zspan->span2) {
MEM_freeN(zspan->span2);
}
zspan->span1 = zspan->span2 = NULL;
}
}
@ -213,18 +215,22 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
my0 = ceil(minv[1]);
my2 = floor(maxv[1]);
if (my2 < 0 || my0 >= zspan->recty)
if (my2 < 0 || my0 >= zspan->recty) {
return;
}
/* clip top */
if (my2 >= zspan->recty)
if (my2 >= zspan->recty) {
my2 = zspan->recty - 1;
}
/* clip bottom */
if (my0 < 0)
if (my0 < 0) {
my0 = 0;
}
if (my0 > my2)
if (my0 > my2) {
return;
}
/* if (my0>my2) should still fill in, that way we get spans that skip nicely */
xx1 = maxv[1] - minv[1];
@ -258,10 +264,12 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
if (zspan->maxp1 == NULL || zspan->maxp1[1] < maxv[1]) {
zspan->maxp1 = maxv;
}
if (my0 < zspan->miny1)
if (my0 < zspan->miny1) {
zspan->miny1 = my0;
if (my2 > zspan->maxy1)
}
if (my2 > zspan->maxy1) {
zspan->maxy1 = my2;
}
}
else {
// printf("right span my0 %d my2 %d\n", my0, my2);
@ -271,10 +279,12 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
if (zspan->maxp2 == NULL || zspan->maxp2[1] < maxv[1]) {
zspan->maxp2 = maxv;
}
if (my0 < zspan->miny2)
if (my0 < zspan->miny2) {
zspan->miny2 = my0;
if (my2 > zspan->maxy2)
}
if (my2 > zspan->maxy2) {
zspan->maxy2 = my2;
}
}
for (y = my2; y >= my0; y--, xs0 += dx0) {
@ -312,15 +322,17 @@ static void zbuf_fill_in_rgba(
zbuf_add_to_span(zspan, v4, v1);
/* clipped */
if (zspan->minp2 == NULL || zspan->maxp2 == NULL)
if (zspan->minp2 == NULL || zspan->maxp2 == NULL) {
return;
}
my0 = max_ii(zspan->miny1, zspan->miny2);
my2 = min_ii(zspan->maxy1, zspan->maxy2);
// printf("my %d %d\n", my0, my2);
if (my2 < my0)
if (my2 < my0) {
return;
}
/* ZBUF DX DY, in floats still */
x1 = v1[0] - v2[0];
@ -333,8 +345,9 @@ static void zbuf_fill_in_rgba(
y0 = z1 * x2 - x1 * z2;
z0 = x1 * y2 - y1 * x2;
if (z0 == 0.0f)
if (z0 == 0.0f) {
return;
}
xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + v1[2];
@ -364,10 +377,12 @@ static void zbuf_fill_in_rgba(
sn2 = floor(*span2);
sn1++;
if (sn2 >= rectx)
if (sn2 >= rectx) {
sn2 = rectx - 1;
if (sn1 < 0)
}
if (sn1 < 0) {
sn1 = 0;
}
if (sn2 >= sn1) {
zverg = (double)sn1 * zxd + zy0;
@ -409,8 +424,9 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
row3 = row2 + xsize;
for (x = 2; x < xsize; x++, row1++, row2++, row3++) {
if (row2[1]) {
if (row2[0] == 0 || row2[2] == 0 || row1[1] == 0 || row3[1] == 0)
if (row2[0] == 0 || row2[2] == 0 || row1[1] == 0 || row3[1] == 0) {
row2[1] = 128;
}
}
}
}
@ -424,8 +440,9 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
/* find previous color and next color and amount of steps to blend */
prev = row1[-1];
step = 1;
while (x + step < xsize && row1[step] == 128)
while (x + step < xsize && row1[step] == 128) {
step++;
}
if (x + step != xsize) {
/* now we can blend values */
@ -455,8 +472,9 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
/* find previous color and next color and amount of steps to blend */
prev = row1[-xsize];
step = 1;
while (y + step < ysize && row1[step * xsize] == 128)
while (y + step < ysize && row1[step * xsize] == 128) {
step++;
}
if (y + step != ysize) {
/* now we can blend values */
@ -483,8 +501,9 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
row3 = row2 + xsize;
for (x = 2; x < xsize; x++, row1++, row2++, row3++) {
if (row2[1] == 0) {
if (row2[0] > 1 || row2[2] > 1 || row1[1] > 1 || row3[1] > 1)
if (row2[0] > 1 || row2[2] > 1 || row1[1] > 1 || row3[1] > 1) {
row2[1] = 1;
}
}
}
}
@ -567,8 +586,9 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
tsktsk = 1;
}
}
if (tsktsk)
if (tsktsk) {
printf("Found uninitialized speed in vector buffer... fixed.\n");
}
/* min speed? then copy speedbuffer to recalculate speed vectors */
if (nbd->minspeed) {
@ -605,15 +625,19 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
dvz = rectvz;
for (y = 0; y <= ysize; y++) {
if (y == 0)
if (y == 0) {
dvec1 = vecbufrect + 4 * y * xsize;
else
}
else {
dvec1 = vecbufrect + 4 * (y - 1) * xsize;
}
if (y == ysize)
if (y == ysize) {
dvec2 = vecbufrect + 4 * (y - 1) * xsize;
else
}
else {
dvec2 = vecbufrect + 4 * y * xsize;
}
for (x = 0; x <= xsize; x++) {
@ -698,8 +722,9 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
dm = rectmove;
dvec1 = vecbufrect;
for (x = xsize * ysize; x > 0; x--, dm++, dvec1 += 4) {
if ((dvec1[0] != 0.0f || dvec1[1] != 0.0f || dvec1[2] != 0.0f || dvec1[3] != 0.0f))
if ((dvec1[0] != 0.0f || dvec1[1] != 0.0f || dvec1[2] != 0.0f || dvec1[3] != 0.0f)) {
*dm = 255;
}
}
antialias_tagbuf(xsize, ysize, rectmove);
@ -722,20 +747,26 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
float blendfac, ipodata[4];
/* clear zbuf, if we draw future we fill in not moving pixels */
if (0)
for (x = xsize * ysize - 1; x >= 0; x--)
rectz[x] = 10e16;
else
if (0) {
for (x = xsize * ysize - 1; x >= 0; x--) {
if (rectmove[x] == 0)
rectz[x] = zbufrect[x];
else
rectz[x] = 10e16;
rectz[x] = 10e16;
}
}
else {
for (x = xsize * ysize - 1; x >= 0; x--) {
if (rectmove[x] == 0) {
rectz[x] = zbufrect[x];
}
else {
rectz[x] = 10e16;
}
}
}
/* clear drawing buffer */
for (x = xsize * ysize - 1; x >= 0; x--)
for (x = xsize * ysize - 1; x >= 0; x--) {
rectdraw[x].colpoin = NULL;
}
dimg = imgrect;
dm = rectmove;
@ -790,12 +821,15 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
v3, speedfac * dz2[4] + jfx + 1.0f, speedfac * dz2[5] + jfy + 1.0f, *dz);
ARRAY_SET_ITEMS(v4, speedfac * dz2[0] + jfx, speedfac * dz2[1] + jfy + 1.0f, *dz);
}
if (*dm == 255)
if (*dm == 255) {
col.alpha = 1.0f;
else if (*dm < 2)
}
else if (*dm < 2) {
col.alpha = 0.0f;
else
}
else {
col.alpha = ((float)*dm) / 255.0f;
}
col.colpoin = dimg;
zbuf_fill_in_rgba(&zspan, &col, v1, v2, v3, v4);
@ -858,7 +892,8 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
MEM_freeN(rectvz);
MEM_freeN(rectweight);
MEM_freeN(rectmax);
if (minvecbufrect)
if (minvecbufrect) {
MEM_freeN(vecbufrect); /* rects were swapped! */
}
zbuf_free_span(&zspan);
}

View File

@ -82,8 +82,9 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
{
float *buffer = this->m_outputBuffer;
float *depthbuffer = this->m_depthBuffer;
if (!buffer)
if (!buffer) {
return;
}
const int x1 = rect->xmin;
const int y1 = rect->ymin;
const int x2 = rect->xmax;
@ -149,8 +150,9 @@ void ViewerOperation::initImage()
ibuf->x = getWidth();
ibuf->y = getHeight();
/* zero size can happen if no image buffers exist to define a sensible resolution */
if (ibuf->x > 0 && ibuf->y > 0)
if (ibuf->x > 0 && ibuf->y > 0) {
imb_addrectfloatImBuf(ibuf);
}
ima->ok = IMA_OK_LOADED;
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;

View File

@ -53,8 +53,9 @@ class ViewerOperation : public NodeOperation {
void executeRegion(rcti *rect, unsigned int tileNumber);
bool isOutputOperation(bool /*rendering*/) const
{
if (G.background)
if (G.background) {
return false;
}
return isActiveViewerOutput();
}
void setImage(Image *image)

View File

@ -25,19 +25,23 @@ WrapOperation::WrapOperation(DataType datatype) : ReadBufferOperation(datatype)
inline float WrapOperation::getWrappedOriginalXPos(float x)
{
if (this->getWidth() == 0)
if (this->getWidth() == 0) {
return 0;
while (x < 0)
}
while (x < 0) {
x += this->m_width;
}
return fmodf(x, this->getWidth());
}
inline float WrapOperation::getWrappedOriginalYPos(float y)
{
if (this->getHeight() == 0)
if (this->getHeight() == 0) {
return 0;
while (y < 0)
}
while (y < 0) {
y += this->m_height;
}
return fmodf(y, this->getHeight());
}