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:
Diffstat (limited to 'source/blender/compositor/intern')
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.cpp3
-rw-r--r--source/blender/compositor/intern/COM_ChannelInfo.cpp3
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.cpp11
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp6
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.cpp9
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h10
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp13
-rw-r--r--source/blender/compositor/intern/COM_Converter.h6
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp100
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.h24
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.cpp61
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h10
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp65
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.h14
-rw-r--r--source/blender/compositor/intern/COM_InputSocket.cpp62
-rw-r--r--source/blender/compositor/intern/COM_InputSocket.h20
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp51
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h20
-rw-r--r--source/blender/compositor/intern/COM_MemoryManager.cpp20
-rw-r--r--source/blender/compositor/intern/COM_MemoryManager.h6
-rw-r--r--source/blender/compositor/intern/COM_MemoryManagerState.cpp19
-rw-r--r--source/blender/compositor/intern/COM_MemoryManagerState.h4
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.cpp6
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.h8
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp45
-rw-r--r--source/blender/compositor/intern/COM_Node.h28
-rw-r--r--source/blender/compositor/intern/COM_NodeBase.cpp48
-rw-r--r--source/blender/compositor/intern/COM_NodeBase.h14
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp41
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h12
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.cpp12
-rw-r--r--source/blender/compositor/intern/COM_OutputSocket.cpp48
-rw-r--r--source/blender/compositor/intern/COM_OutputSocket.h6
-rw-r--r--source/blender/compositor/intern/COM_Socket.cpp11
-rw-r--r--source/blender/compositor/intern/COM_Socket.h12
-rw-r--r--source/blender/compositor/intern/COM_SocketConnection.cpp29
-rw-r--r--source/blender/compositor/intern/COM_SocketConnection.h8
-rw-r--r--source/blender/compositor/intern/COM_SocketReader.h18
-rw-r--r--source/blender/compositor/intern/COM_WorkPackage.cpp3
-rw-r--r--source/blender/compositor/intern/COM_WorkPackage.h6
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp54
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.h6
-rw-r--r--source/blender/compositor/intern/COM_compositor.cpp5
43 files changed, 570 insertions, 387 deletions
diff --git a/source/blender/compositor/intern/COM_CPUDevice.cpp b/source/blender/compositor/intern/COM_CPUDevice.cpp
index 2e74fbf19b3..43ec892985a 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.cpp
+++ b/source/blender/compositor/intern/COM_CPUDevice.cpp
@@ -22,7 +22,8 @@
#include "COM_CPUDevice.h"
-void CPUDevice::execute(WorkPackage *work) {
+void CPUDevice::execute(WorkPackage *work)
+{
const unsigned int chunkNumber = work->getChunkNumber();
ExecutionGroup * executionGroup = work->getExecutionGroup();
rcti rect;
diff --git a/source/blender/compositor/intern/COM_ChannelInfo.cpp b/source/blender/compositor/intern/COM_ChannelInfo.cpp
index e945babe9c3..7dafee5f955 100644
--- a/source/blender/compositor/intern/COM_ChannelInfo.cpp
+++ b/source/blender/compositor/intern/COM_ChannelInfo.cpp
@@ -27,7 +27,8 @@
/**
* @brief create new ChannelInfo instance and sets the defaults.
*/
-ChannelInfo::ChannelInfo() {
+ChannelInfo::ChannelInfo()
+{
this->number = 0;
this->premultiplied = true;
this->type = COM_CT_UNUSED;
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.cpp b/source/blender/compositor/intern/COM_ChunkOrder.cpp
index 784b848a2f9..387e4a6ba70 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrder.cpp
@@ -23,18 +23,20 @@
#include "COM_ChunkOrder.h"
#include "BLI_math.h"
-ChunkOrder::ChunkOrder() {
+ChunkOrder::ChunkOrder()
+{
this->distance = 0.0;
this->number = 0;
this->x = 0;
this->y = 0;
}
-void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots) {
+void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots)
+{
unsigned int index;
double distance = MAXFLOAT;
for (index = 0 ; index < numberOfHotspots ; index ++) {
- ChunkOrderHotspot* hotspot = hotspots[index];
+ ChunkOrderHotspot *hotspot = hotspots[index];
double ndistance = hotspot->determineDistance(this->x, this->y);
if (ndistance < distance) {
distance = ndistance;
@@ -43,6 +45,7 @@ void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int nu
this->distance = distance;
}
-bool operator<(const ChunkOrder& a, const ChunkOrder& b) {
+bool operator<(const ChunkOrder& a, const ChunkOrder& b)
+{
return a.distance < b.distance;
}
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
index 11079878b4f..94110f0bcfe 100644
--- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
@@ -23,13 +23,15 @@
#include "COM_ChunkOrderHotspot.h"
#include <math.h>
-ChunkOrderHotspot::ChunkOrderHotspot(int x, int y, float addition) {
+ChunkOrderHotspot::ChunkOrderHotspot(int x, int y, float addition)
+{
this->x = x;
this->y = y;
this->addition = addition;
}
-double ChunkOrderHotspot::determineDistance(int x, int y) {
+double ChunkOrderHotspot::determineDistance(int x, int y)
+{
int dx = x-this->x;
int dy = y-this->y;
double result = sqrt((double)(dx*dx+dy*dy));
diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp
index abab4edfc3f..911de822f80 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.cpp
+++ b/source/blender/compositor/intern/COM_CompositorContext.cpp
@@ -24,13 +24,15 @@
#include "COM_defines.h"
#include <stdio.h>
-CompositorContext::CompositorContext() {
+CompositorContext::CompositorContext()
+{
this->scene = NULL;
this->quality = COM_QUALITY_HIGH;
this->hasActiveOpenCLDevices = false;
}
-const int CompositorContext::getFramenumber() const {
+const int CompositorContext::getFramenumber() const
+{
if (this->scene) {
return this->scene->r.cfra;
}
@@ -39,7 +41,8 @@ const int CompositorContext::getFramenumber() const {
}
}
-const int CompositorContext::isColorManaged() const {
+const int CompositorContext::isColorManaged() const
+{
if (this->scene) {
return this->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
}
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
index dc5b248f777..2889f43290e 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.h
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -55,14 +55,14 @@ private:
* This field is initialized in ExecutionSystem and must only be read from that point on.
* @see ExecutionSystem
*/
- Scene* scene;
+ Scene *scene;
/**
* @brief reference to the bNodeTree
* This field is initialized in ExecutionSystem and must only be read from that point on.
* @see ExecutionSystem
*/
- bNodeTree* bnodetree;
+ bNodeTree *bnodetree;
/**
* @brief does this system have active opencl devices?
@@ -88,12 +88,12 @@ public:
/**
* @brief set the scene of the context
*/
- void setScene(Scene* scene) {this->scene = scene;}
+ void setScene(Scene *scene) {this->scene = scene;}
/**
* @brief set the bnodetree of the context
*/
- void setbNodeTree(bNodeTree* bnodetree) {this->bnodetree = bnodetree;}
+ void setbNodeTree(bNodeTree *bnodetree) {this->bnodetree = bnodetree;}
/**
* @brief get the bnodetree of the context
@@ -103,7 +103,7 @@ public:
/**
* @brief get the scene of the context
*/
- const Scene* getScene() const {return this->scene;}
+ const Scene *getScene() const {return this->scene;}
/**
* @brief set the quality
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index ac57bf1cadc..3cb297801ca 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -112,7 +112,8 @@
#include "COM_DoubleEdgeMaskNode.h"
#include "COM_CropNode.h"
-Node* Converter::convert(bNode *bNode) {
+Node *Converter::convert(bNode *bNode)
+{
Node * node;
if (bNode->flag & NODE_MUTED) {
@@ -353,9 +354,10 @@ case CMP_NODE_OUTPUT_FILE:
}
return node;
}
-void Converter::convertDataType(SocketConnection* connection, ExecutionSystem *system) {
- OutputSocket* outputSocket = connection->getFromSocket();
- InputSocket* inputSocket = connection->getToSocket();
+void Converter::convertDataType(SocketConnection *connection, ExecutionSystem *system)
+{
+ OutputSocket *outputSocket = connection->getFromSocket();
+ InputSocket *inputSocket = connection->getToSocket();
DataType fromDatatype = outputSocket->getActualDataType();
DataType toDatatype = inputSocket->getActualDataType();
NodeOperation * converter = NULL;
@@ -384,7 +386,8 @@ void Converter::convertDataType(SocketConnection* connection, ExecutionSystem *s
}
}
-void Converter::convertResolution(SocketConnection *connection, ExecutionSystem *system) {
+void Converter::convertResolution(SocketConnection *connection, ExecutionSystem *system)
+{
InputSocketResizeMode mode = connection->getToSocket()->getResizeMode();
NodeOperation * toOperation = (NodeOperation*)connection->getToNode();
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
index f5144d1bfed..fa12be4e79a 100644
--- a/source/blender/compositor/intern/COM_Converter.h
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -42,7 +42,7 @@ public:
* @see Node
* @see MuteNode
*/
- static Node* convert(bNode* bNode);
+ static Node *convert(bNode *bNode);
/**
* @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.
@@ -53,7 +53,7 @@ public:
* @param system the ExecutionSystem to add the conversion to.
* @see SocketConnection - a link between two sockets
*/
- static void convertDataType(SocketConnection* connection, ExecutionSystem *system);
+ static void convertDataType(SocketConnection *connection, ExecutionSystem *system);
/**
* @brief This method will add a resolution rule based on the settings of the InputSocket.
@@ -65,6 +65,6 @@ public:
* @param system the ExecutionSystem to add the conversion to.
* @see SocketConnection - a link between two sockets
*/
- static void convertResolution(SocketConnection* connection, ExecutionSystem *system);
+ static void convertResolution(SocketConnection *connection, ExecutionSystem *system);
};
#endif
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index bce31658a8d..e4fefa6a904 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -41,7 +41,8 @@
#include "BLI_math.h"
#include "COM_ExecutionSystemHelper.h"
-ExecutionGroup::ExecutionGroup() {
+ExecutionGroup::ExecutionGroup()
+{
this->isOutput = false;
this->complex = false;
this->chunkExecutionStates = NULL;
@@ -57,13 +58,15 @@ ExecutionGroup::ExecutionGroup() {
this->chunksFinished = 0;
}
-int ExecutionGroup::getRenderPriotrity() {
+int ExecutionGroup::getRenderPriotrity()
+{
return this->getOutputNodeOperation()->getRenderPriority();
}
-bool ExecutionGroup::containsOperation(NodeOperation* operation) {
+bool ExecutionGroup::containsOperation(NodeOperation *operation)
+{
for (vector<NodeOperation*>::const_iterator iterator = this->operations.begin() ; iterator != this->operations.end() ; ++iterator) {
- NodeOperation* inListOperation = *iterator;
+ NodeOperation *inListOperation = *iterator;
if (inListOperation == operation) {
return true;
}
@@ -71,11 +74,13 @@ bool ExecutionGroup::containsOperation(NodeOperation* operation) {
return false;
}
-const bool ExecutionGroup::isComplex() const {
+const bool ExecutionGroup::isComplex() const
+{
return this->complex;
}
-bool ExecutionGroup::canContainOperation(NodeOperation* operation) {
+bool ExecutionGroup::canContainOperation(NodeOperation *operation)
+{
if (!this->initialized) {return true;}
if (operation->isReadBufferOperation()) {return true;}
if (operation->isWriteBufferOperation()) {return false;}
@@ -89,7 +94,8 @@ bool ExecutionGroup::canContainOperation(NodeOperation* operation) {
}
}
-void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operation) {
+void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operation)
+{
if (containsOperation(operation)) return;
if (canContainOperation(operation)) {
if (!operation->isBufferOperation()) {
@@ -99,8 +105,8 @@ void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operat
}
this->operations.push_back(operation);
if (operation->isReadBufferOperation()) {
- ReadBufferOperation* readOperation = (ReadBufferOperation*)operation;
- WriteBufferOperation* writeOperation = readOperation->getMemoryProxy()->getWriteBufferOperation();
+ ReadBufferOperation *readOperation = (ReadBufferOperation*)operation;
+ WriteBufferOperation *writeOperation = readOperation->getMemoryProxy()->getWriteBufferOperation();
this->addOperation(system, writeOperation);
}
else {
@@ -108,7 +114,7 @@ void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operat
for (index = 0 ; index < operation->getNumberOfInputSockets(); index ++) {
InputSocket * inputSocket = operation->getInputSocket(index);
if (inputSocket->isConnected()) {
- NodeOperation* node = (NodeOperation*)inputSocket->getConnection()->getFromNode();
+ NodeOperation *node = (NodeOperation*)inputSocket->getConnection()->getFromNode();
this->addOperation(system, node);
}
}
@@ -118,7 +124,7 @@ void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operat
if (operation->isWriteBufferOperation()) {
WriteBufferOperation * writeoperation = (WriteBufferOperation*)operation;
if (writeoperation->getMemoryProxy()->getExecutor() == NULL) {
- ExecutionGroup* newGroup = new ExecutionGroup();
+ ExecutionGroup *newGroup = new ExecutionGroup();
writeoperation->getMemoryProxy()->setExecutor(newGroup);
newGroup->addOperation(system, operation);
ExecutionSystemHelper::addExecutionGroup(system->getExecutionGroups(), newGroup);
@@ -127,7 +133,8 @@ void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operat
}
}
-NodeOperation* ExecutionGroup::getOutputNodeOperation() const {
+NodeOperation *ExecutionGroup::getOutputNodeOperation() const
+{
return this->operations[0]; // the first operation of the group is always the output operation.
}
@@ -151,7 +158,7 @@ void ExecutionGroup::initExecution()
unsigned int maxNumber = 0;
for (index = 0 ; index < this->operations.size(); index ++) {
- NodeOperation* operation = this->operations[index];
+ NodeOperation *operation = this->operations[index];
if (operation->isReadBufferOperation()) {
ReadBufferOperation *readOperation = (ReadBufferOperation*)operation;
this->cachedReadOperations.push_back(readOperation);
@@ -163,7 +170,8 @@ void ExecutionGroup::initExecution()
}
-void ExecutionGroup::deinitExecution() {
+void ExecutionGroup::deinitExecution()
+{
if (this->chunkExecutionStates != NULL) {
delete[] this->chunkExecutionStates;
this->chunkExecutionStates = NULL;
@@ -174,8 +182,9 @@ void ExecutionGroup::deinitExecution() {
this->cachedReadOperations.clear();
this->bTree = NULL;
}
-void ExecutionGroup::determineResolution(unsigned int resolution[]) {
- NodeOperation* operation = this->getOutputNodeOperation();
+void ExecutionGroup::determineResolution(unsigned int resolution[])
+{
+ NodeOperation *operation = this->getOutputNodeOperation();
unsigned int preferredResolution[2];
preferredResolution[0] = 0;
preferredResolution[1] = 0;
@@ -184,7 +193,8 @@ void ExecutionGroup::determineResolution(unsigned int resolution[]) {
this->setResolution(resolution);
}
-void ExecutionGroup::determineNumberOfChunks() {
+void ExecutionGroup::determineNumberOfChunks()
+{
const float chunkSizef = this->chunkSize;
this->numberOfXChunks = ceil(this->width / chunkSizef);
this->numberOfYChunks = ceil(this->height / chunkSizef);
@@ -194,9 +204,10 @@ void ExecutionGroup::determineNumberOfChunks() {
/**
* this method is called for the top execution groups. containing the compositor node or the preview node or the viewer node)
*/
-void ExecutionGroup::execute(ExecutionSystem* graph) {
+void ExecutionGroup::execute(ExecutionSystem *graph)
+{
CompositorContext& context = graph->getContext();
- const bNodeTree* bTree = context.getbNodeTree();
+ const bNodeTree *bTree = context.getbNodeTree();
if (this->width == 0 || this->height == 0) {return;} /// @note: break out... no pixels to calculate.
if (bTree->test_break && bTree->test_break(bTree->tbh)) {return;} /// @note: early break out for blur and preview nodes
if (this->numberOfChunks == 0) {return;} /// @note: early break out
@@ -216,7 +227,7 @@ void ExecutionGroup::execute(ExecutionSystem* graph) {
int chunkorder = COM_TO_CENTER_OUT;
if (operation->isViewerOperation()) {
- ViewerBaseOperation* viewer = (ViewerBaseOperation*)operation;
+ ViewerBaseOperation *viewer = (ViewerBaseOperation*)operation;
centerX = viewer->getCenterX();
centerY = viewer->getCenterY();
chunkorder = viewer->getChunkOrder();
@@ -224,7 +235,7 @@ void ExecutionGroup::execute(ExecutionSystem* graph) {
switch (chunkorder) {
case COM_TO_RANDOM:
- for (index = 0 ; index < 2* numberOfChunks ; index ++) {
+ for (index = 0 ; index < 2 * numberOfChunks ; index ++) {
int index1 = rand()%numberOfChunks;
int index2 = rand()%numberOfChunks;
int s = chunkOrder[index1];
@@ -351,7 +362,8 @@ void ExecutionGroup::execute(ExecutionSystem* graph) {
delete[] chunkOrder;
}
-MemoryBuffer** ExecutionGroup::getInputBuffers(int chunkNumber) {
+MemoryBuffer** ExecutionGroup::getInputBuffers(int chunkNumber)
+{
rcti rect;
vector<MemoryProxy*> memoryproxies;
unsigned int index;
@@ -359,7 +371,7 @@ MemoryBuffer** ExecutionGroup::getInputBuffers(int chunkNumber) {
this->determineDependingMemoryProxies(&memoryproxies);
MemoryBuffer **memoryBuffers = new MemoryBuffer*[this->cachedMaxReadBufferOffset];
- for (index= 0 ; index < this->cachedMaxReadBufferOffset ; index ++) {
+ for (index = 0 ; index < this->cachedMaxReadBufferOffset ; index ++) {
memoryBuffers[index] = NULL;
}
rcti output;
@@ -367,13 +379,14 @@ MemoryBuffer** ExecutionGroup::getInputBuffers(int chunkNumber) {
ReadBufferOperation *readOperation = (ReadBufferOperation*)this->cachedReadOperations[index];
MemoryProxy * memoryProxy = readOperation->getMemoryProxy();
this->determineDependingAreaOfInterest(&rect, readOperation, &output);
- MemoryBuffer* memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(memoryProxy, &output);
+ MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(memoryProxy, &output);
memoryBuffers[readOperation->getOffset()] = memoryBuffer;
}
return memoryBuffers;
}
-MemoryBuffer* ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *rect) {
+MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *rect)
+{
// find all chunks inside the rect
// determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers
float chunkSizef = this->chunkSize;
@@ -415,7 +428,8 @@ MemoryBuffer* ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *mem
return result;
}
-void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer** memoryBuffers) {
+void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer** memoryBuffers)
+{
if (this->chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED)
this->chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED;
else
@@ -442,31 +456,35 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer** memo
}
}
-inline void ExecutionGroup::determineChunkRect(rcti* rect, const unsigned int xChunk, const unsigned int yChunk ) const {
+inline void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk ) const
+{
const unsigned int minx = xChunk * chunkSize;
const unsigned int miny = yChunk * chunkSize;
BLI_init_rcti(rect, minx, min(minx + this->chunkSize, this->width), miny, min(miny + this->chunkSize, this->height));
}
-void ExecutionGroup::determineChunkRect(rcti* rect, const unsigned int chunkNumber) const {
+void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int chunkNumber) const
+{
const unsigned int yChunk = chunkNumber / numberOfXChunks;
const unsigned int xChunk = chunkNumber - (yChunk * numberOfXChunks);
determineChunkRect(rect, xChunk, yChunk);
}
-MemoryBuffer* ExecutionGroup::allocateOutputBuffer(int chunkNumber, rcti* rect) {
- MemoryBuffer* outputBuffer = NULL;
+MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int chunkNumber, rcti *rect)
+{
+ MemoryBuffer *outputBuffer = NULL;
// output allocation is only valid when our outputoperation is a memorywriter
NodeOperation * operation = this->getOutputNodeOperation();
if (operation->isWriteBufferOperation()) {
- WriteBufferOperation* writeOperation = (WriteBufferOperation*)operation;
+ WriteBufferOperation *writeOperation = (WriteBufferOperation*)operation;
outputBuffer = MemoryManager::allocateMemoryBuffer(writeOperation->getMemoryProxy(), chunkNumber, rect);
}
return outputBuffer;
}
-bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem * graph, rcti *area) {
+bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem * graph, rcti *area)
+{
// find all chunks inside the rect
// determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers
@@ -490,7 +508,8 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem * graph, rcti *are
return result;
}
-bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber) {
+bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber)
+{
if (this->chunkExecutionStates[chunkNumber] == COM_ES_NOT_SCHEDULED) {
this->chunkExecutionStates[chunkNumber] = COM_ES_SCHEDULED;
WorkScheduler::schedule(this, chunkNumber);
@@ -499,7 +518,8 @@ bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber) {
return false;
}
-bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem * graph, int xChunk, int yChunk) {
+bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem * graph, int xChunk, int yChunk)
+{
if (xChunk < 0 || xChunk >= (int)this->numberOfXChunks) {
return true;
}
@@ -551,11 +571,13 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem * graph, int xChu
return false;
}
-void ExecutionGroup::determineDependingAreaOfInterest(rcti * input, ReadBufferOperation* readOperation, rcti* output) {
+void ExecutionGroup::determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output)
+{
this->getOutputNodeOperation()->determineDependingAreaOfInterest(input, readOperation, output);
}
-void ExecutionGroup::determineDependingMemoryProxies(vector<MemoryProxy*> *memoryProxies) {
+void ExecutionGroup::determineDependingMemoryProxies(vector<MemoryProxy*> *memoryProxies)
+{
unsigned int index;
for (index = 0 ; index < this->cachedReadOperations.size() ; index ++) {
ReadBufferOperation * readOperation = (ReadBufferOperation*) this->cachedReadOperations[index];
@@ -563,10 +585,12 @@ void ExecutionGroup::determineDependingMemoryProxies(vector<MemoryProxy*> *memor
}
}
-bool ExecutionGroup::operator ==(const ExecutionGroup & executionGroup) const {
+bool ExecutionGroup::operator ==(const ExecutionGroup & executionGroup) const
+{
return this->getOutputNodeOperation() == executionGroup.getOutputNodeOperation();
}
-bool ExecutionGroup::isOpenCL() {
+bool ExecutionGroup::isOpenCL()
+{
return this->openCL;
}
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
index 2d5e0965297..adab7df4690 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -166,7 +166,7 @@ private:
* @brief check whether parameter operation can be added to the execution group
* @param operation the operation to be added
*/
- bool canContainOperation(NodeOperation* operation);
+ bool canContainOperation(NodeOperation *operation);
/**
* @brief get the Render priority of this ExecutionGroup
@@ -188,7 +188,7 @@ private:
* @note Only gives usefull results ater the determination of the chunksize
* @see determineChunkSize()
*/
- void determineChunkRect(rcti* rect, const unsigned int xChunk, const unsigned int yChunk) const;
+ 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.
@@ -233,7 +233,7 @@ private:
* @param readOperation The ReadBufferOperation where the area needs to be evaluated
* @param output the area needed of the ReadBufferOperation. Result
*/
- void determineDependingAreaOfInterest(rcti * input, ReadBufferOperation* readOperation, rcti* output);
+ void determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output);
public:
@@ -257,7 +257,7 @@ public:
* @param operation the NodeOperation to check
* @return [true,false]
*/
- bool containsOperation(NodeOperation* operation);
+ bool containsOperation(NodeOperation *operation);
/**
* @brief add an operation to this ExecutionGroup
@@ -266,7 +266,7 @@ public:
* @param system
* @param operation
*/
- void addOperation(ExecutionSystem* system, NodeOperation *operation);
+ void addOperation(ExecutionSystem *system, NodeOperation *operation);
/**
* @brief is this ExecutionGroup an output ExecutionGroup
@@ -312,15 +312,15 @@ public:
/**
* @brief get the output operation of this ExecutionGroup
- * @return NodeOperation* output operation
+ * @return NodeOperation *output operation
*/
- NodeOperation* getOutputNodeOperation() const;
+ NodeOperation *getOutputNodeOperation() const;
/**
* @brief compose multiple chunks into a single chunk
- * @return Memorybuffer* consolidated chunk
+ * @return Memorybuffer *consolidated chunk
*/
- MemoryBuffer* constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *output);
+ MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *output);
/**
* @brief initExecution is called just before the execution of the whole graph will be done.
@@ -342,7 +342,7 @@ public:
* @param rect the rect of that chunk
* @see determineChunkRect
*/
- MemoryBuffer* allocateOutputBuffer(int chunkNumber, rcti *rect);
+ MemoryBuffer *allocateOutputBuffer(int chunkNumber, rcti *rect);
/**
* @brief after a chunk is executed the needed resources can be freed or unlocked.
@@ -372,7 +372,7 @@ public:
* @see ViewerOperation
* @param system
*/
- void execute(ExecutionSystem* system);
+ void execute(ExecutionSystem *system);
/**
* @brief this method determines the MemoryProxy's where this execution group depends on.
@@ -387,7 +387,7 @@ public:
* @note Only gives usefull results ater the determination of the chunksize
* @see determineChunkSize()
*/
- void determineChunkRect(rcti* rect, const unsigned int chunkNumber) const;
+ void determineChunkRect(rcti *rect, const unsigned int chunkNumber) const;
bool operator ==(const ExecutionGroup &executionGroup) const;
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
index b66a6a036b5..84b5bb8f5fc 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
@@ -40,7 +40,8 @@
#include "BKE_global.h"
-ExecutionSystem::ExecutionSystem(bNodeTree* editingtree, bool rendering) {
+ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering)
+{
this->context.setbNodeTree(editingtree);
/* initialize the CompositorContext */
@@ -53,7 +54,7 @@ ExecutionSystem::ExecutionSystem(bNodeTree* editingtree, bool rendering) {
context.setRendering(rendering);
context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL));
- Node* mainOutputNode=NULL;
+ Node *mainOutputNode=NULL;
mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree);
@@ -68,7 +69,7 @@ ExecutionSystem::ExecutionSystem(bNodeTree* editingtree, bool rendering) {
for (index = 0 ; index < executionGroups.size(); index ++) {
resolution[0]=0;
resolution[1]=0;
- ExecutionGroup* executionGroup = executionGroups[index];
+ ExecutionGroup *executionGroup = executionGroups[index];
executionGroup->determineResolution(resolution);
}
}
@@ -76,34 +77,36 @@ ExecutionSystem::ExecutionSystem(bNodeTree* editingtree, bool rendering) {
if (G.f & G_DEBUG) ExecutionSystemHelper::debugDump(this);
}
-ExecutionSystem::~ExecutionSystem() {
+ExecutionSystem::~ExecutionSystem()
+{
unsigned int index;
for (index = 0; index < this->connections.size(); index++) {
- SocketConnection* connection = this->connections[index];
+ SocketConnection *connection = this->connections[index];
delete connection;
}
this->connections.clear();
for (index = 0; index < this->nodes.size(); index++) {
- Node* node = this->nodes[index];
+ Node *node = this->nodes[index];
delete node;
}
this->nodes.clear();
for (index = 0; index < this->operations.size(); index++) {
- NodeOperation* operation = this->operations[index];
+ NodeOperation *operation = this->operations[index];
delete operation;
}
this->operations.clear();
for (index = 0; index < this->groups.size(); index++) {
- ExecutionGroup* group = this->groups[index];
+ ExecutionGroup *group = this->groups[index];
delete group;
}
this->groups.clear();
}
-void ExecutionSystem::execute() {
+void ExecutionSystem::execute()
+{
unsigned int order = 0;
for ( vector<NodeOperation*>::iterator iter = this->operations.begin(); iter != operations.end(); ++iter ) {
- NodeBase* node = *iter;
+ NodeBase *node = *iter;
NodeOperation *operation = (NodeOperation*) node;
if (operation->isReadBufferOperation()) {
ReadBufferOperation * readOperation = (ReadBufferOperation*)operation;
@@ -134,8 +137,8 @@ void ExecutionSystem::execute() {
/* start execution of the ExecutionGroups based on priority of their output node */
for (int priority = 9 ; priority>=0 ; priority--) {
for (index = 0 ; index < executionGroups.size(); index ++) {
- ExecutionGroup* group = executionGroups[index];
- NodeOperation* output = group->getOutputNodeOperation();
+ ExecutionGroup *group = executionGroups[index];
+ NodeOperation *output = group->getOutputNodeOperation();
if (output->getRenderPriority() == priority) {
group->execute(this);
}
@@ -156,19 +159,21 @@ void ExecutionSystem::execute() {
MemoryManager::clear();
}
-void ExecutionSystem::addOperation(NodeOperation *operation) {
+void ExecutionSystem::addOperation(NodeOperation *operation)
+{
ExecutionSystemHelper::addOperation(this->operations, operation);
}
-void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) {
+void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation)
+{
// for every input add write and read operation if input is not a read operation
// only add read operation to other links when they are attached to buffered operations.
unsigned int index;
for (index = 0 ; index < operation->getNumberOfInputSockets();index++) {
- InputSocket* inputsocket = operation->getInputSocket(index);
+ InputSocket *inputsocket = operation->getInputSocket(index);
if (inputsocket->isConnected()) {
SocketConnection *connection = inputsocket->getConnection();
- NodeOperation* otherEnd = (NodeOperation*)connection->getFromNode();
+ NodeOperation *otherEnd = (NodeOperation*)connection->getFromNode();
if (!otherEnd->isReadBufferOperation()) {
// check of other end already has write operation
OutputSocket *fromsocket = connection->getFromSocket();
@@ -201,7 +206,7 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) {
this->addOperation(writeOperation);
for (index = 0 ; index < outputsocket->getNumberOfConnections();index ++) {
SocketConnection * connection = outputsocket->getConnection(index);
- ReadBufferOperation* readoperation = new ReadBufferOperation();
+ ReadBufferOperation *readoperation = new ReadBufferOperation();
readoperation->setMemoryProxy(writeOperation->getMemoryProxy());
connection->setFromSocket(readoperation->getOutputSocket());
readoperation->getOutputSocket()->addConnection(connection);
@@ -211,12 +216,13 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) {
}
}
-void ExecutionSystem::convertToOperations() {
+void ExecutionSystem::convertToOperations()
+{
unsigned int index;
// first determine data types of the nodes, this can be used by the node to convert to a different operation system
this->determineActualSocketDataTypes((vector<NodeBase*>&)this->nodes);
for (index = 0; index < this->nodes.size(); index++) {
- Node* node = (Node*)this->nodes[index];
+ Node *node = (Node*)this->nodes[index];
node->convertToOperations(this, &this->context);
}
@@ -233,7 +239,7 @@ void ExecutionSystem::convertToOperations() {
// determine all resolutions of the operations (Width/Height)
for (index = 0 ; index < this->operations.size(); index ++) {
- NodeOperation* operation= this->operations[index];
+ NodeOperation *operation = this->operations[index];
if (operation->isOutputOperation(context.isRendering())) {
unsigned int resolution[2] = {0,0};
unsigned int preferredResolution[2] = {0,0};
@@ -254,7 +260,8 @@ void ExecutionSystem::convertToOperations() {
}
-void ExecutionSystem::groupOperations() {
+void ExecutionSystem::groupOperations()
+{
vector<NodeOperation*> outputOperations;
NodeOperation * operation;
unsigned int index;
@@ -281,11 +288,12 @@ void ExecutionSystem::addSocketConnection(SocketConnection *connection)
}
-void ExecutionSystem::determineActualSocketDataTypes(vector<NodeBase*> &nodes) {
+void ExecutionSystem::determineActualSocketDataTypes(vector<NodeBase*> &nodes)
+{
unsigned int index;
/* first do all input nodes */
for (index = 0; index < nodes.size(); index++) {
- NodeBase* node = nodes[index];
+ NodeBase *node = nodes[index];
if (node->isInputNode()) {
node->determineActualSocketDataTypes();
}
@@ -293,17 +301,18 @@ void ExecutionSystem::determineActualSocketDataTypes(vector<NodeBase*> &nodes) {
/* then all other nodes */
for (index = 0; index < nodes.size(); index++) {
- NodeBase* node = nodes[index];
+ NodeBase *node = nodes[index];
if (!node->isInputNode()) {
node->determineActualSocketDataTypes();
}
}
}
-void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup*> *result) const {
+void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup*> *result) const
+{
unsigned int index;
for (index = 0 ; index < this->groups.size() ; index ++) {
- ExecutionGroup* group = this->groups[index];
+ ExecutionGroup *group = this->groups[index];
if (group->isOutputExecutionGroup()) {
result->push_back(group);
}
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 7d0830491f3..85fec8b6145 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -135,7 +135,7 @@ private: //methods
* @brief add ReadBufferOperation and WriteBufferOperation around an operation
* @param operation the operation to add the bufferoperations around.
*/
- void addReadWriteBufferOperations(NodeOperation* operation);
+ void addReadWriteBufferOperations(NodeOperation *operation);
/**
@@ -151,7 +151,7 @@ public:
* @param editingtree [bNodeTree*]
* @param rendering [true false]
*/
- ExecutionSystem(bNodeTree* editingtree, bool rendering);
+ ExecutionSystem(bNodeTree *editingtree, bool rendering);
/**
* Destructor
@@ -172,14 +172,14 @@ public:
*
* @param operation the operation to add
*/
- void addOperation(NodeOperation* operation);
+ void addOperation(NodeOperation *operation);
/**
* Add an editor link to the system. convert it to an socketconnection (CPP-representative)
* this converted socket is returned.
*/
- SocketConnection* addNodeLink(bNodeLink* bNodeLink);
- void addSocketConnection(SocketConnection* connection);
+ SocketConnection *addNodeLink(bNodeLink *bNodeLink);
+ void addSocketConnection(SocketConnection *connection);
/**
* @brief Convert all nodes to operations
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
index 4a739ba6a9d..94376f73de9 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
@@ -37,14 +37,15 @@
#include "COM_WriteBufferOperation.h"
#include "COM_ReadBufferOperation.h"
-Node* ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree) {
+Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree)
+{
vector<Node*>& nodes = system.getNodes();
vector<SocketConnection*>& links = system.getConnections();
- Node* mainnode = NULL;
+ Node *mainnode = NULL;
/* add all nodes of the tree to the node list */
- bNode* node = (bNode*)tree->nodes.first;
+ bNode *node = (bNode*)tree->nodes.first;
while (node != NULL) {
- Node* execnode = addNode(nodes, node);
+ Node *execnode = addNode(nodes, node);
if (node->type == CMP_NODE_COMPOSITE) {
mainnode = execnode;
}
@@ -54,7 +55,7 @@ Node* ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_sta
NodeRange node_range(nodes.begin()+nodes_start, nodes.end());
/* add all nodelinks of the tree to the link list */
- bNodeLink* nodelink = (bNodeLink*)tree->links.first;
+ bNodeLink *nodelink = (bNodeLink*)tree->links.first;
while (nodelink != NULL) {
addNodeLink(node_range, links, nodelink);
nodelink = (bNodeLink*)nodelink->next;
@@ -72,11 +73,13 @@ Node* ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_sta
return mainnode;
}
-void ExecutionSystemHelper::addNode(vector<Node*>& nodes, Node *node) {
+void ExecutionSystemHelper::addNode(vector<Node*>& nodes, Node *node)
+{
nodes.push_back(node);
}
-Node* ExecutionSystemHelper::addNode(vector<Node*>& nodes, bNode *bNode) {
+Node *ExecutionSystemHelper::addNode(vector<Node*>& nodes, bNode *bNode)
+{
Converter converter;
Node * node;
node = converter.convert(bNode);
@@ -86,36 +89,40 @@ Node* ExecutionSystemHelper::addNode(vector<Node*>& nodes, bNode *bNode) {
}
return NULL;
}
-void ExecutionSystemHelper::addOperation(vector<NodeOperation*>& operations, NodeOperation *operation) {
+void ExecutionSystemHelper::addOperation(vector<NodeOperation*>& operations, NodeOperation *operation)
+{
operations.push_back(operation);
}
-void ExecutionSystemHelper::addExecutionGroup(vector<ExecutionGroup*>& executionGroups, ExecutionGroup *executionGroup) {
+void ExecutionSystemHelper::addExecutionGroup(vector<ExecutionGroup*>& executionGroups, ExecutionGroup *executionGroup)
+{
executionGroups.push_back(executionGroup);
}
-void ExecutionSystemHelper::findOutputNodeOperations(vector<NodeOperation*>* result, vector<NodeOperation*>& operations, bool rendering) {
+void ExecutionSystemHelper::findOutputNodeOperations(vector<NodeOperation*>* result, vector<NodeOperation*>& operations, bool rendering)
+{
unsigned int index;
for (index = 0 ; index < operations.size() ; index ++) {
- NodeOperation* operation = operations[index];
+ NodeOperation *operation = operations[index];
if (operation->isOutputOperation(rendering)) {
result->push_back(operation);
- }
+ }
}
}
-static InputSocket* find_input(NodeRange &node_range, bNode *bnode, bNodeSocket* bsocket) {
+static InputSocket *find_input(NodeRange &node_range, bNode *bnode, bNodeSocket *bsocket)
+{
if (bnode != NULL) {
for (NodeIterator it=node_range.first; it!=node_range.second; ++it) {
- Node* node = *it;
+ Node *node = *it;
if (node->getbNode() == bnode)
return node->findInputSocketBybNodeSocket(bsocket);
}
}
else {
for (NodeIterator it=node_range.first; it!=node_range.second; ++it) {
- Node* node = *it;
+ Node *node = *it;
if (node->isProxyNode()) {
InputSocket *proxySocket = node->getInputSocket(0);
if (proxySocket->getbNodeSocket()==bsocket)
@@ -125,17 +132,18 @@ static InputSocket* find_input(NodeRange &node_range, bNode *bnode, bNodeSocket*
}
return NULL;
}
-static OutputSocket* find_output(NodeRange &node_range, bNode *bnode, bNodeSocket* bsocket) {
+static OutputSocket *find_output(NodeRange &node_range, bNode *bnode, bNodeSocket *bsocket)
+{
if (bnode != NULL) {
for (NodeIterator it=node_range.first; it!=node_range.second; ++it) {
- Node* node = *it;
+ Node *node = *it;
if (node->getbNode() == bnode)
return node->findOutputSocketBybNodeSocket(bsocket);
}
}
else {
for (NodeIterator it=node_range.first; it!=node_range.second; ++it) {
- Node* node = *it;
+ Node *node = *it;
if (node->isProxyNode()) {
OutputSocket *proxySocket = node->getOutputSocket(0);
if (proxySocket->getbNodeSocket()==bsocket)
@@ -145,7 +153,8 @@ static OutputSocket* find_output(NodeRange &node_range, bNode *bnode, bNodeSocke
}
return NULL;
}
-SocketConnection* ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection*>& links, bNodeLink *bNodeLink) {
+SocketConnection *ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection*>& links, bNodeLink *bNodeLink)
+{
/// @note: cyclic lines will be ignored. This has been copied from node.c
if (bNodeLink->tonode != 0 && bNodeLink->fromnode != 0) {
if (!(bNodeLink->fromnode->level >= bNodeLink->tonode->level && bNodeLink->tonode->level!=0xFFF)) { // only add non cyclic lines! so execution will procede
@@ -161,11 +170,12 @@ SocketConnection* ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vect
if (inputSocket->isConnected()) {
return NULL;
}
- SocketConnection* connection = addLink(links, outputSocket, inputSocket);
+ SocketConnection *connection = addLink(links, outputSocket, inputSocket);
return connection;
}
-SocketConnection* ExecutionSystemHelper::addLink(vector<SocketConnection*>& links, OutputSocket* fromSocket, InputSocket* toSocket) {
+SocketConnection *ExecutionSystemHelper::addLink(vector<SocketConnection*>& links, OutputSocket *fromSocket, InputSocket *toSocket)
+{
SocketConnection * newconnection = new SocketConnection();
newconnection->setFromSocket(fromSocket);
newconnection->setToSocket(toSocket);
@@ -175,11 +185,12 @@ SocketConnection* ExecutionSystemHelper::addLink(vector<SocketConnection*>& link
return newconnection;
}
-void ExecutionSystemHelper::debugDump(ExecutionSystem* system) {
- Node* node;
- NodeOperation* operation;
- ExecutionGroup* group;
- SocketConnection* connection;
+void ExecutionSystemHelper::debugDump(ExecutionSystem *system)
+{
+ Node *node;
+ NodeOperation *operation;
+ ExecutionGroup *group;
+ SocketConnection *connection;
int tot, tot2;
printf("-- BEGIN COMPOSITOR DUMP --\r\n");
printf("digraph compositorexecution {\r\n");
@@ -283,7 +294,7 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem* system) {
operation = system->getOperations()[i];
if (operation->isReadBufferOperation()) {
ReadBufferOperation * read = (ReadBufferOperation*)operation;
- WriteBufferOperation * write= read->getMemoryProxy()->getWriteBufferOperation();
+ WriteBufferOperation * write = read->getMemoryProxy()->getWriteBufferOperation();
printf("\t\"O_%p\" -> \"O_%p\" [style=dotted]\r\n", write, read);
}
}
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h
index e6b11c4043f..a72e269115e 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h
@@ -48,7 +48,7 @@ public:
* @param tree bNodeTree to add
* @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added
*/
- static Node* addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree * tree);
+ static Node *addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree * tree);
/**
* @brief add an editor node to the system.
@@ -58,7 +58,7 @@ public:
* @param bNode node to add
* @return Node that represents the bNode or null when not able to convert.
*/
- static Node* addNode(vector<Node*>& nodes, bNode* bNode);
+ static Node *addNode(vector<Node*>& nodes, bNode *bNode);
/**
* @brief Add a Node to a list
@@ -66,7 +66,7 @@ public:
* @param nodes the list where the node needs to be added to
* @param node the node to be added
*/
- static void addNode(vector<Node*>& nodes, Node* node);
+ static void addNode(vector<Node*>& nodes, Node *node);
/**
* @brief Add an operation to the operation list
@@ -76,7 +76,7 @@ public:
* @param operations the list where the operation need to be added to
* @param operation the operation to add
*/
- static void addOperation(vector<NodeOperation*> &operations, NodeOperation* operation);
+ static void addOperation(vector<NodeOperation*> &operations, NodeOperation *operation);
/**
* @brief Add an ExecutionGroup to a list
@@ -107,7 +107,7 @@ public:
* @param bNodeLink the link to be added
* @return the created SocketConnection or NULL
*/
- static SocketConnection* addNodeLink(NodeRange &node_range, vector<SocketConnection*>& links, bNodeLink *bNodeLink);
+ static SocketConnection *addNodeLink(NodeRange &node_range, vector<SocketConnection*>& links, bNodeLink *bNodeLink);
/**
* @brief create a new SocketConnection and add to a vector of links
@@ -116,12 +116,12 @@ public:
* @param toSocket the endpoint of the connection
* @return the new created SocketConnection
*/
- static SocketConnection* addLink(vector<SocketConnection*>& links, OutputSocket* fromSocket, InputSocket* toSocket);
+ static SocketConnection *addLink(vector<SocketConnection*>& links, OutputSocket *fromSocket, InputSocket *toSocket);
/**
* @brief dumps the content of the execution system to standard out
* @param system the execution system to dump
*/
- static void debugDump(ExecutionSystem* system);
+ static void debugDump(ExecutionSystem *system);
};
#endif
diff --git a/source/blender/compositor/intern/COM_InputSocket.cpp b/source/blender/compositor/intern/COM_InputSocket.cpp
index 8428544cbc2..881aa58ec6b 100644
--- a/source/blender/compositor/intern/COM_InputSocket.cpp
+++ b/source/blender/compositor/intern/COM_InputSocket.cpp
@@ -25,16 +25,19 @@
#include "COM_SocketConnection.h"
#include "COM_ExecutionSystem.h"
-InputSocket::InputSocket(DataType datatype) :Socket(datatype) {
+InputSocket::InputSocket(DataType datatype) :Socket(datatype)
+{
this->connection = NULL;
this->resizeMode = COM_SC_CENTER;
}
-InputSocket::InputSocket(DataType datatype, InputSocketResizeMode resizeMode) :Socket(datatype) {
+InputSocket::InputSocket(DataType datatype, InputSocketResizeMode resizeMode) :Socket(datatype)
+{
this->connection = NULL;
this->resizeMode = resizeMode;
}
-InputSocket::InputSocket(InputSocket* from) :Socket(from->getDataType()) {
+InputSocket::InputSocket(InputSocket *from) :Socket(from->getDataType())
+{
this->connection = NULL;
this->resizeMode = from->getResizeMode();
}
@@ -42,12 +45,17 @@ InputSocket::InputSocket(InputSocket* from) :Socket(from->getDataType()) {
int InputSocket::isInputSocket() const { return true; }
const int InputSocket::isConnected() const { return this->connection != NULL; }
-void InputSocket::setConnection(SocketConnection *connection) {
+void InputSocket::setConnection(SocketConnection *connection)
+{
this->connection = connection;
}
-SocketConnection* InputSocket::getConnection() {return this->connection;}
+SocketConnection *InputSocket::getConnection()
+{
+ return this->connection;
+}
-void InputSocket::determineResolution(unsigned int resolution[],unsigned int preferredResolution[]) {
+void InputSocket::determineResolution(unsigned int resolution[],unsigned int preferredResolution[])
+{
if (this->isConnected()) {
this->connection->getFromSocket()->determineResolution(resolution, preferredResolution);
}
@@ -56,7 +64,8 @@ void InputSocket::determineResolution(unsigned int resolution[],unsigned int pre
}
}
-DataType InputSocket::convertToSupportedDataType(DataType datatype) {
+DataType InputSocket::convertToSupportedDataType(DataType datatype)
+{
int supportedDataTypes = getDataType();
if (supportedDataTypes&datatype) {
return datatype;
@@ -92,7 +101,8 @@ DataType InputSocket::convertToSupportedDataType(DataType datatype) {
return this->getDataType();
}
-void InputSocket::determineActualDataType() {
+void InputSocket::determineActualDataType()
+{
/// @note: this method is only called for inputsocket that are not connected.
/// @note: passes COM_DT_COLOR, the convertToSupportedDataType converts this to a capable DataType
this->setActualDataType(this->convertToSupportedDataType(COM_DT_COLOR));
@@ -105,26 +115,30 @@ void InputSocket::determineActualDataType() {
#endif
}
-void InputSocket::notifyActualInputType(DataType datatype) {
+void InputSocket::notifyActualInputType(DataType datatype)
+{
DataType supportedDataType = convertToSupportedDataType(datatype);
this->setActualDataType(supportedDataType);
this->fireActualDataTypeSet();
}
-void InputSocket::fireActualDataTypeSet() {
+void InputSocket::fireActualDataTypeSet()
+{
this->getNode()->notifyActualDataTypeSet(this, this->getActualDataType());
}
-void InputSocket::relinkConnections(InputSocket *relinkToSocket) {
+void InputSocket::relinkConnections(InputSocket *relinkToSocket)
+{
this->relinkConnections(relinkToSocket, false, -1, NULL);
}
-void InputSocket::relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, bool duplicate, ExecutionSystem* graph) {
+void InputSocket::relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, bool duplicate, ExecutionSystem *graph)
+{
if (!duplicate) {
this->relinkConnections(relinkToSocket, autoconnect, editorNodeInputSocketIndex, graph);
}
else {
if (!this->isConnected() && autoconnect) {
- Node* node = (Node*)this->getNode();
+ Node *node = (Node*)this->getNode();
switch (this->getActualDataType()) {
case COM_DT_UNKNOWN:
case COM_DT_COLOR:
@@ -149,10 +163,11 @@ void InputSocket::relinkConnections(InputSocket *relinkToSocket, bool autoconnec
}
}
-void InputSocket::relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, ExecutionSystem* graph) {
+void InputSocket::relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, ExecutionSystem *graph)
+{
if (!isConnected()) {
if (autoconnect) {
- Node* node = (Node*)this->getNode();
+ Node *node = (Node*)this->getNode();
switch (this->getActualDataType()) {
case COM_DT_UNKNOWN:
case COM_DT_COLOR:
@@ -174,7 +189,8 @@ void InputSocket::relinkConnections(InputSocket *relinkToSocket, bool autoconnec
this->setConnection(NULL);
}
-const ChannelInfo* InputSocket::getChannelInfo(const int channelnumber) {
+const ChannelInfo *InputSocket::getChannelInfo(const int channelnumber)
+{
if (this->isConnected() && this->connection->getFromSocket()) {
return this->connection->getFromSocket()->getChannelInfo(channelnumber);
}
@@ -183,20 +199,23 @@ const ChannelInfo* InputSocket::getChannelInfo(const int channelnumber) {
}
}
-bool InputSocket::isStatic() {
+bool InputSocket::isStatic()
+{
if (isConnected()) {
- NodeBase* node = this->getConnection()->getFromNode();
+ NodeBase *node = this->getConnection()->getFromNode();
if (node) {
return node->isStatic();
}
}
return true;
}
-SocketReader* InputSocket::getReader() {
+SocketReader *InputSocket::getReader()
+{
return this->getOperation();
}
-NodeOperation* InputSocket::getOperation() const {
+NodeOperation *InputSocket::getOperation() const
+{
if (isConnected()) {
return (NodeOperation*)this->connection->getFromSocket()->getNode();
}
@@ -205,7 +224,8 @@ NodeOperation* InputSocket::getOperation() const {
}
}
-float* InputSocket::getStaticValues() {
+float *InputSocket::getStaticValues()
+{
/* XXX only works for socket types with actual float input values.
* currently all compositor socket types (value, rgba, vector) support this.
*/
diff --git a/source/blender/compositor/intern/COM_InputSocket.h b/source/blender/compositor/intern/COM_InputSocket.h
index 340cfa98ef6..e01793317a5 100644
--- a/source/blender/compositor/intern/COM_InputSocket.h
+++ b/source/blender/compositor/intern/COM_InputSocket.h
@@ -65,7 +65,7 @@ private:
* @brief connection connected to this InputSocket.
* An input socket can only have a single connection
*/
- SocketConnection* connection;
+ SocketConnection *connection;
/**
* @brief resize mode of this socket
@@ -89,10 +89,10 @@ private:
public:
InputSocket(DataType datatype);
InputSocket(DataType datatype, InputSocketResizeMode resizeMode);
- InputSocket(InputSocket* from);
+ InputSocket(InputSocket *from);
- void setConnection(SocketConnection* connection);
- SocketConnection* getConnection();
+ void setConnection(SocketConnection *connection);
+ SocketConnection *getConnection();
const int isConnected() const;
int isInputSocket() const;
@@ -126,7 +126,7 @@ public:
* @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection)
* @param system ExecutionSystem to update to
*/
- void relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, ExecutionSystem* system);
+ void relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, ExecutionSystem *system);
/**
* @brief move all connections of this input socket to another socket
@@ -136,7 +136,7 @@ public:
* @param duplicate instead of move do a copy of the connection.
* @param system ExecutionSystem to update to
*/
- void relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, bool duplicate, ExecutionSystem* system);
+ void relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, bool duplicate, ExecutionSystem *system);
/**
* @brief set the resize mode
@@ -150,13 +150,13 @@ public:
*/
InputSocketResizeMode getResizeMode() const {return this->resizeMode;}
- const ChannelInfo* getChannelInfo(const int channelnumber);
+ const ChannelInfo *getChannelInfo(const int channelnumber);
bool isStatic();
- float* getStaticValues();
- SocketReader* getReader();
- NodeOperation* getOperation() const;
+ float *getStaticValues();
+ SocketReader *getReader();
+ NodeOperation *getOperation() const;
};
#endif
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index bfa20656277..19c2c96a8f2 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -25,18 +25,22 @@
#include "BLI_math.h"
#include "BKE_global.h"
-unsigned int MemoryBuffer::determineBufferSize() {
+unsigned int MemoryBuffer::determineBufferSize()
+{
return getWidth() * getHeight();
}
-int MemoryBuffer::getWidth() const {
+int MemoryBuffer::getWidth() const
+{
return this->rect.xmax-this->rect.xmin;
}
-int MemoryBuffer::getHeight() const {
+int MemoryBuffer::getHeight() const
+{
return this->rect.ymax-this->rect.ymin;
}
-MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, unsigned int chunkNumber, rcti* rect) {
+MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, unsigned int chunkNumber, rcti *rect)
+{
BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
this->memoryProxy = memoryProxy;
this->chunkNumber = chunkNumber;
@@ -46,7 +50,8 @@ MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, unsigned int chunkNumber,
this->chunkWidth = this->rect.xmax - this->rect.xmin;
}
-MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, rcti* rect) {
+MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, rcti *rect)
+{
BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
this->memoryProxy = memoryProxy;
this->chunkNumber = -1;
@@ -55,20 +60,23 @@ MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, rcti* rect) {
this->datatype = COM_DT_COLOR;
this->chunkWidth = this->rect.xmax - this->rect.xmin;
}
-MemoryBuffer* MemoryBuffer::duplicate() {
+MemoryBuffer *MemoryBuffer::duplicate()
+{
MemoryBuffer *result = new MemoryBuffer(this->memoryProxy, &this->rect);
memcpy(result->buffer, this->buffer, this->determineBufferSize()*4*sizeof(float));
return result;
}
-void MemoryBuffer::clear() {
+void MemoryBuffer::clear()
+{
memset(this->buffer, 0, this->determineBufferSize()*4*sizeof(float));
}
-float* MemoryBuffer::convertToValueBuffer() {
+float *MemoryBuffer::convertToValueBuffer()
+{
int size = this->determineBufferSize();
int i;
int offset4;
- float* result = new float[size];
+ float *result = new float[size];
for (i = 0, offset4 = 0 ; i < size ; i ++, offset4 +=4) {
result[i] = this->buffer[offset4];
}
@@ -76,14 +84,16 @@ float* MemoryBuffer::convertToValueBuffer() {
return result;
}
-MemoryBuffer::~MemoryBuffer() {
+MemoryBuffer::~MemoryBuffer()
+{
if (this->buffer) {
MEM_freeN(this->buffer);
this->buffer = NULL;
}
}
-void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer) {
+void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer)
+{
if (!otherBuffer) {
return;
}
@@ -103,7 +113,8 @@ void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer) {
}
}
-void MemoryBuffer::read(float* result, int x, int y) {
+void MemoryBuffer::read(float *result, int x, int y)
+{
if (x>=this->rect.xmin && x < this->rect.xmax &&
y>=this->rect.ymin && y < this->rect.ymax) {
int dx = x-this->rect.xmin;
@@ -121,7 +132,8 @@ void MemoryBuffer::read(float* result, int x, int y) {
result[3] = 0.0f;
}
}
-void MemoryBuffer::writePixel(int x, int y, float color[4]) {
+void MemoryBuffer::writePixel(int x, int y, float color[4])
+{
if (x>=this->rect.xmin && x < this->rect.xmax &&
y>=this->rect.ymin && y < this->rect.ymax) {
int offset = (this->chunkWidth*y+x)*4;
@@ -132,7 +144,8 @@ void MemoryBuffer::writePixel(int x, int y, float color[4]) {
}
}
-void MemoryBuffer::readCubic(float* result, float x, float y) {
+void MemoryBuffer::readCubic(float *result, float x, float y)
+{
int x1 = floor(x);
int x2 = x1 + 1;
int y1 = floor(y);
@@ -208,7 +221,7 @@ static float EWA_WTS[EWA_MAXIDX + 1] =
0.00754159f, 0.00625989f, 0.00498819f, 0.00372644f, 0.00247454f, 0.00123242f, 0.f
};
-static void radangle2imp(float a2, float b2, float th, float* A, float* B, float* C, float* F)
+static void radangle2imp(float a2, float b2, float th, float *A, float *B, float *C, float *F)
{
float ct2 = cosf(th);
const float st2 = 1.f - ct2*ct2; // <- sin(th)^2
@@ -220,7 +233,7 @@ static void radangle2imp(float a2, float b2, float th, float* A, float* B, float
}
// all tests here are done to make sure possible overflows are hopefully minimized
-static void imp2radangle(float A, float B, float C, float F, float* a, float* b, float* th, float* ecc)
+static void imp2radangle(float A, float B, float C, float F, float *a, float *b, float *th, float *ecc)
{
if (F <= 1e-5f) { // use arbitrary major radius, zero minor, infinite eccentricity
*a = sqrtf(A > C ? A : C);
@@ -247,12 +260,14 @@ static void imp2radangle(float A, float B, float C, float F, float* a, float* b,
}
}
-float clipuv(float x, float limit) {
+float clipuv(float x, float limit)
+{
x = (x < 0) ? 0 : ((x >= limit) ? (limit - 1) : x);
return x;
}
-void MemoryBuffer::readEWA(float* result, float fx, float fy, float dx, float dy) {
+void MemoryBuffer::readEWA(float *result, float fx, float fy, float dx, float dy)
+{
int width = this->getWidth(), height = this->getHeight();
// scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values,
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 78fb16a7b12..bfc18424570 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -88,18 +88,18 @@ private:
/**
* @brief the actual float buffer/data
*/
- float* buffer;
+ float *buffer;
public:
/**
* @brief construct new MemoryBuffer for a chunk
*/
- MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti* rect);
+ MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect);
/**
* @brief construct new temporarily MemoryBuffer for an area
*/
- MemoryBuffer(MemoryProxy *memoryProxy, rcti* rect);
+ MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect);
/**
* @brief destructor
@@ -115,7 +115,7 @@ public:
* @brief get the data of this MemoryBuffer
* @note buffer should already be available in memory
*/
- float* getBuffer() {return this->buffer;}
+ float *getBuffer() {return this->buffer;}
/**
* @brief after execution the state will be set to available by calling this method
@@ -124,9 +124,9 @@ public:
this->state = COM_MB_AVAILABLE;
}
- void read(float* result, int x, int y);
+ void read(float *result, int x, int y);
void writePixel(int x, int y, float color[4]);
- void readCubic(float* result, float x, float y);
+ void readCubic(float *result, float x, float y);
void readEWA(float *result, float fx, float fy, float dx, float dy);
/**
@@ -138,12 +138,12 @@ public:
* @brief add the content from otherBuffer to this MemoryBuffer
* @param otherBuffer source buffer
*/
- void copyContentFrom(MemoryBuffer* otherBuffer);
+ void copyContentFrom(MemoryBuffer *otherBuffer);
/**
* @brief get the rect of this MemoryBuffer
*/
- rcti* getRect() {return &this->rect;}
+ rcti *getRect() {return &this->rect;}
/**
* @brief get the width of this MemoryBuffer
@@ -160,9 +160,9 @@ public:
*/
void clear();
- MemoryBuffer* duplicate();
+ MemoryBuffer *duplicate();
- float* convertToValueBuffer();
+ float *convertToValueBuffer();
private:
unsigned int determineBufferSize();
};
diff --git a/source/blender/compositor/intern/COM_MemoryManager.cpp b/source/blender/compositor/intern/COM_MemoryManager.cpp
index 661afb20d53..4f97b0b1e80 100644
--- a/source/blender/compositor/intern/COM_MemoryManager.cpp
+++ b/source/blender/compositor/intern/COM_MemoryManager.cpp
@@ -29,7 +29,8 @@ vector<MemoryBuffer*> buffers;
ThreadMutex mutex;
-MemoryBuffer* MemoryManager::allocateMemoryBuffer(MemoryProxy *id, unsigned int chunkNumber, rcti *rect) {
+MemoryBuffer *MemoryManager::allocateMemoryBuffer(MemoryProxy *id, unsigned int chunkNumber, rcti *rect)
+{
MemoryBuffer *result = new MemoryBuffer(id, chunkNumber, rect);
MemoryManagerState * state = MemoryManager::getState(id);
state->addMemoryBuffer(result);
@@ -39,30 +40,35 @@ MemoryBuffer* MemoryManager::allocateMemoryBuffer(MemoryProxy *id, unsigned int
return result;
}
-void MemoryManager::addMemoryProxy(MemoryProxy *memoryProxy) {
+void MemoryManager::addMemoryProxy(MemoryProxy *memoryProxy)
+{
MemoryManagerState * state = MemoryManager::getState(memoryProxy);
if (!state) {
state = new MemoryManagerState(memoryProxy);
memoryProxy->setState(state);
}
}
-MemoryBuffer* MemoryManager::getMemoryBuffer(MemoryProxy *id, unsigned int chunkNumber) {
+MemoryBuffer *MemoryManager::getMemoryBuffer(MemoryProxy *id, unsigned int chunkNumber)
+{
MemoryManagerState * state = MemoryManager::getState(id);
if (!state) {
return NULL;
}
- MemoryBuffer* buffer = state->getMemoryBuffer(chunkNumber);
+ MemoryBuffer *buffer = state->getMemoryBuffer(chunkNumber);
if (!buffer) return NULL;
return buffer;
}
-MemoryManagerState* MemoryManager::getState(MemoryProxy* memoryProxy) {
+MemoryManagerState *MemoryManager::getState(MemoryProxy *memoryProxy)
+{
return memoryProxy->getState();
}
-void MemoryManager::initialize() {
+void MemoryManager::initialize()
+{
BLI_mutex_init(&mutex);
}
-void MemoryManager::clear() {
+void MemoryManager::clear()
+{
buffers.clear();
BLI_mutex_end(&mutex);
}
diff --git a/source/blender/compositor/intern/COM_MemoryManager.h b/source/blender/compositor/intern/COM_MemoryManager.h
index 506bf2a8c24..6194d40d9a5 100644
--- a/source/blender/compositor/intern/COM_MemoryManager.h
+++ b/source/blender/compositor/intern/COM_MemoryManager.h
@@ -109,7 +109,7 @@ private:
* @brief retrieve the state of a certain MemoryProxy;
* @param memoryProxy the MemoryProxy to retrieve the state from
*/
- static MemoryManagerState* getState(MemoryProxy* memoryProxy);
+ static MemoryManagerState *getState(MemoryProxy *memoryProxy);
public:
/**
* @brief allocate a memory buffer
@@ -117,7 +117,7 @@ public:
* @param chunkNumber number of the chunk to receive
* @param rect size + position of the chunk
*/
- static MemoryBuffer* allocateMemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti* rect);
+ static MemoryBuffer *allocateMemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect);
/**
* @brief get a memory buffer
@@ -125,7 +125,7 @@ public:
* @param chunkNumber number of the chunk to receive
* @param addUser must we add a user to the chunk.
*/
- static MemoryBuffer* getMemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber);
+ static MemoryBuffer *getMemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber);
/**
* @brief add a MemoryProxy to the scope of the memory manager
diff --git a/source/blender/compositor/intern/COM_MemoryManagerState.cpp b/source/blender/compositor/intern/COM_MemoryManagerState.cpp
index 620092b2825..b40ae146f9e 100644
--- a/source/blender/compositor/intern/COM_MemoryManagerState.cpp
+++ b/source/blender/compositor/intern/COM_MemoryManagerState.cpp
@@ -22,22 +22,25 @@
#include "COM_MemoryManagerState.h"
-MemoryManagerState::MemoryManagerState(MemoryProxy *memoryProxy) {
+MemoryManagerState::MemoryManagerState(MemoryProxy *memoryProxy)
+{
this->memoryProxy = memoryProxy;
this->currentSize = 0;
this->chunkBuffers = NULL;
BLI_mutex_init(&this->mutex);
}
-MemoryProxy * MemoryManagerState::getMemoryProxy() {
+MemoryProxy * MemoryManagerState::getMemoryProxy()
+{
return this->memoryProxy;
}
-MemoryManagerState::~MemoryManagerState() {
+MemoryManagerState::~MemoryManagerState()
+{
this->memoryProxy = NULL;
unsigned int index;
for (index = 0 ; index < this->currentSize; index ++) {
- MemoryBuffer* buffer = this->chunkBuffers[index];
+ MemoryBuffer *buffer = this->chunkBuffers[index];
if (buffer) {
delete buffer;
}
@@ -46,7 +49,8 @@ MemoryManagerState::~MemoryManagerState() {
BLI_mutex_end(&this->mutex);
}
-void MemoryManagerState::addMemoryBuffer(MemoryBuffer *buffer) {
+void MemoryManagerState::addMemoryBuffer(MemoryBuffer *buffer)
+{
BLI_mutex_lock(&this->mutex);
unsigned int chunkNumber = buffer->getChunkNumber();
unsigned int index;
@@ -76,8 +80,9 @@ void MemoryManagerState::addMemoryBuffer(MemoryBuffer *buffer) {
BLI_mutex_unlock(&this->mutex);
}
-MemoryBuffer* MemoryManagerState::getMemoryBuffer(unsigned int chunkNumber) {
- MemoryBuffer* result = NULL;
+MemoryBuffer *MemoryManagerState::getMemoryBuffer(unsigned int chunkNumber)
+{
+ MemoryBuffer *result = NULL;
if (chunkNumber< this->currentSize) {
result = this->chunkBuffers[chunkNumber];
if (result) {
diff --git a/source/blender/compositor/intern/COM_MemoryManagerState.h b/source/blender/compositor/intern/COM_MemoryManagerState.h
index 4b4f0a112a8..8e8cb484d1a 100644
--- a/source/blender/compositor/intern/COM_MemoryManagerState.h
+++ b/source/blender/compositor/intern/COM_MemoryManagerState.h
@@ -75,13 +75,13 @@ public:
/**
* @brief add a new memorybuffer to the state
*/
- void addMemoryBuffer(MemoryBuffer* buffer);
+ void addMemoryBuffer(MemoryBuffer *buffer);
/**
* @brief get the MemoryBuffer assiciated to a chunk.
* @param chunkNumber the chunknumber
*/
- MemoryBuffer* getMemoryBuffer(unsigned int chunkNumber);
+ MemoryBuffer *getMemoryBuffer(unsigned int chunkNumber);
};
#endif
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.cpp b/source/blender/compositor/intern/COM_MemoryProxy.cpp
index 0880af9833c..7ff4f4949f0 100644
--- a/source/blender/compositor/intern/COM_MemoryProxy.cpp
+++ b/source/blender/compositor/intern/COM_MemoryProxy.cpp
@@ -23,13 +23,15 @@
#include "COM_MemoryProxy.h"
-MemoryProxy::MemoryProxy() {
+MemoryProxy::MemoryProxy()
+{
this->state = NULL;
this->writeBufferOperation = NULL;
this->executor = NULL;
}
-MemoryProxy::~MemoryProxy() {
+MemoryProxy::~MemoryProxy()
+{
if (this->state) {
delete this->state;
this->state = NULL;
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h
index 9424ea9a3e5..276ebeed1e2 100644
--- a/source/blender/compositor/intern/COM_MemoryProxy.h
+++ b/source/blender/compositor/intern/COM_MemoryProxy.h
@@ -76,19 +76,19 @@ public:
/**
* @brief get the ExecutionGroup that can be scheduled to calculate a certain chunk.
*/
- ExecutionGroup* getExecutor() {return this->executor;}
+ ExecutionGroup *getExecutor() {return this->executor;}
/**
* @brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy
* @param operation
*/
- void setWriteBufferOperation(WriteBufferOperation* operation) {this->writeBufferOperation = operation;}
+ void setWriteBufferOperation(WriteBufferOperation *operation) {this->writeBufferOperation = operation;}
/**
* @brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy
* @return WriteBufferOperation
*/
- WriteBufferOperation* getWriteBufferOperation() {return this->writeBufferOperation;}
+ WriteBufferOperation *getWriteBufferOperation() {return this->writeBufferOperation;}
/**
* @brief set the memorymanager state of this MemoryProxy, this is set from the MemoryManager
@@ -100,7 +100,7 @@ public:
* @brief get the state of this MemoryProxy
* @return MemoryManagerState reference to the state of this MemoryProxy.
*/
- MemoryManagerState* getState() {return this->state;}
+ MemoryManagerState *getState() {return this->state;}
};
#endif
diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp
index 4e127c61d4e..f06672ac80b 100644
--- a/source/blender/compositor/intern/COM_Node.cpp
+++ b/source/blender/compositor/intern/COM_Node.cpp
@@ -38,7 +38,8 @@
//#include "stdio.h"
#include "COM_defines.h"
-Node::Node(bNode* editorNode, bool create_sockets) {
+Node::Node(bNode *editorNode, bool create_sockets)
+{
this->editorNode = editorNode;
if (create_sockets) {
@@ -62,13 +63,18 @@ Node::Node(bNode* editorNode, bool create_sockets) {
}
}
}
-Node::Node() {
+Node::Node()
+{
this->editorNode = NULL;
}
-bNode* Node::getbNode() {return this->editorNode;}
+bNode *Node::getbNode()
+{
+ return this->editorNode;
+}
-void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex) {
+void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
+{
bNodeSocket *bSock = (bNodeSocket*)this->getEditorInputSocket(editorNodeInputSocketIndex);
SetValueOperation *operation = new SetValueOperation();
bNodeSocketValueFloat *val = (bNodeSocketValueFloat*)bSock->default_value;
@@ -77,7 +83,8 @@ void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket* inputsocket
graph->addOperation(operation);
}
-void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket, int priority) {
+void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket, int priority)
+{
#ifdef COM_PREVIEW_ENABLED
PreviewOperation *operation = new PreviewOperation();
system->addOperation(operation);
@@ -88,14 +95,16 @@ void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSock
#endif
}
-void Node::addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket, int priority) {
+void Node::addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket, int priority)
+{
if (inputSocket->isConnected()) {
OutputSocket *outputsocket = inputSocket->getConnection()->getFromSocket();
this->addPreviewOperation(system, outputsocket, priority);
}
}
-SocketConnection* Node::addLink(ExecutionSystem *graph, OutputSocket* outputSocket, InputSocket* inputsocket) {
+SocketConnection *Node::addLink(ExecutionSystem *graph, OutputSocket *outputSocket, InputSocket *inputsocket)
+{
if (inputsocket->isConnected()) {
return NULL;
}
@@ -108,7 +117,8 @@ SocketConnection* Node::addLink(ExecutionSystem *graph, OutputSocket* outputSock
return connection;
}
-void Node::addSetColorOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex) {
+void Node::addSetColorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
+{
bNodeSocket *bSock = (bNodeSocket*)this->getEditorInputSocket(editorNodeInputSocketIndex);
SetColorOperation *operation = new SetColorOperation();
bNodeSocketValueRGBA *val = (bNodeSocketValueRGBA*)bSock->default_value;
@@ -120,7 +130,8 @@ void Node::addSetColorOperation(ExecutionSystem *graph, InputSocket* inputsocket
graph->addOperation(operation);
}
-void Node::addSetVectorOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex) {
+void Node::addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
+{
bNodeSocket *bSock = (bNodeSocket*)this->getEditorInputSocket(editorNodeInputSocketIndex);
bNodeSocketValueVector *val = (bNodeSocketValueVector*)bSock->default_value;
SetVectorOperation *operation = new SetVectorOperation();
@@ -132,7 +143,8 @@ void Node::addSetVectorOperation(ExecutionSystem *graph, InputSocket* inputsocke
graph->addOperation(operation);
}
-bNodeSocket* Node::getEditorInputSocket(int editorNodeInputSocketIndex) {
+bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
+{
bNodeSocket *bSock = (bNodeSocket*)this->getbNode()->inputs.first;
int index = 0;
while (bSock != NULL) {
@@ -144,7 +156,8 @@ bNodeSocket* Node::getEditorInputSocket(int editorNodeInputSocketIndex) {
}
return NULL;
}
-bNodeSocket* Node::getEditorOutputSocket(int editorNodeInputSocketIndex) {
+bNodeSocket *Node::getEditorOutputSocket(int editorNodeInputSocketIndex)
+{
bNodeSocket *bSock = (bNodeSocket*)this->getbNode()->outputs.first;
int index = 0;
while (bSock != NULL) {
@@ -157,11 +170,12 @@ bNodeSocket* Node::getEditorOutputSocket(int editorNodeInputSocketIndex) {
return NULL;
}
-InputSocket* Node::findInputSocketBybNodeSocket(bNodeSocket* socket) {
+InputSocket *Node::findInputSocketBybNodeSocket(bNodeSocket *socket)
+{
vector<InputSocket*> &inputsockets = this->getInputSockets();
unsigned int index;
for (index = 0 ; index < inputsockets.size(); index ++) {
- InputSocket* input = inputsockets[index];
+ InputSocket *input = inputsockets[index];
if (input->getbNodeSocket() == socket) {
return input;
}
@@ -169,11 +183,12 @@ InputSocket* Node::findInputSocketBybNodeSocket(bNodeSocket* socket) {
return NULL;
}
-OutputSocket* Node::findOutputSocketBybNodeSocket(bNodeSocket* socket) {
+OutputSocket *Node::findOutputSocketBybNodeSocket(bNodeSocket *socket)
+{
vector<OutputSocket*> &outputsockets = this->getOutputSockets();
unsigned int index;
for (index = 0 ; index < outputsockets.size(); index ++) {
- OutputSocket* output = outputsockets[index];
+ OutputSocket *output = outputsockets[index];
if (output->getbNodeSocket() == socket) {
return output;
}
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index 3706592a585..2666d0a6980 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -50,15 +50,15 @@ private:
/**
* @brief stores the reference to the SDNA bNode struct
*/
- bNode* editorNode;
+ bNode *editorNode;
public:
- Node(bNode* editorNode, bool create_sockets=true);
+ Node(bNode *editorNode, bool create_sockets=true);
/**
* @brief get the reference to the SDNA bNode struct
*/
- bNode* getbNode();
+ bNode *getbNode();
/**
* @brief convert node to operation
@@ -68,31 +68,31 @@ public:
* @param system the ExecutionSystem where the operations need to be added
* @param context reference to the CompositorContext
*/
- virtual void convertToOperations(ExecutionSystem* system, CompositorContext * context) =0;
+ virtual void convertToOperations(ExecutionSystem *system, CompositorContext * context) =0;
/**
* this method adds a SetValueOperation as input of the input socket.
* This can only be used from the convertToOperation method. all other usages are not allowed
*/
- void addSetValueOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex);
+ void addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex);
/**
* this method adds a SetColorOperation as input of the input socket.
* This can only be used from the convertToOperation method. all other usages are not allowed
*/
- void addSetColorOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex);
+ void addSetColorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex);
/**
* this method adds a SetVectorOperation as input of the input socket.
* This can only be used from the convertToOperation method. all other usages are not allowed
*/
- void addSetVectorOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex);
+ void addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex);
/**
* Creates a new link between an outputSocket and inputSocket and registrates the link to the graph
* @return the new created link
*/
- SocketConnection* addLink(ExecutionSystem *graph, OutputSocket* outputSocket, InputSocket* inputsocket);
+ SocketConnection *addLink(ExecutionSystem *graph, OutputSocket *outputSocket, InputSocket *inputsocket);
/**
* is this node a group node.
@@ -108,23 +108,23 @@ public:
*
* @param socket
*/
- InputSocket* findInputSocketBybNodeSocket(bNodeSocket* socket);
+ InputSocket *findInputSocketBybNodeSocket(bNodeSocket *socket);
/**
* @brief find the OutputSocket by bNodeSocket
*
* @param socket
*/
- OutputSocket* findOutputSocketBybNodeSocket(bNodeSocket* socket);
+ OutputSocket *findOutputSocketBybNodeSocket(bNodeSocket *socket);
protected:
Node();
- void addPreviewOperation(ExecutionSystem *system, InputSocket* inputSocket, int priority);
- void addPreviewOperation(ExecutionSystem *system, OutputSocket* inputSocket, int priority);
+ void addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket, int priority);
+ void addPreviewOperation(ExecutionSystem *system, OutputSocket *inputSocket, int priority);
- bNodeSocket* getEditorInputSocket(int editorNodeInputSocketIndex);
- bNodeSocket* getEditorOutputSocket(int editorNodeOutputSocketIndex);
+ bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex);
+ bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex);
private:
};
diff --git a/source/blender/compositor/intern/COM_NodeBase.cpp b/source/blender/compositor/intern/COM_NodeBase.cpp
index b6990ec0d79..17a623c9c81 100644
--- a/source/blender/compositor/intern/COM_NodeBase.cpp
+++ b/source/blender/compositor/intern/COM_NodeBase.cpp
@@ -29,11 +29,13 @@
#include "COM_SocketConnection.h"
#include "COM_ExecutionSystem.h"
-NodeBase::NodeBase() {
+NodeBase::NodeBase()
+{
}
-NodeBase::~NodeBase() {
+NodeBase::~NodeBase()
+{
while (!this->outputsockets.empty()) {
delete (this->outputsockets.back());
this->outputsockets.pop_back();
@@ -44,60 +46,70 @@ NodeBase::~NodeBase() {
}
}
-void NodeBase::addInputSocket(DataType datatype) {
+void NodeBase::addInputSocket(DataType datatype)
+{
this->addInputSocket(datatype, COM_SC_CENTER, NULL);
}
-void NodeBase::addInputSocket(DataType datatype, InputSocketResizeMode resizeMode) {
+void NodeBase::addInputSocket(DataType datatype, InputSocketResizeMode resizeMode)
+{
this->addInputSocket(datatype, resizeMode, NULL);
}
-void NodeBase::addInputSocket(DataType datatype, InputSocketResizeMode resizeMode, bNodeSocket* bSocket) {
+void NodeBase::addInputSocket(DataType datatype, InputSocketResizeMode resizeMode, bNodeSocket *bSocket)
+{
InputSocket *socket = new InputSocket(datatype, resizeMode);
socket->setEditorSocket(bSocket);
socket->setNode(this);
this->inputsockets.push_back(socket);
}
-void NodeBase::addOutputSocket(DataType datatype) {
+void NodeBase::addOutputSocket(DataType datatype)
+{
this->addOutputSocket(datatype, NULL);
}
-void NodeBase::addOutputSocket(DataType datatype, bNodeSocket* bSocket) {
+void NodeBase::addOutputSocket(DataType datatype, bNodeSocket *bSocket)
+{
OutputSocket *socket = new OutputSocket(datatype);
socket->setEditorSocket(bSocket);
socket->setNode(this);
this->outputsockets.push_back(socket);
}
-const bool NodeBase::isInputNode() const {
+const bool NodeBase::isInputNode() const
+{
return this->inputsockets.size() == 0;
}
-OutputSocket* NodeBase::getOutputSocket(int index) {
+OutputSocket *NodeBase::getOutputSocket(int index)
+{
return this->outputsockets[index];
}
-InputSocket* NodeBase::getInputSocket(int index) {
+InputSocket *NodeBase::getInputSocket(int index)
+{
return this->inputsockets[index];
}
-void NodeBase::determineActualSocketDataTypes() {
+void NodeBase::determineActualSocketDataTypes()
+{
unsigned int index;
for (index = 0 ; index < this->outputsockets.size() ; index ++) {
- OutputSocket* socket = this->outputsockets[index];
+ OutputSocket *socket = this->outputsockets[index];
if (socket->getActualDataType() ==COM_DT_UNKNOWN && socket->isConnected()) {
socket->determineActualDataType();
}
}
for (index = 0 ; index < this->inputsockets.size() ; index ++) {
- InputSocket* socket = this->inputsockets[index];
+ InputSocket *socket = this->inputsockets[index];
if (socket->getActualDataType() ==COM_DT_UNKNOWN) {
socket->determineActualDataType();
}
}
}
-DataType NodeBase::determineActualDataType(OutputSocket *outputsocket) {
+DataType NodeBase::determineActualDataType(OutputSocket *outputsocket)
+{
const int inputIndex = outputsocket->getInputSocketDataTypeDeterminatorIndex();
if (inputIndex != -1) {
return this->getInputSocket(inputIndex)->getActualDataType();
@@ -107,7 +119,8 @@ DataType NodeBase::determineActualDataType(OutputSocket *outputsocket) {
}
}
-void NodeBase::notifyActualDataTypeSet(InputSocket *socket, DataType actualType) {
+void NodeBase::notifyActualDataTypeSet(InputSocket *socket, DataType actualType)
+{
unsigned int index;
int socketIndex = -1;
for (index = 0 ; index < this->inputsockets.size() ; index ++) {
@@ -119,9 +132,10 @@ void NodeBase::notifyActualDataTypeSet(InputSocket *socket, DataType actualType)
if (socketIndex == -1) return;
for (index = 0 ; index < this->outputsockets.size() ; index ++) {
- OutputSocket* socket = this->outputsockets[index];
+ OutputSocket *socket = this->outputsockets[index];
if (socket->isActualDataTypeDeterminedByInputSocket() &&
- socket->getInputSocketDataTypeDeterminatorIndex() == socketIndex) {
+ socket->getInputSocketDataTypeDeterminatorIndex() == socketIndex)
+ {
socket->setActualDataType(actualType);
socket->fireActualDataType();
}
diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h
index 10028324d91..123797c780a 100644
--- a/source/blender/compositor/intern/COM_NodeBase.h
+++ b/source/blender/compositor/intern/COM_NodeBase.h
@@ -124,32 +124,32 @@ public:
* @param actualType [COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR]
* the actual data type that is coming from the connected output socket
*/
- virtual void notifyActualDataTypeSet(InputSocket* socket, const DataType actualType);
+ virtual void notifyActualDataTypeSet(InputSocket *socket, const DataType actualType);
/**
* get the reference to a certain outputsocket
* @param index
* the index of the needed outputsocket
*/
- OutputSocket* getOutputSocket(const int index);
+ OutputSocket *getOutputSocket(const int index);
/**
* get the reference to the first outputsocket
* @param index
* the index of the needed outputsocket
*/
- inline OutputSocket* getOutputSocket() {return getOutputSocket(0);}
+ inline OutputSocket *getOutputSocket() {return getOutputSocket(0);}
/**
* get the reference to a certain inputsocket
* @param index
* the index of the needed inputsocket
*/
- InputSocket* getInputSocket(const int index);
+ InputSocket *getInputSocket(const int index);
virtual bool isStatic() const {return false;}
- void getStaticValues(float* result) const {}
+ void getStaticValues(float *result) const {}
protected:
NodeBase();
@@ -160,7 +160,7 @@ protected:
*/
void addInputSocket(DataType datatype);
void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode);
- void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode, bNodeSocket* socket);
+ void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode, bNodeSocket *socket);
/**
* @brief add an OutputSocket to the collection of outputsockets
@@ -168,7 +168,7 @@ protected:
* @param socket the OutputSocket to add
*/
void addOutputSocket(DataType datatype);
- void addOutputSocket(DataType datatype, bNodeSocket* socket);
+ void addOutputSocket(DataType datatype, bNodeSocket *socket);
};
#endif
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp
index 71aaceb1b48..fae652e39d7 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperation.cpp
@@ -27,7 +27,8 @@
#include "COM_defines.h"
#include "stdio.h"
-NodeOperation::NodeOperation() {
+NodeOperation::NodeOperation()
+{
this->resolutionInputSocketIndex = 0;
this->complex = false;
this->width = 0;
@@ -35,13 +36,14 @@ NodeOperation::NodeOperation() {
this->openCL = false;
}
-void NodeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+void NodeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
+{
unsigned int temp[2];
unsigned int temp2[2];
vector<InputSocket*> &inputsockets = this->getInputSockets();
for (unsigned int index = 0 ; index < inputsockets.size();index++) {
- InputSocket* inputSocket = inputsockets[index];
+ InputSocket *inputSocket = inputsockets[index];
if (inputSocket->isConnected()) {
if (index == this->resolutionInputSocketIndex) {
inputSocket->determineResolution(resolution, preferredResolution);
@@ -52,7 +54,7 @@ void NodeOperation::determineResolution(unsigned int resolution[], unsigned int
}
}
for (unsigned int index = 0 ; index < inputsockets.size();index++) {
- InputSocket* inputSocket = inputsockets[index];
+ InputSocket *inputSocket = inputsockets[index];
if (inputSocket->isConnected()) {
if (index != resolutionInputSocketIndex) {
inputSocket->determineResolution(temp, temp2);
@@ -60,28 +62,36 @@ void NodeOperation::determineResolution(unsigned int resolution[], unsigned int
}
}
}
-void NodeOperation::setResolutionInputSocketIndex(unsigned int index) {
+void NodeOperation::setResolutionInputSocketIndex(unsigned int index)
+{
this->resolutionInputSocketIndex = index;
}
-void NodeOperation::initExecution() {
+void NodeOperation::initExecution()
+{
}
-void NodeOperation::initMutex() {
+void NodeOperation::initMutex()
+{
BLI_mutex_init(&mutex);
}
-void NodeOperation::deinitMutex() {
+void NodeOperation::deinitMutex()
+{
BLI_mutex_end(&mutex);
}
-void NodeOperation::deinitExecution() {
+void NodeOperation::deinitExecution()
+{
}
-SocketReader* NodeOperation::getInputSocketReader(unsigned int inputSocketIndex) {
+SocketReader *NodeOperation::getInputSocketReader(unsigned int inputSocketIndex)
+{
return this->getInputSocket(inputSocketIndex)->getReader();
}
-NodeOperation* NodeOperation::getInputOperation(unsigned int inputSocketIndex) {
+NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex)
+{
return this->getInputSocket(inputSocketIndex)->getOperation();
}
-void NodeOperation::getConnectedInputSockets(vector<InputSocket*> *sockets) {
+void NodeOperation::getConnectedInputSockets(vector<InputSocket*> *sockets)
+{
vector<InputSocket*> &inputsockets = this->getInputSockets();
for (vector<InputSocket*>::iterator iterator = inputsockets.begin() ; iterator!= inputsockets.end() ; iterator++) {
InputSocket *socket = *iterator;
@@ -91,7 +101,8 @@ void NodeOperation::getConnectedInputSockets(vector<InputSocket*> *sockets) {
}
}
-bool NodeOperation::determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti* output) {
+bool NodeOperation::determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output)
+{
if (this->isInputNode()) {
BLI_init_rcti(output, input->xmin, input->xmax, input->ymin, input->ymax);
return false;
@@ -101,9 +112,9 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti * input, ReadBufferOpe
vector<InputSocket*> &inputsockets = this->getInputSockets();
for (index = 0 ; index < inputsockets.size() ; index++) {
- InputSocket* inputsocket = inputsockets[index];
+ InputSocket *inputsocket = inputsockets[index];
if (inputsocket->isConnected()) {
- NodeOperation* inputoperation = (NodeOperation*)inputsocket->getConnection()->getFromNode();
+ NodeOperation *inputoperation = (NodeOperation*)inputsocket->getConnection()->getFromNode();
bool result = inputoperation->determineDependingAreaOfInterest(input, readOperation, output);
if (result) {
return true;
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 5dabc4db840..bba3de2ec98 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -153,7 +153,7 @@ public:
* @param clMemToCleanUp all created cl_mem references must be added to this list. Framework will clean this after execution
* @param clKernelsToCleanUp all created cl_kernel references must be added to this list. Framework will clean this after execution
*/
- virtual void executeOpenCL(cl_context context,cl_program program, cl_command_queue queue, MemoryBuffer* outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer** inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {}
+ virtual void executeOpenCL(cl_context context,cl_program program, cl_command_queue queue, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer** inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {}
virtual void deinitExecution();
void deinitMutex();
@@ -195,7 +195,7 @@ public:
*/
virtual const bool isActiveViewerOutput() const {return false;}
- virtual bool determineDependingAreaOfInterest(rcti * input, ReadBufferOperation* readOperation, rcti* output);
+ virtual bool determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti *output);
/**
* @brief set the index of the input socket that will determine the resolution of this operation
@@ -222,11 +222,11 @@ protected:
NodeOperation();
void setWidth(unsigned int width) {this->width = width;}
- void setHeight(unsigned int height) {this->height= height;}
- SocketReader* getInputSocketReader(unsigned int inputSocketindex);
- NodeOperation* getInputOperation(unsigned int inputSocketindex);
+ void setHeight(unsigned int height) {this->height = height;}
+ SocketReader *getInputSocketReader(unsigned int inputSocketindex);
+ NodeOperation *getInputOperation(unsigned int inputSocketindex);
- inline ThreadMutex* getMutex() {return &this->mutex;}
+ inline ThreadMutex *getMutex() {return &this->mutex;}
/**
* @brief set whether this operation is complex
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
index b986865ecf3..0945b426a4e 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
@@ -24,26 +24,30 @@
#include "COM_WorkScheduler.h"
-OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program) {
+OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program)
+{
this->device = device;
this->context = context;
this->program = program;
this->queue = NULL;
}
-bool OpenCLDevice::initialize() {
+bool OpenCLDevice::initialize()
+{
cl_int error;
queue = clCreateCommandQueue(context, device, 0, &error);
return false;
}
-void OpenCLDevice::deinitialize() {
+void OpenCLDevice::deinitialize()
+{
if (queue) {
clReleaseCommandQueue(queue);
}
}
-void OpenCLDevice::execute(WorkPackage *work) {
+void OpenCLDevice::execute(WorkPackage *work)
+{
const unsigned int chunkNumber = work->getChunkNumber();
ExecutionGroup * executionGroup = work->getExecutionGroup();
rcti rect;
diff --git a/source/blender/compositor/intern/COM_OutputSocket.cpp b/source/blender/compositor/intern/COM_OutputSocket.cpp
index 5380a7ec492..00d3518cd15 100644
--- a/source/blender/compositor/intern/COM_OutputSocket.cpp
+++ b/source/blender/compositor/intern/COM_OutputSocket.cpp
@@ -25,30 +25,35 @@
#include "COM_SocketConnection.h"
#include "COM_NodeOperation.h"
-OutputSocket::OutputSocket(DataType datatype) :Socket(datatype) {
+OutputSocket::OutputSocket(DataType datatype) :Socket(datatype)
+{
this->inputSocketDataTypeDeterminatorIndex = -1;
}
-OutputSocket::OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex) :Socket(datatype) {
+OutputSocket::OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex) :Socket(datatype)
+{
this->inputSocketDataTypeDeterminatorIndex = inputSocketDataTypeDeterminatorIndex;
}
-OutputSocket::OutputSocket(OutputSocket *from): Socket(from->getDataType()) {
+OutputSocket::OutputSocket(OutputSocket *from): Socket(from->getDataType())
+{
this->inputSocketDataTypeDeterminatorIndex = from->getInputSocketDataTypeDeterminatorIndex();
}
int OutputSocket::isOutputSocket() const { return true; }
const int OutputSocket::isConnected() const { return this->connections.size()!=0; }
-void OutputSocket::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
- NodeBase* node = this->getNode();
+void OutputSocket::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
+{
+ NodeBase *node = this->getNode();
if (node->isOperation()) {
- NodeOperation* operation = (NodeOperation*)node;
+ NodeOperation *operation = (NodeOperation*)node;
operation->determineResolution(resolution, preferredResolution);
operation->setResolution(resolution);
}
}
-void OutputSocket::determineActualDataType() {
+void OutputSocket::determineActualDataType()
+{
DataType actualDatatype = this->getNode()->determineActualDataType(this);
/** @todo: set the channel info needs to be moved after integration with OCIO */
@@ -79,18 +84,21 @@ void OutputSocket::determineActualDataType() {
this->fireActualDataType();
}
-void OutputSocket::addConnection(SocketConnection *connection) {
+void OutputSocket::addConnection(SocketConnection *connection)
+{
this->connections.push_back(connection);
}
-void OutputSocket::fireActualDataType() {
+void OutputSocket::fireActualDataType()
+{
unsigned int index;
for (index = 0 ; index < this->connections.size();index ++) {
SocketConnection *connection = this->connections[index];
connection->getToSocket()->notifyActualInputType(this->getActualDataType());
}
}
-void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single) {
+void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single)
+{
if (isConnected()) {
if (single) {
SocketConnection *connection = this->connections[0];
@@ -111,28 +119,31 @@ void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single)
}
}
}
-void OutputSocket::removeFirstConnection() {
+void OutputSocket::removeFirstConnection()
+{
SocketConnection *connection = this->connections[0];
- InputSocket* inputSocket = connection->getToSocket();
+ InputSocket *inputSocket = connection->getToSocket();
if (inputSocket != NULL) {
inputSocket->setConnection(NULL);
}
this->connections.erase(this->connections.begin());
}
-void OutputSocket::clearConnections() {
+void OutputSocket::clearConnections()
+{
while (this->isConnected()) {
removeFirstConnection();
}
}
-WriteBufferOperation* OutputSocket::findAttachedWriteBufferOperation() const {
+WriteBufferOperation *OutputSocket::findAttachedWriteBufferOperation() const
+{
unsigned int index;
for (index = 0 ; index < this->connections.size();index++) {
- SocketConnection* connection = this->connections[index];
- NodeBase* node = connection->getToNode();
+ SocketConnection *connection = this->connections[index];
+ NodeBase *node = connection->getToNode();
if (node->isOperation()) {
- NodeOperation* operation = (NodeOperation*)node;
+ NodeOperation *operation = (NodeOperation*)node;
if (operation->isWriteBufferOperation()) {
return (WriteBufferOperation*)operation;
}
@@ -141,7 +152,8 @@ WriteBufferOperation* OutputSocket::findAttachedWriteBufferOperation() const {
return NULL;
}
-ChannelInfo* OutputSocket::getChannelInfo(const int channelnumber) {
+ChannelInfo *OutputSocket::getChannelInfo(const int channelnumber)
+{
return &this->channelinfo[channelnumber];
}
diff --git a/source/blender/compositor/intern/COM_OutputSocket.h b/source/blender/compositor/intern/COM_OutputSocket.h
index 8815f0bb3a8..640588417b4 100644
--- a/source/blender/compositor/intern/COM_OutputSocket.h
+++ b/source/blender/compositor/intern/COM_OutputSocket.h
@@ -58,7 +58,7 @@ public:
OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex);
OutputSocket(OutputSocket * from);
void addConnection(SocketConnection *connection);
- SocketConnection* getConnection(unsigned int index) {return this->connections[index];}
+ SocketConnection *getConnection(unsigned int index) {return this->connections[index];}
const int isConnected() const;
int isOutputSocket() const;
@@ -90,8 +90,8 @@ public:
* @brief find a connected write buffer operation to this OutputSocket
* @return WriteBufferOperation or NULL
*/
- WriteBufferOperation* findAttachedWriteBufferOperation() const;
- ChannelInfo* getChannelInfo(const int channelnumber);
+ WriteBufferOperation *findAttachedWriteBufferOperation() const;
+ ChannelInfo *getChannelInfo(const int channelnumber);
/**
* @brief trigger determine actual data type to all connected sockets
diff --git a/source/blender/compositor/intern/COM_Socket.cpp b/source/blender/compositor/intern/COM_Socket.cpp
index cb429c9df4a..a5336ac1202 100644
--- a/source/blender/compositor/intern/COM_Socket.cpp
+++ b/source/blender/compositor/intern/COM_Socket.cpp
@@ -24,14 +24,16 @@
#include "COM_Node.h"
#include "COM_SocketConnection.h"
-Socket::Socket(DataType datatype) {
+Socket::Socket(DataType datatype)
+{
this->datatype = datatype;
this->actualType = COM_DT_UNKNOWN;
this->editorSocket = NULL;
this->node = NULL;
}
-DataType Socket::getDataType() const {
+DataType Socket::getDataType() const
+{
return this->datatype;
}
@@ -39,9 +41,10 @@ int Socket::isInputSocket() const { return false; }
int Socket::isOutputSocket() const { return false; }
const int Socket::isConnected() const {return false;}
void Socket::setNode(NodeBase *node) {this->node = node;}
-NodeBase* Socket::getNode() const {return this->node;}
+NodeBase *Socket::getNode() const {return this->node;}
DataType Socket::getActualDataType() const {return this->actualType;}
-void Socket::setActualDataType(DataType actualType) {
+void Socket::setActualDataType(DataType actualType)
+{
this->actualType = actualType;
}
diff --git a/source/blender/compositor/intern/COM_Socket.h b/source/blender/compositor/intern/COM_Socket.h
index 3243a371cda..8ad7a5c7fde 100644
--- a/source/blender/compositor/intern/COM_Socket.h
+++ b/source/blender/compositor/intern/COM_Socket.h
@@ -49,7 +49,7 @@ private:
/**
* Reference to the node where this Socket belongs to
*/
- NodeBase* node;
+ NodeBase *node;
/**
* the datatype of this socket. Is used for automatically data transformation.
@@ -63,13 +63,13 @@ private:
*/
DataType actualType;
- bNodeSocket* editorSocket;
+ bNodeSocket *editorSocket;
public:
Socket(DataType datatype);
DataType getDataType() const;
- void setNode(NodeBase* node);
- NodeBase* getNode() const;
+ void setNode(NodeBase *node);
+ NodeBase *getNode() const;
/**
* @brief get the actual data type
@@ -91,8 +91,8 @@ public:
virtual void determineResolution(int resolution[], unsigned int preferredResolution[]) {}
virtual void determineActualDataType() {}
- void setEditorSocket(bNodeSocket* editorSocket) {this->editorSocket = editorSocket;}
- bNodeSocket* getbNodeSocket() const {return this->editorSocket;}
+ void setEditorSocket(bNodeSocket *editorSocket) {this->editorSocket = editorSocket;}
+ bNodeSocket *getbNodeSocket() const {return this->editorSocket;}
};
diff --git a/source/blender/compositor/intern/COM_SocketConnection.cpp b/source/blender/compositor/intern/COM_SocketConnection.cpp
index e3e52005add..9f0c736392a 100644
--- a/source/blender/compositor/intern/COM_SocketConnection.cpp
+++ b/source/blender/compositor/intern/COM_SocketConnection.cpp
@@ -23,30 +23,34 @@
#include "COM_SocketConnection.h"
#include "COM_NodeOperation.h"
-SocketConnection::SocketConnection() {
+SocketConnection::SocketConnection()
+{
this->fromSocket = NULL;
this->toSocket = NULL;
this->setIgnoreResizeCheck(false);
}
-void SocketConnection::setFromSocket(OutputSocket* fromsocket) {
+void SocketConnection::setFromSocket(OutputSocket *fromsocket)
+{
if (fromsocket == NULL) {
throw "ERROR";
}
this->fromSocket = fromsocket;
}
-OutputSocket* SocketConnection::getFromSocket() const {return this->fromSocket;}
-void SocketConnection::setToSocket(InputSocket* tosocket) {
+OutputSocket *SocketConnection::getFromSocket() const {return this->fromSocket;}
+void SocketConnection::setToSocket(InputSocket *tosocket)
+{
if (tosocket == NULL) {
throw "ERROR";
}
this->toSocket = tosocket;
}
-InputSocket* SocketConnection::getToSocket() const {return this->toSocket;}
+InputSocket *SocketConnection::getToSocket() const {return this->toSocket;}
-NodeBase* SocketConnection::getFromNode() const {
+NodeBase *SocketConnection::getFromNode() const
+{
if (this->getFromSocket() == NULL) {
return NULL;
}
@@ -54,7 +58,8 @@ NodeBase* SocketConnection::getFromNode() const {
return this->getFromSocket()->getNode();
}
}
-NodeBase* SocketConnection::getToNode() const {
+NodeBase *SocketConnection::getToNode() const
+{
if (this->getToSocket() == NULL) {
return NULL;
}
@@ -62,7 +67,8 @@ NodeBase* SocketConnection::getToNode() const {
return this->getToSocket()->getNode();
}
}
-bool SocketConnection::isValid() const {
+bool SocketConnection::isValid() const
+{
if ((this->getToSocket() != NULL && this->getFromSocket() != NULL)) {
if (this->getFromNode()->isOperation() && this->getToNode()->isOperation()) {
return true;
@@ -71,10 +77,11 @@ bool SocketConnection::isValid() const {
return false;
}
-bool SocketConnection::needsResolutionConversion() const {
+bool SocketConnection::needsResolutionConversion() const
+{
if (this->ignoreResizeCheck) {return false;}
- NodeOperation* fromOperation = (NodeOperation*)this->getFromNode();
- NodeOperation* toOperation = (NodeOperation*)this->getToNode();
+ NodeOperation *fromOperation = (NodeOperation*)this->getFromNode();
+ NodeOperation *toOperation = (NodeOperation*)this->getToNode();
if (this->toSocket->getResizeMode() == COM_SC_NO_RESIZE) {return false;}
const unsigned int fromWidth = fromOperation->getWidth();
const unsigned int fromHeight = fromOperation->getHeight();
diff --git a/source/blender/compositor/intern/COM_SocketConnection.h b/source/blender/compositor/intern/COM_SocketConnection.h
index 55811cc6ebe..1c4dcebfe07 100644
--- a/source/blender/compositor/intern/COM_SocketConnection.h
+++ b/source/blender/compositor/intern/COM_SocketConnection.h
@@ -66,25 +66,25 @@ public:
* @brief set the startpoint of the connection
* @param fromsocket
*/
- void setFromSocket(OutputSocket* fromsocket);
+ void setFromSocket(OutputSocket *fromsocket);
/**
* @brief get the startpoint of the connection
* @return from OutputSocket
*/
- OutputSocket* getFromSocket() const;
+ OutputSocket *getFromSocket() const;
/**
* @brief set the endpoint of the connection
* @param tosocket
*/
- void setToSocket(InputSocket* tosocket);
+ void setToSocket(InputSocket *tosocket);
/**
* @brief get the endpoint of the connection
* @return to InputSocket
*/
- InputSocket* getToSocket() const;
+ InputSocket *getToSocket() const;
/**
* @brief check if this connection is valid
diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h
index fd07726a939..24322847517 100644
--- a/source/blender/compositor/intern/COM_SocketReader.h
+++ b/source/blender/compositor/intern/COM_SocketReader.h
@@ -59,7 +59,7 @@ protected:
* @param y the y-coordinate of the pixel to calculate in image space
* @param inputBuffers chunks that can be read by their ReadBufferOperation.
*/
- virtual void executePixel(float* result, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {}
+ virtual void executePixel(float *result, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {}
/**
* @brief calculate a single pixel
@@ -70,7 +70,7 @@ protected:
* @param inputBuffers chunks that can be read by their ReadBufferOperation.
* @param chunkData chunk specific data a during execution time.
*/
- virtual void executePixel(float* result, int x, int y, MemoryBuffer *inputBuffers[], void* chunkData) {
+ virtual void executePixel(float *result, int x, int y, MemoryBuffer *inputBuffers[], void *chunkData) {
executePixel(result, x, y, COM_PS_NEAREST, inputBuffers);
}
@@ -84,26 +84,26 @@ protected:
* @param dy
* @param inputBuffers chunks that can be read by their ReadBufferOperation.
*/
- virtual void executePixel(float* result, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) {}
+ virtual void executePixel(float *result, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) {}
public:
- inline void read(float* result, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ inline void read(float *result, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
executePixel(result, x, y, sampler, inputBuffers);
}
- inline void read(float* result, int x, int y, MemoryBuffer *inputBuffers[], void* chunkData) {
+ inline void read(float *result, int x, int y, MemoryBuffer *inputBuffers[], void *chunkData) {
executePixel(result, x, y, inputBuffers, chunkData);
}
- inline void read(float* result, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) {
+ inline void read(float *result, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) {
executePixel(result, x, y, dx, dy, inputBuffers);
}
- virtual void* initializeTileData(rcti *rect, MemoryBuffer** memoryBuffers) {
+ virtual void *initializeTileData(rcti *rect, MemoryBuffer** memoryBuffers) {
return 0;
}
- virtual void deinitializeTileData(rcti *rect, MemoryBuffer** memoryBuffers, void* data) {
+ virtual void deinitializeTileData(rcti *rect, MemoryBuffer** memoryBuffers, void *data) {
}
- virtual MemoryBuffer* getInputMemoryBuffer(MemoryBuffer** memoryBuffers) {return 0;}
+ virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer** memoryBuffers) {return 0;}
inline const unsigned int getWidth() const {return this->width;}
diff --git a/source/blender/compositor/intern/COM_WorkPackage.cpp b/source/blender/compositor/intern/COM_WorkPackage.cpp
index d606e845b00..07974b9aafc 100644
--- a/source/blender/compositor/intern/COM_WorkPackage.cpp
+++ b/source/blender/compositor/intern/COM_WorkPackage.cpp
@@ -22,7 +22,8 @@
#include "COM_WorkPackage.h"
-WorkPackage::WorkPackage(ExecutionGroup *group, unsigned int chunkNumber) {
+WorkPackage::WorkPackage(ExecutionGroup *group, unsigned int chunkNumber)
+{
this->executionGroup = group;
this->chunkNumber = chunkNumber;
}
diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h
index 3169a9dcc30..8bdf21499cf 100644
--- a/source/blender/compositor/intern/COM_WorkPackage.h
+++ b/source/blender/compositor/intern/COM_WorkPackage.h
@@ -36,7 +36,7 @@ private:
/**
* @brief executionGroup with the operations-setup to be evaluated
*/
- ExecutionGroup* executionGroup;
+ ExecutionGroup *executionGroup;
/**
* @brief number of the chunk to be executed
@@ -48,12 +48,12 @@ public:
* @param group the ExecutionGroup
* @param chunkNumber the number of the chunk
*/
- WorkPackage(ExecutionGroup* group, unsigned int chunkNumber);
+ WorkPackage(ExecutionGroup *group, unsigned int chunkNumber);
/**
* @brief get the ExecutionGroup
*/
- ExecutionGroup* getExecutionGroup() const {return this->executionGroup;}
+ ExecutionGroup *getExecutionGroup() const {return this->executionGroup;}
/**
* @brief get the number of the chunk
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index 5130525853b..c82a01a1e0a 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -65,14 +65,15 @@ static bool openclActive = false;
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
-void* WorkScheduler::thread_execute_cpu(void* data) {
+void *WorkScheduler::thread_execute_cpu(void *data)
+{
bool continueLoop = true;
- Device* device = (Device*)data;
+ Device *device = (Device*)data;
while (continueLoop) {
- WorkPackage* work = (WorkPackage*)BLI_thread_queue_pop(cpuqueue);
+ WorkPackage *work = (WorkPackage*)BLI_thread_queue_pop(cpuqueue);
if (work) {
- device->execute(work);
- delete work;
+ device->execute(work);
+ delete work;
}
PIL_sleep_ms(10);
@@ -83,11 +84,12 @@ void* WorkScheduler::thread_execute_cpu(void* data) {
return NULL;
}
-void* WorkScheduler::thread_execute_gpu(void* data) {
+void *WorkScheduler::thread_execute_gpu(void *data)
+{
bool continueLoop = true;
- Device* device = (Device*)data;
+ Device *device = (Device*)data;
while (continueLoop) {
- WorkPackage* work = (WorkPackage*)BLI_thread_queue_pop(gpuqueue);
+ WorkPackage *work = (WorkPackage*)BLI_thread_queue_pop(gpuqueue);
if (work) {
device->execute(work);
delete work;
@@ -106,8 +108,9 @@ bool WorkScheduler::isStopping() {return state == COM_WSS_STOPPING;}
-void WorkScheduler::schedule(ExecutionGroup *group, int chunkNumber) {
- WorkPackage* package = new WorkPackage(group, chunkNumber);
+void WorkScheduler::schedule(ExecutionGroup *group, int chunkNumber)
+{
+ WorkPackage *package = new WorkPackage(group, chunkNumber);
#if COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD
CPUDevice device;
device.execute(package);
@@ -126,14 +129,15 @@ void WorkScheduler::schedule(ExecutionGroup *group, int chunkNumber) {
#endif
}
-void WorkScheduler::start(CompositorContext &context) {
+void WorkScheduler::start(CompositorContext &context)
+{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
unsigned int index;
cpuqueue = BLI_thread_queue_init();
BLI_thread_queue_nowait(cpuqueue);
BLI_init_threads(&cputhreads, thread_execute_cpu, cpudevices.size());
for (index = 0 ; index < cpudevices.size() ; index ++) {
- Device* device = cpudevices[index];
+ Device *device = cpudevices[index];
BLI_insert_thread(&cputhreads, device);
}
#ifdef COM_OPENCL_ENABLED
@@ -142,7 +146,7 @@ void WorkScheduler::start(CompositorContext &context) {
BLI_thread_queue_nowait(gpuqueue);
BLI_init_threads(&gputhreads, thread_execute_gpu, gpudevices.size());
for (index = 0 ; index < gpudevices.size() ; index ++) {
- Device* device = gpudevices[index];
+ Device *device = gpudevices[index];
BLI_insert_thread(&gputhreads, device);
}
openclActive = true;
@@ -154,7 +158,8 @@ void WorkScheduler::start(CompositorContext &context) {
#endif
state = COM_WSS_STARTED;
}
-void WorkScheduler::finish() {
+void WorkScheduler::finish()
+{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
#ifdef COM_OPENCL_ENABLED
if (openclActive) {
@@ -174,7 +179,8 @@ void WorkScheduler::finish() {
#endif
#endif
}
-void WorkScheduler::stop() {
+void WorkScheduler::stop()
+{
state = COM_WSS_STOPPING;
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
BLI_end_threads(&cputhreads);
@@ -191,7 +197,8 @@ void WorkScheduler::stop() {
state = COM_WSS_STOPPED;
}
-bool WorkScheduler::hasGPUDevices() {
+bool WorkScheduler::hasGPUDevices()
+{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
#ifdef COM_OPENCL_ENABLED
return gpudevices.size()>0;
@@ -203,11 +210,13 @@ bool WorkScheduler::hasGPUDevices() {
#endif
}
-extern void clContextError(const char *errinfo, const void *private_info, size_t cb, void *user_data) {
+extern void clContextError(const char *errinfo, const void *private_info, size_t cb, void *user_data)
+{
printf("OPENCL error: %s\n", errinfo);
}
-void WorkScheduler::initialize() {
+void WorkScheduler::initialize()
+{
state = COM_WSS_UNKNOWN;
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
@@ -257,7 +266,7 @@ void WorkScheduler::initialize() {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- char* build_log = new char[ret_val_size+1];
+ char *build_log = new char[ret_val_size+1];
error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
build_log[ret_val_size] = '\0';
@@ -268,7 +277,7 @@ void WorkScheduler::initialize() {
unsigned int indexDevices;
for (indexDevices = 0 ; indexDevices < totalNumberOfDevices ; indexDevices ++) {
cl_device_id device = cldevices[indexDevices];
- OpenCLDevice* clDevice = new OpenCLDevice(context, device, program);
+ OpenCLDevice *clDevice = new OpenCLDevice(context, device, program);
clDevice->initialize(),
gpudevices.push_back(clDevice);
char resultString[32];
@@ -286,9 +295,10 @@ void WorkScheduler::initialize() {
state = COM_WSS_INITIALIZED;
}
-void WorkScheduler::deinitialize() {
+void WorkScheduler::deinitialize()
+{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
- Device* device;
+ Device *device;
while (cpudevices.size()>0) {
device = cpudevices.back();
cpudevices.pop_back();
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h
index 0befa209e47..0de1763749e 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.h
+++ b/source/blender/compositor/intern/COM_WorkScheduler.h
@@ -59,13 +59,13 @@ class WorkScheduler {
* @brief main thread loop for cpudevices
* inside this loop new work is queried and being executed
*/
- static void* thread_execute_cpu(void* data);
+ static void *thread_execute_cpu(void *data);
/**
* @brief main thread loop for gpudevices
* inside this loop new work is queried and being executed
*/
- static void* thread_execute_gpu(void* data);
+ static void *thread_execute_gpu(void *data);
#endif
public:
/**
@@ -77,7 +77,7 @@ public:
* @param group the execution group
* @param chunkNumber the number of the chunk in the group to be executed
*/
- static void schedule(ExecutionGroup* group, int chunkNumber);
+ static void schedule(ExecutionGroup *group, int chunkNumber);
/**
* @brief initialize the WorkScheduler
diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp
index 5707fc2c2fe..bd967190987 100644
--- a/source/blender/compositor/intern/COM_compositor.cpp
+++ b/source/blender/compositor/intern/COM_compositor.cpp
@@ -31,7 +31,8 @@ extern "C" {
#include "COM_WorkScheduler.h"
static ThreadMutex *compositorMutex;
-void COM_execute(bNodeTree *editingtree, int rendering) {
+void COM_execute(bNodeTree *editingtree, int rendering)
+{
if (compositorMutex == NULL) { /// TODO: move to blender startup phase
compositorMutex = new ThreadMutex();
BLI_mutex_init(compositorMutex);
@@ -51,7 +52,7 @@ void COM_execute(bNodeTree *editingtree, int rendering) {
editingtree->stats_draw(editingtree->sdh, (char*)"Compositing");
/* initialize execution system */
- ExecutionSystem* system = new ExecutionSystem(editingtree, rendering);
+ ExecutionSystem *system = new ExecutionSystem(editingtree, rendering);
system->execute();
delete system;