ClangFormat: apply to source, most of intern

Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
This commit is contained in:
2019-04-17 06:17:24 +02:00
parent b3dabc200a
commit e12c08e8d1
4481 changed files with 1230080 additions and 1155401 deletions

View File

@@ -27,91 +27,91 @@
CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode)
{
/* pass */
/* pass */
}
/* This is taken from the Cryptomatte specification 1.0. */
static inline float hash_to_float(uint32_t hash)
{
uint32_t mantissa = hash & (( 1 << 23) - 1);
uint32_t exponent = (hash >> 23) & ((1 << 8) - 1);
exponent = max(exponent, (uint32_t) 1);
exponent = min(exponent, (uint32_t) 254);
exponent = exponent << 23;
uint32_t sign = (hash >> 31);
sign = sign << 31;
uint32_t float_bits = sign | exponent | mantissa;
float f;
/* Bit casting relies on equal size for both types. */
BLI_STATIC_ASSERT(sizeof(float) == sizeof(uint32_t), "float and uint32_t are not the same size")
::memcpy(&f, &float_bits, sizeof(float));
return f;
uint32_t mantissa = hash & ((1 << 23) - 1);
uint32_t exponent = (hash >> 23) & ((1 << 8) - 1);
exponent = max(exponent, (uint32_t)1);
exponent = min(exponent, (uint32_t)254);
exponent = exponent << 23;
uint32_t sign = (hash >> 31);
sign = sign << 31;
uint32_t float_bits = sign | exponent | mantissa;
float f;
/* Bit casting relies on equal size for both types. */
BLI_STATIC_ASSERT(sizeof(float) == sizeof(uint32_t), "float and uint32_t are not the same size")
::memcpy(&f, &float_bits, sizeof(float));
return f;
}
void CryptomatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
void CryptomatteNode::convertToOperations(NodeConverter &converter,
const CompositorContext & /*context*/) const
{
NodeInput *inputSocketImage = this->getInputSocket(0);
NodeOutput *outputSocketImage = this->getOutputSocket(0);
NodeOutput *outputSocketMatte = this->getOutputSocket(1);
NodeOutput *outputSocketPick = this->getOutputSocket(2);
NodeInput *inputSocketImage = this->getInputSocket(0);
NodeOutput *outputSocketImage = this->getOutputSocket(0);
NodeOutput *outputSocketMatte = this->getOutputSocket(1);
NodeOutput *outputSocketPick = this->getOutputSocket(2);
bNode *node = this->getbNode();
NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage;
bNode *node = this->getbNode();
NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage;
CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets() - 1);
if (cryptoMatteSettings) {
if (cryptoMatteSettings->matte_id) {
/* Split the string by commas, ignoring white space. */
std::string input = cryptoMatteSettings->matte_id;
std::istringstream ss(input);
while (ss.good()) {
std::string token;
getline(ss, token, ',');
/* Ignore empty tokens. */
if (token.length() > 0) {
size_t first = token.find_first_not_of(' ');
size_t last = token.find_last_not_of(' ');
if (first == std::string::npos || last == std::string::npos) {
break;
}
token = token.substr(first, (last - first + 1));
if (*token.begin() == '<' && *(--token.end()) == '>') {
operation->addObjectIndex(atof(token.substr(1, token.length() - 2).c_str()));
}
else {
uint32_t hash = BLI_hash_mm3((const unsigned char *)token.c_str(), token.length(), 0);
operation->addObjectIndex(hash_to_float(hash));
}
}
}
}
}
CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets() - 1);
if (cryptoMatteSettings) {
if (cryptoMatteSettings->matte_id) {
/* Split the string by commas, ignoring white space. */
std::string input = cryptoMatteSettings->matte_id;
std::istringstream ss(input);
while (ss.good()) {
std::string token;
getline(ss, token, ',');
/* Ignore empty tokens. */
if (token.length() > 0) {
size_t first = token.find_first_not_of(' ');
size_t last = token.find_last_not_of(' ');
if (first == std::string::npos || last == std::string::npos) {
break;
}
token = token.substr(first, (last - first + 1));
if (*token.begin() == '<' && *(--token.end()) == '>') {
operation->addObjectIndex(atof(token.substr(1, token.length() - 2).c_str()));
}
else {
uint32_t hash = BLI_hash_mm3((const unsigned char *)token.c_str(), token.length(), 0);
operation->addObjectIndex(hash_to_float(hash));
}
}
}
}
}
converter.addOperation(operation);
converter.addOperation(operation);
for (int i = 0; i < getNumberOfInputSockets() - 1; ++i) {
converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i));
}
for (int i = 0; i < getNumberOfInputSockets() - 1; ++i) {
converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i));
}
SeparateChannelOperation *separateOperation = new SeparateChannelOperation;
separateOperation->setChannel(3);
converter.addOperation(separateOperation);
SeparateChannelOperation *separateOperation = new SeparateChannelOperation;
separateOperation->setChannel(3);
converter.addOperation(separateOperation);
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
converter.addOperation(operationAlpha);
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
converter.addOperation(operationAlpha);
converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0));
converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1));
converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0));
converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1));
SetAlphaOperation *clearAlphaOperation = new SetAlphaOperation();
converter.addOperation(clearAlphaOperation);
converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f);
SetAlphaOperation *clearAlphaOperation = new SetAlphaOperation();
converter.addOperation(clearAlphaOperation);
converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f);
converter.addLink(operation->getOutputSocket(0), clearAlphaOperation->getInputSocket(0));
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0));
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0));
converter.mapOutputSocket(outputSocketPick, clearAlphaOperation->getOutputSocket(0));
converter.addLink(operation->getOutputSocket(0), clearAlphaOperation->getInputSocket(0));
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0));
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0));
converter.mapOutputSocket(outputSocketPick, clearAlphaOperation->getOutputSocket(0));
}