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

Jeroen Bakker j.bakker at atmind.nl
Wed May 9 22:47:14 CEST 2012


Revision: 46481
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46481
Author:   jbakker
Date:     2012-05-09 20:47:13 +0000 (Wed, 09 May 2012)
Log Message:
-----------
TileBranch
 * added ImageNode for trunk.

The file COM_defines.h.trunk is a file that needs to be copied over the COM_defines.h when patching trunk
This will will make sure that the new image API, image node and outputfilenode will be used.

Modified Paths:
--------------
    branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp
    branches/tile/source/blender/compositor/nodes/COM_ImageNode.h
    branches/tile/source/blender/compositor/operations/COM_ImageOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_OutputFileOperation.cpp

Added Paths:
-----------
    branches/tile/source/blender/compositor/COM_defines.h.trunk

Added: branches/tile/source/blender/compositor/COM_defines.h.trunk
===================================================================
--- branches/tile/source/blender/compositor/COM_defines.h.trunk	                        (rev 0)
+++ branches/tile/source/blender/compositor/COM_defines.h.trunk	2012-05-09 20:47:13 UTC (rev 46481)
@@ -0,0 +1,101 @@
+/*
+ * 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_defines_h_
+#define _COM_defines_h_
+
+/**
+  * @brief possible data types for SocketConnection
+  * @ingroup Model
+  */
+typedef enum DataType {
+	/** @brief Unknown data type (or not yet known) */
+	COM_DT_UNKNOWN = 0,
+	/** @brief Value data type */
+	COM_DT_VALUE   = 1,
+	/** @brief Vector data type */
+	COM_DT_VECTOR  = 2,
+	/** @brief Color data type */
+	COM_DT_COLOR   = 4
+} DataType;
+
+/**
+  * @brief Possible quality settings
+  * @see CompositorContext.quality
+  * @ingroup Execution
+  */
+typedef enum CompositorQuality {
+	/** @brief High quality setting */
+	COM_QUALITY_HIGH   = 0 ,
+	/** @brief Medium quality setting */
+	COM_QUALITY_MEDIUM = 1,
+	/** @brief Low quality setting */
+	COM_QUALITY_LOW    = 2
+} CompositorQuality;
+
+// configurable items
+
+// chunk size determination
+#define COM_PREVIEW_SIZE 140.0f
+#define COM_OPENCL_ENABLED
+#define COM_PREVIEW_ENABLED
+// workscheduler threading models
+/**
+  * COM_TM_QUEUE is a multithreaded model, which uses the BLI_thread_queue pattern. This is the default option.
+  */
+#define COM_TM_QUEUE 1
+
+/**
+  * COM_TM_NOTHREAD is a single threading model, everything is executed in the caller thread. easy for debugging
+  */
+#define COM_TM_NOTHREAD 0
+
+/**
+  * COM_CURRENT_THREADING_MODEL can be one of the above, COM_TM_QUEUE is currently default.
+  */
+#define COM_CURRENT_THREADING_MODEL COM_TM_QUEUE
+// chunk order
+/**
+  * @brief The order of chunks to be scheduled
+  * @ingroup Execution
+  */
+typedef enum OrderOfChunks {
+	/** @brief order from a distance to centerX/centerY */
+	COM_TO_CENTER_OUT = 0,
+	/** @brief order randomly */
+	COM_TO_RANDOM = 1,
+	/** @brief no ordering */
+	COM_TO_TOP_DOWN = 2,
+	/** @brief experimental ordering with 9 hotspots */
+	COM_TO_RULE_OF_THIRDS = 3
+} OrderOfChunks;
+
+#define COM_RULE_OF_THIRDS_DIVIDER 100.0f
+
+#define COM_NUMBER_OF_CHANNELS 4
+
+#define COM_DEFAULT_RESOLUTION_WIDTH 640
+#define COM_DEFAULT_RESOLUTION_HEIGHT 480
+
+#define COM_TRUNK 1
+
+#endif

Modified: branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp	2012-05-09 19:40:54 UTC (rev 46480)
+++ branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp	2012-05-09 20:47:13 UTC (rev 46481)
@@ -25,14 +25,14 @@
 #include "COM_ImageOperation.h"
 #include "COM_MultilayerImageOperation.h"
 #include "BKE_node.h"
+#include "BLI_utildefines.h"
 
 ImageNode::ImageNode(bNode *editorNode): Node(editorNode) {
 }
-
-void ImageNode::doMultilayerCheck(ExecutionSystem *system, RenderLayer* rl, Image* image, ImageUser* user, int framenumber, int outputsocketIndex, int pass, DataType datatype) {
+NodeOperation* ImageNode::doMultilayerCheck(ExecutionSystem *system, RenderLayer* rl, Image* image, ImageUser* user, int framenumber, int outputsocketIndex, int pass, DataType datatype) {
 	OutputSocket *outputSocket = this->getOutputSocket(outputsocketIndex);
+	MultilayerBaseOperation * operation = NULL;
 	if (outputSocket->isConnected()) {
-		MultilayerBaseOperation * operation = NULL;
 		switch (datatype) {
 		case COM_DT_VALUE:
 			operation = new MultilayerValueOperation(pass);
@@ -43,6 +43,8 @@
 		case COM_DT_COLOR:
 			operation = new MultilayerColorOperation(pass);
 			break;
+		default:
+			break;
 		}
 		operation->setImage(image);
 		operation->setRenderLayer(rl);
@@ -51,8 +53,10 @@
 		outputSocket->relinkConnections(operation->getOutputSocket());
 		system->addOperation(operation);
 	}
+	return operation;
 }
 
+#ifndef COM_TRUNK
 void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
 	/// Image output
 	OutputSocket *outputImage = this->getOutputSocket(0);
@@ -133,3 +137,93 @@
 	}
 	
 }
+#else
+void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+	/// Image output
+	OutputSocket *outputImage = this->getOutputSocket(0);
+	bNode *editorNode = this->getbNode();
+	Image *image = (Image*)editorNode->id;
+	ImageUser *imageuser = (ImageUser*)editorNode->storage;
+	int framenumber = context->getFramenumber();
+	int numberOfOutputs = this->getNumberOfOutputSockets();
+
+	/* force a load, we assume iuser index will be set OK anyway */
+	if(image && image->type==IMA_TYPE_MULTILAYER) {
+		BKE_image_get_ibuf(image, imageuser);
+		if(image->rr) {
+			RenderLayer *rl= (RenderLayer*)BLI_findlink(&image->rr->layers, imageuser->layer);
+			if (rl) {
+				OutputSocket * socket;
+				int index;
+				for (index = 0 ; index < numberOfOutputs ; index ++) {
+					socket = this->getOutputSocket(index);
+					if (socket->isConnected() || index == 0) {
+						bNodeSocket *bnodeSocket = socket->getbNodeSocket();
+						int passindex = GET_INT_FROM_POINTER(bnodeSocket->storage);
+						RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex);
+						if (rpass) {
+							NodeOperation * operation = NULL;
+							switch (rpass->channels) {
+							case 1:
+								operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VALUE);
+								break;
+							/* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */
+							/* XXX any way to detect actual vector images? */
+							case 3:
+								operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VECTOR);
+								break;
+							case 4:
+								operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_COLOR);
+								break;
+							
+							default:
+							/* XXX add a dummy operation? */
+							break;
+							}
+							if (index == 0 && operation) {
+								addPreviewOperation(graph, operation->getOutputSocket(), 9);
+							}
+						}
+					}
+				}
+			}
+		}
+	} else {
+		if (numberOfOutputs >  0) {
+			ImageOperation *operation = new ImageOperation();
+			if (outputImage->isConnected()) {
+				outputImage->relinkConnections(operation->getOutputSocket());
+			}
+			operation->setImage(image);
+			operation->setImageUser(imageuser);
+			operation->setFramenumber(framenumber);
+			graph->addOperation(operation);
+			addPreviewOperation(graph, operation->getOutputSocket(), 9);
+		}
+		
+		if (numberOfOutputs > 1) {
+			OutputSocket *alphaImage = this->getOutputSocket(1);
+			if (alphaImage->isConnected()) {
+				ImageAlphaOperation *alphaOperation = new ImageAlphaOperation();
+				alphaOperation->setImage(image);
+				alphaOperation->setImageUser(imageuser);
+				alphaOperation->setFramenumber(framenumber);
+				alphaImage->relinkConnections(alphaOperation->getOutputSocket());
+				graph->addOperation(alphaOperation);
+			}
+		}
+		if (numberOfOutputs > 2) {
+			OutputSocket *depthImage = this->getOutputSocket(2);
+			if (depthImage->isConnected()) {
+				ImageDepthOperation *depthOperation = new ImageDepthOperation();
+				depthOperation->setImage(image);
+				depthOperation->setImageUser(imageuser);
+				depthOperation->setFramenumber(framenumber);
+				depthImage->relinkConnections(depthOperation->getOutputSocket());
+				graph->addOperation(depthOperation);
+			}
+		}
+	}
+}
+
+#endif

Modified: branches/tile/source/blender/compositor/nodes/COM_ImageNode.h
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ImageNode.h	2012-05-09 19:40:54 UTC (rev 46480)
+++ branches/tile/source/blender/compositor/nodes/COM_ImageNode.h	2012-05-09 20:47:13 UTC (rev 46481)
@@ -20,11 +20,12 @@
  *		Monique Dewanchand
  */
 
+#include "COM_defines.h"
 #include "COM_Node.h"
 #include "DNA_node_types.h"
 #include "DNA_image_types.h"
 extern "C" {
-#include "RE_engine.h"
+	#include "RE_engine.h"
 }
 
 /**
@@ -34,7 +35,7 @@
 class ImageNode : public Node {
 
 private:
-	void doMultilayerCheck(ExecutionSystem *system, RenderLayer* rl, Image* image, ImageUser* user, int framenumber, int outputsocketIndex, int pass, DataType datatype);
+	NodeOperation* doMultilayerCheck(ExecutionSystem *system, RenderLayer* rl, Image* image, ImageUser* user, int framenumber, int outputsocketIndex, int pass, DataType datatype);
 public:
 	ImageNode(bNode* editorNode);
 	void convertToOperations(ExecutionSystem *graph, CompositorContext * context);

Modified: branches/tile/source/blender/compositor/operations/COM_ImageOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_ImageOperation.cpp	2012-05-09 19:40:54 UTC (rev 46480)
+++ branches/tile/source/blender/compositor/operations/COM_ImageOperation.cpp	2012-05-09 20:47:13 UTC (rev 46481)
@@ -73,7 +73,10 @@
 
 
 void BaseImageOperation::initExecution() {
+#ifdef COM_TRUNK
+#else
 	BKE_image_user_calc_frame(this->imageUser, this->framenumber, 0);
+#endif
 	ImBuf *stackbuf= getImBuf();
 	this->buffer = stackbuf;
 	if (stackbuf) {
@@ -90,7 +93,10 @@
 }
 
 void BaseImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+#ifdef COM_TRUNK
+#else
 	BKE_image_user_calc_frame(this->imageUser, this->framenumber, 0);
+#endif
 	ImBuf *stackbuf= getImBuf();
 	if (stackbuf) {
 		resolution[0] = stackbuf->x;


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list