[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49064] branches/soc-2011-tomato: svn merge ^/trunk/blender -r49061:49063
Campbell Barton
ideasman42 at gmail.com
Thu Jul 19 13:35:47 CEST 2012
Revision: 49064
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49064
Author: campbellbarton
Date: 2012-07-19 11:35:45 +0000 (Thu, 19 Jul 2012)
Log Message:
-----------
svn merge ^/trunk/blender -r49061:49063
Revision Links:
--------------
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49061
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/compositor/nodes/COM_BlurNode.cpp
branches/soc-2011-tomato/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
branches/soc-2011-tomato/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
branches/soc-2011-tomato/source/blender/makesdna/DNA_node_types.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree.c
Property Changed:
----------------
branches/soc-2011-tomato/
branches/soc-2011-tomato/source/blender/editors/interface/interface.c
branches/soc-2011-tomato/source/blender/editors/space_outliner/
Property changes on: branches/soc-2011-tomato
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/vgroup_modifiers:38694-39989
/trunk/blender:36831-49061
+ /branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/vgroup_modifiers:38694-39989
/trunk/blender:36831-49063
Modified: branches/soc-2011-tomato/source/blender/compositor/nodes/COM_BlurNode.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/nodes/COM_BlurNode.cpp 2012-07-19 11:05:18 UTC (rev 49063)
+++ branches/soc-2011-tomato/source/blender/compositor/nodes/COM_BlurNode.cpp 2012-07-19 11:35:45 UTC (rev 49064)
@@ -25,9 +25,13 @@
#include "DNA_node_types.h"
#include "COM_GaussianXBlurOperation.h"
#include "COM_GaussianYBlurOperation.h"
+#include "COM_GaussianAlphaXBlurOperation.h"
+#include "COM_GaussianAlphaYBlurOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_GaussianBokehBlurOperation.h"
#include "COM_FastGaussianBlurOperation.h"
+#include "COM_MathBaseOperation.h"
+#include "COM_SetValueOperation.h"
BlurNode::BlurNode(bNode *editorNode) : Node(editorNode)
{
@@ -56,6 +60,42 @@
graph->addOperation(operationfgb);
addPreviewOperation(graph, operationfgb->getOutputSocket());
}
+ else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_REFERENCE) {
+ MathAddOperation *clamp = new MathAddOperation();
+ SetValueOperation *zero = new SetValueOperation();
+ addLink(graph, zero->getOutputSocket(), clamp->getInputSocket(1));
+ this->getInputSocket(1)->relinkConnections(clamp->getInputSocket(0), 1, graph);
+ zero->setValue(0.0f);
+ clamp->setUseClamp(true);
+ graph->addOperation(clamp);
+ graph->addOperation(zero);
+
+ GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
+ operationx->setData(data);
+ operationx->setbNode(editorNode);
+ operationx->setQuality(quality);
+ operationx->setSize(1.0f);
+ addLink(graph, clamp->getOutputSocket(), operationx->getInputSocket(0));
+ graph->addOperation(operationx);
+
+ GaussianYBlurOperation *operationy = new GaussianYBlurOperation();
+ operationy->setData(data);
+ operationy->setbNode(editorNode);
+ operationy->setQuality(quality);
+ operationy->setSize(1.0f);
+ addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0));
+ graph->addOperation(operationy);
+
+ GaussianBlurReferenceOperation *operation = new GaussianBlurReferenceOperation();
+ operation->setData(data);
+ operation->setbNode(editorNode);
+ operation->setQuality(quality);
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
+ addLink(graph, operationy->getOutputSocket(), operation->getInputSocket(1));
+ graph->addOperation(operation);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ addPreviewOperation(graph, operation->getOutputSocket());
+ }
else if (!data->bokeh) {
GaussianXBlurOperation *operationx = new GaussianXBlurOperation();
operationx->setData(data);
Modified: branches/soc-2011-tomato/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp 2012-07-19 11:05:18 UTC (rev 49063)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp 2012-07-19 11:35:45 UTC (rev 49064)
@@ -22,7 +22,7 @@
#include "COM_GaussianBokehBlurOperation.h"
#include "BLI_math.h"
-
+#include "MEM_guardedalloc.h"
extern "C" {
#include "RE_pipeline.h"
}
@@ -198,25 +198,20 @@
}
// reference image
-GaussianBokehBlurReferenceOperation::GaussianBokehBlurReferenceOperation() : NodeOperation()
+GaussianBlurReferenceOperation::GaussianBlurReferenceOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
- this->m_gausstab = NULL;
- this->m_inputImage = NULL;
- this->m_inputSize = NULL;
+ this->m_maintabs = NULL;
}
-void *GaussianBokehBlurReferenceOperation::initializeTileData(rcti *rect)
+void *GaussianBlurReferenceOperation::initializeTileData(rcti *rect)
{
void *buffer = getInputOperation(0)->initializeTileData(NULL);
return buffer;
}
-void GaussianBokehBlurReferenceOperation::initExecution()
+void GaussianBlurReferenceOperation::initExecution()
{
+ BlurBaseOperation::initExecution();
// setup gaustab
this->m_data->image_in_width = this->getWidth();
this->m_data->image_in_height = this->getHeight();
@@ -237,100 +232,106 @@
}
}
+
+ /* horizontal */
+ m_radx = (float)this->m_data->sizex;
+ int imgx = getWidth()/2;
+ if (m_radx > imgx)
+ m_radx = imgx;
+ else if (m_radx < 1)
+ m_radx = 1;
+ m_radxf = (float)m_radx;
+
+ /* vertical */
+ m_rady = (float)this->m_data->sizey;
+ int imgy = getHeight()/2;
+ if (m_rady > imgy)
+ m_rady = imgy;
+ else if (m_rady < 1)
+ m_rady = 1;
+ m_radyf = (float)m_rady;
updateGauss();
- this->m_inputImage = this->getInputSocketReader(0);
- this->m_inputSize = this->getInputSocketReader(1);
}
-void GaussianBokehBlurReferenceOperation::updateGauss()
+void GaussianBlurReferenceOperation::updateGauss()
{
- int n;
- float *dgauss;
- float *ddgauss;
- int j, i;
-
- n = (2 * radx + 1) * (2 * rady + 1);
-
- /* create a full filter image */
- ddgauss = new float[n];
- dgauss = ddgauss;
- for (j = -rady; j <= rady; j++) {
- for (i = -radx; i <= radx; i++, dgauss++) {
- float fj = (float)j / radyf;
- float fi = (float)i / radxf;
- float dist = sqrt(fj * fj + fi * fi);
- *dgauss = RE_filter_value(this->m_data->filtertype, dist);
- }
- }
- this->m_gausstab = ddgauss;
+ int i;
+ int x = MAX2(m_radx, m_rady);
+ this->m_maintabs = (float**)MEM_mallocN(x * sizeof(float *), "gauss array");
+ for (i = 0; i < x; i++)
+ m_maintabs[i] = make_gausstab(i + 1);
}
-void GaussianBokehBlurReferenceOperation::executePixel(float *color, int x, int y, void *data)
+void GaussianBlurReferenceOperation::executePixel(float *color, int x, int y, void *data)
{
- float tempColor[4];
+ MemoryBuffer *memorybuffer = (MemoryBuffer*)data;
+ float *buffer = memorybuffer->getBuffer();
+ float *gausstabx, *gausstabcenty;
+ float *gausstaby, *gausstabcentx;
+ int i, j;
+ float *src;
+ register float sum, val;
+ float rval, gval, bval, aval;
+ int imgx = getWidth();
+ int imgy = getHeight();
float tempSize[4];
- tempColor[0] = 0;
- tempColor[1] = 0;
- tempColor[2] = 0;
- tempColor[3] = 0;
- float multiplier_accum = 0;
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- int bufferwidth = inputBuffer->getWidth();
- int bufferstartx = inputBuffer->getRect()->xmin;
- int bufferstarty = inputBuffer->getRect()->ymin;
this->m_inputSize->read(tempSize, x, y, data);
- float size = tempSize[0];
- CLAMP(size, 0.0f, 1.0f);
- float sizeX = ceil(this->m_data->sizex * size);
- float sizeY = ceil(this->m_data->sizey * size);
+ float refSize = tempSize[0];
+ int refradx = (int)(refSize * m_radxf);
+ int refrady = (int)(refSize * m_radyf);
+ if (refradx > m_radx) refradx = m_radx;
+ else if (refradx < 1) refradx = 1;
+ if (refrady > m_rady) refrady = m_rady;
+ else if (refrady < 1) refrady = 1;
- if (sizeX <= 0.5f && sizeY <= 0.5f) {
- this->m_inputImage->read(color, x, y, data);
- return;
- }
-
- int miny = y - sizeY;
- int maxy = y + sizeY;
- int minx = x - sizeX;
- int maxx = x + sizeX;
- miny = max(miny, inputBuffer->getRect()->ymin);
- minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax);
- maxx = min(maxx, inputBuffer->getRect()->xmax);
+ if (refradx == 1 && refrady == 1) {
+ memorybuffer->readNoCheck(color, x, y);
+ } else {
+ int minxr = x - refradx < 0 ? -x : -refradx;
+ int maxxr = x + refradx > imgx ? imgx - x : refradx;
+ int minyr = y - refrady < 0 ? -y : -refrady;
+ int maxyr = y + refrady > imgy ? imgy - y : refrady;
- int step = QualityStepHelper::getStep();
- int offsetadd = QualityStepHelper::getOffsetAdd();
- for (int ny = miny; ny < maxy; ny += step) {
- int u = ny - y;
- float uf = ((u/sizeY)*radyf)+radyf;
- int indexu = uf * (radx*2+1);
- int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
- for (int nx = minx; nx < maxx; nx += step) {
- int v = nx - x;
- float vf = ((v/sizeX)*radxf)+radxf;
- int index = indexu + vf;
- const float multiplier = this->m_gausstab[index];
- madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplier);
- multiplier_accum += multiplier;
- index += step;
- bufferindex += offsetadd;
+ float *srcd = buffer + COM_NUMBER_OF_CHANNELS * ( (y + minyr) * imgx + x + minxr);
+
+ gausstabx = m_maintabs[refradx - 1];
+ gausstabcentx = gausstabx + refradx;
+ gausstaby = m_maintabs[refrady - 1];
+ gausstabcenty = gausstaby + refrady;
+
+ sum = gval = rval = bval = aval = 0.0f;
+ for (i = minyr; i < maxyr; i++, srcd += COM_NUMBER_OF_CHANNELS * imgx) {
+ src = srcd;
+ for (j = minxr; j < maxxr; j++, src += COM_NUMBER_OF_CHANNELS) {
+
+ val = gausstabcenty[i] * gausstabcentx[j];
+ sum += val;
+ rval += val * src[0];
+ gval += val * src[1];
+ bval += val * src[2];
+ aval += val * src[3];
+ }
}
+ sum = 1.0f / sum;
+ color[0] = rval * sum;
+ color[1] = gval * sum;
+ color[2] = bval * sum;
+ color[3] = aval * sum;
}
- mul_v4_v4fl(color, tempColor, 1.0f / multiplier_accum);
}
-void GaussianBokehBlurReferenceOperation::deinitExecution()
+void GaussianBlurReferenceOperation::deinitExecution()
{
- delete [] this->m_gausstab;
- this->m_gausstab = NULL;
- this->m_inputImage = NULL;
- this->m_inputSize = NULL;
-
+ int x, i;
+ x = MAX2(m_radx, m_rady);
+ for (i = 0; i < x; i++)
+ delete []m_maintabs[i];
+ MEM_freeN(m_maintabs);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list