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_AntiAliasOperation.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_AntiAliasOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.cpp217
1 files changed, 128 insertions, 89 deletions
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
index a33fe6bcdb0..94514c64e08 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
@@ -23,126 +23,165 @@
#include "MEM_guardedalloc.h"
extern "C" {
-# include "RE_render_ext.h"
+#include "RE_render_ext.h"
}
-
/* An implementation of the Scale3X edge-extrapolation algorithm.
*
* Code from GIMP plugin, based on code from Adam D. Moss (adam@gimp.org)
* licensed by the MIT license.
*/
-static int extrapolate9(float *E0, float *E1, float *E2,
- float *E3, float *E4, float *E5,
- float *E6, float *E7, float *E8,
- const float *A, const float *B, const float *C,
- const float *D, const float *E, const float *F,
- const float *G, const float *H, const float *I)
+static int extrapolate9(float *E0,
+ float *E1,
+ float *E2,
+ float *E3,
+ float *E4,
+ float *E5,
+ float *E6,
+ float *E7,
+ float *E8,
+ const float *A,
+ const float *B,
+ const float *C,
+ const float *D,
+ const float *E,
+ const float *F,
+ const float *G,
+ const float *H,
+ const float *I)
{
#define PEQ(X, Y) (fabsf(*X - *Y) < 1e-3f)
-#define PCPY(DST, SRC) do { *DST = *SRC; } while (0)
- if ((!PEQ(B, H)) && (!PEQ(D, F))) {
- if (PEQ(D, B)) PCPY(E0, D); else PCPY(E0, E);
- if ((PEQ(D, B) && !PEQ(E, C)) || (PEQ(B, F) && !PEQ(E, A)))
- PCPY(E1, B); else PCPY(E1, E);
- if (PEQ(B, F)) PCPY(E2, F); else PCPY(E2, E);
- if ((PEQ(D, B) && !PEQ(E, G)) || (PEQ(D, H) && !PEQ(E, A)))
- PCPY(E3, D); else PCPY(E3, E);
- PCPY(E4, E);
- if ((PEQ(B, F) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, C)))
- PCPY(E5, F); else PCPY(E5, E);
- if (PEQ(D, H)) PCPY(E6, D); else PCPY(E6, E);
- if ((PEQ(D, H) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, G)))
- PCPY(E7, H); else PCPY(E7, E);
- if (PEQ(H, F)) PCPY(E8, F); else PCPY(E8, E);
- return 1;
- }
- else {
- return 0;
- }
+#define PCPY(DST, SRC) \
+ do { \
+ *DST = *SRC; \
+ } while (0)
+ if ((!PEQ(B, H)) && (!PEQ(D, F))) {
+ if (PEQ(D, B))
+ PCPY(E0, D);
+ else
+ PCPY(E0, E);
+ if ((PEQ(D, B) && !PEQ(E, C)) || (PEQ(B, F) && !PEQ(E, A)))
+ PCPY(E1, B);
+ else
+ PCPY(E1, E);
+ if (PEQ(B, F))
+ PCPY(E2, F);
+ else
+ PCPY(E2, E);
+ if ((PEQ(D, B) && !PEQ(E, G)) || (PEQ(D, H) && !PEQ(E, A)))
+ PCPY(E3, D);
+ else
+ PCPY(E3, E);
+ PCPY(E4, E);
+ if ((PEQ(B, F) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, C)))
+ PCPY(E5, F);
+ else
+ PCPY(E5, E);
+ if (PEQ(D, H))
+ PCPY(E6, D);
+ else
+ PCPY(E6, E);
+ if ((PEQ(D, H) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, G)))
+ PCPY(E7, H);
+ else
+ PCPY(E7, E);
+ if (PEQ(H, F))
+ PCPY(E8, F);
+ else
+ PCPY(E8, E);
+ return 1;
+ }
+ else {
+ return 0;
+ }
#undef PEQ
#undef PCPY
}
AntiAliasOperation::AntiAliasOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_valueReader = NULL;
- this->setComplex(true);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_valueReader = NULL;
+ this->setComplex(true);
}
void AntiAliasOperation::initExecution()
{
- this->m_valueReader = this->getInputSocketReader(0);
+ this->m_valueReader = this->getInputSocketReader(0);
}
-void AntiAliasOperation::executePixel(float output[4],
- int x, int y,
- void *data)
+void AntiAliasOperation::executePixel(float output[4], int x, int y, void *data)
{
- MemoryBuffer *input_buffer = (MemoryBuffer *)data;
- const int buffer_width = input_buffer->getWidth(),
- buffer_height = input_buffer->getHeight();
- if (y < 0 || y >= buffer_height || x < 0 || x >= buffer_width) {
- output[0] = 0.0f;
- }
- else {
- const float *buffer = input_buffer->getBuffer();
- const float *row_curr = &buffer[y * buffer_width];
- if (x == 0 || x == buffer_width - 1 ||
- y == 0 || y == buffer_height - 1)
- {
- output[0] = row_curr[x];
- return;
- }
- const float *row_prev = &buffer[(y - 1) * buffer_width],
- *row_next = &buffer[(y + 1) * buffer_width];
- float ninepix[9];
- if (extrapolate9(&ninepix[0], &ninepix[1], &ninepix[2],
- &ninepix[3], &ninepix[4], &ninepix[5],
- &ninepix[6], &ninepix[7], &ninepix[8],
- &row_prev[x - 1], &row_prev[x], &row_prev[x + 1],
- &row_curr[x - 1], &row_curr[x], &row_curr[x + 1],
- &row_next[x - 1], &row_next[x], &row_next[x + 1]))
- {
- /* Some rounding magic to so make weighting correct with the
- * original coefficients.
- */
- unsigned char result = ((3 * ninepix[0] + 5 * ninepix[1] + 3 * ninepix[2] +
- 5 * ninepix[3] + 6 * ninepix[4] + 5 * ninepix[5] +
- 3 * ninepix[6] + 5 * ninepix[7] + 3 * ninepix[8]) * 255.0f +
- 19.0f) / 38.0f;
- output[0] = result / 255.0f;
- }
- else {
- output[0] = row_curr[x];
- }
- }
+ MemoryBuffer *input_buffer = (MemoryBuffer *)data;
+ const int buffer_width = input_buffer->getWidth(), buffer_height = input_buffer->getHeight();
+ if (y < 0 || y >= buffer_height || x < 0 || x >= buffer_width) {
+ output[0] = 0.0f;
+ }
+ else {
+ const float *buffer = input_buffer->getBuffer();
+ const float *row_curr = &buffer[y * buffer_width];
+ if (x == 0 || x == buffer_width - 1 || y == 0 || y == buffer_height - 1) {
+ output[0] = row_curr[x];
+ return;
+ }
+ const float *row_prev = &buffer[(y - 1) * buffer_width],
+ *row_next = &buffer[(y + 1) * buffer_width];
+ float ninepix[9];
+ if (extrapolate9(&ninepix[0],
+ &ninepix[1],
+ &ninepix[2],
+ &ninepix[3],
+ &ninepix[4],
+ &ninepix[5],
+ &ninepix[6],
+ &ninepix[7],
+ &ninepix[8],
+ &row_prev[x - 1],
+ &row_prev[x],
+ &row_prev[x + 1],
+ &row_curr[x - 1],
+ &row_curr[x],
+ &row_curr[x + 1],
+ &row_next[x - 1],
+ &row_next[x],
+ &row_next[x + 1])) {
+ /* Some rounding magic to so make weighting correct with the
+ * original coefficients.
+ */
+ unsigned char result = ((3 * ninepix[0] + 5 * ninepix[1] + 3 * ninepix[2] + 5 * ninepix[3] +
+ 6 * ninepix[4] + 5 * ninepix[5] + 3 * ninepix[6] + 5 * ninepix[7] +
+ 3 * ninepix[8]) *
+ 255.0f +
+ 19.0f) /
+ 38.0f;
+ output[0] = result / 255.0f;
+ }
+ else {
+ output[0] = row_curr[x];
+ }
+ }
}
void AntiAliasOperation::deinitExecution()
{
- this->m_valueReader = NULL;
+ this->m_valueReader = NULL;
}
-bool AntiAliasOperation::determineDependingAreaOfInterest(
- rcti *input,
- ReadBufferOperation *readOperation,
- rcti *output)
+bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti imageInput;
- NodeOperation *operation = getInputOperation(0);
- imageInput.xmax = input->xmax + 1;
- imageInput.xmin = input->xmin - 1;
- imageInput.ymax = input->ymax + 1;
- imageInput.ymin = input->ymin - 1;
- return operation->determineDependingAreaOfInterest(&imageInput,
- readOperation,
- output);
+ rcti imageInput;
+ NodeOperation *operation = getInputOperation(0);
+ imageInput.xmax = input->xmax + 1;
+ imageInput.xmin = input->xmin - 1;
+ imageInput.ymax = input->ymax + 1;
+ imageInput.ymin = input->ymin - 1;
+ return operation->determineDependingAreaOfInterest(&imageInput, readOperation, output);
}
void *AntiAliasOperation::initializeTileData(rcti *rect)
{
- return getInputOperation(0)->initializeTileData(rect);
+ return getInputOperation(0)->initializeTileData(rect);
}