[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47419] trunk/blender/source/blender: remaining mask files from tomato.
Campbell Barton
ideasman42 at gmail.com
Mon Jun 4 17:50:01 CEST 2012
Revision: 47419
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47419
Author: campbellbarton
Date: 2012-06-04 15:49:58 +0000 (Mon, 04 Jun 2012)
Log Message:
-----------
remaining mask files from tomato. these wont get svn history carried over.
Added Paths:
-----------
trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp
trunk/blender/source/blender/compositor/nodes/COM_MaskNode.h
trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h
trunk/blender/source/blender/editors/include/ED_mask.h
trunk/blender/source/blender/makesdna/DNA_mask_types.h
trunk/blender/source/blender/makesrna/intern/rna_mask.c
trunk/blender/source/blender/nodes/composite/nodes/node_composite_mask.c
Added: trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp (rev 0)
+++ trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp 2012-06-04 15:49:58 UTC (rev 47419)
@@ -0,0 +1,65 @@
+/*
+ * 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:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_MaskNode.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_MaskOperation.h"
+
+extern "C" {
+ #include "DNA_mask_types.h"
+}
+
+MaskNode::MaskNode(bNode *editorNode): Node(editorNode)
+{
+}
+
+void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+{
+ const RenderData *data = &context->getScene()->r;
+
+ InputSocket *inputImage = this->getInputSocket(0);
+ OutputSocket *outputMask = this->getOutputSocket(0);
+
+ bNode *editorNode = this->getbNode();
+ Mask *mask = (Mask *)editorNode->id;
+
+ // always connect the output image
+ MaskOperation *operation = new MaskOperation();
+
+ if (inputImage->isConnected()) {
+ inputImage->relinkConnections(operation->getInputSocket(0), 0, graph);
+ }
+ else {
+ operation->setMaskWidth(data->xsch * data->size / 100.0f);
+ operation->setMaskHeight(data->ysch * data->size / 100.0f);
+ }
+
+ if (outputMask->isConnected()) {
+ outputMask->relinkConnections(operation->getOutputSocket());
+ }
+
+ operation->setMask(mask);
+ operation->setFramenumber(context->getFramenumber());
+
+ graph->addOperation(operation);
+}
Added: trunk/blender/source/blender/compositor/nodes/COM_MaskNode.h
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_MaskNode.h (rev 0)
+++ trunk/blender/source/blender/compositor/nodes/COM_MaskNode.h 2012-06-04 15:49:58 UTC (rev 47419)
@@ -0,0 +1,38 @@
+/*
+ * 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:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief MaskNode
+ * @ingroup Node
+ */
+class MaskNode : public Node {
+
+
+public:
+ MaskNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+
+};
Added: trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp (rev 0)
+++ trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp 2012-06-04 15:49:58 UTC (rev 47419)
@@ -0,0 +1,124 @@
+/*
+ * 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:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+#include "COM_MaskOperation.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+
+#include "DNA_scene_types.h"
+
+extern "C" {
+ #include "BKE_mask.h"
+}
+
+MaskOperation::MaskOperation(): NodeOperation()
+{
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->mask = NULL;
+ this->maskWidth = 0;
+ this->maskHeight = 0;
+ this->framenumber = 0;
+ this->rasterizedMask = NULL;
+ setComplex(true);
+}
+
+void MaskOperation::initExecution()
+{
+ initMutex();
+ this->rasterizedMask = NULL;
+}
+
+void MaskOperation::deinitExecution()
+{
+ if (this->rasterizedMask) {
+ MEM_freeN(rasterizedMask);
+ this->rasterizedMask = NULL;
+ }
+}
+
+void *MaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
+{
+ if (this->rasterizedMask)
+ return this->rasterizedMask;
+
+ if (!this->mask)
+ return NULL;
+
+ BLI_mutex_lock(getMutex());
+ if (this->rasterizedMask == NULL) {
+ int width = this->getWidth();
+ int height = this->getHeight();
+ float *buffer;
+
+ buffer = (float *)MEM_callocN(sizeof(float) * width * height, "rasterized mask");
+ BKE_mask_rasterize(mask, width, height, buffer);
+
+ this->rasterizedMask = buffer;
+ }
+ BLI_mutex_unlock(getMutex());
+
+ return this->rasterizedMask;
+}
+
+void MaskOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
+{
+ if (maskWidth == 0 || maskHeight == 0) {
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ }
+ else {
+ unsigned int nr[2];
+
+ nr[0] = maskWidth;
+ nr[1] = maskHeight;
+
+ NodeOperation::determineResolution(resolution, nr);
+
+ resolution[0] = maskWidth;
+ resolution[1] = maskHeight;
+ }
+}
+
+void MaskOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
+{
+ if (!data) {
+ color[0] = 0;
+ color[1] = 0;
+ color[2] = 0;
+ color[3] = 1.0f;
+ }
+ else {
+ float *buffer = (float*) data;
+ int index = (y * this->getWidth() + x);
+
+ color[0] = buffer[index];
+ color[1] = buffer[index];
+ color[2] = buffer[index];
+ color[3] = 1.0f;
+ }
+}
+
+
Added: trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h (rev 0)
+++ trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h 2012-06-04 15:49:58 UTC (rev 47419)
@@ -0,0 +1,66 @@
+/*
+ * 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:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Sergey Sharybin
+ */
+
+
+#ifndef _COM_MaskOperation_h
+#define _COM_MaskOperation_h
+
+#include "COM_NodeOperation.h"
+#include "DNA_scene_types.h"
+#include "DNA_mask_types.h"
+#include "BLI_listbase.h"
+#include "IMB_imbuf_types.h"
+
+/**
+ * Class with implementation of mask rasterization
+ */
+class MaskOperation : public NodeOperation {
+protected:
+ Mask *mask;
+ int maskWidth;
+ int maskHeight;
+ int framenumber;
+ float *rasterizedMask;
+
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+public:
+ MaskOperation();
+
+ void initExecution();
+ void deinitExecution();
+
+ void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+ void setMask(Mask *mask) {this->mask = mask;}
+ void setMaskWidth(int width) {this->maskWidth = width;}
+ void setMaskHeight(int height) {this->maskHeight = height;}
+ void setFramenumber(int framenumber) {this->framenumber = framenumber;}
+
+ void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+};
+
+#endif
Added: trunk/blender/source/blender/editors/include/ED_mask.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_mask.h (rev 0)
+++ trunk/blender/source/blender/editors/include/ED_mask.h 2012-06-04 15:49:58 UTC (rev 47419)
@@ -0,0 +1,47 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list