[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46266] branches/tile/source/blender/ compositor: TileBranch

Jeroen Bakker j.bakker at atmind.nl
Fri May 4 13:17:33 CEST 2012


Revision: 46266
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46266
Author:   jbakker
Date:     2012-05-04 11:17:32 +0000 (Fri, 04 May 2012)
Log Message:
-----------
TileBranch
 * Added an AntiAlias Operation. It utilizes Blender internal renderer.
 * Fix for [#31263] ID Mask - Smooth Mask option doesnt do anything

 - At Mind - 

Modified Paths:
--------------
    branches/tile/source/blender/compositor/CMakeLists.txt
    branches/tile/source/blender/compositor/nodes/COM_IDMaskNode.cpp

Added Paths:
-----------
    branches/tile/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_AntiAliasOperation.h

Modified: branches/tile/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/tile/source/blender/compositor/CMakeLists.txt	2012-05-04 09:58:35 UTC (rev 46265)
+++ branches/tile/source/blender/compositor/CMakeLists.txt	2012-05-04 11:17:32 UTC (rev 46266)
@@ -599,6 +599,9 @@
 	operations/COM_MovieClipOperation.h
 	operations/COM_ConvertColorProfileOperation.cpp
 	operations/COM_ConvertColorProfileOperation.h
+
+	operations/COM_AntiAliasOperation.cpp
+	operations/COM_AntiAliasOperation.h
 )
 
 blender_add_lib(bf_compositor "${SRC}" "${INC}" "${INC_SYS}")

Modified: branches/tile/source/blender/compositor/nodes/COM_IDMaskNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_IDMaskNode.cpp	2012-05-04 09:58:35 UTC (rev 46265)
+++ branches/tile/source/blender/compositor/nodes/COM_IDMaskNode.cpp	2012-05-04 11:17:32 UTC (rev 46266)
@@ -24,15 +24,25 @@
 #include "DNA_scene_types.h"
 #include "COM_IDMaskOperation.h"
 #include "COM_ExecutionSystem.h"
+#include "COM_AntiAliasOperation.h"
 
 IDMaskNode::IDMaskNode(bNode *editorNode): Node(editorNode) {
 }
 void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+	bNode* bnode = this->getbNode();
 	IDMaskOperation *operation;
 	operation = new IDMaskOperation();
-	operation->setObjectIndex(this->getbNode()->custom1);
+	operation->setObjectIndex(bnode->custom1);
 	
 	this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0));
-	this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+	if (bnode->custom2==0 || context->getScene()->r.scemode & R_FULL_SAMPLE) {
+		this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+	} else {
+		AntiAliasOperation * antiAliasOperation = new AntiAliasOperation();
+		addLink(graph, operation->getOutputSocket(), antiAliasOperation->getInputSocket(0));
+		this->getOutputSocket(0)->relinkConnections(antiAliasOperation->getOutputSocket(0));
+		graph->addOperation(antiAliasOperation);
+	}
 	graph->addOperation(operation);
+	
 }

Added: branches/tile/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_AntiAliasOperation.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_AntiAliasOperation.cpp	2012-05-04 11:17:32 UTC (rev 46266)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2011, 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: 
+ *		Jeroen Bakker 
+ *		Monique Dewanchand
+ */
+
+#include "COM_AntiAliasOperation.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+extern "C" {
+	#include "RE_render_ext.h"
+}
+
+
+AntiAliasOperation::AntiAliasOperation(): NodeOperation() {
+	this->addInputSocket(COM_DT_VALUE);
+	this->addOutputSocket(COM_DT_VALUE);
+	this->valueReader = NULL;
+	this->buffer = NULL;
+	this->setComplex(true);
+}
+void AntiAliasOperation::initExecution() {
+	this->valueReader = this->getInputSocketReader(0);
+	NodeOperation::initMutex();
+}
+
+void AntiAliasOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data) {
+	if (y < 0 || y >= this->height || x < 0 || x >= this->width) {
+		color[0] = 0.0f;
+	} else {
+		int offset = y*this->width + x;
+		color[0] = buffer[offset]/255.0f;
+	}
+	
+}
+
+void AntiAliasOperation::deinitExecution() {
+	this->valueReader = NULL;
+	if (this->buffer) {
+		delete buffer;
+	}
+	NodeOperation::deinitMutex();
+}
+
+bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+	rcti imageInput;
+	if (this->buffer) {
+		return false;
+	} else {
+		NodeOperation* operation = getInputOperation(0);
+		imageInput.xmax = operation->getWidth();
+		imageInput.xmin = 0;
+		imageInput.ymax = operation->getHeight();
+		imageInput.ymin = 0;
+		if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output) ) {
+			return true;
+		}
+	}
+	return false;
+}
+
+void* AntiAliasOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+	if (this->buffer) {return buffer;}
+	BLI_mutex_lock(getMutex());
+	if (this->buffer == NULL) {
+		MemoryBuffer* tile = (MemoryBuffer*)valueReader->initializeTileData(rect, memoryBuffers);
+		int size = tile->getHeight()*tile->getWidth();
+		float * input = tile->getBuffer();
+		char* valuebuffer = new char[size];
+		for (int i = 0 ; i < size ; i ++) {
+			float in = input[i* COM_NUMBER_OF_CHANNELS];
+			if (in < 0.0f) { in = 0.0f;}
+			if (in > 1.0f) {in = 1.0f;}
+			valuebuffer[i] = in * 255;
+		}
+		antialias_tagbuf(tile->getWidth(), tile->getHeight(), valuebuffer);
+		this->buffer = valuebuffer;
+	}
+	BLI_mutex_unlock(getMutex());
+	return this->buffer;
+}

Added: branches/tile/source/blender/compositor/operations/COM_AntiAliasOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_AntiAliasOperation.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_AntiAliasOperation.h	2012-05-04 11:17:32 UTC (rev 46266)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011, 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: 
+ *		Jeroen Bakker 
+ *		Monique Dewanchand
+ */
+
+#ifndef _COM_AntiAliasOperation_h
+#define _COM_AntiAliasOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+
+/**
+  * @brief AntiAlias operations
+  * it only supports anti aliasing on BW buffers.
+  * @ingroup operation
+  */
+class AntiAliasOperation : public NodeOperation {
+protected:
+	/**
+	  * @brief Cached reference to the reader
+	  */
+	SocketReader * valueReader;
+	char *buffer;
+public:
+	AntiAliasOperation();
+	
+	/**
+	  * the inner loop of this program
+	  */
+	void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
+	
+	/**
+	  * Initialize the execution
+	  */
+	void initExecution();
+	
+	void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+	
+	/**
+	  * Deinitialize the execution
+	  */
+	void deinitExecution();
+	bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+};
+#endif




More information about the Bf-blender-cvs mailing list