[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45630] branches/tile/source/blender/ compositor: Tile: Alpha Convert node (premul/key)

Dalai Felinto dfelinto at gmail.com
Sat Apr 14 17:14:24 CEST 2012


Revision: 45630
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45630
Author:   dfelinto
Date:     2012-04-14 15:14:24 +0000 (Sat, 14 Apr 2012)
Log Message:
-----------
Tile: Alpha Convert node (premul/key)

Modified Paths:
--------------
    branches/tile/source/blender/compositor/CMakeLists.txt
    branches/tile/source/blender/compositor/intern/COM_Converter.cpp

Added Paths:
-----------
    branches/tile/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
    branches/tile/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
    branches/tile/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h
    branches/tile/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h

Modified: branches/tile/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/tile/source/blender/compositor/CMakeLists.txt	2012-04-14 15:06:41 UTC (rev 45629)
+++ branches/tile/source/blender/compositor/CMakeLists.txt	2012-04-14 15:14:24 UTC (rev 45630)
@@ -217,6 +217,8 @@
 #    nodes/COM_ColorSpaceNode.h
 	nodes/COM_SetAlphaNode.cpp
 	nodes/COM_SetAlphaNode.h
+	nodes/COM_ConvertAlphaNode.cpp
+	nodes/COM_ConvertAlphaNode.h
 	nodes/COM_AlphaOverNode.cpp
 	nodes/COM_AlphaOverNode.h
 	nodes/COM_HueSaturationValueNode.cpp
@@ -440,6 +442,10 @@
 	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_ReadBufferOperation.cpp
 	operations/COM_ReadBufferOperation.h

Modified: branches/tile/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-04-14 15:06:41 UTC (rev 45629)
+++ branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-04-14 15:14:24 UTC (rev 45630)
@@ -65,6 +65,7 @@
 #include "COM_VectorCurveNode.h"
 #include "COM_DilateErode2Node.h"
 #include "COM_SetAlphaNode.h"
+#include "COM_ConvertAlphaNode.h"
 #include "COM_MapUVNode.h"
 #include "COM_DisplaceNode.h"
 #include "COM_MathNode.h"
@@ -214,6 +215,9 @@
 	case CMP_NODE_SETALPHA:
 		node = new SetAlphaNode(bNode);
 		break;
+	case CMP_NODE_PREMULKEY:
+		node = new ConvertAlphaNode(bNode);
+		break;
 	case CMP_NODE_MATH:
 		node = new MathNode(bNode);
 		break;
@@ -348,7 +352,6 @@
 	case CMP_NODE_DOUBLEEDGEMASK:
 	case CMP_NODE_DEFOCUS:
 	case CMP_NODE_CROP:
-	case CMP_NODE_PREMULKEY:
 	case CMP_NODE_VIEW_LEVELS:
 	default:
 		node = new MuteNode(bNode);

Added: branches/tile/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp	2012-04-14 15:14:24 UTC (rev 45630)
@@ -0,0 +1,43 @@
+/*
+ * 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_ConvertAlphaNode.h"
+#include "COM_ConvertPremulToKeyOperation.h"
+#include "COM_ConvertKeyToPremulOperation.h"
+#include "COM_ExecutionSystem.h"
+
+void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+	NodeOperation* operation = NULL;
+	bNode* node = this->getbNode();
+
+	/* value hardcoded in rna_nodetree.c */
+	if (node->custom1 == 1){
+		operation = new ConvertPremulToKeyOperation();
+	}
+	else {
+		operation = new ConvertKeyToPremulOperation();
+	} 
+
+	this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+	this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+
+	graph->addOperation(operation);
+}


Property changes on: branches/tile/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
___________________________________________________________________
Added: svn:eol-style
   + native

Added: branches/tile/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ConvertAlphaNode.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_ConvertAlphaNode.h	2012-04-14 15:14:24 UTC (rev 45630)
@@ -0,0 +1,37 @@
+/*
+ * 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_ConvertAlphaNode_h
+#define _COM_ConvertAlphaNode_h
+
+#include "COM_Node.h"
+
+/**
+  * @brief ConvertAlphaNode
+  * @ingroup Node
+  */
+class ConvertAlphaNode: public Node {
+public:
+	ConvertAlphaNode(bNode* editorNode) :Node(editorNode) {}
+	void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+
+#endif


Property changes on: branches/tile/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
___________________________________________________________________
Added: svn:eol-style
   + native

Added: branches/tile/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp	2012-04-14 15:14:24 UTC (rev 45630)
@@ -0,0 +1,53 @@
+/*
+ * 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->inputColor = NULL;
+}
+
+void ConvertKeyToPremulOperation::initExecution() {
+	this->inputColor = getInputSocketReader(0);
+}
+
+void ConvertKeyToPremulOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+	float inputValue[4];
+	float alpha;
+
+	this->inputColor->read(inputValue, x, y, sampler, inputBuffers);
+	alpha = inputValue[3];
+
+	outputValue[0] = inputValue[0] * alpha;
+	outputValue[1] = inputValue[1] * alpha;
+	outputValue[2] = inputValue[2] * alpha;
+
+	/* never touches the alpha */
+	outputValue[3] = alpha;
+}
+
+void ConvertKeyToPremulOperation::deinitExecution() {
+    this->inputColor = NULL;
+}


Property changes on: branches/tile/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp
___________________________________________________________________
Added: svn:eol-style
   + native

Added: branches/tile/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h	2012-04-14 15:14:24 UTC (rev 45630)
@@ -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_ConvertKeyToPremulOperation_h
+#define _COM_ConvertKeyToPremulOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+  * this program converts an input colour to an output value.
+  * it assumes we are in sRGB colour space.
+  */
+class ConvertKeyToPremulOperation : public NodeOperation {
+private:
+	SocketReader *inputColor;
+public:
+	/**
+	  * Default constructor
+	  */
+	ConvertKeyToPremulOperation();
+
+	/**
+	  * the inner loop of this program
+	  */
+	void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+	void initExecution();
+	void deinitExecution();
+
+};
+#endif


Property changes on: branches/tile/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h
___________________________________________________________________
Added: svn:eol-style
   + native

Added: branches/tile/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list