ChunkOrder();
void determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots);
friend bool operator<(const ChunkOrder &a, const ChunkOrder &b);
-
+
void setChunkNumber(unsigned int chunknumber) { this->m_number = chunknumber; }
void setX(int x) { this->m_x = x; }
void setY(int y) { this->m_y = y; }
* @brief get the scene of the context
*/
const RenderData *getRenderData() const { return this->m_rd; }
-
+
void setScene(Scene *scene) { m_scene = scene; }
Scene *getScene() const { return m_scene; }
void setViewName(const char *viewName) { this->m_viewName = viewName; }
int getChunksize() const { return this->getbNodeTree()->chunksize; }
-
+
void setFastCalculation(bool fastCalculation) {this->m_fastCalculation = fastCalculation;}
bool isFastCalculation() const { return this->m_fastCalculation; }
bool isGroupnodeBufferEnabled() const { return (this->getbNodeTree()->flag & NTREE_COM_GROUPNODE_BUFFER) != 0; }
{
DataType fromDatatype = from->getDataType();
DataType toDatatype = to->getDataType();
-
+
if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) {
return new ConvertValueToColorOperation();
}
else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) {
return new ConvertVectorToColorOperation();
}
-
+
return NULL;
}
* @see Node
*/
static Node *convert(bNode *b_node);
-
+
/**
* @brief True if the node is considered 'fast'.
*
* Slow nodes will be skipped if fast execution is required.
*/
static bool is_fast_node(bNode *b_node);
-
+
/**
* @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.
*
* @see NodeLink - a link between two sockets
*/
static NodeOperation *convertDataType(NodeOperationOutput *from, NodeOperationInput *to);
-
+
/**
* @brief This method will add a resolution rule based on the settings of the NodeInput.
*
int DebugInfo::graphviz_operation(const ExecutionSystem *system, const NodeOperation *operation, const ExecutionGroup *group, char *str, int maxlen)
{
int len = 0;
-
+
std::string fillcolor = "gainsboro";
if (operation->isViewerOperation()) {
const ViewerOperation *viewer = (const ViewerOperation *)operation;
else if (operation->isWriteBufferOperation()) {
fillcolor = "darkorange";
}
-
+
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %p\r\n", operation);
if (group)
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p_%p\"", operation, group);
else
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p\"", operation);
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " [fillcolor=%s,style=filled,shape=record,label=\"{", fillcolor.c_str());
-
+
int totinputs = operation->getNumberOfInputSockets();
if (totinputs != 0) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
}
-
+
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "%s\\n(%s)", m_op_names[operation].c_str(), typeid(*operation).name());
-
+
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " (%u,%u)", operation->getWidth(), operation->getHeight());
-
+
int totoutputs = operation->getNumberOfOutputSockets();
if (totoutputs != 0) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
}
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\"]");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\r\n");
-
+
return len;
}
int DebugInfo::graphviz_legend(char *str, int maxlen)
{
int len = 0;
-
+
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "rank = sink;\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Legend [shape=none, margin=0, label=<\r\n");
{
char strbuf[64];
int len = 0;
-
+
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "digraph compositorexecution {\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "ranksep=1.5\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "rankdir=LR\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "splines=false\r\n");
-
+
#if 0
for (ExecutionSystem::Operations::const_iterator it = system->m_operations.begin();
it != system->m_operations.end(); ++it) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %s\r\n", node->getbNode()->typeinfo->ui_name);
}
#endif
-
+
int totops = system->m_operations.size();
int totgroups = system->m_groups.size();
std::map<NodeOperation *, std::vector<std::string> > op_groups;
for (int i = 0; i < totgroups; ++i) {
const ExecutionGroup *group = system->m_groups[i];
-
+
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// GROUP: %d\r\n", i);
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "subgraph cluster_%d{\r\n", i);
/* used as a check for executing group */
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=chartreuse4\r\n");
}
-
+
for (ExecutionGroup::Operations::const_iterator it = group->m_operations.begin(); it != group->m_operations.end(); ++it) {
NodeOperation *operation = *it;
-
+
sprintf(strbuf, "_%p", group);
op_groups[operation].push_back(std::string(strbuf));
-
+
len += graphviz_operation(system, operation, group, str + len, maxlen > len ? maxlen - len : 0);
}
-
+
// len += snprintf(str+len, maxlen>len ? maxlen-len : 0, "// OUTPUTOPERATION: %p\r\n", group->getOutputOperation());
// len += snprintf(str+len, maxlen>len ? maxlen-len : 0, " O_%p\r\n", group->getOutputOperation());
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
}
-
+
/* operations not included in any group */
for (int j = 0; j < totops; ++j) {
NodeOperation *operation = system->m_operations[j];
if (op_groups.find(operation) != op_groups.end())
continue;
-
+
op_groups[operation].push_back(std::string(""));
-
+
len += graphviz_operation(system, operation, 0, str + len, maxlen > len ? maxlen - len : 0);
}
-
+
for (int i = 0; i < totops; i++) {
NodeOperation *operation = system->m_operations[i];
-
+
if (operation->isReadBufferOperation()) {
ReadBufferOperation *read = (ReadBufferOperation *)operation;
WriteBufferOperation *write = read->getMemoryProxy()->getWriteBufferOperation();
std::vector<std::string> &read_groups = op_groups[read];
std::vector<std::string> &write_groups = op_groups[write];
-
+
for (int k = 0; k < write_groups.size(); ++k) {
for (int l = 0; l < read_groups.size(); ++l) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p%s\" -> \"O_%p%s\" [style=dotted]\r\n", write, write_groups[k].c_str(), read, read_groups[l].c_str());
}
}
}
-
+
for (int i = 0; i < totops; i++) {
NodeOperation *op = system->m_operations[i];
-
+
for (NodeOperation::Inputs::const_iterator it = op->m_inputs.begin(); it != op->m_inputs.end(); ++it) {
NodeOperationInput *to = *it;
NodeOperationOutput *from = to->getLink();
-
+
if (!from)
continue;
-
+
std::string color;
switch (from->getDataType()) {
case COM_DT_VALUE:
color = "orange";
break;
}
-
+
NodeOperation *to_op = &to->getOperation();
NodeOperation *from_op = &from->getOperation();
std::vector<std::string> &from_groups = op_groups[from_op];
std::vector<std::string> &to_groups = op_groups[to_op];
-
+
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// CONNECTION: %p.%p -> %p.%p\r\n",
from_op, from, to_op, to);
for (int k = 0; k < from_groups.size(); ++k) {
}
}
}
-
+
len += graphviz_legend(str + len, maxlen > len ? maxlen - len : 0);
-
+
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
-
+
return (len < maxlen);
}
if (graphviz_system(system, str, sizeof(str) - 1)) {
char basename[FILE_MAX];
char filename[FILE_MAX];
-
+
BLI_snprintf(basename, sizeof(basename), "compositor_%d.dot", m_file_index);
BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), basename);
++m_file_index;
-
+
FILE *fp = BLI_fopen(filename, "wb");
fputs(str, fp);
fclose(fp);
EG_RUNNING,
EG_FINISHED
} GroupState;
-
+
typedef std::map<const Node *, std::string> NodeNameMap;
typedef std::map<const NodeOperation *, std::string> OpNameMap;
typedef std::map<const ExecutionGroup *, GroupState> GroupStateMap;
-
+
static std::string node_name(const Node *node);
static std::string operation_name(const NodeOperation *op);
-
+
static void convert_started();
static void execute_started(const ExecutionSystem *system);
-
+
static void node_added(const Node *node);
static void node_to_operations(const Node *node);
static void operation_added(const NodeOperation *operation);
static void operation_read_write_buffer(const NodeOperation *operation);
-
+
static void execution_group_started(const ExecutionGroup *group);
static void execution_group_finished(const ExecutionGroup *group);
-
+
static void graphviz(const ExecutionSystem *system);
-
+
#ifdef COM_DEBUG
protected:
static int graphviz_operation(const ExecutionSystem *system, const NodeOperation *operation, const ExecutionGroup *group, char *str, int maxlen);
static int graphviz_legend_group(const char *name, const char *color, const char *style, char *str, int maxlen);
static int graphviz_legend(char *str, int maxlen);
static bool graphviz_system(const ExecutionSystem *system, char *str, int maxlen);
-
+
private:
static int m_file_index;
static NodeNameMap m_node_names; /**< map nodes to usable names for debug output */
public:
/**
- * @brief Declaration of the virtual destructor
+ * @brief Declaration of the virtual destructor
* @note resolve warning gcc 4.7
*/
virtual ~Device() {}
-
+
/**
* @brief initialize the device
*/
bool ExecutionGroup::canContainOperation(NodeOperation *operation)
{
if (!this->m_initialized) { return true; }
-
+
if (operation->isReadBufferOperation()) { return true; }
if (operation->isWriteBufferOperation()) { return false; }
if (operation->isSetOperation()) { return true; }
-
+
/* complex groups don't allow further ops (except read buffer and values, see above) */
if (m_complex) { return false; }
/* complex ops can't be added to other groups (except their own, which they initialize, see above) */
if (operation->isComplex()) { return false; }
-
+
return true;
}
{
if (!canContainOperation(operation))
return false;
-
+
if (!operation->isReadBufferOperation() && !operation->isWriteBufferOperation()) {
m_complex = operation->isComplex();
m_openCL = operation->isOpenCL();
m_singleThreaded = operation->isSingleThreaded();
m_initialized = true;
}
-
+
m_operations.push_back(operation);
-
+
return true;
}
{
if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED)
this->m_chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED;
-
+
atomic_add_and_fetch_u(&this->m_chunksFinished, 1);
if (memoryBuffers) {
for (unsigned int index = 0; index < this->m_cachedMaxReadBufferOffset; index++) {
class ExecutionGroup {
public:
typedef std::vector<NodeOperation*> Operations;
-
+
private:
// fields
-
+
/**
* @brief list of operations in this ExecutionGroup
*/
Operations m_operations;
-
+
/**
* @brief is this ExecutionGroup an input ExecutionGroup
* an input execution group is a group that is at the end of the calculation (the output is important for the user)
*/
int m_isOutput;
-
+
/**
* @brief Width of the output
*/
unsigned int m_width;
-
+
/**
* @brief Height of the output
*/
unsigned int m_height;
-
+
/**
* @brief size of a single chunk, being Width or of height
* a chunk is always a square, except at the edges of the MemoryBuffer
*/
unsigned int m_chunkSize;
-
+
/**
* @brief number of chunks in the x-axis
*/
unsigned int m_numberOfXChunks;
-
+
/**
* @brief number of chunks in the y-axis
*/
unsigned int m_numberOfYChunks;
-
+
/**
* @brief total number of chunks
*/
unsigned int m_numberOfChunks;
-
+
/**
* @brief contains this ExecutionGroup a complex NodeOperation.
*/
bool m_complex;
-
+
/**
* @brief can this ExecutionGroup be scheduled on an OpenCLDevice
*/
bool m_openCL;
-
+
/**
* @brief Is this Execution group SingleThreaded
*/
bool m_singleThreaded;
-
+
/**
* @brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup.
* @note this is used to construct the MemoryBuffers that will be passed during execution.
*/
unsigned int m_cachedMaxReadBufferOffset;
-
+
/**
* @brief a cached vector of all read operations in the execution group.
*/
Operations m_cachedReadOperations;
-
+
/**
* @brief reference to the original bNodeTree, this field is only set for the 'top' execution group.
* @note can only be used to call the callbacks for progress, status and break
*/
const bNodeTree *m_bTree;
-
+
/**
* @brief total number of chunks that have been calculated for this ExecutionGroup
*/
unsigned int m_chunksFinished;
-
+
/**
* @brief the chunkExecutionStates holds per chunk the execution state. this state can be
* - COM_ES_NOT_SCHEDULED: not scheduled
* - COM_ES_EXECUTED: executed
*/
ChunkExecutionState *m_chunkExecutionStates;
-
+
/**
* @brief indicator when this ExecutionGroup has valid Operations in its vector for Execution
* @note When building the ExecutionGroup Operations are added via recursion. First a WriteBufferOperations is added, then the
* @param operation the operation to be added
*/
bool canContainOperation(NodeOperation *operation);
-
+
/**
* @brief calculate the actual chunk size of this execution group.
* @note A chunk size is an unsigned int that is both the height and width of a chunk.
* @note by the calling method.
*/
unsigned int determineChunkSize();
-
-
+
+
/**
* @brief Determine the rect (minx, maxx, miny, maxy) of a chunk at a position.
* @note Only gives useful results ater the determination of the chunksize
* @see determineChunkSize()
*/
void determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const;
-
+
/**
* @brief determine the number of chunks, based on the chunkSize, width and height.
* @note The result are stored in the fields numberOfChunks, numberOfXChunks, numberOfYChunks
*/
void determineNumberOfChunks();
-
+
/**
* @brief try to schedule a specific chunk.
* @note scheduling succeeds when all input requirements are met and the chunks hasn't been scheduled yet.
* @param chunknumber
*/
bool scheduleChunk(unsigned int chunkNumber);
-
+
/**
* @brief determine the area of interest of a certain input area
* @note This method only evaluates a single ReadBufferOperation
public:
// constructors
ExecutionGroup();
-
+
// methods
/**
* @brief add an operation to this ExecutionGroup
* @return True if the operation was successfully added
*/
bool addOperation(NodeOperation *operation);
-
+
/**
* @brief is this ExecutionGroup an output ExecutionGroup
* @note An OutputExecution group are groups containing a
* @param resolution
*/
void determineResolution(unsigned int resolution[2]);
-
+
/**
* @brief set the resolution of this executiongroup
* @param resolution
*/
void setResolution(unsigned int resolution[2]) { this->m_width = resolution[0]; this->m_height = resolution[1]; }
-
+
/**
* @brief get the width of this execution group
*/
unsigned int getWidth() const { return m_width; }
-
+
/**
* @brief get the height of this execution group
*/
unsigned int getHeight() const { return m_height; }
-
+
/**
* @brief does this ExecutionGroup contains a complex NodeOperation
*/
bool isComplex() const { return m_complex; }
-
-
+
+
/**
* @brief get the output operation of this ExecutionGroup
* @return NodeOperation *output operation
*/
NodeOperation *getOutputOperation() const;
-
+
/**
* @brief compose multiple chunks into a single chunk
* @return Memorybuffer *consolidated chunk
*/
MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *output);
-
+
/**
* @brief initExecution is called just before the execution of the whole graph will be done.
* @note The implementation will calculate the chunkSize of this execution group.
*/
void initExecution();
-
+
/**
* @brief get all inputbuffers needed to calculate an chunk
* @note all inputbuffers must be executed
* @param memorybuffers
*/
void finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers);
-
+
/**
* @brief deinitExecution is called just after execution the whole graph.
* @note It will release all needed resources
*/
void deinitExecution();
-
-
+
+
/**
* @brief schedule an ExecutionGroup
* @note this method will return when all chunks have been calculated, or the execution has breaked (by user)
* @param system
*/
void execute(ExecutionSystem *system);
-
+
/**
* @brief this method determines the MemoryProxy's where this execution group depends on.
* @note After this method determineDependingAreaOfInterest can be called to determine
* @param memoryProxies result
*/
void determineDependingMemoryProxies(vector<MemoryProxy *> *memoryProxies);
-
+
/**
* @brief Determine the rect (minx, maxx, miny, maxy) of a chunk.
* @note Only gives useful results ater the determination of the chunksize
editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing | Initializing execution"));
DebugInfo::execute_started(this);
-
+
unsigned int order = 0;
for (vector<NodeOperation *>::iterator iter = this->m_operations.begin(); iter != this->m_operations.end(); ++iter) {
NodeOperation *operation = *iter;
public:
typedef std::vector<NodeOperation*> Operations;
typedef std::vector<ExecutionGroup*> Groups;
-
+
private:
/**
* @brief the context used during execution
* find all execution group with output nodes
*/
void findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const;
-
+
/**
* find all execution group with output nodes
*/
* @brief proxy of the memory (same for all chunks in the same buffer)
*/
MemoryProxy *m_memoryProxy;
-
+
/**
* @brief the type of buffer COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR
*/
DataType m_datatype;
-
-
+
+
/**
* @brief region of this buffer inside relative to the MemoryProxy
*/
rcti m_rect;
-
+
/**
* brief refers to the chunknumber within the executiongroup where related to the MemoryProxy
* @see memoryProxy
*/
unsigned int m_chunkNumber;
-
+
/**
* @brief state of the buffer
*/
MemoryBufferState m_state;
-
+
/**
* @brief the actual float buffer/data
*/
* @brief construct new MemoryBuffer for a chunk
*/
MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect);
-
+
/**
* @brief construct new temporarily MemoryBuffer for an area
*/
* @brief destructor
*/
~MemoryBuffer();
-
+
/**
* @brief read the ChunkNumber of this MemoryBuffer
*/
* @note buffer should already be available in memory
*/
float *getBuffer() { return this->m_buffer; }
-
+
/**
* @brief after execution the state will be set to available by calling this method
*/
{
this->m_state = COM_MB_AVAILABLE;
}
-
+
inline void wrap_pixel(int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
{
int w = this->m_width;
int h = this->m_height;
x = x - m_rect.xmin;
y = y - m_rect.ymin;
-
+
switch (extend_x) {
case COM_MB_CLIP:
break;
x = (x >= 0.0f ? (x % w) : (x % w) + w);
break;
}
-
+
switch (extend_y) {
case COM_MB_CLIP:
break;
break;
}
}
-
+
inline void wrap_pixel(float &x, float &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
{
float w = (float)this->m_width;
float *buffer = &this->m_buffer[offset];
memcpy(result, buffer, sizeof(float) * this->m_num_channels);
}
-
+
void writePixel(int x, int y, const float color[4]);
void addPixel(int x, int y, const float color[4]);
inline void readBilinear(float *result, float x, float y,
}
void readEWA(float *result, const float uv[2], const float derivatives[2][2]);
-
+
/**
* @brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk)
*/
inline const bool isTemporarily() const { return this->m_state == COM_MB_TEMPORARILY; }
-
+
/**
* @brief add the content from otherBuffer to this MemoryBuffer
* @param otherBuffer source buffer
* uninitialized values in areas where the buffers don't overlap.
*/
void copyContentFrom(MemoryBuffer *otherBuffer);
-
+
/**
* @brief get the rect of this MemoryBuffer
*/
rcti *getRect() { return &this->m_rect; }
-
+
/**
* @brief get the width of this MemoryBuffer
*/
int getWidth() const;
-
+
/**
* @brief get the height of this MemoryBuffer
*/
int getHeight() const;
-
+
/**
* @brief clear the buffer. Make all pixels black transparent.
*/
void clear();
-
+
MemoryBuffer *duplicate();
-
+
float getMaximumValue();
float getMaximumValue(rcti *rect);
private:
* @brief reference to the ouput operation of the executiongroup
*/
WriteBufferOperation *m_writeBufferOperation;
-
+
/**
* @brief reference to the executor. the Execution group that can fill a chunk
*/
ExecutionGroup *m_executor;
-
+
/**
* @brief datatype of this MemoryProxy
*/
/* DataType m_datatype; */ /* UNUSED */
-
+
/**
* @brief channel information of this buffer
*/
public:
MemoryProxy(DataType type);
-
+
/**
* @brief set the ExecutionGroup that can be scheduled to calculate a certain chunk.
* @param group the ExecutionGroup to set
DataType dt = COM_DT_VALUE;
if (input->type == SOCK_RGBA) dt = COM_DT_COLOR;
if (input->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
-
+
this->addInputSocket(dt, input);
input = input->next;
}
DataType dt = COM_DT_VALUE;
if (output->type == SOCK_RGBA) dt = COM_DT_COLOR;
if (output->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
-
+
this->addOutputSocket(dt, output);
output = output->next;
}
void Node::addOutputSocket(DataType datatype)
{
this->addOutputSocket(datatype, NULL);
-
+
}
void Node::addOutputSocket(DataType datatype, bNodeSocket *bSocket)
{
public:
typedef std::vector<NodeInput *> Inputs;
typedef std::vector<NodeOutput *> Outputs;
-
+
private:
/**
* @brief stores the reference to the SDNA bNode struct
*/
bNodeTree *m_editorNodeTree;
-
+
/**
* @brief stores the reference to the SDNA bNode struct
*/
* @brief get access to the vector of input sockets
*/
const Inputs &getInputSockets() const { return this->m_inputsockets; }
-
+
/**
* @brief get access to the vector of input sockets
*/
* @brief get the reference to the SDNA bNodeTree struct
*/
bNodeTree *getbNodeTree() const {return m_editorNodeTree;}
-
+
/**
* @brief set the reference to the bNode
* @note used in Node instances to receive the storage/settings and complex node for highlight during execution
* @param bNode
*/
void setbNode(bNode *node) {this->m_editorNode = node;}
-
+
/**
* @brief set the reference to the bNodeTree
* @param bNodeTree
* the index of the needed outputsocket
*/
NodeOutput *getOutputSocket(const unsigned int index) const;
-
+
/**
* get the reference to the first outputsocket
* @param index
* the index of the needed outputsocket
*/
inline NodeOutput *getOutputSocket() const { return getOutputSocket(0); }
-
+
/**
* get the reference to a certain inputsocket
* @param index
* the index of the needed inputsocket
*/
NodeInput *getInputSocket(const unsigned int index) const;
-
+
/** Check if this is an input node
* An input node is a node that only has output sockets and no input sockets
*/
bool isInputNode() const { return m_inputsockets.empty(); }
-
+
/**
* @brief Is this node in the active group (the group that is being edited)
* @param isInActiveGroup
*/
void setIsInActiveGroup(bool value) { this->m_inActiveGroup = value; }
-
+
/**
* @brief Is this node part of the active group
- * the active group is the group that is currently being edited. When no group is edited,
+ * the active group is the group that is currently being edited. When no group is edited,
* the active group will be the main tree (all nodes that are not part of a group will be active)
* @return bool [false:true]
*/
* @param context reference to the CompositorContext
*/
virtual void convertToOperations(NodeConverter &converter, const CompositorContext &context) const = 0;
-
+
/**
* Create dummy warning operation, use when we can't get the source data.
*/
* into valid outputs, without this the compositor system gets confused and crashes, see [#32490]
*/
void convertToOperations_invalid(NodeConverter *compiler) const;
-
+
void setInstanceKey(bNodeInstanceKey instance_key) { m_instanceKey = instance_key; }
bNodeInstanceKey getInstanceKey() const { return m_instanceKey; }
-
+
protected:
/**
* @brief add an NodeInput to the collection of inputsockets
*/
void addInputSocket(DataType datatype);
void addInputSocket(DataType datatype, bNodeSocket *socket);
-
+
/**
* @brief add an NodeOutput to the collection of outputsockets
* @note may only be called in an constructor
*/
void addOutputSocket(DataType datatype);
void addOutputSocket(DataType datatype, bNodeSocket *socket);
-
+
bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex);
bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex);
};
private:
Node *m_node;
bNodeSocket *m_editorSocket;
-
+
DataType m_datatype;
-
+
/**
* @brief link connected to this NodeInput.
* An input socket can only have a single link
*/
NodeOutput *m_link;
-
+
public:
NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype);
-
+
Node *getNode() const { return this->m_node; }
DataType getDataType() const { return m_datatype; }
bNodeSocket *getbNodeSocket() const { return this->m_editorSocket; }
-
+
void setLink(NodeOutput *link);
bool isLinked() const { return m_link; }
NodeOutput *getLink() { return m_link; }
-
+
float getEditorValueFloat();
void getEditorValueColor(float *value);
void getEditorValueVector(float *value);
private:
Node *m_node;
bNodeSocket *m_editorSocket;
-
+
DataType m_datatype;
-
+
public:
NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype);
-
+
Node *getNode() const { return this->m_node; }
DataType getDataType() const { return m_datatype; }
bNodeSocket *getbNodeSocket() const { return this->m_editorSocket; }
-
+
float getEditorValueFloat();
void getEditorValueColor(float *value);
void getEditorValueVector(float *value);
{
/* this is a really bad situation - bring on the pink! - so artists know this is bad */
const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
-
+
SetColorOperation *operation = new SetColorOperation();
operation->setChannels(warning_color);
-
+
m_builder->addOperation(operation);
m_builder->mapOutputSocket(output, operation->getOutputSocket());
-
+
return operation;
}
{
SocketProxyOperation *proxy = new SocketProxyOperation(input->getDataType(), use_conversion);
m_builder->addOperation(proxy);
-
+
m_builder->mapInputSocket(input, proxy->getInputSocket(0));
-
+
return proxy->getOutputSocket();
}
{
SocketProxyOperation *proxy = new SocketProxyOperation(output->getDataType(), use_conversion);
m_builder->addOperation(proxy);
-
+
m_builder->mapOutputSocket(output, proxy->getOutputSocket());
-
+
return proxy->getInputSocket(0);
}
{
SetValueOperation *operation = new SetValueOperation();
operation->setValue(value);
-
+
m_builder->addOperation(operation);
m_builder->addLink(operation->getOutputSocket(), input);
}
{
SetColorOperation *operation = new SetColorOperation();
operation->setChannels(value);
-
+
m_builder->addOperation(operation);
m_builder->addLink(operation->getOutputSocket(), input);
}
{
SetVectorOperation *operation = new SetVectorOperation();
operation->setVector(value);
-
+
m_builder->addOperation(operation);
m_builder->addLink(operation->getOutputSocket(), input);
}
{
SetValueOperation *operation = new SetValueOperation();
operation->setValue(value);
-
+
m_builder->addOperation(operation);
m_builder->mapOutputSocket(output, operation->getOutputSocket());
}
{
SetColorOperation *operation = new SetColorOperation();
operation->setChannels(value);
-
+
m_builder->addOperation(operation);
m_builder->mapOutputSocket(output, operation->getOutputSocket());
}
{
SetVectorOperation *operation = new SetVectorOperation();
operation->setVector(value);
-
+
m_builder->addOperation(operation);
m_builder->mapOutputSocket(output, operation->getOutputSocket());
}
class NodeConverter {
public:
NodeConverter(NodeOperationBuilder *builder);
-
+
/** Insert a new operation into the operations graph.
* The operation must be created by the node.
*/
void addOperation(NodeOperation *operation);
-
+
/** Map input socket of the node to an operation socket.
* Links between nodes will then generate equivalent links between
* the mapped operation sockets.
- *
+ *
* \note A \a Node input can be mapped to multiple \a NodeOperation inputs.
*/
void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket);
/** Map output socket of the node to an operation socket.
* Links between nodes will then generate equivalent links between
* the mapped operation sockets.
- *
+ *
* \note A \a Node output can only be mapped to one \a NodeOperation output.
* Any existing operation output mapping will be replaced.
*/
void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
-
+
/** Create a proxy operation for a node input.
* This operation will be removed later and replaced
* by direct links between the connected operations.
* by direct links between the connected operations.
*/
NodeOperationInput *addOutputProxy(NodeOutput *output, bool use_conversion);
-
+
/** Define a constant input value. */
void addInputValue(NodeOperationInput *input, float value);
/** Define a constant input color. */
void addInputColor(NodeOperationInput *input, const float value[4]);
/** Define a constant input vector. */
void addInputVector(NodeOperationInput *input, const float value[3]);
-
+
/** Define a constant output value. */
void addOutputValue(NodeOutput *output, float value);
/** Define a constant output color. */
void addOutputColor(NodeOutput *output, const float value[4]);
/** Define a constant output vector. */
void addOutputVector(NodeOutput *output, const float value[3]);
-
+
/** Add an explicit link between two operations. */
void addLink(NodeOperationOutput *from, NodeOperationInput *to);
-
+
/** Add a preview operation for a operation output. */
void addPreview(NodeOperationOutput *output);
/** Add a preview operation for a node input. */
void addNodeInputPreview(NodeInput *input);
-
+
/** When a node has no valid data
* @note missing image / group pointer, or missing renderlayer from EXR
*/
NodeOperation *setInvalidOutput(NodeOutput *output);
-
+
/** Define a viewer operation as the active output, if possible */
void registerViewer(ViewerOperation *viewer);
/** The currently active viewer output operation */
ViewerOperation *active_viewer() const;
-
+
private:
/** The internal builder for storing the results of the graph construction. */
NodeOperationBuilder *m_builder;
node->setbNodeTree(b_ntree);
node->setInstanceKey(key);
node->setIsInActiveGroup(is_active_group);
-
+
m_nodes.push_back(node);
-
+
DebugInfo::node_added(node);
}
void NodeGraph::add_link(NodeOutput *fromSocket, NodeInput *toSocket)
{
m_links.push_back(Link(fromSocket, toSocket));
-
+
/* register with the input */
toSocket->setLink(fromSocket);
}
void NodeGraph::add_bNodeTree(const CompositorContext &context, int nodes_start, bNodeTree *tree, bNodeInstanceKey parent_key)
{
const bNodeTree *basetree = context.getbNodeTree();
-
+
/* update viewers in the active edittree as well the base tree (for backdrop) */
bool is_active_group = (parent_key.value == basetree->active_viewer_key.value);
-
+
/* add all nodes of the tree to the node list */
for (bNode *node = (bNode *)tree->nodes.first; node; node = node->next) {
bNodeInstanceKey key = BKE_node_instance_key(parent_key, tree, node);
add_proxies_mute(b_ntree, b_node, key, is_active_group);
return;
}
-
+
/* replace slow nodes with proxies for fast execution */
if (context.isFastCalculation() && !Converter::is_fast_node(b_node)) {
add_proxies_skip(b_ntree, b_node, key, is_active_group);
return;
}
-
+
/* special node types */
if (b_node->type == NODE_GROUP) {
add_proxies_group(context, b_node, key);
return;
if ((b_nodelink->fromsock->flag & SOCK_UNAVAIL) || (b_nodelink->tosock->flag & SOCK_UNAVAIL))
return;
-
+
/* Note: a DNA input socket can have multiple NodeInput in the compositor tree! (proxies)
* The output then gets linked to each one of them.
*/
-
+
NodeOutput *output = find_output(node_range, b_nodelink->fromsock);
if (!output)
return;
-
+
NodeInputs inputs = find_inputs(node_range, b_nodelink->tosock);
for (NodeInputs::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
NodeInput *input = *it;
{
for (bNodeSocket *output = (bNodeSocket *)b_node->outputs.first; output; output = output->next) {
bNodeSocket *input;
-
+
/* look for first input with matching datatype for each output */
for (input = (bNodeSocket *)b_node->inputs.first; input; input = input->next) {
if (input->type == output->type)
break;
}
-
+
if (input) {
SocketProxyNode *proxy = new SocketProxyNode(b_node, input, output, true);
add_node(proxy, b_ntree, key, is_active_group);
{
bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
BLI_assert(b_group_tree); /* should have been checked in advance */
-
+
/* not important for proxies */
bNodeInstanceKey key = NODE_INSTANCE_KEY_BASE;
bool is_active_group = false;
-
+
for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->outputs.first; b_sock_io; b_sock_io = b_sock_io->next) {
bNodeSocket *b_sock_group = find_b_node_input(b_node, b_sock_io->identifier);
if (b_sock_group) {
{
bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
BLI_assert(b_group_tree); /* should have been checked in advance */
-
+
/* not important for proxies */
bNodeInstanceKey key = NODE_INSTANCE_KEY_BASE;
bool is_active_group = false;
-
+
for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->inputs.first; b_sock_io; b_sock_io = b_sock_io->next) {
bNodeSocket *b_sock_group = find_b_node_output(b_node, b_sock_io->identifier);
if (b_sock_group) {
for (bNode *b_node_io = (bNode *)b_group_tree->nodes.first; b_node_io; b_node_io = b_node_io->next) {
if (b_node_io->type == NODE_GROUP_INPUT)
add_proxies_group_inputs(b_node, b_node_io);
-
+
if (b_node_io->type == NODE_GROUP_OUTPUT && (b_node_io->flag & NODE_DO_OUTPUT))
add_proxies_group_outputs(b_node, b_node_io, context.isGroupnodeBufferEnabled());
}
-
+
add_bNodeTree(context, nodes_start, b_group_tree, key);
}
private:
NodeOutput *m_from;
NodeInput *m_to;
-
+
public:
Link(NodeOutput *from, NodeInput *to) :
m_from(from),
m_to(to)
{}
-
+
NodeOutput *getFromSocket() const { return m_from; }
NodeInput *getToSocket() const { return m_to; }
};
-
+
typedef std::vector<Node *> Nodes;
typedef Nodes::iterator NodeIterator;
typedef std::vector<Link> Links;
-
+
private:
Nodes m_nodes;
Links m_links;
-
+
public:
NodeGraph();
~NodeGraph();
-
+
const Nodes &nodes() const { return m_nodes; }
const Links &links() const { return m_links; }
-
+
void from_bNodeTree(const CompositorContext &context, bNodeTree *tree);
-
+
protected:
typedef std::pair<NodeIterator, NodeIterator> NodeRange;
typedef std::vector<NodeInput *> NodeInputs;
-
+
static bNodeSocket *find_b_node_input(bNode *b_node, const char *identifier);
static bNodeSocket *find_b_node_output(bNode *b_node, const char *identifier);
-
+
void add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group);
void add_link(NodeOutput *fromSocket, NodeInput *toSocket);
-
+
void add_bNodeTree(const CompositorContext &context, int nodes_start, bNodeTree *tree, bNodeInstanceKey parent_key);
-
+
void add_bNode(const CompositorContext &context, bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
-
+
NodeInputs find_inputs(const NodeRange &node_range, bNodeSocket *b_socket);
NodeOutput *find_output(const NodeRange &node_range, bNodeSocket *b_socket);
void add_bNodeLink(const NodeRange &node_range, bNodeLink *bNodeLink);
-
+
/* **** Special proxy node type conversions **** */
/* These nodes are not represented in the node graph themselves,
* but converted into a number of proxy links
*/
-
+
void add_proxies_mute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
void add_proxies_skip(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
-
+
void add_proxies_group_inputs(bNode *b_node, bNode *b_node_io);
void add_proxies_group_outputs(bNode *b_node, bNode *b_node_io, bool use_buffer);
void add_proxies_group(const CompositorContext &context, bNode *b_node, bNodeInstanceKey key);
void add_proxies_reroute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
-
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeGraph")
#endif
{
unsigned int temp[2];
unsigned int temp2[2];
-
+
for (unsigned int index = 0; index < m_inputs.size(); index++) {
NodeOperationInput *input = m_inputs[index];
if (input->isConnected()) {
public:
typedef std::vector<NodeOperationInput*> Inputs;
typedef std::vector<NodeOperationOutput*> Outputs;
-
+
private:
Inputs m_inputs;
Outputs m_outputs;
-
+
/**
* @brief the index of the input socket that will be used to determine the resolution
*/
* @see NodeOperation.getMutex retrieve a pointer to this mutex.
*/
ThreadMutex m_mutex;
-
+
/**
* @brief reference to the editing bNodeTree, used for break and update callback
*/
* @brief set to truth when resolution for this operation is set
*/
bool m_isResolutionSet;
-
+
public:
virtual ~NodeOperation();
-
+
unsigned int getNumberOfInputSockets() const { return m_inputs.size(); }
unsigned int getNumberOfOutputSockets() const { return m_outputs.size(); }
NodeOperationOutput *getOutputSocket(unsigned int index) const;
NodeOperationOutput *getOutputSocket() const { return getOutputSocket(0); }
NodeOperationInput *getInputSocket(unsigned int index) const;
-
+
/** Check if this is an input operation
* An input operation is an operation that only has output sockets and no input sockets
*/
bool isInputOperation() const { return m_inputs.empty(); }
-
+
/**
* @brief determine the resolution of this node
* @note this method will not set the resolution, this is the responsibility of the caller
void setbNodeTree(const bNodeTree *tree) { this->m_btree = tree; }
virtual void initExecution();
-
+
/**
* @brief when a chunk is executed by a CPUDevice, this method is called
* @ingroup execution
this->m_isResolutionSet = true;
}
}
-
+
void getConnectedInputSockets(Inputs *sockets);
* @see ExecutionGroup.addOperation
*/
bool isOpenCL() const { return this->m_openCL; }
-
+
virtual bool isViewerOperation() const { return false; }
virtual bool isPreviewOperation() const { return false; }
virtual bool isFileOutputOperation() const { return false; }
virtual bool isProxyOperation() const { return false; }
-
+
virtual bool useDatatypeConversion() const { return true; }
-
+
inline bool isBreaked() const {
return this->m_btree->test_break(this->m_btree->tbh);
}
void initMutex();
void lockMutex();
void unlockMutex();
-
+
/**
* @brief set whether this operation is complex
*
class NodeOperationInput {
private:
NodeOperation *m_operation;
-
+
/** Datatype of this socket. Is used for automatically data transformation.
* @section data-conversion
*/
DataType m_datatype;
-
+
/** Resize mode of this socket */
InputResizeMode m_resizeMode;
-
+
/** Connected output */
NodeOperationOutput *m_link;
-
+
public:
NodeOperationInput(NodeOperation *op, DataType datatype, InputResizeMode resizeMode = COM_SC_CENTER);
-
+
NodeOperation &getOperation() const { return *m_operation; }
DataType getDataType() const { return m_datatype; }
-
+
void setLink(NodeOperationOutput *link) { m_link = link; }
NodeOperationOutput *getLink() const { return m_link; }
bool isConnected() const { return m_link; }
-
+
void setResizeMode(InputResizeMode resizeMode) { this->m_resizeMode = resizeMode; }
InputResizeMode getResizeMode() const { return this->m_resizeMode; }
-
+
SocketReader *getReader();
-
+
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
#endif
class NodeOperationOutput {
private:
NodeOperation *m_operation;
-
+
/** Datatype of this socket. Is used for automatically data transformation.
* @section data-conversion
*/
DataType m_datatype;
-
+
public:
NodeOperationOutput(NodeOperation *op, DataType datatype);
-
+
NodeOperation &getOperation() const { return *m_operation; }
DataType getDataType() const { return m_datatype; }
-
+
/**
* @brief determine the resolution of this data going through this socket
* @param resolution the result of this operation
{
/* interface handle for nodes */
NodeConverter converter(this);
-
+
for (int index = 0; index < m_graph.nodes().size(); index++) {
Node *node = (Node *)m_graph.nodes()[index];
-
+
m_current_node = node;
-
+
DebugInfo::node_to_operations(node);
node->convertToOperations(converter, *m_context);
}
-
+
m_current_node = NULL;
-
+
/* The input map constructed by nodes maps operation inputs to node inputs.
* Inverting yields a map of node inputs to all connected operation inputs,
* so multiple operations can use the same node input.
OpInputInverseMap inverse_input_map;
for (InputSocketMap::const_iterator it = m_input_map.begin(); it != m_input_map.end(); ++it)
inverse_input_map[it->second].push_back(it->first);
-
+
for (NodeGraph::Links::const_iterator it = m_graph.links().begin(); it != m_graph.links().end(); ++it) {
const NodeGraph::Link &link = *it;
NodeOutput *from = link.getFromSocket();
NodeInput *to = link.getToSocket();
-
+
NodeOperationOutput *op_from = find_operation_output(m_output_map, from);
const OpInputs &op_to_list = find_operation_inputs(inverse_input_map, to);
if (!op_from || op_to_list.empty()) {
*/
continue;
}
-
+
for (OpInputs::const_iterator it = op_to_list.begin(); it != op_to_list.end(); ++it) {
NodeOperationInput *op_to = *it;
addLink(op_from, op_to);
}
}
-
+
add_operation_input_constants();
-
+
resolve_proxies();
-
+
add_datatype_conversions();
-
+
determineResolutions();
-
+
/* surround complex ops with read/write buffer */
add_complex_operation_buffers();
-
+
/* links not available from here on */
/* XXX make m_links a local variable to avoid confusion! */
m_links.clear();
-
+
prune_operations();
-
+
/* ensure topological (link-based) order of nodes */
/*sort_operations();*/ /* not needed yet */
-
+
/* create execution groups */
group_operations();
-
+
/* transfer resulting operations to the system */
system->set_operations(m_operations, m_groups);
}
{
BLI_assert(m_current_node);
BLI_assert(node_socket->getNode() == m_current_node);
-
+
/* note: this maps operation sockets to node sockets.
* for resolving links the map will be inverted first in convertToOperations,
* to get a list of links for each node input socket.
{
BLI_assert(m_current_node);
BLI_assert(node_socket->getNode() == m_current_node);
-
+
m_output_map[node_socket] = operation_socket;
}
{
if (to->isConnected())
return;
-
+
m_links.push_back(Link(from, to));
-
+
/* register with the input */
to->setLink(from);
}
if (link.to() == to) {
/* unregister with the input */
to->setLink(NULL);
-
+
m_links.erase(it);
return;
}
PreviewOperation *NodeOperationBuilder::make_preview_operation() const
{
BLI_assert(m_current_node);
-
+
if (!(m_current_node->getbNode()->flag & NODE_PREVIEW))
return NULL;
/* previews only in the active group */
/* do not calculate previews of hidden nodes */
if (m_current_node->getbNode()->flag & NODE_HIDDEN)
return NULL;
-
+
bNodeInstanceHash *previews = m_context->getPreviewHash();
if (previews) {
PreviewOperation *operation = new PreviewOperation(m_context->getViewSettings(), m_context->getDisplaySettings());
operation->verifyPreview(previews, m_current_node->getInstanceKey());
return operation;
}
-
+
return NULL;
}
PreviewOperation *operation = make_preview_operation();
if (operation) {
addOperation(operation);
-
+
addLink(output, operation->getInputSocket(0));
}
}
PreviewOperation *operation = make_preview_operation();
if (operation) {
addOperation(operation);
-
+
mapInputSocket(input, operation->getInputSocket(0));
}
}
if (m_current_node->isInActiveGroup()) {
/* deactivate previous viewer */
m_active_viewer->setActive(false);
-
+
m_active_viewer = viewer;
viewer->setActive(true);
}
Links convert_links;
for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
const Link &link = *it;
-
+
/* proxy operations can skip data type conversion */
NodeOperation *from_op = &link.from()->getOperation();
NodeOperation *to_op = &link.to()->getOperation();
if (!(from_op->useDatatypeConversion() || to_op->useDatatypeConversion()))
continue;
-
+
if (link.from()->getDataType() != link.to()->getDataType())
convert_links.push_back(link);
}
NodeOperation *converter = Converter::convertDataType(link.from(), link.to());
if (converter) {
addOperation(converter);
-
+
removeInputLink(link.to());
addLink(link.from(), converter->getInputSocket(0));
addLink(converter->getOutputSocket(0), link.to());
value = node_input->getEditorValueFloat();
else
value = 0.0f;
-
+
SetValueOperation *op = new SetValueOperation();
op->setValue(value);
addOperation(op);
node_input->getEditorValueColor(value);
else
zero_v4(value);
-
+
SetColorOperation *op = new SetColorOperation();
op->setChannels(value);
addOperation(op);
node_input->getEditorValueVector(value);
else
zero_v3(value);
-
+
SetVectorOperation *op = new SetVectorOperation();
op->setVector(value);
addOperation(op);
proxy_links.push_back(link);
}
}
-
+
for (Links::const_iterator it = proxy_links.begin(); it != proxy_links.end(); ++it) {
const Link &link = *it;
-
+
NodeOperationInput *to = link.to();
NodeOperationOutput *from = link.from();
do {
/* walk upstream bypassing the proxy operation */
from = from->getOperation().getInputSocket(0)->getLink();
} while (from && from->getOperation().isProxyOperation());
-
+
removeInputLink(to);
/* we may not have a final proxy input link,
* in that case it just gets dropped
/* determine all resolutions of the operations (Width/Height) */
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
NodeOperation *op = *it;
-
+
if (op->isOutputOperation(m_context->isRendering()) && !op->isPreviewOperation()) {
unsigned int resolution[2] = {0, 0};
unsigned int preferredResolution[2] = {0, 0};
op->setResolution(resolution);
}
}
-
+
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
NodeOperation *op = *it;
-
+
if (op->isOutputOperation(m_context->isRendering()) && op->isPreviewOperation()) {
unsigned int resolution[2] = {0, 0};
unsigned int preferredResolution[2] = {0, 0};
op->setResolution(resolution);
}
}
-
+
/* add convert resolution operations when needed */
{
Links convert_links;
for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
const Link &link = *it;
-
+
if (link.to()->getResizeMode() != COM_SC_NO_RESIZE) {
NodeOperation &from_op = link.from()->getOperation();
NodeOperation &to_op = link.to()->getOperation();
{
if (!input->isConnected())
return;
-
+
NodeOperationOutput *output = input->getLink();
if (output->getOperation().isReadBufferOperation()) {
/* input is already buffered, no need to add another */
return;
}
-
+
/* this link will be replaced below */
removeInputLink(input);
-
+
/* check of other end already has write operation, otherwise add a new one */
WriteBufferOperation *writeoperation = find_attached_write_buffer_operation(output);
if (!writeoperation) {
writeoperation = new WriteBufferOperation(output->getDataType());
writeoperation->setbNodeTree(m_context->getbNodeTree());
addOperation(writeoperation);
-
+
addLink(output, writeoperation->getInputSocket(0));
-
+
writeoperation->readResolutionFromInputSocket();
}
-
+
/* add readbuffer op for the input */
ReadBufferOperation *readoperation = new ReadBufferOperation(output->getDataType());
readoperation->setMemoryProxy(writeoperation->getMemoryProxy());
this->addOperation(readoperation);
-
+
addLink(readoperation->getOutputSocket(), input);
-
+
readoperation->readResolutionFromWriteBuffer();
}
OpInputs targets = cache_output_links(output);
if (targets.empty())
return;
-
+
WriteBufferOperation *writeOperation = NULL;
for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
NodeOperationInput *target = *it;
-
+
/* try to find existing write buffer operation */
if (target->getOperation().isWriteBufferOperation()) {
BLI_assert(writeOperation == NULL); /* there should only be one write op connected */
removeInputLink(target);
}
}
-
+
/* if no write buffer operation exists yet, create a new one */
if (!writeOperation) {
writeOperation = new WriteBufferOperation(operation->getOutputSocket()->getDataType());
writeOperation->setbNodeTree(m_context->getbNodeTree());
addOperation(writeOperation);
-
+
addLink(output, writeOperation->getInputSocket(0));
}
-
+
writeOperation->readResolutionFromInputSocket();
-
+
/* add readbuffer op for every former connected input */
for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
NodeOperationInput *target = *it;
if (&target->getOperation() == writeOperation)
continue; /* skip existing write op links */
-
+
ReadBufferOperation *readoperation = new ReadBufferOperation(operation->getOutputSocket()->getDataType());
readoperation->setMemoryProxy(writeOperation->getMemoryProxy());
addOperation(readoperation);
-
+
addLink(readoperation->getOutputSocket(), target);
-
+
readoperation->readResolutionFromWriteBuffer();
}
}
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
if ((*it)->isComplex())
complex_ops.push_back(*it);
-
+
for (Operations::const_iterator it = complex_ops.begin(); it != complex_ops.end(); ++it) {
NodeOperation *op = *it;
-
+
DebugInfo::operation_read_write_buffer(op);
-
+
for (int index = 0; index < op->getNumberOfInputSockets(); index++)
add_input_buffers(op, op->getInputSocket(index));
-
+
for (int index = 0; index < op->getNumberOfOutputSockets(); index++)
add_output_buffers(op, op->getOutputSocket(index));
}
if (reachable.find(op) != reachable.end())
return;
reachable.insert(op);
-
+
for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
NodeOperationInput *input = op->getInputSocket(i);
if (input->isConnected())
find_reachable_operations_recursive(reachable, &input->getLink()->getOperation());
}
-
+
/* associated write-buffer operations are executed as well */
if (op->isReadBufferOperation()) {
ReadBufferOperation *read_op = (ReadBufferOperation *)op;
Tags reachable;
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
NodeOperation *op = *it;
-
+
/* output operations are primary executed operations */
if (op->isOutputOperation(m_context->isRendering()))
find_reachable_operations_recursive(reachable, op);
}
-
+
/* delete unreachable operations */
Operations reachable_ops;
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
NodeOperation *op = *it;
-
+
if (reachable.find(op) != reachable.end())
reachable_ops.push_back(op);
else
if (visited.find(op) != visited.end())
return;
visited.insert(op);
-
+
for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
NodeOperationInput *input = op->getInputSocket(i);
if (input->isConnected())
sort_operations_recursive(sorted, visited, &input->getLink()->getOperation());
}
-
+
sorted.push_back(op);
}
Operations sorted;
sorted.reserve(m_operations.size());
Tags visited;
-
+
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
sort_operations_recursive(sorted, visited, *it);
-
+
m_operations = sorted;
}
if (visited.find(op) != visited.end())
return;
visited.insert(op);
-
+
if (!group->addOperation(op))
return;
-
+
/* add all eligible input ops to the group */
for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
NodeOperationInput *input = op->getInputSocket(i);
{
ExecutionGroup *group = new ExecutionGroup();
m_groups.push_back(group);
-
+
Tags visited;
add_group_operations_recursive(visited, op, group);
-
+
return group;
}
{
for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
NodeOperation *op = *it;
-
+
if (op->isOutputOperation(m_context->isRendering())) {
ExecutionGroup *group = make_group(op);
group->setOutputExecutionGroup(true);
}
-
+
/* add new groups for associated memory proxies where needed */
if (op->isReadBufferOperation()) {
ReadBufferOperation *read_op = (ReadBufferOperation *)op;
MemoryProxy *memproxy = read_op->getMemoryProxy();
-
+
if (memproxy->getExecutor() == NULL) {
ExecutionGroup *group = make_group(memproxy->getWriteBufferOperation());
memproxy->setExecutor(group);
private:
NodeOperationOutput *m_from;
NodeOperationInput *m_to;
-
+
public:
Link(NodeOperationOutput *from, NodeOperationInput *to) :
m_from(from),
m_to(to)
{}
-
+
NodeOperationOutput *from() const { return m_from; }
NodeOperationInput *to() const { return m_to; }
};
-
+
typedef std::vector<NodeOperation *> Operations;
typedef std::vector<Link> Links;
typedef std::vector<ExecutionGroup *> Groups;
-
+
typedef std::map<NodeOperationInput *, NodeInput *> InputSocketMap;
typedef std::map<NodeOutput *, NodeOperationOutput *> OutputSocketMap;
-
+
typedef std::vector<NodeOperationInput *> OpInputs;
typedef std::map<NodeInput *, OpInputs> OpInputInverseMap;
-
+
private:
const CompositorContext *m_context;
NodeGraph m_graph;
-
+
Operations m_operations;
Links m_links;
Groups m_groups;
-
+
/** Maps operation inputs to node inputs */
InputSocketMap m_input_map;
/** Maps node outputs to operation outputs */
OutputSocketMap m_output_map;
-
+
Node *m_current_node;
-
+
/** Operation that will be writing to the viewer image
* Only one operation can occupy this place at a time,
* to avoid race conditions
*/
ViewerOperation *m_active_viewer;
-
+
public:
NodeOperationBuilder(const CompositorContext *context, bNodeTree *b_nodetree);
~NodeOperationBuilder();
void convertToOperations(ExecutionSystem *system);
void addOperation(NodeOperation *operation);
-
+
/** Map input socket of the current node to an operation socket */
void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket);
/** Map output socket of the current node to an operation socket */
void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
-
+
void addLink(NodeOperationOutput *from, NodeOperationInput *to);
void removeInputLink(NodeOperationInput *to);
-
+
/** Add a preview operation for a operation output */
void addPreview(NodeOperationOutput *output);
/** Add a preview operation for a node input */
void addNodeInputPreview(NodeInput *input);
-
+
/** Define a viewer operation as the active output, if possible */
void registerViewer(ViewerOperation *viewer);
/** The currently active viewer output operation */
ViewerOperation *active_viewer() const { return m_active_viewer; }
-
+
protected:
static NodeInput *find_node_input(const InputSocketMap &map, NodeOperationInput *op_input);
static const OpInputs &find_operation_inputs(const OpInputInverseMap &map, NodeInput *node_input);
static NodeOperationOutput *find_operation_output(const OutputSocketMap &map, NodeOutput *node_output);
-
+
/** Add datatype conversion where needed */
void add_datatype_conversions();
-
+
/** Construct a constant value operation for every unconnected input */
void add_operation_input_constants();
void add_input_constant_value(NodeOperationInput *input, NodeInput *node_input);
-
+
/** Replace proxy operations with direct links */
void resolve_proxies();
-
+
/** Calculate resolution for each operation */
void determineResolutions();
-
+
/** Helper function to store connected inputs for replacement */
OpInputs cache_output_links(NodeOperationOutput *output) const;
/** Find a connected write buffer operation to an OpOutput */
void add_complex_operation_buffers();
void add_input_buffers(NodeOperation *operation, NodeOperationInput *input);
void add_output_buffers(NodeOperation *operation, NodeOperationOutput *output);
-
+
/** Remove unreachable operations */
void prune_operations();
-
+
/** Sort operations by link dependencies */
void sort_operations();
-
+
/** Create execution groups */
void group_operations();
ExecutionGroup *make_group(NodeOperation *op);
-
+
private:
PreviewOperation *make_preview_operation() const;
chunkNumber, inputBuffers, outputBuffer);
delete outputBuffer;
-
+
executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers);
}
cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex,
ReadBufferOperation *reader)
{
cl_int error;
-
+
MemoryBuffer *result = reader->getInputMemoryBuffer(inputMemoryBuffers);
const cl_image_format *imageFormat = determineImageFormat(result);
* @brief opencl context
*/
cl_context m_context;
-
+
/**
* @brief opencl device
*/
cl_device_id m_device;
-
+
/**
* @brief opencl program
*/
cl_program m_program;
-
+
/**
* @brief opencl command queue
*/
* @param vendorID
*/
OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId);
-
-
+
+
/**
* @brief initialize the device
* During initialization the OpenCL cl_command_queue is created
* @see queue
*/
bool initialize();
-
+
/**
* @brief deinitialize the device
* During deintiialization the command queue is cleared
*/
void deinitialize();
-
+
/**
* @brief execute a WorkPackage
* @param work the WorkPackage to execute
void *SingleThreadedOperation::initializeTileData(rcti *rect)
{
if (this->m_cachedInstance) return this->m_cachedInstance;
-
+
lockMutex();
if (this->m_cachedInstance == NULL) {
//
class SingleThreadedOperation : public NodeOperation {
private:
MemoryBuffer *m_cachedInstance;
-
+
protected:
inline bool isCached() {
return this->m_cachedInstance != NULL;
public:
SingleThreadedOperation();
-
+
/**
* the inner loop of this program
*/
void executePixel(float output[4], int x, int y, void *data);
-
+
/**
* Initialize the execution
*/
void initExecution();
-
+
/**
* Deinitialize the execution
*/
void *initializeTileData(rcti *rect);
virtual MemoryBuffer *createMemoryBuffer(rcti *rect) = 0;
-
+
int isSingleThreaded() { return true; }
};
#endif
device->execute(work);
delete work;
}
-
+
return NULL;
}
{
Device *device = (Device *)data;
WorkPackage *work;
-
+
while ((work = (WorkPackage *)BLI_thread_queue_pop(g_gpuqueue))) {
device->execute(work);
delete work;
}
-
+
return NULL;
}
#endif
* inside this loop new work is queried and being executed
*/
static void *thread_execute_gpu(void *data);
-#endif
+#endif
public:
/**
* @brief schedule a chunk of a group to be calculated.
ExecutionSystem *system = new ExecutionSystem(rd, scene, editingtree, rendering, twopass, viewSettings, displaySettings, viewName);
system->execute();
delete system;
-
+
if (editingtree->test_break(editingtree->tbh)) {
// during editing multiple calls to this method can be triggered.
// make sure one the last one will be doing the work.
NodeInput *color1Socket = this->getInputSocket(1);
NodeInput *color2Socket = this->getInputSocket(2);
bNode *editorNode = this->getbNode();
-
+
MixBaseOperation *convertProg;
NodeTwoFloats *ntf = (NodeTwoFloats *)editorNode->storage;
if (ntf->x != 0.0f) {
AlphaOverMixedOperation *mixOperation = new AlphaOverMixedOperation();
mixOperation->setX(ntf->x);
convertProg = mixOperation;
-
+
}
else if (editorNode->custom1) {
convertProg = new AlphaOverKeyOperation();
else {
convertProg = new AlphaOverPremultiplyOperation();
}
-
+
convertProg->setUseValueAlphaMultiply(false);
if (color1Socket->isLinked()) {
convertProg->setResolutionInputSocketIndex(1);
else {
convertProg->setResolutionInputSocketIndex(0);
}
-
+
converter.addOperation(convertProg);
converter.mapInputSocket(getInputSocket(0), convertProg->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), convertProg->getInputSocket(1));
BilateralBlurOperation *operation = new BilateralBlurOperation();
operation->setQuality(context.getQuality());
operation->setData(data);
-
+
converter.addOperation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
operationfgb->setData(data);
operationfgb->setExtendBounds(extend_bounds);
converter.addOperation(operationfgb);
-
+
converter.mapInputSocket(getInputSocket(1), operationfgb->getInputSocket(1));
-
+
input_operation = operationfgb;
output_operation = operationfgb;
}
SetValueOperation *zero = new SetValueOperation();
zero->setValue(0.0f);
clamp->setUseClamp(true);
-
+
converter.addOperation(clamp);
converter.addOperation(zero);
converter.mapInputSocket(getInputSocket(1), clamp->getInputSocket(0));
converter.addLink(zero->getOutputSocket(), clamp->getInputSocket(1));
-
+
GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
operationx->setData(data);
operationx->setQuality(quality);
operationx->setFalloff(PROP_SMOOTH);
operationx->setSubtract(false);
operationx->setExtendBounds(extend_bounds);
-
+
converter.addOperation(operationx);
converter.addLink(clamp->getOutputSocket(), operationx->getInputSocket(0));
-
+
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
operationy->setData(data);
operationy->setQuality(quality);
converter.addOperation(operationy);
converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
-
+
GaussianBlurReferenceOperation *operation = new GaussianBlurReferenceOperation();
operation->setData(data);
operation->setQuality(quality);
converter.addOperation(operation);
converter.addLink(operationy->getOutputSocket(), operation->getInputSocket(1));
-
+
output_operation = operation;
input_operation = operation;
}
converter.addOperation(operationx);
converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1));
-
+
GaussianYBlurOperation *operationy = new GaussianYBlurOperation();
operationy->setData(data);
operationy->setQuality(quality);
GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
converter.addOperation(correct);
converter.addOperation(inverse);
-
+
converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0));
converter.addLink(correct->getOutputSocket(), input_operation->getInputSocket(0));
converter.addLink(output_operation->getOutputSocket(), inverse->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(), inverse->getOutputSocket());
-
+
converter.addPreview(inverse->getOutputSocket());
}
else {
converter.mapInputSocket(getInputSocket(0), input_operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(), output_operation->getOutputSocket());
-
+
converter.addPreview(output_operation->getOutputSocket());
}
}
operation->setThreshold(0.0f);
operation->setMaxBlur(b_node->custom4);
operation->setDoScaleSize(true);
-
+
converter.addOperation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
BokehBlurOperation *operation = new BokehBlurOperation();
operation->setQuality(context.getQuality());
operation->setExtendBounds(extend_bounds);
-
+
converter.addOperation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
{
BokehImageOperation *operation = new BokehImageOperation();
operation->setData((NodeBokehImage *)this->getbNode()->storage);
-
+
converter.addOperation(operation);
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
-
+
converter.addPreview(operation->getOutputSocket(0));
}
{
NodeInput *inputSocket = this->getInputSocket(0);
NodeOutput *outputSocket = this->getOutputSocket(0);
-
+
BoxMaskOperation *operation;
operation = new BoxMaskOperation();
operation->setData((NodeBoxMask *)this->getbNode()->storage);
operation->setMaskType(this->getbNode()->custom1);
converter.addOperation(operation);
-
+
if (inputSocket->isLinked()) {
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
BrightnessOperation *operation = new BrightnessOperation();
operation->setUsePremultiply((bnode->custom1 & 1) != 0);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
void ChromaMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
bNode *editorsnode = getbNode();
-
+
NodeInput *inputSocketImage = this->getInputSocket(0);
NodeInput *inputSocketKey = this->getInputSocket(1);
NodeOutput *outputSocketImage = this->getOutputSocket(0);
NodeOutput *outputSocketMatte = this->getOutputSocket(1);
-
+
ConvertRGBToYCCOperation *operationRGBToYCC_Image = new ConvertRGBToYCCOperation();
ConvertRGBToYCCOperation *operationRGBToYCC_Key = new ConvertRGBToYCCOperation();
operationRGBToYCC_Image->setMode(BLI_YCC_ITU_BT709);
operationRGBToYCC_Key->setMode(BLI_YCC_ITU_BT709);
converter.addOperation(operationRGBToYCC_Image);
converter.addOperation(operationRGBToYCC_Key);
-
+
ChromaMatteOperation *operation = new ChromaMatteOperation();
operation->setSettings((NodeChroma *)editorsnode->storage);
converter.addOperation(operation);
-
+
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
converter.addOperation(operationAlpha);
-
+
converter.mapInputSocket(inputSocketImage, operationRGBToYCC_Image->getInputSocket(0));
converter.mapInputSocket(inputSocketKey, operationRGBToYCC_Key->getInputSocket(0));
converter.addLink(operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0));
converter.addLink(operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1));
converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket());
-
+
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
-
+
converter.addPreview(operationAlpha->getOutputSocket());
}
{
bNode *node = this->getbNode();
NodeColorBalance *n = (NodeColorBalance *)node->storage;
-
+
NodeInput *inputSocket = this->getInputSocket(0);
NodeInput *inputImageSocket = this->getInputSocket(1);
NodeOutput *outputSocket = this->getOutputSocket(0);
-
+
NodeOperation *operation;
if (node->custom1 == 0) {
ColorBalanceLGGOperation *operationLGG = new ColorBalanceLGGOperation();
operation = operationCDL;
}
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapInputSocket(inputImageSocket, operation->getInputSocket(1));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
void ColorCorrectionNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
bNode *editorNode = getbNode();
-
+
ColorCorrectionOperation *operation = new ColorCorrectionOperation();
operation->setData((NodeColorCorrection *)editorNode->storage);
operation->setRedChannelEnabled((editorNode->custom1 & 1) > 0);
operation->setGreenChannelEnabled((editorNode->custom1 & 2) > 0);
operation->setBlueChannelEnabled((editorNode->custom1 & 4) > 0);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
ColorCurveOperation *operation = new ColorCurveOperation();
operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3));
-
+
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
else {
operation->setWhiteLevel(col);
operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
void ColorMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
bNode *editorsnode = getbNode();
-
+
NodeInput *inputSocketImage = this->getInputSocket(0);
NodeInput *inputSocketKey = this->getInputSocket(1);
NodeOutput *outputSocketImage = this->getOutputSocket(0);
NodeOutput *outputSocketMatte = this->getOutputSocket(1);
-
+
ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation();
ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation();
converter.addOperation(operationRGBToHSV_Image);
converter.addOperation(operationRGBToHSV_Key);
-
+
ColorMatteOperation *operation = new ColorMatteOperation();
operation->setSettings((NodeChroma *)editorsnode->storage);
converter.addOperation(operation);
-
+
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
converter.addOperation(operationAlpha);
-
+
converter.mapInputSocket(inputSocketImage, operationRGBToHSV_Image->getInputSocket(0));
converter.mapInputSocket(inputSocketKey, operationRGBToHSV_Key->getInputSocket(0));
converter.addLink(operationRGBToHSV_Image->getOutputSocket(), operation->getInputSocket(0));
converter.addLink(operationRGBToHSV_Key->getOutputSocket(), operation->getInputSocket(1));
converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));
-
+
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
-
+
converter.addPreview(operationAlpha->getOutputSocket());
}
output->getEditorValueColor(col);
operation->setChannels(col);
converter.addOperation(operation);
-
+
converter.mapOutputSocket(output, operation->getOutputSocket());
}
ColorRampOperation *operation = new ColorRampOperation();
operation->setColorBand((ColorBand *)editorNode->storage);
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
-
+
SeparateChannelOperation *operation2 = new SeparateChannelOperation();
operation2->setChannel(3);
converter.addOperation(operation2);
-
+
converter.addLink(operation->getOutputSocket(), operation2->getInputSocket(0));
converter.mapOutputSocket(outputSocketAlpha, operation2->getOutputSocket());
}
void ColorSpillNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
bNode *editorsnode = getbNode();
-
+
NodeInput *inputSocketImage = this->getInputSocket(0);
NodeInput *inputSocketFac = this->getInputSocket(1);
NodeOutput *outputSocketImage = this->getOutputSocket(0);
-
+
ColorSpillOperation *operation;
operation = new ColorSpillOperation();
operation->setSettings((NodeColorspill *)editorsnode->storage);
operation->setSpillChannel(editorsnode->custom1 - 1); // Channel for spilling
operation->setSpillMethod(editorsnode->custom2); // Channel method
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0));
converter.mapInputSocket(inputSocketFac, operation->getInputSocket(1));
converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
{
NodeInput *colorSocket = this->getInputSocket(0);
NodeOutput *valueSocket = this->getOutputSocket(0);
-
+
ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation();
converter.addOperation(convertProg);
-
+
converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0));
converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0));
}
NodeInput *inputBSocket = this->getInputSocket(2);
NodeInput *inputASocket = this->getInputSocket(3);
NodeOutput *outputSocket = this->getOutputSocket(0);
-
+
CombineChannelsOperation *operation = new CombineChannelsOperation();
if (inputRSocket->isLinked()) {
operation->setResolutionInputSocketIndex(0);
operation->setResolutionInputSocketIndex(3);
}
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputRSocket, operation->getInputSocket(0));
converter.mapInputSocket(inputGSocket, operation->getInputSocket(1));
converter.mapInputSocket(inputBSocket, operation->getInputSocket(2));
converter.mapInputSocket(inputASocket, operation->getInputSocket(3));
-
+
NodeOperation *color_conv = getColorConverter(context);
if (color_conv) {
converter.addOperation(color_conv);
-
+
converter.addLink(operation->getOutputSocket(), color_conv->getInputSocket(0));
converter.mapOutputSocket(outputSocket, color_conv->getOutputSocket());
}
public:
CombineColorNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
-
+
protected:
virtual NodeOperation *getColorConverter(const CompositorContext &context) const = 0;
};
CombineRGBANode(bNode *editorNode) :
CombineColorNode(editorNode)
{}
-
+
NodeOperation *getColorConverter(const CompositorContext &context) const;
};
CombineHSVANode(bNode *editorNode) :
CombineColorNode(editorNode)
{}
-
+
NodeOperation *getColorConverter(const CompositorContext &context) const;
};
CombineYCCANode(bNode *editorNode) :
CombineColorNode(editorNode)
{}
-
+
NodeOperation *getColorConverter(const CompositorContext &context) const;
};
CombineYUVANode(bNode *editorNode) :
CombineColorNode(editorNode)
{}
-
+
NodeOperation *getColorConverter(const CompositorContext &context) const;
};
/* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
compositorOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked());
compositorOperation->setActive(is_active);
-
+
converter.addOperation(compositorOperation);
converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0));
/* only use alpha link if "use alpha" is enabled */
else
converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1));
converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2));
-
+
converter.addNodeInputPreview(imageSocket);
}
else {
operation = new ConvertStraightToPremulOperation();
}
-
+
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
converter.addOperation(warp_image_operation);
PlaneCornerPinMaskOperation *plane_mask_operation = new PlaneCornerPinMaskOperation();
converter.addOperation(plane_mask_operation);
-
+
converter.mapInputSocket(input_image, warp_image_operation->getInputSocket(0));
for (int i = 0; i < 4; ++i) {
NodeInput *corner_input = getInputSocket(node_corner_index[i]);
operation->setCropSettings(cropSettings);
operation->setRelative(relative);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket());
}
SetValueOperation *maxRadius = new SetValueOperation();
maxRadius->setValue(data->maxblur);
MathMinimumOperation *minimize = new MathMinimumOperation();
-
+
converter.addOperation(multiply);
converter.addOperation(multiplier);
converter.addOperation(maxRadius);
converter.addOperation(minimize);
-
+
converter.mapInputSocket(getInputSocket(1), multiply->getInputSocket(0));
converter.addLink(multiplier->getOutputSocket(), multiply->getInputSocket(1));
converter.addLink(multiply->getOutputSocket(), minimize->getInputSocket(0));
converter.addLink(maxRadius->getOutputSocket(), minimize->getInputSocket(1));
-
+
radiusOperation = minimize;
}
else {
radius_op->setfStop(data->fstop);
radius_op->setMaxRadius(data->maxblur);
converter.addOperation(radius_op);
-
+
converter.mapInputSocket(getInputSocket(1), radius_op->getInputSocket(0));
-
+
FastGaussianBlurValueOperation *blur = new FastGaussianBlurValueOperation();
/* maintain close pixels so far Z values don't bleed into the foreground */
blur->setOverlay(FAST_GAUSS_OVERLAY_MIN);
converter.addOperation(blur);
-
+
converter.addLink(radius_op->getOutputSocket(0), blur->getInputSocket(0));
radius_op->setPostBlur(blur);
-
+
radiusOperation = blur;
}
-
+
NodeBokehImage *bokehdata = new NodeBokehImage();
bokehdata->angle = data->rotation;
bokehdata->rounding = 0.0f;
}
bokehdata->catadioptric = 0.0f;
bokehdata->lensshift = 0.0f;
-
+
BokehImageOperation *bokeh = new BokehImageOperation();
bokeh->setData(bokehdata);
bokeh->deleteDataOnFinish();
converter.addOperation(bokeh);
-
+
#ifdef COM_DEFOCUS_SEARCH
InverseSearchRadiusOperation *search = new InverseSearchRadiusOperation();
search->setMaxBlur(data->maxblur);
converter.addOperation(search);
-
+
converter.addLink(radiusOperation->getOutputSocket(0), search->getInputSocket(0));
#endif
-
+
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
if (data->preview)
operation->setQuality(COM_QUALITY_LOW);
operation->setMaxBlur(data->maxblur);
operation->setThreshold(data->bthresh);
converter.addOperation(operation);
-
+
converter.addLink(bokeh->getOutputSocket(), operation->getInputSocket(1));
converter.addLink(radiusOperation->getOutputSocket(), operation->getInputSocket(2));
#ifdef COM_DEFOCUS_SEARCH
converter.addLink(search->getOutputSocket(), operation->getInputSocket(3));
#endif
-
+
if (data->gamco) {
GammaCorrectOperation *correct = new GammaCorrectOperation();
converter.addOperation(correct);
GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
converter.addOperation(inverse);
-
+
converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0));
converter.addLink(correct->getOutputSocket(), operation->getInputSocket(0));
converter.addLink(operation->getOutputSocket(), inverse->getInputSocket(0));
NodeInput *inputSocket = this->getInputSocket(0);
NodeInput *inputImageSocket = this->getInputSocket(1);
NodeOutput *outputSocket = this->getOutputSocket(0);
-
+
DespeckleOperation *operation = new DespeckleOperation();
operation->setThreshold(editorNode->custom3);
operation->setThresholdNeighbor(editorNode->custom4);
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputImageSocket, operation->getInputSocket(0));
converter.mapInputSocket(inputSocket, operation->getInputSocket(1));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
-
+
converter.addPreview(operation->getOutputSocket(0));
}
DifferenceMatteOperation *operationSet = new DifferenceMatteOperation();
operationSet->setSettings((NodeChroma *)editorNode->storage);
converter.addOperation(operationSet);
-
+
converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0));
converter.mapInputSocket(inputSocket2, operationSet->getInputSocket(1));
converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0));
SetAlphaOperation *operation = new SetAlphaOperation();
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1));
converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
-
+
converter.addPreview(operation->getOutputSocket());
}
void DilateErodeNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
-
+
bNode *editorNode = this->getbNode();
if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_THRESH) {
DilateErodeThresholdOperation *operation = new DilateErodeThresholdOperation();
operation->setDistance(editorNode->custom2);
operation->setInset(editorNode->custom3);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
-
+
if (editorNode->custom3 < 2.0f) {
AntiAliasOperation *antiAlias = new AntiAliasOperation();
converter.addOperation(antiAlias);
-
+
converter.addLink(operation->getOutputSocket(), antiAlias->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), antiAlias->getOutputSocket(0));
}
DilateDistanceOperation *operation = new DilateDistanceOperation();
operation->setDistance(editorNode->custom2);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
ErodeDistanceOperation *operation = new ErodeDistanceOperation();
operation->setDistance(-editorNode->custom2);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
operationx->setQuality(quality);
operationx->setFalloff(PROP_SMOOTH);
converter.addOperation(operationx);
-
+
converter.mapInputSocket(getInputSocket(0), operationx->getInputSocket(0));
// converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); // no size input yet
-
+
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
operationy->setData(&m_alpha_blur);
operationy->setQuality(quality);
operationy->setFalloff(PROP_SMOOTH);
converter.addOperation(operationy);
-
+
converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
// converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); // no size input yet
converter.mapOutputSocket(getOutputSocket(0), operationy->getOutputSocket());
-
+
converter.addPreview(operationy->getOutputSocket());
/* TODO? */
DilateStepOperation *operation = new DilateStepOperation();
operation->setIterations(editorNode->custom2);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
ErodeStepOperation *operation = new ErodeStepOperation();
operation->setIterations(-editorNode->custom2);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
operation->setQuality(context.getQuality());
operation->setData(data);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
{
bNode *editorsnode = getbNode();
NodeChroma *storage = (NodeChroma *)editorsnode->storage;
-
+
NodeInput *inputSocketImage = this->getInputSocket(0);
NodeInput *inputSocketKey = this->getInputSocket(1);
NodeOutput *outputSocketImage = this->getOutputSocket(0);
NodeOutput *outputSocketMatte = this->getOutputSocket(1);
-
+
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
converter.addOperation(operationAlpha);
-
+
/* work in RGB color space */
NodeOperation *operation;
if (storage->channel == 1) {
DistanceRGBMatteOperation *matte = new DistanceRGBMatteOperation();
matte->setSettings(storage);
converter.addOperation(matte);
-
+
converter.mapInputSocket(inputSocketImage, matte->getInputSocket(0));
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
-
+
converter.mapInputSocket(inputSocketKey, matte->getInputSocket(1));
-
+
operation = matte;
}
/* work in YCbCr color space */
DistanceYCCMatteOperation *matte = new DistanceYCCMatteOperation();
matte->setSettings(storage);
converter.addOperation(matte);
-
+
ConvertRGBToYCCOperation *operationYCCImage = new ConvertRGBToYCCOperation();
ConvertRGBToYCCOperation *operationYCCMatte = new ConvertRGBToYCCOperation();
operationYCCImage->setMode(BLI_YCC_ITU_BT709);
operationYCCMatte->setMode(BLI_YCC_ITU_BT709);
converter.addOperation(operationYCCImage);
converter.addOperation(operationYCCMatte);
-
+
converter.mapInputSocket(inputSocketImage, operationYCCImage->getInputSocket(0));
converter.addLink(operationYCCImage->getOutputSocket(), matte->getInputSocket(0));
converter.addLink(operationYCCImage->getOutputSocket(), operationAlpha->getInputSocket(0));
-
+
converter.mapInputSocket(inputSocketKey, operationYCCMatte->getInputSocket(0));
converter.addLink(operationYCCMatte->getOutputSocket(), matte->getInputSocket(1));
-
+
operation = matte;
}
-
+
converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));
converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
-
+
if (storage->channel != 1) {
ConvertYCCToRGBOperation *inv_convert = new ConvertYCCToRGBOperation();
inv_convert->setMode(BLI_YCC_ITU_BT709);
{
DoubleEdgeMaskOperation *operation;
bNode *bnode = this->getbNode();
-
+
operation = new DoubleEdgeMaskOperation();
operation->setAdjecentOnly(bnode->custom1);
operation->setKeepInside(bnode->custom2);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
{
NodeInput *inputSocket = this->getInputSocket(0);
NodeOutput *outputSocket = this->getOutputSocket(0);
-
+
EllipseMaskOperation *operation;
operation = new EllipseMaskOperation();
operation->setData((NodeEllipseMask *)this->getbNode()->storage);
operation->setMaskType(this->getbNode()->custom1);
converter.addOperation(operation);
-
+
if (inputSocket->isLinked()) {
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
-
+
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
}
NodeInput *inputImageSocket = this->getInputSocket(1);
NodeOutput *outputSocket = this->getOutputSocket(0);
ConvolutionFilterOperation *operation = NULL;
-
+
switch (this->getbNode()->custom1) {
case CMP_FILT_SOFT:
operation = new ConvolutionFilterOperation();
break;
}
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputImageSocket, operation->getInputSocket(0));
converter.mapInputSocket(inputSocket, operation->getInputSocket(1));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
-
+
converter.addPreview(operation->getOutputSocket(0));
}
operation->setFlipY(true);
break;
}
-
+
converter.addOperation(operation);
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
{
GammaOperation *operation = new GammaOperation();
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
{
bNode *node = this->getbNode();
NodeGlare *glare = (NodeGlare *)node->storage;
-
+
GlareBaseOperation *glareoperation = NULL;
switch (glare->type) {
default:
}
BLI_assert(glareoperation);
glareoperation->setGlareSettings(glare);
-
+
GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
thresholdOperation->setGlareSettings(glare);
-
+
SetValueOperation *mixvalueoperation = new SetValueOperation();
mixvalueoperation->setValue(0.5f + glare->mix * 0.5f);
-
+
MixGlareOperation *mixoperation = new MixGlareOperation();
mixoperation->setResolutionInputSocketIndex(1);
mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT);
-
+
converter.addOperation(glareoperation);
converter.addOperation(thresholdOperation);
converter.addOperation(mixvalueoperation);
converter.mapInputSocket(getInputSocket(0), thresholdOperation->getInputSocket(0));
converter.addLink(thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
-
+
converter.addLink(mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(0), mixoperation->getInputSocket(1));
converter.addLink(glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
NodeOutput *outputSocket = this->getOutputSocket(0);
bNode *editorsnode = getbNode();
CurveMapping *storage = (CurveMapping *)editorsnode->storage;
-
+
ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation();
converter.addOperation(rgbToHSV);
-
+
ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation();
converter.addOperation(hsvToRGB);
-
+
HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation();
changeHSV->setCurveMapping(storage);
converter.addOperation(changeHSV);
-
+
MixBlendOperation *blend = new MixBlendOperation();
blend->setResolutionInputSocketIndex(1);
converter.addOperation(blend);
ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation();
converter.addOperation(rgbToHSV);
-
+
ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation();
converter.addOperation(hsvToRGB);
-
+
ChangeHSVOperation *changeHSV = new ChangeHSVOperation();
converter.mapInputSocket(hueSocket, changeHSV->getInputSocket(1));
converter.mapInputSocket(saturationSocket, changeHSV->getInputSocket(2));
converter.mapInputSocket(valueSocket, changeHSV->getInputSocket(3));
converter.addOperation(changeHSV);
-
+
MixBlendOperation *blend = new MixBlendOperation();
blend->setResolutionInputSocketIndex(1);
converter.addOperation(blend);
void IDMaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *bnode = this->getbNode();
-
+
IDMaskOperation *operation;
operation = new IDMaskOperation();
operation->setObjectIndex(bnode->custom1);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
if (bnode->custom2 == 0 || context.getRenderData()->scemode & R_FULL_SAMPLE) {
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
else {
AntiAliasOperation *antiAliasOperation = new AntiAliasOperation();
converter.addOperation(antiAliasOperation);
-
+
converter.addLink(operation->getOutputSocket(), antiAliasOperation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), antiAliasOperation->getOutputSocket(0));
}
operation->setRenderLayer(rl);
operation->setImageUser(user);
operation->setFramenumber(framenumber);
-
+
converter.addOperation(operation);
converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
-
+
return operation;
}
operation->setRenderData(context.getRenderData());
operation->setViewName(context.getViewName());
converter.addOperation(operation);
-
+
if (outputStraightAlpha) {
NodeOperation *alphaConvertOperation = new ConvertPremulToStraightOperation();
-
+
converter.addOperation(alphaConvertOperation);
converter.mapOutputSocket(outputImage, alphaConvertOperation->getOutputSocket());
converter.addLink(operation->getOutputSocket(0), alphaConvertOperation->getInputSocket(0));
else {
converter.mapOutputSocket(outputImage, operation->getOutputSocket());
}
-
+
converter.addPreview(operation->getOutputSocket());
}
-
+
if (numberOfOutputs > 1) {
NodeOutput *alphaImage = this->getOutputSocket(1);
ImageAlphaOperation *alphaOperation = new ImageAlphaOperation();
alphaOperation->setRenderData(context.getRenderData());
alphaOperation->setViewName(context.getViewName());
converter.addOperation(alphaOperation);
-
+
converter.mapOutputSocket(alphaImage, alphaOperation->getOutputSocket());
}
if (numberOfOutputs > 2) {
depthOperation->setRenderData(context.getRenderData());
depthOperation->setViewName(context.getViewName());
converter.addOperation(depthOperation);
-
+
converter.mapOutputSocket(depthImage, depthOperation->getOutputSocket());
}
if (numberOfOutputs > 3) {
void InpaintNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
-
+
bNode *editorNode = this->getbNode();
/* if (editorNode->custom1 == CMP_NODE_INPAINT_SIMPLE) { */
InpaintSimpleOperation *operation = new InpaintSimpleOperation();
operation->setIterations(editorNode->custom2);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
operation->setColor(node->custom1 & CMP_CHAN_RGB);
operation->setAlpha(node->custom1 & CMP_CHAN_A);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
ConvertRGBToYCCOperation *convertRGBToYCCOperation = new ConvertRGBToYCCOperation();
convertRGBToYCCOperation->setMode(BLI_YCC_ITU_BT709);
converter.addOperation(convertRGBToYCCOperation);
-
+
converter.mapInputSocket(inputImage, convertRGBToYCCOperation->getInputSocket(0));
-
+
CombineChannelsOperation *combineOperation = new CombineChannelsOperation();
converter.addOperation(combineOperation);
SeparateChannelOperation *separateOperation = new SeparateChannelOperation();
separateOperation->setChannel(channel);
converter.addOperation(separateOperation);
-
+
converter.addLink(convertRGBToYCCOperation->getOutputSocket(0), separateOperation->getInputSocket(0));
-
+
if (channel == 0 || channel == 3) {
converter.addLink(separateOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
}
blurXOperation->setSize(size);
blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X);
converter.addOperation(blurXOperation);
-
+
KeyingBlurOperation *blurYOperation = new KeyingBlurOperation();
blurYOperation->setSize(size);
blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y);
converter.addOperation(blurYOperation);
-
+
converter.addLink(separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0));
converter.addLink(blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0));
converter.addLink(blurYOperation->getOutputSocket(0), combineOperation->getInputSocket(channel));
}
}
-
+
ConvertYCCToRGBOperation *convertYCCToRGBOperation = new ConvertYCCToRGBOperation();
convertYCCToRGBOperation->setMode(BLI_YCC_ITU_BT709);
converter.addOperation(convertYCCToRGBOperation);
-
+
converter.addLink(combineOperation->getOutputSocket(0), convertYCCToRGBOperation->getInputSocket(0));
-
+
return convertYCCToRGBOperation->getOutputSocket(0);
}
blurXOperation->setSize(size);
blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X);
converter.addOperation(blurXOperation);
-
+
KeyingBlurOperation *blurYOperation = new KeyingBlurOperation();
blurYOperation->setSize(size);
blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y);
converter.addOperation(blurYOperation);
-
+
converter.addLink(postBlurInput, blurXOperation->getInputSocket(0));
converter.addLink(blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0));
-
+
return blurYOperation->getOutputSocket();
}
dilateErodeOperation->setDistance(-distance);
}
converter.addOperation(dilateErodeOperation);
-
+
converter.addLink(dilateErodeInput, dilateErodeOperation->getInputSocket(0));
-
+
return dilateErodeOperation->getOutputSocket(0);
}
operationx->setSubtract(distance < 0);
operationx->setFalloff(falloff);
converter.addOperation(operationx);
-
+
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
operationy->setData(&data);
operationy->setQuality(quality);
despillOperation->setDespillFactor(factor);
despillOperation->setColorBalance(colorBalance);
converter.addOperation(despillOperation);
-
+
converter.addLink(despillInput, despillOperation->getInputSocket(0));
converter.mapInputSocket(inputScreen, despillOperation->getInputSocket(1));
-
+
return despillOperation->getOutputSocket(0);
}
clipOperation->setClipWhite(clipWhite);
clipOperation->setIsEdgeMatte(edgeMatte);
converter.addOperation(clipOperation);
-
+
converter.addLink(clipInput, clipOperation->getInputSocket(0));
-
+
return clipOperation->getOutputSocket(0);
}
{
bNode *editorNode = this->getbNode();
NodeKeyingData *keying_data = (NodeKeyingData *) editorNode->storage;
-
+
NodeInput *inputImage = this->getInputSocket(0);
NodeInput *inputScreen = this->getInputSocket(1);
NodeInput *inputGarbageMatte = this->getInputSocket(2);
NodeOutput *outputMatte = this->getOutputSocket(1);
NodeOutput *outputEdges = this->getOutputSocket(2);
NodeOperationOutput *postprocessedMatte = NULL, *postprocessedImage = NULL, *edgesMatte = NULL;
-
+
/* keying operation */
KeyingOperation *keyingOperation = new KeyingOperation();
keyingOperation->setScreenBalance(keying_data->screen_balance);
converter.addOperation(keyingOperation);
-
+
converter.mapInputSocket(inputScreen, keyingOperation->getInputSocket(1));
-
+
if (keying_data->blur_pre) {
/* chroma preblur operation for input of keying operation */
NodeOperationOutput *preBluredImage = setupPreBlur(converter, inputImage, keying_data->blur_pre);
else {
converter.mapInputSocket(inputImage, keyingOperation->getInputSocket(0));
}
-
+
postprocessedMatte = keyingOperation->getOutputSocket();
-
+
/* black / white clipping */
if (keying_data->clip_black > 0.0f || keying_data->clip_white < 1.0f) {
postprocessedMatte = setupClip(converter, postprocessedMatte,
keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance,
keying_data->clip_black, keying_data->clip_white, false);
}
-
+
/* output edge matte */
edgesMatte = setupClip(converter, postprocessedMatte,
keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance,
keying_data->clip_black, keying_data->clip_white, true);
-
+
/* apply garbage matte */
if (inputGarbageMatte->isLinked()) {
SetValueOperation *valueOperation = new SetValueOperation();
valueOperation->setValue(1.0f);
converter.addOperation(valueOperation);
-
+
MathSubtractOperation *subtractOperation = new MathSubtractOperation();
converter.addOperation(subtractOperation);
-
+
MathMinimumOperation *minOperation = new MathMinimumOperation();
converter.addOperation(minOperation);
-
+
converter.addLink(valueOperation->getOutputSocket(), subtractOperation->getInputSocket(0));
converter.mapInputSocket(inputGarbageMatte, subtractOperation->getInputSocket(1));
-
+
converter.addLink(subtractOperation->getOutputSocket(), minOperation->getInputSocket(0));
converter.addLink(postprocessedMatte, minOperation->getInputSocket(1));
-
+
postprocessedMatte = minOperation->getOutputSocket();
}
-
+
/* apply core matte */
if (inputCoreMatte->isLinked()) {
MathMaximumOperation *maxOperation = new MathMaximumOperation();
converter.addOperation(maxOperation);
-
+
converter.mapInputSocket(inputCoreMatte, maxOperation->getInputSocket(0));
converter.addLink(postprocessedMatte, maxOperation->getInputSocket(1));
-
+
postprocessedMatte = maxOperation->getOutputSocket();
}
-
+
/* apply blur on matte if needed */
if (keying_data->blur_post)
postprocessedMatte = setupPostBlur(converter, postprocessedMatte, keying_data->blur_post);
/* set alpha channel to output image */
SetAlphaOperation *alphaOperation = new SetAlphaOperation();
converter.addOperation(alphaOperation);
-
+
converter.mapInputSocket(inputImage, alphaOperation->getInputSocket(0));
converter.addLink(postprocessedMatte, alphaOperation->getInputSocket(1));
bNode *editorNode = this->getbNode();
MovieClip *clip = (MovieClip *) editorNode->id;
NodeKeyingScreenData *keyingscreen_data = (NodeKeyingScreenData *) editorNode->storage;
-
+
NodeOutput *outputScreen = this->getOutputSocket(0);
-
+
// always connect the output image
KeyingScreenOperation *operation = new KeyingScreenOperation();
operation->setMovieClip(clip);
operation->setTrackingObject(keyingscreen_data->tracking_object);
operation->setFramenumber(context.getFramenumber());
converter.addOperation(operation);
-
+
converter.mapOutputSocket(outputScreen, operation->getOutputSocket());
}
if (data->proj) {
ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation();
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
operation->setDistortion(getInputSocket(1)->getEditorValueFloat());
if (!getInputSocket(2)->isLinked())
operation->setDispersion(getInputSocket(2)->getEditorValueFloat());
-
+
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
SetAlphaOperation *operation = new SetAlphaOperation();
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1));
converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
-
+
converter.addPreview(operation->getOutputSocket());
}
NodeInput *destMinSocket = this->getInputSocket(3);
NodeInput *destMaxSocket = this->getInputSocket(4);
NodeOutput *outputSocket = this->getOutputSocket(0);
-
+
MapRangeOperation *operation = new MapRangeOperation();
operation->setUseClamp(this->getbNode()->custom1);
converter.addOperation(operation);
-
+
converter.mapInputSocket(valueSocket, operation->getInputSocket(0));
converter.mapInputSocket(sourceMinSocket, operation->getInputSocket(1));
converter.mapInputSocket(sourceMaxSocket, operation->getInputSocket(2));
void MapUVNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
bNode *node = this->getbNode();
-
+
MapUVOperation *operation = new MapUVOperation();
operation->setAlpha((float)node->custom1);
operation->setResolutionInputSocketIndex(1);
void MapValueNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
TexMapping *storage = (TexMapping *)this->getbNode()->storage;
-
+
NodeInput *colorSocket = this->getInputSocket(0);
NodeOutput *valueSocket = this->getOutputSocket(0);
-
+
MapValueOperation *convertProg = new MapValueOperation();
convertProg->setSettings(storage);
converter.addOperation(convertProg);
-
+
converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0));
converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0));
}
void MathNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
MathBaseOperation *operation = NULL;
-
+
switch (this->getbNode()->custom1) {
case NODE_MATH_ADD:
operation = new MathAddOperation();
operation = new MathArcTan2Operation();
break;
}
-
+
if (operation) {
bool useClamp = getbNode()->custom2;
operation->setUseClamp(useClamp);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
bNode *editorNode = this->getbNode();
bool useAlphaPremultiply = (this->getbNode()->custom2 & 1) != 0;
bool useClamp = (this->getbNode()->custom2 & 2) != 0;
-
+
MixBaseOperation *convertProg;
switch (editorNode->custom1) {
case MA_RAMP_ADD:
convertProg->setUseValueAlphaMultiply(useAlphaPremultiply);
convertProg->setUseClamp(useClamp);
converter.addOperation(convertProg);
-
+
converter.mapInputSocket(valueSocket, convertProg->getInputSocket(0));
converter.mapInputSocket(color1Socket, convertProg->getInputSocket(1));
converter.mapInputSocket(color2Socket, convertProg->getInputSocket(2));
converter.mapOutputSocket(outputSocket, convertProg->getOutputSocket(0));
-
+
converter.addPreview(convertProg->getOutputSocket(0));
}
NodeOutput *offsetYMovieClip = this->getOutputSocket(3);
NodeOutput *scaleMovieClip = this->getOutputSocket(4);
NodeOutput *angleMovieClip = this->getOutputSocket(5);
-
+
bNode *editorNode = this->getbNode();
MovieClip *movieClip = (MovieClip *)editorNode->id;
MovieClipUser *movieClipUser = (MovieClipUser *)editorNode->storage;
else
ibuf = BKE_movieclip_get_ibuf_flag(movieClip, movieClipUser, movieClip->flag, MOVIECLIP_CACHE_SKIP);
}
-
+
// always connect the output image
MovieClipOperation *operation = new MovieClipOperation();
operation->setMovieClip(movieClip);
alphaOperation->setMovieClipUser(movieClipUser);
alphaOperation->setFramenumber(context.getFramenumber());
alphaOperation->setCacheFrame(cacheFrame);
-
+
converter.addOperation(alphaOperation);
converter.mapOutputSocket(alphaMovieClip, alphaOperation->getOutputSocket());
converter.addOutputValue(offsetYMovieClip, loc[1]);
converter.addOutputValue(scaleMovieClip, scale);
converter.addOutputValue(angleMovieClip, angle);
-
+
if (ibuf) {
IMB_freeImBuf(ibuf);
}
{
bNode *bnode = this->getbNode();
MovieClip *clip = (MovieClip *)bnode->id;
-
+
NodeInput *inputSocket = this->getInputSocket(0);
NodeOutput *outputSocket = this->getOutputSocket(0);
-
+
MovieDistortionOperation *operation = new MovieDistortionOperation(bnode->custom1 == 1);
operation->setMovieClip(clip);
operation->setFramenumber(context.getFramenumber());
NodeInput *inputSocket = this->getInputSocket(0);
NodeOutput *outputSocket = this->getOutputSocket(0);
NodeOutput *outputSocketDotproduct = this->getOutputSocket(1);
-
+
SetVectorOperation *operationSet = new SetVectorOperation();
float normal[3];
outputSocket->getEditorValueVector(normal);
operationSet->setZ(normal[2]);
operationSet->setW(0.0f);
converter.addOperation(operationSet);
-
+
converter.mapOutputSocket(outputSocket, operationSet->getOutputSocket(0));
-
+
DotproductOperation *operation = new DotproductOperation();
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.addLink(operationSet->getOutputSocket(0), operation->getInputSocket(1));
converter.mapOutputSocket(outputSocketDotproduct, operation->getOutputSocket(0));
{
NodeImageMultiFile *storage = (NodeImageMultiFile *)this->getbNode()->storage;
const bool is_multiview = (context.getRenderData()->scemode & R_MULTIVIEW) != 0;
-
+
if (!context.isRendering()) {
/* only output files when rendering a sequence -
* otherwise, it overwrites the output files just
for (int i = 0; i < num_inputs; ++i) {
NodeInput *input = getInputSocket(i);
NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
-
+
/* note: layer becomes an empty placeholder if the input is not linked */
outputOperation->add_layer(sockdata->layer, input->getDataType(), input->isLinked());
-
+
converter.mapInputSocket(input, outputOperation->getInputSocket(i));
-
+
if (!previewAdded) {
converter.addNodeInputPreview(input);
previewAdded = true;
NodeInput *inputSocket = this->getInputSocket(0);
NodeOutput *outputSocket = this->getOutputSocket(0);
DataType datatype = inputSocket->getDataType();
-
+
if (inputSocket->isLinked()) {
NodeOutput *link = inputSocket->getLink();
datatype = link->getDataType();
PixelateOperation *operation = new PixelateOperation(datatype);
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
bNode *editorNode = this->getbNode();
MovieClip *clip = (MovieClip *) editorNode->id;
NodePlaneTrackDeformData *data = (NodePlaneTrackDeformData *) editorNode->storage;
-
+
int frame_number = context.getFramenumber();
-
+
NodeInput *input_image = this->getInputSocket(0);
NodeOutput *output_warped_image = this->getOutputSocket(0);
NodeOutput *output_plane = this->getOutputSocket(1);
-
+
PlaneTrackWarpImageOperation *warp_image_operation = new PlaneTrackWarpImageOperation();
warp_image_operation->setMovieClip(clip);
warp_image_operation->setTrackingObject(data->tracking_object);
warp_image_operation->setMotionBlurShutter(data->motion_blur_shutter);
}
converter.addOperation(warp_image_operation);
-
+
converter.mapInputSocket(input_image, warp_image_operation->getInputSocket(0));
converter.mapOutputSocket(output_warped_image, warp_image_operation->getOutputSocket());
-
+
PlaneTrackMaskOperation *plane_mask_operation = new PlaneTrackMaskOperation();
plane_mask_operation->setMovieClip(clip);
plane_mask_operation->setTrackingObject(data->tracking_object);
plane_mask_operation->setMotionBlurShutter(data->motion_blur_shutter);
}
converter.addOperation(plane_mask_operation);
-
+
converter.mapOutputSocket(output_plane, plane_mask_operation->getOutputSocket());
}
RotateOperation *operation = new RotateOperation();
SetSamplerOperation *sampler = new SetSamplerOperation();
sampler->setSampler((PixelSampler)this->getbNode()->custom1);
-
+
converter.addOperation(sampler);
converter.addOperation(operation);
-
+
converter.addLink(sampler->getOutputSocket(), operation->getInputSocket(0));
converter.mapInputSocket(inputSocket, sampler->getInputSocket(0));
converter.mapInputSocket(inputDegreeSocket, operation->getInputSocket(1));
void ScaleNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
{
bNode *bnode = this->getbNode();
-
+
NodeInput *inputSocket = this->getInputSocket(0);
NodeInput *inputXSocket = this->getInputSocket(1);
NodeInput *inputYSocket = this->getInputSocket(2);
{
ScaleOperation *operation = new ScaleOperation();
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.mapInputSocket(inputXSocket, operation->getInputSocket(1));
converter.mapInputSocket(inputYSocket, operation->getInputSocket(2));
SetValueOperation *scaleFactorOperation = new SetValueOperation();
scaleFactorOperation->setValue(context.getRenderData()->size / 100.0f);
converter.addOperation(scaleFactorOperation);
-
+
ScaleOperation *operation = new ScaleOperation();
converter.addOperation(operation);
-
+
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
converter.addLink(scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
converter.addLink(scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2));
NodeOutput *outputGSocket = this->getOutputSocket(1);
NodeOutput *outputBSocket = this->getOutputSocket(2);
NodeOutput *outputASocket = this->getOutputSocket(3);
-
+
NodeOperation *color_conv = getColorConverter(context);
if (color_conv) {
converter.addOperation(color_conv);
-
+
converter.mapInputSocket(imageSocket, color_conv->getInputSocket(0));
}
-
+
{
SeparateChannelOperation *operation = new SeparateChannelOperation();
operation->setChannel(0);
converter.addOperation(operation);
-
+
if (color_conv)
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
else
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
converter.mapOutputSocket(outputRSocket, operation->getOutputSocket(0));
}
-
+
{
SeparateChannelOperation *operation = new SeparateChannelOperation();
operation->setChannel(1);
converter.addOperation(operation);
-
+
if (color_conv)
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
else
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
converter.mapOutputSocket(outputGSocket, operation->getOutputSocket(0));
}
-
+
{
SeparateChannelOperation *operation = new SeparateChannelOperation();
operation->setChannel(2);
converter.addOperation(operation);
-
+
if (color_conv)
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
else
converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
converter.mapOutputSocket(outputBSocket, operation->getOutputSocket(0));
}
-
+
{
SeparateChannelOperation *operation = new SeparateChannelOperation();
operation->setChannel(3);
converter.addOperation(operation);
-
+
if (color_conv)
converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
else
public:
SeparateColorNode(bNode *editorNode);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
-
+
protected:
virtual NodeOperation *getColorConverter(const CompositorContext &context) const = 0;
};
SeparateRGBANode(bNode *editorNode) :
SeparateColorNode(editorNode)
{}
-
+
NodeOperation *getColorConverter(const CompositorContext &context) const;
};
SeparateHSVANode(bNode *editorNode) :
SeparateColorNode(editorNode)
{}
-
+
NodeOperation *getColorConverter(const CompositorContext &context) const;
};
SeparateYCCANode(bNode *editorNode) :
SeparateColorNode(editorNode)
{}
-
+
NodeOperation *getColorConverter(const CompositorContext &context) const;
};
SeparateYUVANode(bNode *editorNode) :
SeparateColorNode(editorNode)
{}
-
+
NodeOperation *getColorConverter(const CompositorContext &context) const;
};
void SetAlphaNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
SetAlphaOperation *operation = new SetAlphaOperation();
-
+
if (!this->getInputSocket(0)->isLinked() && this->getInputSocket(1)->isLinked()) {
operation->setResolutionInputSocketIndex(1);
}
-
+
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
{
NodeOutput *output = this->getOutputSocket(0);
NodeInput *input = this->getInputSocket(0);
-
+
DataType datatype = output->getDataType();
WriteBufferOperation *writeOperation = new WriteBufferOperation(datatype);
ReadBufferOperation *readOperation = new ReadBufferOperation(datatype);
readOperation->setMemoryProxy(writeOperation->getMemoryProxy());
converter.addOperation(writeOperation);
converter.addOperation(readOperation);
-
+
converter.mapInputSocket(input, writeOperation->getInputSocket(0));
converter.mapOutputSocket(output, readOperation->getOutputSocket());
}
public:
SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool use_conversion);
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
-
+
bool getUseConversion() const { return m_use_conversion; }
void setUseConversion(bool use_conversion) { m_use_conversion = use_conversion; }
-
+
private:
/** If true, the proxy will convert input and output data to/from the proxy socket types. */
bool m_use_conversion;
NodeInput *imageInput = this->getInputSocket(0);
MovieClip *clip = (MovieClip *)editorNode->id;
bool invert = (editorNode->custom2 & CMP_NODEFLAG_STABILIZE_INVERSE) != 0;
-
+
ScaleOperation *scaleOperation = new ScaleOperation();
scaleOperation->setSampler((PixelSampler)editorNode->custom1);
RotateOperation *rotateOperation = new RotateOperation();
converter.addOperation(translateOperation);
converter.addOperation(rotateOperation);
converter.addOperation(psoperation);
-
+
converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
-
+
converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
-
+
converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
}
void SwitchNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
bool condition = this->getbNode()->custom1;
-
+
NodeOperationOutput *result;
if (!condition)
result = converter.addInputProxy(getInputSocket(0), false);
else
result = converter.addInputProxy(getInputSocket(1), false);
-
+
converter.mapOutputSocket(getOutputSocket(0), result);
}
operation->setRenderData(context.getRenderData());
operation->setSceneColorManage(sceneColorManage);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(1), operation->getOutputSocket());
-
+
converter.addPreview(operation->getOutputSocket());
TextureAlphaOperation *alphaOperation = new TextureAlphaOperation();
alphaOperation->setRenderData(context.getRenderData());
alphaOperation->setSceneColorManage(sceneColorManage);
converter.addOperation(alphaOperation);
-
+
converter.mapInputSocket(getInputSocket(0), alphaOperation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), alphaOperation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(0), alphaOperation->getOutputSocket());
fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
operation->setValue(clamp_f(fac, 0.0f, 1.0f));
converter.addOperation(operation);
-
+
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
void TonemapNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
{
NodeTonemap *data = (NodeTonemap *)this->getbNode()->storage;
-
+
TonemapOperation *operation = data->type == 1 ? new PhotoreceptorTonemapOperation() : new TonemapOperation();
operation->setData(data);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
bNode *editorNode = this->getbNode();
MovieClip *clip = (MovieClip *) editorNode->id;
NodeTrackPosData *trackpos_data = (NodeTrackPosData *) editorNode->storage;
-
+
NodeOutput *outputX = this->getOutputSocket(0);
NodeOutput *outputY = this->getOutputSocket(1);
NodeOutput *outputSpeed = this->getOutputSocket(2);
NodeInput *yInput = this->getInputSocket(2);
NodeInput *angleInput = this->getInputSocket(3);
NodeInput *scaleInput = this->getInputSocket(4);
-
+
ScaleOperation *scaleOperation = new ScaleOperation();
converter.addOperation(scaleOperation);
-
+
RotateOperation *rotateOperation = new RotateOperation();
rotateOperation->setDoDegree2RadConversion(false);
converter.addOperation(rotateOperation);
-
+
TranslateOperation *translateOperation = new TranslateOperation();
converter.addOperation(translateOperation);
-
+
SetSamplerOperation *sampler = new SetSamplerOperation();
sampler->setSampler((PixelSampler)this->getbNode()->custom1);
converter.addOperation(sampler);
-
+
converter.mapInputSocket(imageInput, sampler->getInputSocket(0));
converter.addLink(sampler->getOutputSocket(), scaleOperation->getInputSocket(0));
converter.mapInputSocket(scaleInput, scaleOperation->getInputSocket(1));
converter.mapInputSocket(scaleInput, scaleOperation->getInputSocket(2)); // xscale = yscale
-
+
converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
converter.mapInputSocket(angleInput, rotateOperation->getInputSocket(1));
-
+
converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
converter.mapInputSocket(xInput, translateOperation->getInputSocket(1));
converter.mapInputSocket(yInput, translateOperation->getInputSocket(2));
-
+
converter.mapOutputSocket(getOutputSocket(), translateOperation->getOutputSocket());
}
{
bNode *bnode = this->getbNode();
NodeTranslateData *data = (NodeTranslateData *)bnode->storage;
-
+
NodeInput *inputSocket = this->getInputSocket(0);
NodeInput *inputXSocket = this->getInputSocket(1);
NodeInput *inputYSocket = this->getInputSocket(2);
NodeOutput *outputSocket = this->getOutputSocket(0);
-
+
TranslateOperation *operation = new TranslateOperation();
if (data->relative) {
const RenderData *rd = context.getRenderData();
float fx = rd->xsch * rd->size / 100.0f;
float fy = rd->ysch * rd->size / 100.0f;
-
+
operation->setFactorXY(fx, fy);
}
-
+
converter.addOperation(operation);
converter.mapInputSocket(inputXSocket, operation->getInputSocket(1));
converter.mapInputSocket(inputYSocket, operation->getInputSocket(2));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
-
+
if (data->wrap_axis) {
WriteBufferOperation *writeOperation = new WriteBufferOperation(COM_DT_COLOR);
WrapOperation *wrapOperation = new WrapOperation(COM_DT_COLOR);
wrapOperation->setMemoryProxy(writeOperation->getMemoryProxy());
wrapOperation->setWrapping(data->wrap_axis);
-
+
converter.addOperation(writeOperation);
converter.addOperation(wrapOperation);
converter.mapInputSocket(inputSocket, writeOperation->getInputSocket(0));
NodeOutput *output = this->getOutputSocket(0);
operation->setValue(output->getEditorValueFloat());
converter.addOperation(operation);
-
+
converter.mapOutputSocket(output, operation->getOutputSocket());
}
{
bNode *node = this->getbNode();
NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage;
-
+
VectorBlurOperation *operation = new VectorBlurOperation();
operation->setVectorBlurSettings(vectorBlurSettings);
operation->setQuality(context.getQuality());
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
VectorCurveOperation *operation = new VectorCurveOperation();
operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
NodeInput *input = this->getInputSocket(0);
if (input->isLinked()) {
// add preview to inputSocket;
-
+
/* calculate mean operation */
{
CalculateMeanOperation *operation = new CalculateMeanOperation();
operation->setSetting(this->getbNode()->custom1);
-
+
converter.addOperation(operation);
converter.mapInputSocket(input, operation->getInputSocket(0));
converter.mapOutputSocket(this->getOutputSocket(0), operation->getOutputSocket());
{
CalculateStandardDeviationOperation *operation = new CalculateStandardDeviationOperation();
operation->setSetting(this->getbNode()->custom1);
-
+
converter.addOperation(operation);
converter.mapInputSocket(input, operation->getInputSocket(0));
converter.mapOutputSocket(this->getOutputSocket(1), operation->getOutputSocket());
operation = new ZCombineOperation();
}
converter.addOperation(operation);
-
+
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
-
+
MathMinimumOperation *zoperation = new MathMinimumOperation();
converter.addOperation(zoperation);
-
+
converter.mapInputSocket(getInputSocket(1), zoperation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(3), zoperation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(1), zoperation->getOutputSocket());
if (this->getbNode()->custom1) {
maskoperation = new MathGreaterThanOperation();
converter.addOperation(maskoperation);
-
+
converter.mapInputSocket(getInputSocket(1), maskoperation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(3), maskoperation->getInputSocket(1));
}
else {
maskoperation = new MathLessThanOperation();
converter.addOperation(maskoperation);
-
+
converter.mapInputSocket(getInputSocket(1), maskoperation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(3), maskoperation->getInputSocket(1));
}
// step 2 anti alias mask bit of an expensive operation, but does the trick
AntiAliasOperation *antialiasoperation = new AntiAliasOperation();
converter.addOperation(antialiasoperation);
-
+
converter.addLink(maskoperation->getOutputSocket(), antialiasoperation->getInputSocket(0));
// use mask to blend between the input colors.
ZCombineMaskOperation *zcombineoperation = this->getbNode()->custom1 ? new ZCombineMaskAlphaOperation() : new ZCombineMaskOperation();
converter.addOperation(zcombineoperation);
-
+
converter.addLink(antialiasoperation->getOutputSocket(), zcombineoperation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(0), zcombineoperation->getInputSocket(1));
converter.mapInputSocket(getInputSocket(2), zcombineoperation->getInputSocket(2));
MathMinimumOperation *zoperation = new MathMinimumOperation();
converter.addOperation(zoperation);
-
+
converter.mapInputSocket(getInputSocket(1), zoperation->getInputSocket(0));
converter.mapInputSocket(getInputSocket(3), zoperation->getInputSocket(1));
converter.mapOutputSocket(getOutputSocket(1), zoperation->getOutputSocket());
float inputColor1[4];
float inputOverColor[4];
float value[4];
-
+
this->m_inputValueOperation->readSampled(value, x, y, sampler);
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
-
+
if (inputOverColor[3] <= 0.0f) {
copy_v4_v4(output, inputColor1);
}
else {
float premul = value[0] * inputOverColor[3];
float mul = 1.0f - premul;
-
+
output[0] = (mul * inputColor1[0]) + premul * inputOverColor[0];
output[1] = (mul * inputColor1[1]) + premul * inputOverColor[1];
output[2] = (mul * inputColor1[2]) + premul * inputOverColor[2];
* Default constructor
*/
AlphaOverKeyOperation();
-
+
/**
* the inner loop of this program
*/
float inputColor1[4];
float inputOverColor[4];
float value[4];
-
+
this->m_inputValueOperation->readSampled(value, x, y, sampler);
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
-
+
if (inputOverColor[3] <= 0.0f) {
copy_v4_v4(output, inputColor1);
}
* Default constructor
*/
AlphaOverMixedOperation();
-
+
/**
* the inner loop of this program
*/
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
+
void setX(float x) { this->m_x = x; }
};
#endif
float inputColor1[4];
float inputOverColor[4];
float value[4];
-
+
this->m_inputValueOperation->readSampled(value, x, y, sampler);
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
-
+
/* Zero alpha values should still permit an add of RGB data */
if (inputOverColor[3] < 0.0f) {
copy_v4_v4(output, inputColor1);
}
else {
float mul = 1.0f - value[0] * inputOverColor[3];
-
+
output[0] = (mul * inputColor1[0]) + value[0] * inputOverColor[0];
output[1] = (mul * inputColor1[1]) + value[0] * inputOverColor[1];
output[2] = (mul * inputColor1[2]) + value[0] * inputOverColor[2];
* Default constructor
*/
AlphaOverPremultiplyOperation();
-
+
/**
* the inner loop of this program
*/
SocketReader *m_valueReader;
public:
AntiAliasOperation();
-
+
/**
* the inner loop of this program
*/
void executePixel(float output[4], int x, int y, void *data);
-
+
/**
* Initialize the execution
*/
void initExecution();
-
+
void *initializeTileData(rcti *rect);
-
+
/**
* Deinitialize the execution
*/
}
}
}
-
+
if (blurDivider > 0.0f) {
mul_v4_v4fl(output, blurColor, 1.0f / blurDivider);
}
* the inner loop of this program
*/
void executePixel(float output[4], int x, int y, void *data);
-
+
/**
* Initialize the execution
*/
void initExecution();
-
+
/**
* Deinitialize the execution
*/
void deinitExecution();
-
+
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
+
void setData(NodeBilateralBlurData *data) { this->m_data = data; }
};
#endif
* Initialize the execution
*/
void initExecution();
-
+
/**
* Deinitialize the execution
*/
void deinitExecution();
-
+
void setData(const NodeBlurData *data);
void setSize(float size) { this->m_size = size; this->m_sizeavailable = true; }
}
void BokehBlurOperation::executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
cl_kernel kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL);
const float max_dim = max(this->getWidth(), this->getHeight());
cl_int radius = this->m_size * max_dim / 100.0f;
cl_int step = this->getStep();
-
+
device->COM_clAttachMemoryBufferToKernelParameter(kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBoundingBoxReader);
device->COM_clAttachMemoryBufferToKernelParameter(kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
device->COM_clAttachMemoryBufferToKernelParameter(kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
clSetKernelArg(kernel, 6, sizeof(cl_int), &radius);
clSetKernelArg(kernel, 7, sizeof(cl_int), &step);
device->COM_clAttachSizeToKernelParameter(kernel, 8, this);
-
+
device->COM_clEnqueueRange(kernel, outputMemoryBuffer, 9, this);
}