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:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/compositor/nodes/COM_ImageNode.cpp
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
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
Diffstat (limited to 'source/blender/compositor/nodes/COM_ImageNode.cpp')
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.cpp454
1 files changed, 242 insertions, 212 deletions
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp
index fb3a222cc66..cf25e9f26ae 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -31,238 +31,268 @@
ImageNode::ImageNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
-
+ /* pass */
}
-NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter, RenderLayer *rl, Image *image, ImageUser *user,
- int framenumber, int outputsocketIndex, int passindex, int view, DataType datatype) const
+NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter,
+ RenderLayer *rl,
+ Image *image,
+ ImageUser *user,
+ int framenumber,
+ int outputsocketIndex,
+ int passindex,
+ int view,
+ DataType datatype) const
{
- NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex);
- MultilayerBaseOperation *operation = NULL;
- switch (datatype) {
- case COM_DT_VALUE:
- operation = new MultilayerValueOperation(passindex, view);
- break;
- case COM_DT_VECTOR:
- operation = new MultilayerVectorOperation(passindex, view);
- break;
- case COM_DT_COLOR:
- operation = new MultilayerColorOperation(passindex, view);
- break;
- default:
- break;
- }
- operation->setImage(image);
- operation->setRenderLayer(rl);
- operation->setImageUser(user);
- operation->setFramenumber(framenumber);
+ NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex);
+ MultilayerBaseOperation *operation = NULL;
+ switch (datatype) {
+ case COM_DT_VALUE:
+ operation = new MultilayerValueOperation(passindex, view);
+ break;
+ case COM_DT_VECTOR:
+ operation = new MultilayerVectorOperation(passindex, view);
+ break;
+ case COM_DT_COLOR:
+ operation = new MultilayerColorOperation(passindex, view);
+ break;
+ default:
+ break;
+ }
+ operation->setImage(image);
+ operation->setRenderLayer(rl);
+ operation->setImageUser(user);
+ operation->setFramenumber(framenumber);
- converter.addOperation(operation);
- converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
+ converter.addOperation(operation);
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
- return operation;
+ return operation;
}
-void ImageNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void ImageNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- /// Image output
- NodeOutput *outputImage = this->getOutputSocket(0);
- bNode *editorNode = this->getbNode();
- Image *image = (Image *)editorNode->id;
- ImageUser *imageuser = (ImageUser *)editorNode->storage;
- int framenumber = context.getFramenumber();
- int numberOfOutputs = this->getNumberOfOutputSockets();
- bool outputStraightAlpha = (editorNode->custom1 & CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT) != 0;
- BKE_image_user_frame_calc(imageuser, context.getFramenumber());
- /* force a load, we assume iuser index will be set OK anyway */
- if (image && image->type == IMA_TYPE_MULTILAYER) {
- bool is_multilayer_ok = false;
- ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, NULL);
- if (image->rr) {
- RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer);
- if (rl) {
- NodeOutput *socket;
- int index;
+ /// Image output
+ NodeOutput *outputImage = this->getOutputSocket(0);
+ bNode *editorNode = this->getbNode();
+ Image *image = (Image *)editorNode->id;
+ ImageUser *imageuser = (ImageUser *)editorNode->storage;
+ int framenumber = context.getFramenumber();
+ int numberOfOutputs = this->getNumberOfOutputSockets();
+ bool outputStraightAlpha = (editorNode->custom1 & CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT) != 0;
+ BKE_image_user_frame_calc(imageuser, context.getFramenumber());
+ /* force a load, we assume iuser index will be set OK anyway */
+ if (image && image->type == IMA_TYPE_MULTILAYER) {
+ bool is_multilayer_ok = false;
+ ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, NULL);
+ if (image->rr) {
+ RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer);
+ if (rl) {
+ NodeOutput *socket;
+ int index;
- is_multilayer_ok = true;
+ is_multilayer_ok = true;
- for (index = 0; index < numberOfOutputs; index++) {
- NodeOperation *operation = NULL;
- socket = this->getOutputSocket(index);
- bNodeSocket *bnodeSocket = socket->getbNodeSocket();
- NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;
- RenderPass *rpass = (RenderPass *)BLI_findstring(&rl->passes, storage->pass_name, offsetof(RenderPass, name));
- int view = 0;
+ for (index = 0; index < numberOfOutputs; index++) {
+ NodeOperation *operation = NULL;
+ socket = this->getOutputSocket(index);
+ bNodeSocket *bnodeSocket = socket->getbNodeSocket();
+ NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;
+ RenderPass *rpass = (RenderPass *)BLI_findstring(
+ &rl->passes, storage->pass_name, offsetof(RenderPass, name));
+ int view = 0;
- if (STREQ(storage->pass_name, RE_PASSNAME_COMBINED) && STREQ(bnodeSocket->name, "Alpha")) {
- /* Alpha output is already handled with the associated combined output. */
- continue;
- }
+ if (STREQ(storage->pass_name, RE_PASSNAME_COMBINED) &&
+ STREQ(bnodeSocket->name, "Alpha")) {
+ /* Alpha output is already handled with the associated combined output. */
+ continue;
+ }
- /* returns the image view to use for the current active view */
- if (BLI_listbase_count_at_most(&image->rr->views, 2) > 1) {
- const int view_image = imageuser->view;
- const bool is_allview = (view_image == 0); /* if view selected == All (0) */
+ /* returns the image view to use for the current active view */
+ if (BLI_listbase_count_at_most(&image->rr->views, 2) > 1) {
+ const int view_image = imageuser->view;
+ const bool is_allview = (view_image == 0); /* if view selected == All (0) */
- if (is_allview) {
- /* heuristic to match image name with scene names
- * check if the view name exists in the image */
- view = BLI_findstringindex(&image->rr->views, context.getViewName(), offsetof(RenderView, name));
- if (view == -1) view = 0;
- }
- else {
- view = view_image - 1;
- }
- }
+ if (is_allview) {
+ /* heuristic to match image name with scene names
+ * check if the view name exists in the image */
+ view = BLI_findstringindex(
+ &image->rr->views, context.getViewName(), offsetof(RenderView, name));
+ if (view == -1)
+ view = 0;
+ }
+ else {
+ view = view_image - 1;
+ }
+ }
- if (rpass) {
- int passindex = BLI_findindex(&rl->passes, rpass);
- switch (rpass->channels) {
- case 1:
- operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index,
- passindex, view, COM_DT_VALUE);
- break;
- /* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */
- /* XXX any way to detect actual vector images? */
- case 3:
- operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index,
- passindex, view, COM_DT_VECTOR);
- break;
- case 4:
- operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index,
- passindex, view, COM_DT_COLOR);
- break;
- default:
- /* dummy operation is added below */
- break;
- }
- if (index == 0 && operation) {
- converter.addPreview(operation->getOutputSocket());
- }
- if (STREQ(rpass->name, RE_PASSNAME_COMBINED)) {
- for (int alphaIndex = 0; alphaIndex < numberOfOutputs; alphaIndex++) {
- NodeOutput *alphaSocket = this->getOutputSocket(alphaIndex);
- bNodeSocket *bnodeAlphaSocket = alphaSocket->getbNodeSocket();
- if (!STREQ(bnodeAlphaSocket->name, "Alpha")) {
- continue;
- }
- NodeImageLayer *alphaStorage = (NodeImageLayer *)bnodeSocket->storage;
- if (!STREQ(alphaStorage->pass_name, RE_PASSNAME_COMBINED)) {
- continue;
- }
- SeparateChannelOperation *separate_operation;
- separate_operation = new SeparateChannelOperation();
- separate_operation->setChannel(3);
- converter.addOperation(separate_operation);
- converter.addLink(operation->getOutputSocket(), separate_operation->getInputSocket(0));
- converter.mapOutputSocket(alphaSocket, separate_operation->getOutputSocket());
- break;
- }
- }
- }
+ if (rpass) {
+ int passindex = BLI_findindex(&rl->passes, rpass);
+ switch (rpass->channels) {
+ case 1:
+ operation = doMultilayerCheck(converter,
+ rl,
+ image,
+ imageuser,
+ framenumber,
+ index,
+ passindex,
+ view,
+ COM_DT_VALUE);
+ break;
+ /* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */
+ /* XXX any way to detect actual vector images? */
+ case 3:
+ operation = doMultilayerCheck(converter,
+ rl,
+ image,
+ imageuser,
+ framenumber,
+ index,
+ passindex,
+ view,
+ COM_DT_VECTOR);
+ break;
+ case 4:
+ operation = doMultilayerCheck(converter,
+ rl,
+ image,
+ imageuser,
+ framenumber,
+ index,
+ passindex,
+ view,
+ COM_DT_COLOR);
+ break;
+ default:
+ /* dummy operation is added below */
+ break;
+ }
+ if (index == 0 && operation) {
+ converter.addPreview(operation->getOutputSocket());
+ }
+ if (STREQ(rpass->name, RE_PASSNAME_COMBINED)) {
+ for (int alphaIndex = 0; alphaIndex < numberOfOutputs; alphaIndex++) {
+ NodeOutput *alphaSocket = this->getOutputSocket(alphaIndex);
+ bNodeSocket *bnodeAlphaSocket = alphaSocket->getbNodeSocket();
+ if (!STREQ(bnodeAlphaSocket->name, "Alpha")) {
+ continue;
+ }
+ NodeImageLayer *alphaStorage = (NodeImageLayer *)bnodeSocket->storage;
+ if (!STREQ(alphaStorage->pass_name, RE_PASSNAME_COMBINED)) {
+ continue;
+ }
+ SeparateChannelOperation *separate_operation;
+ separate_operation = new SeparateChannelOperation();
+ separate_operation->setChannel(3);
+ converter.addOperation(separate_operation);
+ converter.addLink(operation->getOutputSocket(),
+ separate_operation->getInputSocket(0));
+ converter.mapOutputSocket(alphaSocket, separate_operation->getOutputSocket());
+ break;
+ }
+ }
+ }
- /* incase we can't load the layer */
- if (operation == NULL)
- converter.setInvalidOutput(getOutputSocket(index));
- }
- }
- }
- BKE_image_release_ibuf(image, ibuf, NULL);
+ /* incase we can't load the layer */
+ if (operation == NULL)
+ converter.setInvalidOutput(getOutputSocket(index));
+ }
+ }
+ }
+ BKE_image_release_ibuf(image, ibuf, NULL);
- /* without this, multilayer that fail to load will crash blender [#32490] */
- if (is_multilayer_ok == false) {
- for (int i = 0; i < getNumberOfOutputSockets(); ++i)
- converter.setInvalidOutput(getOutputSocket(i));
- }
- }
- else {
- if (numberOfOutputs > 0) {
- ImageOperation *operation = new ImageOperation();
- operation->setImage(image);
- operation->setImageUser(imageuser);
- operation->setFramenumber(framenumber);
- operation->setRenderData(context.getRenderData());
- operation->setViewName(context.getViewName());
- converter.addOperation(operation);
+ /* without this, multilayer that fail to load will crash blender [#32490] */
+ if (is_multilayer_ok == false) {
+ for (int i = 0; i < getNumberOfOutputSockets(); ++i)
+ converter.setInvalidOutput(getOutputSocket(i));
+ }
+ }
+ else {
+ if (numberOfOutputs > 0) {
+ ImageOperation *operation = new ImageOperation();
+ operation->setImage(image);
+ operation->setImageUser(imageuser);
+ operation->setFramenumber(framenumber);
+ operation->setRenderData(context.getRenderData());
+ operation->setViewName(context.getViewName());
+ converter.addOperation(operation);
- if (outputStraightAlpha) {
- NodeOperation *alphaConvertOperation = new ConvertPremulToStraightOperation();
+ if (outputStraightAlpha) {
+ NodeOperation *alphaConvertOperation = new ConvertPremulToStraightOperation();
- converter.addOperation(alphaConvertOperation);
- converter.mapOutputSocket(outputImage, alphaConvertOperation->getOutputSocket());
- converter.addLink(operation->getOutputSocket(0), alphaConvertOperation->getInputSocket(0));
- }
- else {
- converter.mapOutputSocket(outputImage, operation->getOutputSocket());
- }
+ converter.addOperation(alphaConvertOperation);
+ converter.mapOutputSocket(outputImage, alphaConvertOperation->getOutputSocket());
+ converter.addLink(operation->getOutputSocket(0), alphaConvertOperation->getInputSocket(0));
+ }
+ else {
+ converter.mapOutputSocket(outputImage, operation->getOutputSocket());
+ }
- converter.addPreview(operation->getOutputSocket());
- }
+ converter.addPreview(operation->getOutputSocket());
+ }
- if (numberOfOutputs > 1) {
- NodeOutput *alphaImage = this->getOutputSocket(1);
- ImageAlphaOperation *alphaOperation = new ImageAlphaOperation();
- alphaOperation->setImage(image);
- alphaOperation->setImageUser(imageuser);
- alphaOperation->setFramenumber(framenumber);
- alphaOperation->setRenderData(context.getRenderData());
- alphaOperation->setViewName(context.getViewName());
- converter.addOperation(alphaOperation);
+ if (numberOfOutputs > 1) {
+ NodeOutput *alphaImage = this->getOutputSocket(1);
+ ImageAlphaOperation *alphaOperation = new ImageAlphaOperation();
+ alphaOperation->setImage(image);
+ alphaOperation->setImageUser(imageuser);
+ alphaOperation->setFramenumber(framenumber);
+ alphaOperation->setRenderData(context.getRenderData());
+ alphaOperation->setViewName(context.getViewName());
+ converter.addOperation(alphaOperation);
- converter.mapOutputSocket(alphaImage, alphaOperation->getOutputSocket());
- }
- if (numberOfOutputs > 2) {
- NodeOutput *depthImage = this->getOutputSocket(2);
- ImageDepthOperation *depthOperation = new ImageDepthOperation();
- depthOperation->setImage(image);
- depthOperation->setImageUser(imageuser);
- depthOperation->setFramenumber(framenumber);
- depthOperation->setRenderData(context.getRenderData());
- depthOperation->setViewName(context.getViewName());
- converter.addOperation(depthOperation);
+ converter.mapOutputSocket(alphaImage, alphaOperation->getOutputSocket());
+ }
+ if (numberOfOutputs > 2) {
+ NodeOutput *depthImage = this->getOutputSocket(2);
+ ImageDepthOperation *depthOperation = new ImageDepthOperation();
+ depthOperation->setImage(image);
+ depthOperation->setImageUser(imageuser);
+ depthOperation->setFramenumber(framenumber);
+ depthOperation->setRenderData(context.getRenderData());
+ depthOperation->setViewName(context.getViewName());
+ converter.addOperation(depthOperation);
- converter.mapOutputSocket(depthImage, depthOperation->getOutputSocket());
- }
- if (numberOfOutputs > 3) {
- /* happens when unlinking image datablock from multilayer node */
- for (int i = 3; i < numberOfOutputs; i++) {
- NodeOutput *output = this->getOutputSocket(i);
- NodeOperation *operation = NULL;
- switch (output->getDataType()) {
- case COM_DT_VALUE:
- {
- SetValueOperation *valueoperation = new SetValueOperation();
- valueoperation->setValue(0.0f);
- operation = valueoperation;
- break;
- }
- case COM_DT_VECTOR:
- {
- SetVectorOperation *vectoroperation = new SetVectorOperation();
- vectoroperation->setX(0.0f);
- vectoroperation->setY(0.0f);
- vectoroperation->setW(0.0f);
- operation = vectoroperation;
- break;
- }
- case COM_DT_COLOR:
- {
- SetColorOperation *coloroperation = new SetColorOperation();
- coloroperation->setChannel1(0.0f);
- coloroperation->setChannel2(0.0f);
- coloroperation->setChannel3(0.0f);
- coloroperation->setChannel4(0.0f);
- operation = coloroperation;
- break;
- }
- }
+ converter.mapOutputSocket(depthImage, depthOperation->getOutputSocket());
+ }
+ if (numberOfOutputs > 3) {
+ /* happens when unlinking image datablock from multilayer node */
+ for (int i = 3; i < numberOfOutputs; i++) {
+ NodeOutput *output = this->getOutputSocket(i);
+ NodeOperation *operation = NULL;
+ switch (output->getDataType()) {
+ case COM_DT_VALUE: {
+ SetValueOperation *valueoperation = new SetValueOperation();
+ valueoperation->setValue(0.0f);
+ operation = valueoperation;
+ break;
+ }
+ case COM_DT_VECTOR: {
+ SetVectorOperation *vectoroperation = new SetVectorOperation();
+ vectoroperation->setX(0.0f);
+ vectoroperation->setY(0.0f);
+ vectoroperation->setW(0.0f);
+ operation = vectoroperation;
+ break;
+ }
+ case COM_DT_COLOR: {
+ SetColorOperation *coloroperation = new SetColorOperation();
+ coloroperation->setChannel1(0.0f);
+ coloroperation->setChannel2(0.0f);
+ coloroperation->setChannel3(0.0f);
+ coloroperation->setChannel4(0.0f);
+ operation = coloroperation;
+ break;
+ }
+ }
- if (operation) {
- /* not supporting multiview for this generic case */
- converter.addOperation(operation);
- converter.mapOutputSocket(output, operation->getOutputSocket());
- }
- }
- }
- }
+ if (operation) {
+ /* not supporting multiview for this generic case */
+ converter.addOperation(operation);
+ converter.mapOutputSocket(output, operation->getOutputSocket());
+ }
+ }
+ }
+ }
}