From e22aa7bc38c5d38a0714bed8a2a1869383cd5e5a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jun 2012 14:33:50 +0000 Subject: style cleanup --- .../operations/COM_GlareBaseOperation.cpp | 4 +- .../compositor/operations/COM_GlareBaseOperation.h | 40 +++++++------- .../operations/COM_GlareGhostOperation.cpp | 16 +++--- .../operations/COM_GlareGhostOperation.h | 7 +-- .../operations/COM_GlareSimpleStarOperation.cpp | 22 ++++---- .../operations/COM_GlareSimpleStarOperation.h | 7 +-- .../operations/COM_GlareStreaksOperation.cpp | 62 +++++++++++----------- .../operations/COM_GlareStreaksOperation.h | 7 +-- .../operations/COM_GlareThresholdOperation.cpp | 18 ++++--- .../operations/COM_GlareThresholdOperation.h | 38 ++++++------- 10 files changed, 117 insertions(+), 104 deletions(-) (limited to 'source/blender') diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp index 83132963f0b..90bdd705a7c 100644 --- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp @@ -23,7 +23,7 @@ #include "COM_GlareBaseOperation.h" #include "BLI_math.h" -GlareBaseOperation::GlareBaseOperation(): SingleThreadedNodeOperation() +GlareBaseOperation::GlareBaseOperation() : SingleThreadedNodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); @@ -43,7 +43,7 @@ void GlareBaseOperation::deinitExecution() MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2, MemoryBuffer **memoryBuffers) { - MemoryBuffer *tile = (MemoryBuffer*)inputProgram->initializeTileData(rect2, memoryBuffers); + MemoryBuffer *tile = (MemoryBuffer *)inputProgram->initializeTileData(rect2, memoryBuffers); rcti rect; rect.xmin = 0; rect.ymin = 0; diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.h b/source/blender/compositor/operations/COM_GlareBaseOperation.h index d79f449f426..0d20dd363c7 100644 --- a/source/blender/compositor/operations/COM_GlareBaseOperation.h +++ b/source/blender/compositor/operations/COM_GlareBaseOperation.h @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: - * Jeroen Bakker + * Contributor: + * Jeroen Bakker * Monique Dewanchand */ @@ -59,34 +59,36 @@ typedef float fRGB[4]; class GlareBaseOperation : public SingleThreadedNodeOperation { private: /** - * @brief Cached reference to the inputProgram - */ - SocketReader * inputProgram; - + * @brief Cached reference to the inputProgram + */ + SocketReader *inputProgram; + /** - * @brief settings of the glare node. - */ - NodeGlare * settings; + * @brief settings of the glare node. + */ + NodeGlare *settings; public: /** - * Initialize the execution - */ + * Initialize the execution + */ void initExecution(); - + /** - * Deinitialize the execution - */ + * Deinitialize the execution + */ void deinitExecution(); - void setGlareSettings(NodeGlare * settings) {this->settings = settings;} + void setGlareSettings(NodeGlare *settings) { + this->settings = settings; + } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - + protected: GlareBaseOperation(); - + virtual void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) = 0; - + MemoryBuffer *createMemoryBuffer(rcti *rect, MemoryBuffer **memoryBuffers); - + }; #endif diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp index d3ecee2a508..9bf39db2727 100644 --- a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: - * Jeroen Bakker + * Contributor: + * Jeroen Bakker * Monique Dewanchand */ @@ -27,12 +27,16 @@ static float smoothMask(float x, float y) { float t; - x = 2.f * x - 1.f, y = 2.f * y - 1.f; - if ((t = 1.f - sqrtf(x * x + y * y)) <= 0.f) return 0.f; - return t; + x = 2.0f * x - 1.0f; + y = 2.0f * y - 1.0f; + if ((t = 1.0f - sqrtf(x * x + y * y)) > 0.0f) { + return t; + } + else { + return 0.0f; + } } - void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) { const int qt = 1 << settings->quality; diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.h b/source/blender/compositor/operations/COM_GlareGhostOperation.h index 48b5e8986a9..2ee85cc4543 100644 --- a/source/blender/compositor/operations/COM_GlareGhostOperation.h +++ b/source/blender/compositor/operations/COM_GlareGhostOperation.h @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: - * Jeroen Bakker + * Contributor: + * Jeroen Bakker * Monique Dewanchand */ @@ -28,7 +28,8 @@ class GlareGhostOperation : public GlareBaseOperation { public: - GlareGhostOperation() : GlareBaseOperation() {} + GlareGhostOperation() : GlareBaseOperation() { + } protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp index 4a393a33073..957ac5af748 100644 --- a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: - * Jeroen Bakker + * Contributor: + * Jeroen Bakker * Monique Dewanchand */ @@ -25,21 +25,21 @@ void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) { int i, x, y, ym, yp, xm, xp; - float c[4] = {0,0,0,0}, tc[4] = {0,0,0,0}; - const float f1 = 1.f - settings->fade, f2 = (1.f - f1)*0.5f; - + float c[4] = {0, 0, 0, 0}, tc[4] = {0, 0, 0, 0}; + const float f1 = 1.0f - settings->fade; + const float f2 = (1.0f - f1) * 0.5f; MemoryBuffer *tbuf1 = inputTile->duplicate(); MemoryBuffer *tbuf2 = inputTile->duplicate(); bool breaked = false; - for (i=0; iiter && (!breaked); i++) { + for (i = 0; i < settings->iter && (!breaked); i++) { // // (x || x-1, y-1) to (x || x+1, y+1) // // F - for (y=0; ygetHeight() && (!breaked); y++) { + for (y = 0; y < this->getHeight() && (!breaked); y++) { ym = y - i; yp = y + i; - for (x=0; xgetWidth(); x++) { + for (x = 0; x < this->getWidth(); x++) { xm = x - i; xp = x + i; tbuf1->read(c, x, y); @@ -65,10 +65,10 @@ void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTil } } // // B - for (y=tbuf1->getHeight()-1 && (!breaked); y>=0; y--) { + for (y = tbuf1->getHeight() - 1 && (!breaked); y >= 0; y--) { ym = y - i; yp = y + i; - for (x=tbuf1->getWidth()-1; x>=0; x--) { + for (x = tbuf1->getWidth() - 1; x >= 0; x--) { xm = x - i; xp = x + i; tbuf1->read(c, x, y); @@ -95,7 +95,7 @@ void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTil } } - for (i = 0 ; i < this->getWidth()*this->getHeight()*4 ; i++) { + for (i = 0; i < this->getWidth() * this->getHeight() * 4; i++) { data[i] = tbuf1->getBuffer()[i] + tbuf2->getBuffer()[i]; } diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h index 22040da9bc5..a12d1191a1a 100644 --- a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h +++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: - * Jeroen Bakker + * Contributor: + * Jeroen Bakker * Monique Dewanchand */ @@ -28,7 +28,8 @@ class GlareSimpleStarOperation : public GlareBaseOperation { public: - GlareSimpleStarOperation() : GlareBaseOperation() {} + GlareSimpleStarOperation() : GlareBaseOperation() { + } protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp index e735893ed6d..9125783c222 100644 --- a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: - * Jeroen Bakker + * Contributor: + * Jeroen Bakker * Monique Dewanchand */ @@ -26,73 +26,73 @@ void GlareStreaksOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) { int x, y, n; - unsigned int nump=0; + unsigned int nump = 0; float c1[4], c2[4], c3[4], c4[4]; - float a, ang = DEG2RADF(360.0f)/(float)settings->angle; - - int size = inputTile->getWidth()*inputTile->getHeight(); - int size4 = size*4; + float a, ang = DEG2RADF(360.0f) / (float)settings->angle; + + int size = inputTile->getWidth() * inputTile->getHeight(); + int size4 = size * 4; bool breaked = false; - + MemoryBuffer *tsrc = inputTile->duplicate(); MemoryBuffer *tdst = new MemoryBuffer(NULL, inputTile->getRect()); tdst->clear(); - memset(data, 0, size4*sizeof(float)); - - for (a=0.f; aangle_ofs; const float vx = cos((double)an), vy = sin((double)an); - for (n=0; niter && (!breaked); ++n) { + for (n = 0; n < settings->iter && (!breaked); ++n) { const float p4 = pow(4.0, (double)n); - const float vxp = vx*p4, vyp = vy*p4; + const float vxp = vx * p4, vyp = vy * p4; const float wt = pow((double)settings->fade, (double)p4); - const float cmo = 1.f - (float)pow((double)settings->colmod, (double)n+1); // colormodulation amount relative to current pass + const float cmo = 1.f - (float)pow((double)settings->colmod, (double)n + 1); // colormodulation amount relative to current pass float *tdstcol = tdst->getBuffer(); - for (y=0; ygetHeight() && (!breaked); ++y) { - for (x=0; xgetWidth(); ++x, tdstcol+=4) { + for (y = 0; y < tsrc->getHeight() && (!breaked); ++y) { + 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) tsrc->read(c1, x, y); else c1[0]=c1[1]=c1[2]=0; + if (n == 0) tsrc->read(c1, x, y); else c1[0] = c1[1] = c1[2] = 0; tsrc->readCubic(c2, x + vxp, y + vyp); - tsrc->readCubic(c3, x + vxp*2.f, y + vyp*2.f); - tsrc->readCubic(c4, x + vxp*3.f, y + vyp*3.f); + tsrc->readCubic(c3, x + vxp * 2.f, y + vyp * 2.f); + tsrc->readCubic(c4, x + vxp * 3.f, y + vyp * 3.f); // modulate color to look vaguely similar to a color spectrum c2[1] *= cmo; c2[2] *= cmo; c3[0] *= cmo; c3[1] *= cmo; - + c4[0] *= cmo; c4[2] *= cmo; - tdstcol[0] = 0.5f*(tdstcol[0] + c1[0] + wt*(c2[0] + wt*(c3[0] + wt*c4[0]))); - tdstcol[1] = 0.5f*(tdstcol[1] + c1[1] + wt*(c2[1] + wt*(c3[1] + wt*c4[1]))); - tdstcol[2] = 0.5f*(tdstcol[2] + c1[2] + wt*(c2[2] + wt*(c3[2] + wt*c4[2]))); + tdstcol[0] = 0.5f * (tdstcol[0] + c1[0] + wt * (c2[0] + wt * (c3[0] + wt * c4[0]))); + tdstcol[1] = 0.5f * (tdstcol[1] + c1[1] + wt * (c2[1] + wt * (c3[1] + wt * c4[1]))); + tdstcol[2] = 0.5f * (tdstcol[2] + c1[2] + wt * (c2[2] + wt * (c3[2] + wt * c4[2]))); tdstcol[3] = 1.0f; } if (isBreaked()) { breaked = true; } } - memcpy(tsrc->getBuffer(), tdst->getBuffer(), sizeof(float)*size4); + memcpy(tsrc->getBuffer(), tdst->getBuffer(), sizeof(float) * size4); } float *sourcebuffer = tsrc->getBuffer(); - float factor = 1.f/(float)(6 - settings->iter); - for (int i = 0 ; i < size4; i ++) { + float factor = 1.f / (float)(6 - settings->iter); + for (int i = 0; i < size4; i++) { data[i] += sourcebuffer[i] * factor; } - for (int i = 0 ; i < size; i ++) { - data[i*4+3] = 1.0f; + for (int i = 0; i < size; i++) { + data[i * 4 + 3] = 1.0f; } - + tdst->clear(); - memcpy(tsrc->getBuffer(), inputTile->getBuffer(), sizeof(float)*size4); + memcpy(tsrc->getBuffer(), inputTile->getBuffer(), sizeof(float) * size4); nump++; } - + delete tsrc; delete tdst; } diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.h b/source/blender/compositor/operations/COM_GlareStreaksOperation.h index 07155a4713a..6520a05b44f 100644 --- a/source/blender/compositor/operations/COM_GlareStreaksOperation.h +++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.h @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: - * Jeroen Bakker + * Contributor: + * Jeroen Bakker * Monique Dewanchand */ @@ -28,7 +28,8 @@ class GlareStreaksOperation : public GlareBaseOperation { public: - GlareStreaksOperation() : GlareBaseOperation() {} + GlareStreaksOperation() : GlareBaseOperation() { + } protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp index e8def72b7da..4ca5f575cfe 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp @@ -15,15 +15,15 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: - * Jeroen Bakker + * Contributor: + * Jeroen Bakker * Monique Dewanchand */ #include "COM_GlareThresholdOperation.h" #include "BLI_math.h" -GlareThresholdOperation::GlareThresholdOperation(): NodeOperation() +GlareThresholdOperation::GlareThresholdOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); @@ -37,13 +37,15 @@ void GlareThresholdOperation::initExecution() void GlareThresholdOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { this->inputProgram->read(color, x, y, sampler, inputBuffers); - if ((0.212671f*color[0] + 0.71516f*color[1] + 0.072169f*color[2]) >= threshold) { + if ((0.212671f * color[0] + 0.71516f * color[1] + 0.072169f * color[2]) >= threshold) { color[0] -= threshold, color[1] -= threshold, color[2] -= threshold; - color[0] = MAX2(color[0], 0.f); - color[1] = MAX2(color[1], 0.f); - color[2] = MAX2(color[2], 0.f); + color[0] = MAX2(color[0], 0.0f); + color[1] = MAX2(color[1], 0.0f); + color[2] = MAX2(color[2], 0.0f); + } + else { + zero_v3(color); } - else color[0] = color[1] = color[2] = 0.f; } void GlareThresholdOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h index 3dfa2f44339..d5ec8ba93a6 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h @@ -15,8 +15,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor: - * Jeroen Bakker + * Contributor: + * Jeroen Bakker * Monique Dewanchand */ @@ -28,30 +28,32 @@ class GlareThresholdOperation : public NodeOperation { private: /** - * @brief Cached reference to the inputProgram - */ - SocketReader * inputProgram; - + * @brief Cached reference to the inputProgram + */ + SocketReader *inputProgram; + float threshold; public: GlareThresholdOperation(); - + /** - * the inner loop of this program - */ - void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]); - + * the inner loop of this program + */ + void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); + /** - * Initialize the execution - */ + * Initialize the execution + */ void initExecution(); - + /** - * Deinitialize the execution - */ + * Deinitialize the execution + */ void deinitExecution(); - - void setThreshold(float threshold) {this->threshold = threshold;} + + void setThreshold(float threshold) { + this->threshold = threshold; + } }; #endif -- cgit v1.2.3