diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-15 19:04:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-15 19:04:56 +0400 |
commit | 2ca89f7add1949295ac58de6697534d44508bca3 (patch) | |
tree | 1e01dca23380d77500345398619596a49b887b4e /source/blender | |
parent | 77ec3ae9d100ba32e3bd32e2208cf2686b2c6ded (diff) |
style cleanup
Diffstat (limited to 'source/blender')
3 files changed, 128 insertions, 128 deletions
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp index 0619bb5133e..fe9e97a3e4b 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp @@ -27,11 +27,11 @@ #include "COM_AntiAliasOperation.h" #include "BLI_math.h" -DilateErodeNode::DilateErodeNode(bNode *editorNode): Node(editorNode) +DilateErodeNode::DilateErodeNode(bNode *editorNode) : Node(editorNode) { } -void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) +void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { bNode *editorNode = this->getbNode(); @@ -43,7 +43,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); if (editorNode->custom3 < 2.0f) { - AntiAliasOperation * antiAlias = new AntiAliasOperation(); + AntiAliasOperation *antiAlias = new AntiAliasOperation(); addLink(graph, operation->getOutputSocket(), antiAlias->getInputSocket(0)); this->getOutputSocket(0)->relinkConnections(antiAlias->getOutputSocket(0)); graph->addOperation(antiAlias); @@ -55,14 +55,14 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont } else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) { if (editorNode->custom2 > 0) { - DilateDistanceOperation * operation = new DilateDistanceOperation(); + DilateDistanceOperation *operation = new DilateDistanceOperation(); operation->setDistance(editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); } else { - ErodeDistanceOperation * operation = new ErodeDistanceOperation(); + ErodeDistanceOperation *operation = new ErodeDistanceOperation(); operation->setDistance(-editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); @@ -71,14 +71,14 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont } else { if (editorNode->custom2 > 0) { - DilateStepOperation * operation = new DilateStepOperation(); + DilateStepOperation *operation = new DilateStepOperation(); operation->setIterations(editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); } else { - ErodeStepOperation * operation = new ErodeStepOperation(); + ErodeStepOperation *operation = new ErodeStepOperation(); operation->setIterations(-editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index bdd7362952a..17b043009ac 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -24,7 +24,7 @@ #include "BLI_math.h" // DilateErode Distance Threshold -DilateErodeThresholdOperation::DilateErodeThresholdOperation(): NodeOperation() +DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); @@ -38,11 +38,11 @@ void DilateErodeThresholdOperation::initExecution() { this->inputProgram = this->getInputSocketReader(0); if (this->distance < 0.0f) { - this->scope = - this->distance + this->inset; + this->scope = -this->distance + this->inset; } else { - if (this->inset*2 > this->distance) { - this->scope = max(this->inset*2 - this->distance, this->distance); + if (this->inset * 2 > this->distance) { + this->scope = max(this->inset * 2 - this->distance, this->distance); } else { this->scope = distance; @@ -67,45 +67,45 @@ void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, Mem float pixelvalue; const float rd = scope * scope; const float inset = this->inset; - float mindist = rd*2; + float mindist = rd * 2; - MemoryBuffer *inputBuffer = (MemoryBuffer*)data; + MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); rcti *rect = inputBuffer->getRect(); const int minx = max(x - scope, rect->xmin); const int miny = max(y - scope, rect->ymin); const int maxx = min(x + scope, rect->xmax); const int maxy = min(y + scope, rect->ymax); - const int bufferWidth = rect->xmax-rect->xmin; + const int bufferWidth = rect->xmax - rect->xmin; int offset; this->inputProgram->read(inputValue, x, y, inputBuffers, NULL); - if (inputValue[0]>sw) { - for (int yi = miny ; yi<maxy;yi++) { - offset = ((yi-rect->ymin)*bufferWidth+(minx-rect->xmin))*4; - for (int xi = minx ; xi<maxx;xi++) { - if (buffer[offset]<sw) { - const float dx = xi-x; - const float dy = yi-y; - const float dis = dx*dx+dy*dy; + if (inputValue[0] > sw) { + for (int yi = miny; yi < maxy; yi++) { + offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin)) * 4; + for (int xi = minx; xi < maxx; xi++) { + if (buffer[offset] < sw) { + const float dx = xi - x; + const float dy = yi - y; + const float dis = dx * dx + dy * dy; mindist = min(mindist, dis); } - offset +=4; + offset += 4; } } pixelvalue = -sqrtf(mindist); } else { - for (int yi = miny ; yi<maxy;yi++) { - offset = ((yi-rect->ymin)*bufferWidth+(minx-rect->xmin))*4; - for (int xi = minx ; xi<maxx;xi++) { - if (buffer[offset]>sw) { - const float dx = xi-x; - const float dy = yi-y; - const float dis = dx*dx+dy*dy; + for (int yi = miny; yi < maxy; yi++) { + offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin)) * 4; + for (int xi = minx; xi < maxx; xi++) { + if (buffer[offset] > sw) { + const float dx = xi - x; + const float dy = yi - y; + const float dis = dx * dx + dy * dy; mindist = min(mindist, dis); } - offset +=4; + offset += 4; } } @@ -119,7 +119,7 @@ void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, Mem color[0] = 1.0f; } else { - color[0] = delta/inset; + color[0] = delta / inset; } } else { @@ -127,13 +127,13 @@ void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, Mem } } else { - const float delta = -distance+pixelvalue; + const float delta = -distance + pixelvalue; if (delta < 0.0f) { if (delta < -inset) { color[0] = 1.0f; } else { - color[0] = (-delta)/inset; + color[0] = (-delta) / inset; } } else { @@ -160,7 +160,7 @@ bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(rcti *input } // Dilate Distance -DilateDistanceOperation::DilateDistanceOperation(): NodeOperation() +DilateDistanceOperation::DilateDistanceOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); @@ -189,28 +189,28 @@ void DilateDistanceOperation::executePixel(float *color, int x, int y, MemoryBuf const float distance = this->distance; float mindist = distance * distance; - MemoryBuffer *inputBuffer = (MemoryBuffer*)data; + MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); rcti *rect = inputBuffer->getRect(); const int minx = max(x - scope, rect->xmin); const int miny = max(y - scope, rect->ymin); const int maxx = min(x + scope, rect->xmax); const int maxy = min(y + scope, rect->ymax); - const int bufferWidth = rect->xmax-rect->xmin; + const int bufferWidth = rect->xmax - rect->xmin; int offset; float value = 0.0f; - for (int yi = miny ; yi<maxy;yi++) { - offset = ((yi-rect->ymin)*bufferWidth+(minx-rect->xmin))*4; - for (int xi = minx ; xi<maxx;xi++) { - const float dx = xi-x; - const float dy = yi-y; - const float dis = dx*dx+dy*dy; + for (int yi = miny; yi < maxy; yi++) { + offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin)) * 4; + for (int xi = minx; xi < maxx; xi++) { + const float dx = xi - x; + const float dy = yi - y; + const float dis = dx * dx + dy * dy; if (dis <= mindist) { value = max(buffer[offset], value); } - offset +=4; + offset += 4; } } color[0] = value; @@ -235,14 +235,14 @@ bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input, Read static cl_kernel dilateKernel = 0; void DilateDistanceOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, - MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, - MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, - list<cl_kernel> *clKernelsToCleanUp) + MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, + MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, + list<cl_kernel> *clKernelsToCleanUp) { if (!dilateKernel) { dilateKernel = COM_clCreateKernel(program, "dilateKernel", NULL); } - cl_int distanceSquared = this->distance*this->distance; + cl_int distanceSquared = this->distance * this->distance; cl_int scope = this->scope; COM_clAttachMemoryBufferToKernelParameter(context, dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); @@ -264,28 +264,28 @@ void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuff const float distance = this->distance; float mindist = distance * distance; - MemoryBuffer *inputBuffer = (MemoryBuffer*)data; + MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); rcti *rect = inputBuffer->getRect(); const int minx = max(x - scope, rect->xmin); const int miny = max(y - scope, rect->ymin); const int maxx = min(x + scope, rect->xmax); const int maxy = min(y + scope, rect->ymax); - const int bufferWidth = rect->xmax-rect->xmin; + const int bufferWidth = rect->xmax - rect->xmin; int offset; float value = 1.0f; - for (int yi = miny ; yi<maxy;yi++) { - offset = ((yi-rect->ymin)*bufferWidth+(minx-rect->xmin))*4; - for (int xi = minx ; xi<maxx;xi++) { - const float dx = xi-x; - const float dy = yi-y; - const float dis = dx*dx+dy*dy; + for (int yi = miny; yi < maxy; yi++) { + offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin)) * 4; + for (int xi = minx; xi < maxx; xi++) { + const float dx = xi - x; + const float dy = yi - y; + const float dis = dx * dx + dy * dy; if (dis <= mindist) { value = min(buffer[offset], value); } - offset +=4; + offset += 4; } } color[0] = value; @@ -293,14 +293,14 @@ void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuff static cl_kernel erodeKernel = 0; void ErodeDistanceOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, - MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, - MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, - list<cl_kernel> *clKernelsToCleanUp) + MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, + MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, + list<cl_kernel> *clKernelsToCleanUp) { if (!erodeKernel) { erodeKernel = COM_clCreateKernel(program, "erodeKernel", NULL); } - cl_int distanceSquared = this->distance*this->distance; + cl_int distanceSquared = this->distance * this->distance; cl_int scope = this->scope; COM_clAttachMemoryBufferToKernelParameter(context, erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); @@ -313,7 +313,7 @@ void ErodeDistanceOperation::executeOpenCL(cl_context context, cl_program progra } // Dilate step -DilateStepOperation::DilateStepOperation(): NodeOperation() +DilateStepOperation::DilateStepOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); @@ -334,37 +334,37 @@ void *DilateStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB } lockMutex(); if (this->cached_buffer == NULL) { - MemoryBuffer *buffer = (MemoryBuffer*)inputProgram->initializeTileData(NULL, memoryBuffers); + MemoryBuffer *buffer = (MemoryBuffer *)inputProgram->initializeTileData(NULL, memoryBuffers); float *rectf = buffer->convertToValueBuffer(); int x, y, i; float *p; int bwidth = buffer->getWidth(); int bheight = buffer->getHeight(); - for (i = 0 ; i < this->iterations ; i ++) { - for (y=0; y < bheight; y++) { - for (x=0; x < bwidth-1; x++) { - p = rectf + (bwidth*y + x); + for (i = 0; i < this->iterations; i++) { + for (y = 0; y < bheight; y++) { + for (x = 0; x < bwidth - 1; x++) { + p = rectf + (bwidth * y + x); *p = MAX2(*p, *(p + 1)); } } - for (y=0; y < bheight; y++) { - for (x=bwidth-1; x >= 1; x--) { - p = rectf + (bwidth*y + x); + for (y = 0; y < bheight; y++) { + for (x = bwidth - 1; x >= 1; x--) { + p = rectf + (bwidth * y + x); *p = MAX2(*p, *(p - 1)); } } - for (x=0; x < bwidth; x++) { - for (y=0; y < bheight-1; y++) { - p = rectf + (bwidth*y + x); + for (x = 0; x < bwidth; x++) { + for (y = 0; y < bheight - 1; y++) { + p = rectf + (bwidth * y + x); *p = MAX2(*p, *(p + bwidth)); } } - for (x=0; x < bwidth; x++) { - for (y=bheight-1; y >= 1; y--) { - p = rectf + (bwidth*y + x); + for (x = 0; x < bwidth; x++) { + for (y = bheight - 1; y >= 1; y--) { + p = rectf + (bwidth * y + x); *p = MAX2(*p, *(p - bwidth)); } } @@ -378,7 +378,7 @@ void *DilateStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB void DilateStepOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - color[0] = this->cached_buffer[y*this->getWidth()+x]; + color[0] = this->cached_buffer[y * this->getWidth() + x]; } void DilateStepOperation::deinitExecution() @@ -409,7 +409,7 @@ bool DilateStepOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff } // Erode step -ErodeStepOperation::ErodeStepOperation(): DilateStepOperation() +ErodeStepOperation::ErodeStepOperation() : DilateStepOperation() { } @@ -420,37 +420,37 @@ void *ErodeStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu } lockMutex(); if (this->cached_buffer == NULL) { - MemoryBuffer *buffer = (MemoryBuffer*)inputProgram->initializeTileData(NULL, memoryBuffers); + MemoryBuffer *buffer = (MemoryBuffer *)inputProgram->initializeTileData(NULL, memoryBuffers); float *rectf = buffer->convertToValueBuffer(); int x, y, i; float *p; int bwidth = buffer->getWidth(); int bheight = buffer->getHeight(); - for (i = 0 ; i < this->iterations ; i ++) { - for (y=0; y < bheight; y++) { - for (x=0; x < bwidth-1; x++) { - p = rectf + (bwidth*y + x); + for (i = 0; i < this->iterations; i++) { + for (y = 0; y < bheight; y++) { + for (x = 0; x < bwidth - 1; x++) { + p = rectf + (bwidth * y + x); *p = MIN2(*p, *(p + 1)); } } - for (y=0; y < bheight; y++) { - for (x=bwidth-1; x >= 1; x--) { - p = rectf + (bwidth*y + x); + for (y = 0; y < bheight; y++) { + for (x = bwidth - 1; x >= 1; x--) { + p = rectf + (bwidth * y + x); *p = MIN2(*p, *(p - 1)); } } - for (x=0; x < bwidth; x++) { - for (y=0; y < bheight-1; y++) { - p = rectf + (bwidth*y + x); + for (x = 0; x < bwidth; x++) { + for (y = 0; y < bheight - 1; y++) { + p = rectf + (bwidth * y + x); *p = MIN2(*p, *(p + bwidth)); } } - for (x=0; x < bwidth; x++) { - for (y=bheight-1; y >= 1; y--) { - p = rectf + (bwidth*y + x); + for (x = 0; x < bwidth; x++) { + for (y = bheight - 1; y >= 1; y--) { + p = rectf + (bwidth * y + x); *p = MIN2(*p, *(p - bwidth)); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c index 8363d5928bf..ec7aaccdbe2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.c +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c @@ -35,13 +35,13 @@ /* **************** Dilate/Erode ******************** */ -static bNodeSocketTemplate cmp_node_dilateerode_in[]= { - { SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, - { -1, 0, "" } +static bNodeSocketTemplate cmp_node_dilateerode_in[] = { + { SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, + { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_dilateerode_out[]= { - { SOCK_FLOAT, 0, N_("Mask")}, - { -1, 0, "" } +static bNodeSocketTemplate cmp_node_dilateerode_out[] = { + { SOCK_FLOAT, 0, N_("Mask")}, + { -1, 0, "" } }; static void morpho_dilate(CompBuf *cbuf) @@ -49,30 +49,30 @@ static void morpho_dilate(CompBuf *cbuf) int x, y; float *p, *rectf = cbuf->rect; - for (y=0; y < cbuf->y; y++) { - for (x=0; x < cbuf->x-1; x++) { - p = rectf + cbuf->x*y + x; + for (y = 0; y < cbuf->y; y++) { + for (x = 0; x < cbuf->x - 1; x++) { + p = rectf + cbuf->x * y + x; *p = MAX2(*p, *(p + 1)); } } - for (y=0; y < cbuf->y; y++) { - for (x=cbuf->x-1; x >= 1; x--) { - p = rectf + cbuf->x*y + x; + for (y = 0; y < cbuf->y; y++) { + for (x = cbuf->x - 1; x >= 1; x--) { + p = rectf + cbuf->x * y + x; *p = MAX2(*p, *(p - 1)); } } - for (x=0; x < cbuf->x; x++) { - for (y=0; y < cbuf->y-1; y++) { - p = rectf + cbuf->x*y + x; + for (x = 0; x < cbuf->x; x++) { + for (y = 0; y < cbuf->y - 1; y++) { + p = rectf + cbuf->x * y + x; *p = MAX2(*p, *(p + cbuf->x)); } } - for (x=0; x < cbuf->x; x++) { - for (y=cbuf->y-1; y >= 1; y--) { - p = rectf + cbuf->x*y + x; + for (x = 0; x < cbuf->x; x++) { + for (y = cbuf->y - 1; y >= 1; y--) { + p = rectf + cbuf->x * y + x; *p = MAX2(*p, *(p - cbuf->x)); } } @@ -83,30 +83,30 @@ static void morpho_erode(CompBuf *cbuf) int x, y; float *p, *rectf = cbuf->rect; - for (y=0; y < cbuf->y; y++) { - for (x=0; x < cbuf->x-1; x++) { - p = rectf + cbuf->x*y + x; + for (y = 0; y < cbuf->y; y++) { + for (x = 0; x < cbuf->x - 1; x++) { + p = rectf + cbuf->x * y + x; *p = MIN2(*p, *(p + 1)); } } - for (y=0; y < cbuf->y; y++) { - for (x=cbuf->x-1; x >= 1; x--) { - p = rectf + cbuf->x*y + x; + for (y = 0; y < cbuf->y; y++) { + for (x = cbuf->x - 1; x >= 1; x--) { + p = rectf + cbuf->x * y + x; *p = MIN2(*p, *(p - 1)); } } - for (x=0; x < cbuf->x; x++) { - for (y=0; y < cbuf->y-1; y++) { - p = rectf + cbuf->x*y + x; + for (x = 0; x < cbuf->x; x++) { + for (y = 0; y < cbuf->y - 1; y++) { + p = rectf + cbuf->x * y + x; *p = MIN2(*p, *(p + cbuf->x)); } } - for (x=0; x < cbuf->x; x++) { - for (y=cbuf->y-1; y >= 1; y--) { - p = rectf + cbuf->x*y + x; + for (x = 0; x < cbuf->x; x++) { + for (y = cbuf->y - 1; y >= 1; y--) { + p = rectf + cbuf->x * y + x; *p = MIN2(*p, *(p - cbuf->x)); } } @@ -117,18 +117,18 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod { /* stack order in: mask */ /* stack order out: mask */ - if (out[0]->hasoutput==0) + if (out[0]->hasoutput == 0) return; /* input no image? then only color operation */ - if (in[0]->data==NULL) { + if (in[0]->data == NULL) { out[0]->vec[0] = out[0]->vec[1] = out[0]->vec[2] = 0.0f; out[0]->vec[3] = 0.0f; } else { /* make output size of input image */ - CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_VAL); - CompBuf *stackbuf= dupalloc_compbuf(cbuf); + CompBuf *cbuf = typecheck_compbuf(in[0]->data, CB_VAL); + CompBuf *stackbuf = dupalloc_compbuf(cbuf); short i; if (node->custom2 > 0) { // positive, dilate @@ -140,10 +140,10 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod morpho_erode(stackbuf); } - if (cbuf!=in[0]->data) + if (cbuf != in[0]->data) free_compbuf(cbuf); - out[0]->data= stackbuf; + out[0]->data = stackbuf; } } |