diff options
Diffstat (limited to 'source/blender/compositor/operations')
5 files changed, 84 insertions, 42 deletions
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp index 7106b015fe6..29d8bbea2db 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp @@ -49,7 +49,6 @@ MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperat this->m_movieClip = NULL; this->m_cache = NULL; this->m_distortion = distortion; - setComplex(true); } void MovieDistortionOperation::initExecution() diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp index a4015c6283f..f4160a5fbcb 100644 --- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp @@ -69,6 +69,46 @@ void RenderLayersBaseProg::initExecution() } } +void RenderLayersBaseProg::doInterpolation(float output[4], float x, float y, PixelSampler sampler) +{ + unsigned int offset; + int ix, iy; + int width = this->getWidth(), height = this->getHeight(); + + switch (sampler) { + case COM_PS_NEAREST: + ix = x; + iy = y; + offset = (iy * width + ix) * this->m_elementsize; + + if (this->m_elementsize == 1) + output[0] = this->m_inputBuffer[offset]; + else if (this->m_elementsize == 3) + copy_v3_v3(output, &this->m_inputBuffer[offset]); + else + copy_v4_v4(output, &this->m_inputBuffer[offset]); + + break; + + case COM_PS_BILINEAR: + BLI_bilinear_interpolation(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y); + break; + + case COM_PS_BICUBIC: + BLI_bicubic_interpolation(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y); + break; + } + + if (this->m_elementsize == 1) { + output[1] = 0.0f; + output[2] = 0.0f; + output[3] = 0.0f; + } + else if (this->m_elementsize == 3) { + output[3] = 1.0f; + } +} + void RenderLayersBaseProg::executePixel(float output[4], float x, float y, PixelSampler sampler) { int ix = x; @@ -78,20 +118,7 @@ void RenderLayersBaseProg::executePixel(float output[4], float x, float y, Pixel zero_v4(output); } else { - unsigned int offset = (iy * this->getWidth() + ix) * this->m_elementsize; - if (this->m_elementsize == 1) { - output[0] = this->m_inputBuffer[offset]; - output[1] = 0.0f; - output[2] = 0.0f; - output[3] = 0.0f; - } - else if (this->m_elementsize == 3) { - copy_v3_v3(output, &this->m_inputBuffer[offset]); - output[3] = 1.0f; - } - else { - copy_v4_v4(output, &this->m_inputBuffer[offset]); - } + doInterpolation(output, x, y, sampler); } } diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h index ea57d4bc421..3916862a0b3 100644 --- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h @@ -80,6 +80,7 @@ protected: */ inline float *getInputBuffer() { return this->m_inputBuffer; } + void doInterpolation(float output[4], float x, float y, PixelSampler sampler); public: /** * setter for the scene field. Will be called from diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp index 276b2f54b6e..9e8f5af0ef0 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.cpp +++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp @@ -29,7 +29,16 @@ * note: use bilinear because bicubic makes fuzzy even when not scaling at all (1:1) */ -ScaleOperation::ScaleOperation() : NodeOperation() +BaseScaleOperation::BaseScaleOperation() +{ +#ifdef USE_FORCE_BILINEAR + m_sampler = (int) COM_PS_BILINEAR; +#else + m_sampler = -1; +#endif +} + +ScaleOperation::ScaleOperation() : BaseScaleOperation() { this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); @@ -59,22 +68,20 @@ void ScaleOperation::deinitExecution() void ScaleOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { -#ifdef USE_FORCE_BILINEAR - sampler = COM_PS_BILINEAR; -#endif + PixelSampler effective_sampler = getEffectiveSampler(sampler); float scaleX[4]; float scaleY[4]; - this->m_inputXOperation->read(scaleX, x, y, sampler); - this->m_inputYOperation->read(scaleY, x, y, sampler); + this->m_inputXOperation->read(scaleX, x, y, effective_sampler); + this->m_inputYOperation->read(scaleY, x, y, effective_sampler); const float scx = scaleX[0]; const float scy = scaleY[0]; float nx = this->m_centerX + (x - this->m_centerX) / scx; float ny = this->m_centerY + (y - this->m_centerY) / scy; - this->m_inputOperation->read(output, nx, ny, sampler); + this->m_inputOperation->read(output, nx, ny, effective_sampler); } bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -94,12 +101,12 @@ bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / scy; newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / scy; - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } // SCALE ABSOLUTE -ScaleAbsoluteOperation::ScaleAbsoluteOperation() : NodeOperation() +ScaleAbsoluteOperation::ScaleAbsoluteOperation() : BaseScaleOperation() { this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); @@ -129,15 +136,13 @@ void ScaleAbsoluteOperation::deinitExecution() void ScaleAbsoluteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { -#ifdef USE_FORCE_BILINEAR - sampler = COM_PS_BILINEAR; -#endif + PixelSampler effective_sampler = getEffectiveSampler(sampler); float scaleX[4]; float scaleY[4]; - this->m_inputXOperation->read(scaleX, x, y, sampler); - this->m_inputYOperation->read(scaleY, x, y, sampler); + this->m_inputXOperation->read(scaleX, x, y, effective_sampler); + this->m_inputYOperation->read(scaleY, x, y, effective_sampler); const float scx = scaleX[0]; // target absolute scale const float scy = scaleY[0]; // target absolute scale @@ -151,7 +156,7 @@ void ScaleAbsoluteOperation::executePixel(float output[4], float x, float y, Pix float nx = this->m_centerX + (x - this->m_centerX) / relativeXScale; float ny = this->m_centerY + (y - this->m_centerY) / relativeYScale; - this->m_inputOperation->read(output, nx, ny, sampler); + this->m_inputOperation->read(output, nx, ny, effective_sampler); } bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -176,12 +181,12 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / relateveYScale; newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / relateveYScale; - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } // Absolute fixed siez -ScaleFixedSizeOperation::ScaleFixedSizeOperation() : NodeOperation() +ScaleFixedSizeOperation::ScaleFixedSizeOperation() : BaseScaleOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->addOutputSocket(COM_DT_COLOR); @@ -250,17 +255,15 @@ void ScaleFixedSizeOperation::deinitExecution() void ScaleFixedSizeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { -#ifdef USE_FORCE_BILINEAR - sampler = COM_PS_BILINEAR; -#endif + PixelSampler effective_sampler = getEffectiveSampler(sampler); if (this->m_is_offset) { float nx = ((x - this->m_offsetX) * this->m_relX); float ny = ((y - this->m_offsetY) * this->m_relY); - this->m_inputOperation->read(output, nx, ny, sampler); + this->m_inputOperation->read(output, nx, ny, effective_sampler); } else { - this->m_inputOperation->read(output, x * this->m_relX, y * this->m_relY, sampler); + this->m_inputOperation->read(output, x * this->m_relX, y * this->m_relY, effective_sampler); } } @@ -273,7 +276,7 @@ bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, Read newInput.ymax = input->ymax * this->m_relY; newInput.ymin = input->ymin * this->m_relY; - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) @@ -281,7 +284,7 @@ void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[2], un unsigned int nr[2]; nr[0] = this->m_newWidth; nr[1] = this->m_newHeight; - NodeOperation::determineResolution(resolution, nr); + BaseScaleOperation::determineResolution(resolution, nr); resolution[0] = this->m_newWidth; resolution[1] = this->m_newHeight; } diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h index 4239ff063fb..f42cdbd78ed 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.h +++ b/source/blender/compositor/operations/COM_ScaleOperation.h @@ -25,7 +25,19 @@ #include "COM_NodeOperation.h" -class ScaleOperation : public NodeOperation { +class BaseScaleOperation : public NodeOperation { +public: + void setSampler(PixelSampler sampler) { this->m_sampler = (int) sampler; } + +protected: + BaseScaleOperation(); + + PixelSampler getEffectiveSampler(PixelSampler sampler) { return (m_sampler == -1) ? sampler : (PixelSampler) m_sampler; } + + int m_sampler; +}; + +class ScaleOperation : public BaseScaleOperation { private: SocketReader *m_inputOperation; SocketReader *m_inputXOperation; @@ -41,7 +53,7 @@ public: void deinitExecution(); }; -class ScaleAbsoluteOperation : public NodeOperation { +class ScaleAbsoluteOperation : public BaseScaleOperation { SocketReader *m_inputOperation; SocketReader *m_inputXOperation; SocketReader *m_inputYOperation; @@ -57,7 +69,7 @@ public: void deinitExecution(); }; -class ScaleFixedSizeOperation : public NodeOperation { +class ScaleFixedSizeOperation : public BaseScaleOperation { SocketReader *m_inputOperation; int m_newWidth; int m_newHeight; |