From c2dfcd9208a6afe03b108e682cc4d47fadb5f2bf Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 28 Dec 2012 14:46:32 +0000 Subject: Convert alpha node: rename "key alpha" to "straight alpha" for consistency. --- source/blender/compositor/CMakeLists.txt | 8 +-- .../compositor/nodes/COM_ConvertAlphaNode.cpp | 8 +-- .../operations/COM_ConvertKeyToPremulOperation.cpp | 55 -------------------- .../operations/COM_ConvertKeyToPremulOperation.h | 49 ------------------ .../operations/COM_ConvertPremulToKeyOperation.cpp | 60 ---------------------- .../operations/COM_ConvertPremulToKeyOperation.h | 48 ----------------- .../COM_ConvertPremulToStraightOperation.cpp | 60 ++++++++++++++++++++++ .../COM_ConvertPremulToStraightOperation.h | 48 +++++++++++++++++ .../COM_ConvertStraightToPremulOperation.cpp | 55 ++++++++++++++++++++ .../COM_ConvertStraightToPremulOperation.h | 49 ++++++++++++++++++ 10 files changed, 220 insertions(+), 220 deletions(-) delete mode 100644 source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp delete mode 100644 source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h delete mode 100644 source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp delete mode 100644 source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h create mode 100644 source/blender/compositor/operations/COM_ConvertPremulToStraightOperation.cpp create mode 100644 source/blender/compositor/operations/COM_ConvertPremulToStraightOperation.h create mode 100644 source/blender/compositor/operations/COM_ConvertStraightToPremulOperation.cpp create mode 100644 source/blender/compositor/operations/COM_ConvertStraightToPremulOperation.h (limited to 'source/blender/compositor') diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index 8259cb6f297..0e8ddf4068c 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -491,10 +491,10 @@ set(SRC operations/COM_ColorMatteOperation.h operations/COM_ChannelMatteOperation.cpp operations/COM_ChannelMatteOperation.h - operations/COM_ConvertPremulToKeyOperation.cpp - operations/COM_ConvertPremulToKeyOperation.h - operations/COM_ConvertKeyToPremulOperation.cpp - operations/COM_ConvertKeyToPremulOperation.h + operations/COM_ConvertPremulToStraightOperation.cpp + operations/COM_ConvertPremulToStraightOperation.h + operations/COM_ConvertStraightToPremulOperation.cpp + operations/COM_ConvertStraightToPremulOperation.h operations/COM_ReadBufferOperation.cpp operations/COM_ReadBufferOperation.h diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp index 254dfb7b9c7..a7149cc63b2 100644 --- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp +++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp @@ -20,8 +20,8 @@ */ #include "COM_ConvertAlphaNode.h" -#include "COM_ConvertPremulToKeyOperation.h" -#include "COM_ConvertKeyToPremulOperation.h" +#include "COM_ConvertPremulToStraightOperation.h" +#include "COM_ConvertStraightToPremulOperation.h" #include "COM_ExecutionSystem.h" void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) @@ -31,10 +31,10 @@ void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorCon /* value hardcoded in rna_nodetree.c */ if (node->custom1 == 1) { - operation = new ConvertPremulToKeyOperation(); + operation = new ConvertPremulToStraightOperation(); } else { - operation = new ConvertKeyToPremulOperation(); + operation = new ConvertStraightToPremulOperation(); } this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp deleted file mode 100644 index 4497db52a0f..00000000000 --- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2012, Blender Foundation. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor: - * Dalai Felinto - */ - -#include "COM_ConvertKeyToPremulOperation.h" -#include "BLI_math.h" - -ConvertKeyToPremulOperation::ConvertKeyToPremulOperation() : NodeOperation() -{ - this->addInputSocket(COM_DT_COLOR); - this->addOutputSocket(COM_DT_COLOR); - - this->m_inputColor = NULL; -} - -void ConvertKeyToPremulOperation::initExecution() -{ - this->m_inputColor = getInputSocketReader(0); -} - -void ConvertKeyToPremulOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) -{ - float inputValue[4]; - float alpha; - - this->m_inputColor->read(inputValue, x, y, sampler); - alpha = inputValue[3]; - - mul_v3_v3fl(output, inputValue, alpha); - - /* never touches the alpha */ - output[3] = alpha; -} - -void ConvertKeyToPremulOperation::deinitExecution() -{ - this->m_inputColor = NULL; -} diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h deleted file mode 100644 index 502674e26db..00000000000 --- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012, Blender Foundation. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor: - * Dalai Felinto - */ - -#ifndef _COM_ConvertKeyToPremulOperation_h -#define _COM_ConvertKeyToPremulOperation_h -#include "COM_NodeOperation.h" - - -/** - * this program converts an input color to an output value. - * it assumes we are in sRGB color space. - */ -class ConvertKeyToPremulOperation : public NodeOperation { -private: - SocketReader *m_inputColor; -public: - /** - * Default constructor - */ - ConvertKeyToPremulOperation(); - - /** - * the inner loop of this program - */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); - - void initExecution(); - void deinitExecution(); - -}; -#endif diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp deleted file mode 100644 index b92da4c324f..00000000000 --- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2012, Blender Foundation. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor: - * Dalai Felinto - */ - -#include "COM_ConvertPremulToKeyOperation.h" -#include "BLI_math.h" - -ConvertPremulToKeyOperation::ConvertPremulToKeyOperation() : NodeOperation() -{ - this->addInputSocket(COM_DT_COLOR); - this->addOutputSocket(COM_DT_COLOR); - - this->m_inputColor = NULL; -} - -void ConvertPremulToKeyOperation::initExecution() -{ - this->m_inputColor = getInputSocketReader(0); -} - -void ConvertPremulToKeyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) -{ - float inputValue[4]; - float alpha; - - this->m_inputColor->read(inputValue, x, y, sampler); - alpha = inputValue[3]; - - if (fabsf(alpha) < 1e-5f) { - zero_v3(output); - } - else { - mul_v3_v3fl(output, inputValue, 1.0f / alpha); - } - - /* never touches the alpha */ - output[3] = alpha; -} - -void ConvertPremulToKeyOperation::deinitExecution() -{ - this->m_inputColor = NULL; -} diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h deleted file mode 100644 index 04a9965858d..00000000000 --- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012, Blender Foundation. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor: - * Dalai Felinto - */ - -#ifndef _COM_ConvertPremulToKeyOperation_h -#define _COM_ConvertPremulToKeyOperation_h -#include "COM_NodeOperation.h" - - -/** - * this program converts an input color to an output value. - * it assumes we are in sRGB color space. - */ -class ConvertPremulToKeyOperation : public NodeOperation { -private: - SocketReader *m_inputColor; -public: - /** - * Default constructor - */ - ConvertPremulToKeyOperation(); - - /** - * the inner loop of this program - */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); - - void initExecution(); - void deinitExecution(); -}; -#endif diff --git a/source/blender/compositor/operations/COM_ConvertPremulToStraightOperation.cpp b/source/blender/compositor/operations/COM_ConvertPremulToStraightOperation.cpp new file mode 100644 index 00000000000..2af4b55de1a --- /dev/null +++ b/source/blender/compositor/operations/COM_ConvertPremulToStraightOperation.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_ConvertPremulToStraightOperation.h" +#include "BLI_math.h" + +ConvertPremulToStraightOperation::ConvertPremulToStraightOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_COLOR); + + this->m_inputColor = NULL; +} + +void ConvertPremulToStraightOperation::initExecution() +{ + this->m_inputColor = getInputSocketReader(0); +} + +void ConvertPremulToStraightOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +{ + float inputValue[4]; + float alpha; + + this->m_inputColor->read(inputValue, x, y, sampler); + alpha = inputValue[3]; + + if (fabsf(alpha) < 1e-5f) { + zero_v3(output); + } + else { + mul_v3_v3fl(output, inputValue, 1.0f / alpha); + } + + /* never touches the alpha */ + output[3] = alpha; +} + +void ConvertPremulToStraightOperation::deinitExecution() +{ + this->m_inputColor = NULL; +} diff --git a/source/blender/compositor/operations/COM_ConvertPremulToStraightOperation.h b/source/blender/compositor/operations/COM_ConvertPremulToStraightOperation.h new file mode 100644 index 00000000000..9d3ab156555 --- /dev/null +++ b/source/blender/compositor/operations/COM_ConvertPremulToStraightOperation.h @@ -0,0 +1,48 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_ConvertPremulToStraightOperation_h +#define _COM_ConvertPremulToStraightOperation_h +#include "COM_NodeOperation.h" + + +/** + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. + */ +class ConvertPremulToStraightOperation : public NodeOperation { +private: + SocketReader *m_inputColor; +public: + /** + * Default constructor + */ + ConvertPremulToStraightOperation(); + + /** + * the inner loop of this program + */ + void executePixel(float output[4], float x, float y, PixelSampler sampler); + + void initExecution(); + void deinitExecution(); +}; +#endif diff --git a/source/blender/compositor/operations/COM_ConvertStraightToPremulOperation.cpp b/source/blender/compositor/operations/COM_ConvertStraightToPremulOperation.cpp new file mode 100644 index 00000000000..ae55d949ff2 --- /dev/null +++ b/source/blender/compositor/operations/COM_ConvertStraightToPremulOperation.cpp @@ -0,0 +1,55 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_ConvertStraightToPremulOperation.h" +#include "BLI_math.h" + +ConvertStraightToPremulOperation::ConvertStraightToPremulOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_COLOR); + + this->m_inputColor = NULL; +} + +void ConvertStraightToPremulOperation::initExecution() +{ + this->m_inputColor = getInputSocketReader(0); +} + +void ConvertStraightToPremulOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +{ + float inputValue[4]; + float alpha; + + this->m_inputColor->read(inputValue, x, y, sampler); + alpha = inputValue[3]; + + mul_v3_v3fl(output, inputValue, alpha); + + /* never touches the alpha */ + output[3] = alpha; +} + +void ConvertStraightToPremulOperation::deinitExecution() +{ + this->m_inputColor = NULL; +} diff --git a/source/blender/compositor/operations/COM_ConvertStraightToPremulOperation.h b/source/blender/compositor/operations/COM_ConvertStraightToPremulOperation.h new file mode 100644 index 00000000000..d0191f292d2 --- /dev/null +++ b/source/blender/compositor/operations/COM_ConvertStraightToPremulOperation.h @@ -0,0 +1,49 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_ConvertStraightToPremulOperation_h +#define _COM_ConvertStraightToPremulOperation_h +#include "COM_NodeOperation.h" + + +/** + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. + */ +class ConvertStraightToPremulOperation : public NodeOperation { +private: + SocketReader *m_inputColor; +public: + /** + * Default constructor + */ + ConvertStraightToPremulOperation(); + + /** + * the inner loop of this program + */ + void executePixel(float output[4], float x, float y, PixelSampler sampler); + + void initExecution(); + void deinitExecution(); + +}; +#endif -- cgit v1.2.3