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:
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp55
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h8
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.cpp62
4 files changed, 60 insertions, 67 deletions
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index d22c75c922b..37d79607d12 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -73,12 +73,16 @@ void MemoryBuffer::clear()
float *MemoryBuffer::convertToValueBuffer()
{
- int size = this->determineBufferSize();
- int i;
- int offset4;
+ const unsigned int size = this->determineBufferSize();
+ unsigned int i;
+
float *result = new float[size];
- for (i = 0, offset4 = 0 ; i < size ; i ++, offset4 +=COM_NUMBER_OF_CHANNELS) {
- result[i] = this->buffer[offset4];
+
+ const float *fp_src = this->buffer;
+ float *fp_dst = result;
+
+ for (i = 0; i < size ; i++, fp_dst++, fp_src += COM_NUMBER_OF_CHANNELS) {
+ *fp_dst = *fp_src;
}
return result;
@@ -113,38 +117,31 @@ void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer)
}
}
-void MemoryBuffer::read(float *result, int x, int y)
+void MemoryBuffer::read(float result[4], int x, int y)
{
if (x>=this->rect.xmin && x < this->rect.xmax &&
- y>=this->rect.ymin && y < this->rect.ymax) {
- int dx = x-this->rect.xmin;
- int dy = y-this->rect.ymin;
- int offset = (this->chunkWidth*dy+dx)*COM_NUMBER_OF_CHANNELS;
- result[0] = this->buffer[offset];
- result[1] = this->buffer[offset+1];
- result[2] = this->buffer[offset+2];
- result[3] = this->buffer[offset+3];
+ y>=this->rect.ymin && y < this->rect.ymax)
+ {
+ const int dx = x - this->rect.xmin;
+ const int dy = y - this->rect.ymin;
+ const int offset = (this->chunkWidth * dy + dx) * COM_NUMBER_OF_CHANNELS;
+ copy_v4_v4(result, &this->buffer[offset]);
}
else {
- result[0] = 0.0f;
- result[1] = 0.0f;
- result[2] = 0.0f;
- result[3] = 0.0f;
+ zero_v4(result);
}
}
-void MemoryBuffer::writePixel(int x, int y, float color[4])
+void MemoryBuffer::writePixel(int x, int y, const float color[4])
{
- if (x>=this->rect.xmin && x < this->rect.xmax &&
- y>=this->rect.ymin && y < this->rect.ymax) {
- int offset = (this->chunkWidth*y+x)*COM_NUMBER_OF_CHANNELS;
- this->buffer[offset] = color[0];
- this->buffer[offset+1] = color[1];
- this->buffer[offset+2] = color[2];
- this->buffer[offset+3] = color[3];
+ if (x >= this->rect.xmin && x < this->rect.xmax &&
+ y >= this->rect.ymin && y < this->rect.ymax)
+ {
+ const int offset = (this->chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS;
+ copy_v4_v4(&this->buffer[offset], color);
}
}
-void MemoryBuffer::readCubic(float *result, float x, float y)
+void MemoryBuffer::readCubic(float result[4], float x, float y)
{
int x1 = floor(x);
int x2 = x1 + 1;
@@ -266,9 +263,9 @@ float clipuv(float x, float limit)
return x;
}
-void MemoryBuffer::readEWA(float *result, float fx, float fy, float dx, float dy)
+void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float dy)
{
- int width = this->getWidth(), height = this->getHeight();
+ const int width = this->getWidth(), height = this->getHeight();
// scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values,
// scaling by aspect ratio alone does the opposite, so try something in between instead...
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index bfc18424570..fd90e5fcb5a 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -124,10 +124,10 @@ public:
this->state = COM_MB_AVAILABLE;
}
- void read(float *result, int x, int y);
- void writePixel(int x, int y, float color[4]);
- void readCubic(float *result, float x, float y);
- void readEWA(float *result, float fx, float fy, float dx, float dy);
+ void read(float result[4], int x, int y);
+ void writePixel(int x, int y, const float color[4]);
+ void readCubic(float result[4], float x, float y);
+ void readEWA(float result[4], float fx, float fy, float dx, float dy);
/**
* @brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk)
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
index aedf6ec5e9e..7d489ce856e 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
@@ -27,7 +27,7 @@ AlphaOverMixedOperation::AlphaOverMixedOperation(): MixBaseOperation()
this->x = 0.0f;
}
-void AlphaOverMixedOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
float inputColor1[4];
float inputOverColor[4];
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
index 56141efe681..9b57d64eb40 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
@@ -40,40 +40,40 @@ void ColorSpillOperation::initExecution()
this->inputImageReader = this->getInputSocketReader(0);
this->inputFacReader = this->getInputSocketReader(1);
if (spillChannel == 0) {
- rmut = -1.0f;
- gmut = 1.0f;
- bmut = 1.0f;
+ this->rmut = -1.0f;
+ this->gmut = 1.0f;
+ this->bmut = 1.0f;
this->channel2 = 1;
this->channel3 = 2;
- if (settings->unspill == 0) {
- settings->uspillr = 1.0f;
- settings->uspillg = 0.0f;
- settings->uspillb = 0.0f;
+ if (this->settings->unspill == 0) {
+ this->settings->uspillr = 1.0f;
+ this->settings->uspillg = 0.0f;
+ this->settings->uspillb = 0.0f;
}
}
else if (spillChannel == 1) {
- rmut = 1.0f;
- gmut = -1.0f;
- bmut = 1.0f;
+ this->rmut = 1.0f;
+ this->gmut = -1.0f;
+ this->bmut = 1.0f;
this->channel2 = 0;
this->channel3 = 2;
- if (settings->unspill == 0) {
- settings->uspillr = 0.0f;
- settings->uspillg = 1.0f;
- settings->uspillb = 0.0f;
+ if (this->settings->unspill == 0) {
+ this->settings->uspillr = 0.0f;
+ this->settings->uspillg = 1.0f;
+ this->settings->uspillb = 0.0f;
}
}
else {
- rmut = 1.0f;
- gmut = 1.0f;
- bmut = -1.0f;
+ this->rmut = 1.0f;
+ this->gmut = 1.0f;
+ this->bmut = -1.0f;
this->channel2 = 0;
this->channel3 = 1;
- if (settings->unspill == 0) {
- settings->uspillr = 0.0f;
- settings->uspillg = 0.0f;
- settings->uspillb = 1.0f;
+ if (this->settings->unspill == 0) {
+ this->settings->uspillr = 0.0f;
+ this->settings->uspillg = 0.0f;
+ this->settings->uspillb = 1.0f;
}
}
}
@@ -88,27 +88,23 @@ void ColorSpillOperation::executePixel(float *outputValue, float x, float y, Pix
{
float fac[4];
float input[4];
- float map;
this->inputFacReader->read(fac, x, y, sampler, inputBuffers);
this->inputImageReader->read(input, x, y, sampler, inputBuffers);
float rfac = min(1.0f, fac[0]);
- map = calculateMapValue(rfac, input);
- if (map>0) {
- outputValue[0]=input[0]+rmut*(settings->uspillr*map);
- outputValue[1]=input[1]+gmut*(settings->uspillg*map);
- outputValue[2]=input[2]+bmut*(settings->uspillb*map);
- outputValue[3]=input[3];
+ float map = calculateMapValue(rfac, input);
+ if (map > 0.0f) {
+ outputValue[0] = input[0] + this->rmut * (this->settings->uspillr * map);
+ outputValue[1] = input[1] + this->gmut * (this->settings->uspillg * map);
+ outputValue[2] = input[2] + this->bmut * (this->settings->uspillb * map);
+ outputValue[3] = input[3];
}
else {
- outputValue[0]=input[0];
- outputValue[1]=input[1];
- outputValue[2]=input[2];
- outputValue[3]=input[3];
+ copy_v4_v4(outputValue, input);
}
}
float ColorSpillOperation::calculateMapValue(float fac, float *input)
{
- return fac * (input[this->spillChannel]-(this->settings->limscale*input[settings->limchan]));
+ return fac * (input[this->spillChannel]-(this->settings->limscale*input[this->settings->limchan]));
}