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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp189
1 files changed, 97 insertions, 92 deletions
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
index a9f9ec9f091..59a397ab32d 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
@@ -20,122 +20,127 @@
#include "BLI_math.h"
#include "COM_OpenCLDevice.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
DirectionalBlurOperation::DirectionalBlurOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
- this->setOpenCL(true);
- this->m_inputProgram = NULL;
+ this->setOpenCL(true);
+ this->m_inputProgram = NULL;
}
void DirectionalBlurOperation::initExecution()
{
- this->m_inputProgram = getInputSocketReader(0);
- QualityStepHelper::initExecution(COM_QH_INCREASE);
- const float angle = this->m_data->angle;
- const float zoom = this->m_data->zoom;
- const float spin = this->m_data->spin;
- const float iterations = this->m_data->iter;
- const float distance = this->m_data->distance;
- const float center_x = this->m_data->center_x;
- const float center_y = this->m_data->center_y;
- const float width = getWidth();
- const float height = getHeight();
-
- const float a = angle;
- const float itsc = 1.0f / powf(2.0f, (float)iterations);
- float D;
-
- D = distance * sqrtf(width * width + height * height);
- this->m_center_x_pix = center_x * width;
- this->m_center_y_pix = center_y * height;
-
- this->m_tx = itsc * D * cosf(a);
- this->m_ty = -itsc * D * sinf(a);
- this->m_sc = itsc * zoom;
- this->m_rot = itsc * spin;
-
+ this->m_inputProgram = getInputSocketReader(0);
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
+ const float angle = this->m_data->angle;
+ const float zoom = this->m_data->zoom;
+ const float spin = this->m_data->spin;
+ const float iterations = this->m_data->iter;
+ const float distance = this->m_data->distance;
+ const float center_x = this->m_data->center_x;
+ const float center_y = this->m_data->center_y;
+ const float width = getWidth();
+ const float height = getHeight();
+
+ const float a = angle;
+ const float itsc = 1.0f / powf(2.0f, (float)iterations);
+ float D;
+
+ D = distance * sqrtf(width * width + height * height);
+ this->m_center_x_pix = center_x * width;
+ this->m_center_y_pix = center_y * height;
+
+ this->m_tx = itsc * D * cosf(a);
+ this->m_ty = -itsc * D * sinf(a);
+ this->m_sc = itsc * zoom;
+ this->m_rot = itsc * spin;
}
void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void * /*data*/)
{
- const int iterations = pow(2.0f, this->m_data->iter);
- float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- float col2[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- this->m_inputProgram->readSampled(col2, x, y, COM_PS_BILINEAR);
- float ltx = this->m_tx;
- float lty = this->m_ty;
- float lsc = this->m_sc;
- float lrot = this->m_rot;
- /* blur the image */
- for (int i = 0; i < iterations; ++i) {
- const float cs = cosf(lrot), ss = sinf(lrot);
- const float isc = 1.0f / (1.0f + lsc);
-
- const float v = isc * (y - this->m_center_y_pix) + lty;
- const float u = isc * (x - this->m_center_x_pix) + ltx;
-
- this->m_inputProgram->readSampled(col,
- cs * u + ss * v + this->m_center_x_pix,
- cs * v - ss * u + this->m_center_y_pix,
- COM_PS_BILINEAR);
-
- add_v4_v4(col2, col);
-
- /* double transformations */
- ltx += this->m_tx;
- lty += this->m_ty;
- lrot += this->m_rot;
- lsc += this->m_sc;
- }
-
- mul_v4_v4fl(output, col2, 1.0f / (iterations + 1));
+ const int iterations = pow(2.0f, this->m_data->iter);
+ float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ float col2[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ this->m_inputProgram->readSampled(col2, x, y, COM_PS_BILINEAR);
+ float ltx = this->m_tx;
+ float lty = this->m_ty;
+ float lsc = this->m_sc;
+ float lrot = this->m_rot;
+ /* blur the image */
+ for (int i = 0; i < iterations; ++i) {
+ const float cs = cosf(lrot), ss = sinf(lrot);
+ const float isc = 1.0f / (1.0f + lsc);
+
+ const float v = isc * (y - this->m_center_y_pix) + lty;
+ const float u = isc * (x - this->m_center_x_pix) + ltx;
+
+ this->m_inputProgram->readSampled(col,
+ cs * u + ss * v + this->m_center_x_pix,
+ cs * v - ss * u + this->m_center_y_pix,
+ COM_PS_BILINEAR);
+
+ add_v4_v4(col2, col);
+
+ /* double transformations */
+ ltx += this->m_tx;
+ lty += this->m_ty;
+ lrot += this->m_rot;
+ lsc += this->m_sc;
+ }
+
+ mul_v4_v4fl(output, col2, 1.0f / (iterations + 1));
}
void DirectionalBlurOperation::executeOpenCL(OpenCLDevice *device,
- 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*/)
{
- cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", NULL);
-
- cl_int iterations = pow(2.0f, this->m_data->iter);
- cl_float2 ltxy = {{this->m_tx, this->m_ty}};
- cl_float2 centerpix = {{this->m_center_x_pix, this->m_center_y_pix}};
- cl_float lsc = this->m_sc;
- cl_float lrot = this->m_rot;
-
- device->COM_clAttachMemoryBufferToKernelParameter(directionalBlurKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
- device->COM_clAttachOutputMemoryBufferToKernelParameter(directionalBlurKernel, 1, clOutputBuffer);
- device->COM_clAttachMemoryBufferOffsetToKernelParameter(directionalBlurKernel, 2, outputMemoryBuffer);
- clSetKernelArg(directionalBlurKernel, 3, sizeof(cl_int), &iterations);
- clSetKernelArg(directionalBlurKernel, 4, sizeof(cl_float), &lsc);
- clSetKernelArg(directionalBlurKernel, 5, sizeof(cl_float), &lrot);
- clSetKernelArg(directionalBlurKernel, 6, sizeof(cl_float2), &ltxy);
- clSetKernelArg(directionalBlurKernel, 7, sizeof(cl_float2), &centerpix);
-
- device->COM_clEnqueueRange(directionalBlurKernel, outputMemoryBuffer, 8, this);
+ cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", NULL);
+
+ cl_int iterations = pow(2.0f, this->m_data->iter);
+ cl_float2 ltxy = {{this->m_tx, this->m_ty}};
+ cl_float2 centerpix = {{this->m_center_x_pix, this->m_center_y_pix}};
+ cl_float lsc = this->m_sc;
+ cl_float lrot = this->m_rot;
+
+ device->COM_clAttachMemoryBufferToKernelParameter(
+ directionalBlurKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
+ device->COM_clAttachOutputMemoryBufferToKernelParameter(
+ directionalBlurKernel, 1, clOutputBuffer);
+ device->COM_clAttachMemoryBufferOffsetToKernelParameter(
+ directionalBlurKernel, 2, outputMemoryBuffer);
+ clSetKernelArg(directionalBlurKernel, 3, sizeof(cl_int), &iterations);
+ clSetKernelArg(directionalBlurKernel, 4, sizeof(cl_float), &lsc);
+ clSetKernelArg(directionalBlurKernel, 5, sizeof(cl_float), &lrot);
+ clSetKernelArg(directionalBlurKernel, 6, sizeof(cl_float2), &ltxy);
+ clSetKernelArg(directionalBlurKernel, 7, sizeof(cl_float2), &centerpix);
+
+ device->COM_clEnqueueRange(directionalBlurKernel, outputMemoryBuffer, 8, this);
}
-
void DirectionalBlurOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
-bool DirectionalBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool DirectionalBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
+ rcti newInput;
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}