Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cc40
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h205
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cc2
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.h2
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.cc2
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.h2
8 files changed, 122 insertions, 135 deletions
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cc b/source/blender/compositor/intern/COM_NodeOperation.cc
index 195073545ec..e68c53bd7b2 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cc
+++ b/source/blender/compositor/intern/COM_NodeOperation.cc
@@ -39,38 +39,24 @@ NodeOperation::NodeOperation()
this->m_btree = nullptr;
}
-NodeOperation::~NodeOperation()
+NodeOperationOutput *NodeOperation::getOutputSocket(unsigned int index)
{
- while (!this->m_outputs.is_empty()) {
- delete (this->m_outputs.pop_last());
- }
- while (!this->m_inputs.is_empty()) {
- delete (this->m_inputs.pop_last());
- }
-}
-
-NodeOperationOutput *NodeOperation::getOutputSocket(unsigned int index) const
-{
- BLI_assert(index < m_outputs.size());
- return m_outputs[index];
+ return &m_outputs[index];
}
-NodeOperationInput *NodeOperation::getInputSocket(unsigned int index) const
+NodeOperationInput *NodeOperation::getInputSocket(unsigned int index)
{
- BLI_assert(index < m_inputs.size());
- return m_inputs[index];
+ return &m_inputs[index];
}
void NodeOperation::addInputSocket(DataType datatype, ResizeMode resize_mode)
{
- NodeOperationInput *socket = new NodeOperationInput(this, datatype, resize_mode);
- m_inputs.append(socket);
+ m_inputs.append(NodeOperationInput(this, datatype, resize_mode));
}
void NodeOperation::addOutputSocket(DataType datatype)
{
- NodeOperationOutput *socket = new NodeOperationOutput(this, datatype);
- m_outputs.append(socket);
+ m_outputs.append(NodeOperationOutput(this, datatype));
}
void NodeOperation::determineResolution(unsigned int resolution[2],
@@ -79,11 +65,12 @@ void NodeOperation::determineResolution(unsigned int resolution[2],
unsigned int temp[2];
unsigned int temp2[2];
+ // TODO(jbakker): Replace for loops with direct array access.
for (unsigned int index = 0; index < m_inputs.size(); index++) {
- NodeOperationInput *input = m_inputs[index];
- if (input->isConnected()) {
+ NodeOperationInput &input = m_inputs[index];
+ if (input.isConnected()) {
if (index == this->m_resolutionInputSocketIndex) {
- input->determineResolution(resolution, preferredResolution);
+ input.determineResolution(resolution, preferredResolution);
temp2[0] = resolution[0];
temp2[1] = resolution[1];
break;
@@ -91,14 +78,15 @@ void NodeOperation::determineResolution(unsigned int resolution[2],
}
}
for (unsigned int index = 0; index < m_inputs.size(); index++) {
- NodeOperationInput *input = m_inputs[index];
- if (input->isConnected()) {
+ NodeOperationInput &input = m_inputs[index];
+ if (input.isConnected()) {
if (index != this->m_resolutionInputSocketIndex) {
- input->determineResolution(temp, temp2);
+ input.determineResolution(temp, temp2);
}
}
}
}
+
void NodeOperation::setResolutionInputSocketIndex(unsigned int index)
{
this->m_resolutionInputSocketIndex = index;
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 3836268c63c..5b9375ae531 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -37,9 +37,6 @@ class OpenCLDevice;
class ReadBufferOperation;
class WriteBufferOperation;
-class NodeOperationInput;
-class NodeOperationOutput;
-
class NodeOperation;
typedef NodeOperation SocketReader;
@@ -73,6 +70,99 @@ enum class PixelSampler {
Bicubic = 2,
};
+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 */
+ ResizeMode m_resizeMode;
+
+ /** Connected output */
+ NodeOperationOutput *m_link;
+
+ public:
+ NodeOperationInput(NodeOperation *op,
+ DataType datatype,
+ ResizeMode resizeMode = ResizeMode::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(ResizeMode resizeMode)
+ {
+ this->m_resizeMode = resizeMode;
+ }
+ ResizeMode 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
+ * \param preferredResolution: the preferable resolution as no resolution could be determined
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+#ifdef WITH_CXX_GUARDEDALLOC
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
+#endif
+};
+
/**
* \brief NodeOperation contains calculation logic
*
@@ -81,8 +171,8 @@ enum class PixelSampler {
*/
class NodeOperation {
private:
- blender::Vector<NodeOperationInput *> m_inputs;
- blender::Vector<NodeOperationOutput *> m_outputs;
+ blender::Vector<NodeOperationInput> m_inputs;
+ blender::Vector<NodeOperationOutput> m_outputs;
/**
* \brief the index of the input socket that will be used to determine the resolution
@@ -136,7 +226,9 @@ class NodeOperation {
unsigned int m_height;
public:
- virtual ~NodeOperation();
+ virtual ~NodeOperation()
+ {
+ }
unsigned int getNumberOfInputSockets() const
{
@@ -146,12 +238,12 @@ class NodeOperation {
{
return m_outputs.size();
}
- NodeOperationOutput *getOutputSocket(unsigned int index) const;
- NodeOperationOutput *getOutputSocket() const
+ NodeOperationOutput *getOutputSocket(unsigned int index);
+ NodeOperationOutput *getOutputSocket()
{
return getOutputSocket(0);
}
- NodeOperationInput *getInputSocket(unsigned int index) const;
+ NodeOperationInput *getInputSocket(unsigned int index);
/** Check if this is an input operation
* An input operation is an operation that only has output sockets and no input sockets
@@ -430,7 +522,7 @@ class NodeOperation {
* Return the meta data associated with this branch.
*
* The return parameter holds an instance or is an nullptr. */
- virtual std::unique_ptr<MetaData> getMetaData() const
+ virtual std::unique_ptr<MetaData> getMetaData()
{
return std::unique_ptr<MetaData>();
}
@@ -529,96 +621,3 @@ class NodeOperation {
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
#endif
};
-
-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 */
- ResizeMode m_resizeMode;
-
- /** Connected output */
- NodeOperationOutput *m_link;
-
- public:
- NodeOperationInput(NodeOperation *op,
- DataType datatype,
- ResizeMode resizeMode = ResizeMode::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(ResizeMode resizeMode)
- {
- this->m_resizeMode = resizeMode;
- }
- ResizeMode 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
- * \param preferredResolution: the preferable resolution as no resolution could be determined
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
-#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
-#endif
-};
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cc b/source/blender/compositor/operations/COM_MultilayerImageOperation.cc
index 312bce55eea..844dae74cdd 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cc
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cc
@@ -49,7 +49,7 @@ ImBuf *MultilayerBaseOperation::getImBuf()
return nullptr;
}
-std::unique_ptr<MetaData> MultilayerColorOperation::getMetaData() const
+std::unique_ptr<MetaData> MultilayerColorOperation::getMetaData()
{
BLI_assert(this->m_buffer);
MetaDataExtractCallbackData callback_data = {nullptr};
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
index dceb57de140..cff9d606249 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
@@ -45,7 +45,7 @@ class MultilayerColorOperation : public MultilayerBaseOperation {
this->addOutputSocket(DataType::Color);
}
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
- std::unique_ptr<MetaData> getMetaData() const override;
+ std::unique_ptr<MetaData> getMetaData() override;
};
class MultilayerValueOperation : public MultilayerBaseOperation {
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cc b/source/blender/compositor/operations/COM_RenderLayersProg.cc
index c3d127473ae..27e27bcb06c 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cc
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cc
@@ -216,7 +216,7 @@ void RenderLayersProg::determineResolution(unsigned int resolution[2],
}
}
-std::unique_ptr<MetaData> RenderLayersProg::getMetaData() const
+std::unique_ptr<MetaData> RenderLayersProg::getMetaData()
{
Scene *scene = this->getScene();
Render *re = (scene) ? RE_GetSceneRender(scene) : nullptr;
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h
index f3e1c892a83..8c4bf90c878 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.h
@@ -123,7 +123,7 @@ class RenderLayersProg : public NodeOperation {
void deinitExecution() override;
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
- std::unique_ptr<MetaData> getMetaData() const override;
+ std::unique_ptr<MetaData> getMetaData() override;
};
class RenderLayersAOOperation : public RenderLayersProg {
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cc b/source/blender/compositor/operations/COM_SocketProxyOperation.cc
index 53f5fea8795..44e5a23b4c8 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.cc
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cc
@@ -25,7 +25,7 @@ SocketProxyOperation::SocketProxyOperation(DataType type, bool use_conversion)
this->addOutputSocket(type);
}
-std::unique_ptr<MetaData> SocketProxyOperation::getMetaData() const
+std::unique_ptr<MetaData> SocketProxyOperation::getMetaData()
{
return this->getInputSocket(0)->getReader()->getMetaData();
}
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h
index 712347a8ea2..fe38915bf84 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.h
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h
@@ -41,7 +41,7 @@ class SocketProxyOperation : public NodeOperation {
{
m_use_conversion = use_conversion;
}
- std::unique_ptr<MetaData> getMetaData() const override;
+ std::unique_ptr<MetaData> getMetaData() override;
private:
bool m_use_conversion;