diff options
Diffstat (limited to 'source/blender/compositor/intern')
41 files changed, 1200 insertions, 1181 deletions
diff --git a/source/blender/compositor/intern/COM_BufferOperation.cc b/source/blender/compositor/intern/COM_BufferOperation.cc index c6530cf6bd1..21238733925 100644 --- a/source/blender/compositor/intern/COM_BufferOperation.cc +++ b/source/blender/compositor/intern/COM_BufferOperation.cc @@ -25,7 +25,7 @@ BufferOperation::BufferOperation(MemoryBuffer *buffer, DataType data_type) buffer_ = buffer; inflated_buffer_ = nullptr; set_canvas(buffer->get_rect()); - addOutputSocket(data_type); + add_output_socket(data_type); flags.is_constant_operation = buffer_->is_a_single_elem(); flags.is_fullframe_operation = false; } @@ -33,39 +33,42 @@ BufferOperation::BufferOperation(MemoryBuffer *buffer, DataType data_type) const float *BufferOperation::get_constant_elem() { BLI_assert(buffer_->is_a_single_elem()); - return buffer_->getBuffer(); + return buffer_->get_buffer(); } -void BufferOperation::initExecution() +void BufferOperation::init_execution() { if (buffer_->is_a_single_elem()) { - initMutex(); + init_mutex(); } } -void *BufferOperation::initializeTileData(rcti * /*rect*/) +void *BufferOperation::initialize_tile_data(rcti * /*rect*/) { if (buffer_->is_a_single_elem() == false) { return buffer_; } - lockMutex(); + lock_mutex(); if (!inflated_buffer_) { inflated_buffer_ = buffer_->inflate(); } - unlockMutex(); + unlock_mutex(); return inflated_buffer_; } -void BufferOperation::deinitExecution() +void BufferOperation::deinit_execution() { if (buffer_->is_a_single_elem()) { - deinitMutex(); + deinit_mutex(); } delete inflated_buffer_; } -void BufferOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) +void BufferOperation::execute_pixel_sampled(float output[4], + float x, + float y, + PixelSampler sampler) { switch (sampler) { case PixelSampler::Nearest: @@ -73,16 +76,16 @@ void BufferOperation::executePixelSampled(float output[4], float x, float y, Pix break; case PixelSampler::Bilinear: default: - buffer_->readBilinear(output, x, y); + buffer_->read_bilinear(output, x, y); break; case PixelSampler::Bicubic: /* No bicubic. Same implementation as ReadBufferOperation. */ - buffer_->readBilinear(output, x, y); + buffer_->read_bilinear(output, x, y); break; } } -void BufferOperation::executePixelFiltered( +void BufferOperation::execute_pixel_filtered( float output[4], float x, float y, float dx[2], float dy[2]) { const float uv[2] = {x, y}; diff --git a/source/blender/compositor/intern/COM_BufferOperation.h b/source/blender/compositor/intern/COM_BufferOperation.h index b4cbc0a56b6..4aba3a705dd 100644 --- a/source/blender/compositor/intern/COM_BufferOperation.h +++ b/source/blender/compositor/intern/COM_BufferOperation.h @@ -31,11 +31,12 @@ class BufferOperation : public ConstantOperation { BufferOperation(MemoryBuffer *buffer, DataType data_type); const float *get_constant_elem() override; - void *initializeTileData(rcti *rect) override; - void initExecution() override; - void deinitExecution() override; - void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override; - void executePixelFiltered(float output[4], float x, float y, float dx[2], float dy[2]) override; + void *initialize_tile_data(rcti *rect) override; + void init_execution() override; + void deinit_execution() override; + void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override; + void execute_pixel_filtered( + float output[4], float x, float y, float dx[2], float dy[2]) override; }; } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_CPUDevice.cc b/source/blender/compositor/intern/COM_CPUDevice.cc index 89aea47f4a6..ad7a807b8fd 100644 --- a/source/blender/compositor/intern/COM_CPUDevice.cc +++ b/source/blender/compositor/intern/COM_CPUDevice.cc @@ -31,11 +31,11 @@ void CPUDevice::execute(WorkPackage *work_package) { switch (work_package->type) { case eWorkPackageType::Tile: { - const unsigned int chunkNumber = work_package->chunk_number; - ExecutionGroup *executionGroup = work_package->execution_group; + const unsigned int chunk_number = work_package->chunk_number; + ExecutionGroup *execution_group = work_package->execution_group; - executionGroup->getOutputOperation()->executeRegion(&work_package->rect, chunkNumber); - executionGroup->finalizeChunkExecution(chunkNumber, nullptr); + execution_group->get_output_operation()->execute_region(&work_package->rect, chunk_number); + execution_group->finalize_chunk_execution(chunk_number, nullptr); break; } case eWorkPackageType::CustomFunction: { diff --git a/source/blender/compositor/intern/COM_CompositorContext.cc b/source/blender/compositor/intern/COM_CompositorContext.cc index 5e2e5ea295b..7b0f7b0f8fb 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cc +++ b/source/blender/compositor/intern/COM_CompositorContext.cc @@ -26,13 +26,13 @@ CompositorContext::CompositorContext() rd_ = nullptr; quality_ = eCompositorQuality::High; hasActiveOpenCLDevices_ = false; - fastCalculation_ = false; - viewSettings_ = nullptr; - displaySettings_ = nullptr; + fast_calculation_ = false; + view_settings_ = nullptr; + display_settings_ = nullptr; bnodetree_ = nullptr; } -int CompositorContext::getFramenumber() const +int CompositorContext::get_framenumber() const { BLI_assert(rd_); return rd_->cfra; @@ -40,8 +40,8 @@ int CompositorContext::getFramenumber() const Size2f CompositorContext::get_render_size() const { - return {getRenderData()->xsch * getRenderPercentageAsFactor(), - getRenderData()->ysch * getRenderPercentageAsFactor()}; + return {get_render_data()->xsch * get_render_percentage_as_factor(), + get_render_data()->ysch * get_render_percentage_as_factor()}; } eExecutionModel CompositorContext::get_execution_model() const diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 9354551d66a..e41576b6f69 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -77,16 +77,16 @@ class CompositorContext { /** * \brief Skip slow nodes */ - bool fastCalculation_; + bool fast_calculation_; /* \brief color management settings */ - const ColorManagedViewSettings *viewSettings_; - const ColorManagedDisplaySettings *displaySettings_; + const ColorManagedViewSettings *view_settings_; + const ColorManagedDisplaySettings *display_settings_; /** * \brief active rendering view name */ - const char *viewName_; + const char *view_name_; public: /** @@ -97,7 +97,7 @@ class CompositorContext { /** * \brief set the rendering field of the context */ - void setRendering(bool rendering) + void set_rendering(bool rendering) { rendering_ = rendering; } @@ -105,7 +105,7 @@ class CompositorContext { /** * \brief get the rendering field of the context */ - bool isRendering() const + bool is_rendering() const { return rendering_; } @@ -113,7 +113,7 @@ class CompositorContext { /** * \brief set the scene of the context */ - void setRenderData(RenderData *rd) + void set_render_data(RenderData *rd) { rd_ = rd; } @@ -121,7 +121,7 @@ class CompositorContext { /** * \brief set the bnodetree of the context */ - void setbNodeTree(bNodeTree *bnodetree) + void set_bnodetree(bNodeTree *bnodetree) { bnodetree_ = bnodetree; } @@ -129,7 +129,7 @@ class CompositorContext { /** * \brief get the bnodetree of the context */ - const bNodeTree *getbNodeTree() const + const bNodeTree *get_bnodetree() const { return bnodetree_; } @@ -137,16 +137,16 @@ class CompositorContext { /** * \brief get the scene of the context */ - const RenderData *getRenderData() const + const RenderData *get_render_data() const { return rd_; } - void setScene(Scene *scene) + void set_scene(Scene *scene) { scene_ = scene; } - Scene *getScene() const + Scene *get_scene() const { return scene_; } @@ -154,7 +154,7 @@ class CompositorContext { /** * \brief set the preview image hash table */ - void setPreviewHash(bNodeInstanceHash *previews) + void set_preview_hash(bNodeInstanceHash *previews) { previews_ = previews; } @@ -162,7 +162,7 @@ class CompositorContext { /** * \brief get the preview image hash table */ - bNodeInstanceHash *getPreviewHash() const + bNodeInstanceHash *get_preview_hash() const { return previews_; } @@ -170,39 +170,39 @@ class CompositorContext { /** * \brief set view settings of color management */ - void setViewSettings(const ColorManagedViewSettings *viewSettings) + void set_view_settings(const ColorManagedViewSettings *view_settings) { - viewSettings_ = viewSettings; + view_settings_ = view_settings; } /** * \brief get view settings of color management */ - const ColorManagedViewSettings *getViewSettings() const + const ColorManagedViewSettings *get_view_settings() const { - return viewSettings_; + return view_settings_; } /** * \brief set display settings of color management */ - void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) + void set_display_settings(const ColorManagedDisplaySettings *display_settings) { - displaySettings_ = displaySettings; + display_settings_ = display_settings; } /** * \brief get display settings of color management */ - const ColorManagedDisplaySettings *getDisplaySettings() const + const ColorManagedDisplaySettings *get_display_settings() const { - return displaySettings_; + return display_settings_; } /** * \brief set the quality */ - void setQuality(eCompositorQuality quality) + void set_quality(eCompositorQuality quality) { quality_ = quality; } @@ -210,7 +210,7 @@ class CompositorContext { /** * \brief get the quality */ - eCompositorQuality getQuality() const + eCompositorQuality get_quality() const { return quality_; } @@ -218,18 +218,18 @@ class CompositorContext { /** * \brief get the current frame-number of the scene in this context */ - int getFramenumber() const; + int get_framenumber() const; /** - * \brief has this system active openclDevices? + * \brief has this system active opencl_devices? */ - bool getHasActiveOpenCLDevices() const + bool get_has_active_opencl_devices() const { return hasActiveOpenCLDevices_; } /** - * \brief set has this system active openclDevices? + * \brief set has this system active opencl_devices? */ void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices) { @@ -239,48 +239,48 @@ class CompositorContext { /** Whether it has a view with a specific name and not the default one. */ bool has_explicit_view() const { - return viewName_ && viewName_[0] != '\0'; + return view_name_ && view_name_[0] != '\0'; } /** * \brief get the active rendering view */ - const char *getViewName() const + const char *get_view_name() const { - return viewName_; + return view_name_; } /** * \brief set the active rendering view */ - void setViewName(const char *viewName) + void set_view_name(const char *view_name) { - viewName_ = viewName; + view_name_ = view_name; } - int getChunksize() const + int get_chunksize() const { - return this->getbNodeTree()->chunksize; + return this->get_bnodetree()->chunksize; } - void setFastCalculation(bool fastCalculation) + void set_fast_calculation(bool fast_calculation) { - fastCalculation_ = fastCalculation; + fast_calculation_ = fast_calculation; } - bool isFastCalculation() const + bool is_fast_calculation() const { - return fastCalculation_; + return fast_calculation_; } - bool isGroupnodeBufferEnabled() const + bool is_groupnode_buffer_enabled() const { - return (this->getbNodeTree()->flag & NTREE_COM_GROUPNODE_BUFFER) != 0; + return (this->get_bnodetree()->flag & NTREE_COM_GROUPNODE_BUFFER) != 0; } /** * \brief Get the render percentage as a factor. * The compositor uses a factor i.o. a percentage. */ - float getRenderPercentageAsFactor() const + float get_render_percentage_as_factor() const { return rd_->size * 0.01f; } diff --git a/source/blender/compositor/intern/COM_ConstantFolder.cc b/source/blender/compositor/intern/COM_ConstantFolder.cc index d3031765eae..2cf3ac001d1 100644 --- a/source/blender/compositor/intern/COM_ConstantFolder.cc +++ b/source/blender/compositor/intern/COM_ConstantFolder.cc @@ -44,7 +44,7 @@ ConstantFolder::ConstantFolder(NodeOperationBuilder &operations_builder) static bool is_constant_foldable(NodeOperation *operation) { if (operation->get_flags().can_be_constant && !operation->get_flags().is_constant_operation) { - for (int i = 0; i < operation->getNumberOfInputSockets(); i++) { + for (int i = 0; i < operation->get_number_of_input_sockets(); i++) { NodeOperation *input = operation->get_input_operation(i); if (!input->get_flags().is_constant_operation || !static_cast<ConstantOperation *>(input)->can_get_constant_elem()) { @@ -72,17 +72,17 @@ static ConstantOperation *create_constant_operation(DataType data_type, const fl switch (data_type) { case DataType::Color: { SetColorOperation *color_op = new SetColorOperation(); - color_op->setChannels(constant_elem); + color_op->set_channels(constant_elem); return color_op; } case DataType::Vector: { SetVectorOperation *vector_op = new SetVectorOperation(); - vector_op->setVector(constant_elem); + vector_op->set_vector(constant_elem); return vector_op; } case DataType::Value: { SetValueOperation *value_op = new SetValueOperation(); - value_op->setValue(*constant_elem); + value_op->set_value(*constant_elem); return value_op; } default: { @@ -94,7 +94,7 @@ static ConstantOperation *create_constant_operation(DataType data_type, const fl ConstantOperation *ConstantFolder::fold_operation(NodeOperation *operation) { - const DataType data_type = operation->getOutputSocket()->getDataType(); + const DataType data_type = operation->get_output_socket()->get_data_type(); MemoryBuffer fold_buf(data_type, first_elem_area_); Vector<MemoryBuffer *> input_bufs = get_constant_input_buffers(operation); operation->init_data(); @@ -102,7 +102,8 @@ ConstantOperation *ConstantFolder::fold_operation(NodeOperation *operation) MemoryBuffer *constant_buf = create_constant_buffer(data_type); constant_buf->copy_from(&fold_buf, first_elem_area_); - ConstantOperation *constant_op = create_constant_operation(data_type, constant_buf->getBuffer()); + ConstantOperation *constant_op = create_constant_operation(data_type, + constant_buf->get_buffer()); operations_builder_.replace_operation_with_constant(operation, constant_op); constant_buffers_.add_new(constant_op, constant_buf); return constant_op; @@ -117,14 +118,15 @@ MemoryBuffer *ConstantFolder::create_constant_buffer(const DataType data_type) Vector<MemoryBuffer *> ConstantFolder::get_constant_input_buffers(NodeOperation *operation) { - const int num_inputs = operation->getNumberOfInputSockets(); + const int num_inputs = operation->get_number_of_input_sockets(); Vector<MemoryBuffer *> inputs_bufs(num_inputs); for (int i = 0; i < num_inputs; i++) { BLI_assert(operation->get_input_operation(i)->get_flags().is_constant_operation); ConstantOperation *constant_op = static_cast<ConstantOperation *>( operation->get_input_operation(i)); MemoryBuffer *constant_buf = constant_buffers_.lookup_or_add_cb(constant_op, [=] { - MemoryBuffer *buf = create_constant_buffer(constant_op->getOutputSocket()->getDataType()); + MemoryBuffer *buf = create_constant_buffer( + constant_op->get_output_socket()->get_data_type()); constant_op->render(buf, {first_elem_area_}, {}); return buf; }); @@ -186,8 +188,8 @@ void ConstantFolder::get_operation_output_operations(NodeOperation *operation, { const Vector<Link> &links = operations_builder_.get_links(); for (const Link &link : links) { - if (&link.from()->getOperation() == operation) { - r_outputs.append(&link.to()->getOperation()); + if (&link.from()->get_operation() == operation) { + r_outputs.append(&link.to()->get_operation()); } } } diff --git a/source/blender/compositor/intern/COM_Converter.cc b/source/blender/compositor/intern/COM_Converter.cc index 346c3c4b600..0af4ff7d98d 100644 --- a/source/blender/compositor/intern/COM_Converter.cc +++ b/source/blender/compositor/intern/COM_Converter.cc @@ -433,8 +433,8 @@ Node *COM_convert_bnode(bNode *b_node) /* TODO(jbakker): make this an std::optional<NodeOperation>. */ NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, const NodeOperationInput &to) { - const DataType src_data_type = from.getDataType(); - const DataType dst_data_type = to.getDataType(); + const DataType src_data_type = from.get_data_type(); + const DataType dst_data_type = to.get_data_type(); if (src_data_type == DataType::Value && dst_data_type == DataType::Color) { return new ConvertValueToColorOperation(); @@ -459,24 +459,24 @@ NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, const Node } void COM_convert_canvas(NodeOperationBuilder &builder, - NodeOperationOutput *fromSocket, - NodeOperationInput *toSocket) + NodeOperationOutput *from_socket, + NodeOperationInput *to_socket) { /* Data type conversions are executed before resolutions to ensure convert operations have * resolution. This method have to ensure same datatypes are linked for new operations. */ - BLI_assert(fromSocket->getDataType() == toSocket->getDataType()); + BLI_assert(from_socket->get_data_type() == to_socket->get_data_type()); - ResizeMode mode = toSocket->getResizeMode(); + ResizeMode mode = to_socket->get_resize_mode(); BLI_assert(mode != ResizeMode::None); - NodeOperation *toOperation = &toSocket->getOperation(); - const float toWidth = toOperation->getWidth(); - const float toHeight = toOperation->getHeight(); - NodeOperation *fromOperation = &fromSocket->getOperation(); - const float fromWidth = fromOperation->getWidth(); - const float fromHeight = fromOperation->getHeight(); - bool doCenter = false; - bool doScale = false; + NodeOperation *to_operation = &to_socket->get_operation(); + const float to_width = to_operation->get_width(); + const float to_height = to_operation->get_height(); + NodeOperation *from_operation = &from_socket->get_operation(); + const float from_width = from_operation->get_width(); + const float from_height = from_operation->get_height(); + bool do_center = false; + bool do_scale = false; float scaleX = 0; float scaleY = 0; @@ -485,23 +485,23 @@ void COM_convert_canvas(NodeOperationBuilder &builder, case ResizeMode::Align: break; case ResizeMode::Center: - doCenter = true; + do_center = true; break; case ResizeMode::FitWidth: - doCenter = true; - doScale = true; - scaleX = scaleY = toWidth / fromWidth; + do_center = true; + do_scale = true; + scaleX = scaleY = to_width / from_width; break; case ResizeMode::FitHeight: - doCenter = true; - doScale = true; - scaleX = scaleY = toHeight / fromHeight; + do_center = true; + do_scale = true; + scaleX = scaleY = to_height / from_height; break; case ResizeMode::FitAny: - doCenter = true; - doScale = true; - scaleX = toWidth / fromWidth; - scaleY = toHeight / fromHeight; + do_center = true; + do_scale = true; + scaleX = to_width / from_width; + scaleY = to_height / from_height; if (scaleX < scaleY) { scaleX = scaleY; } @@ -510,81 +510,82 @@ void COM_convert_canvas(NodeOperationBuilder &builder, } break; case ResizeMode::Stretch: - doCenter = true; - doScale = true; - scaleX = toWidth / fromWidth; - scaleY = toHeight / fromHeight; + do_center = true; + do_scale = true; + scaleX = to_width / from_width; + scaleY = to_height / from_height; break; } - float addX = doCenter ? (toWidth - fromWidth) / 2.0f : 0.0f; - float addY = doCenter ? (toHeight - fromHeight) / 2.0f : 0.0f; + float addX = do_center ? (to_width - from_width) / 2.0f : 0.0f; + float addY = do_center ? (to_height - from_height) / 2.0f : 0.0f; NodeOperation *first = nullptr; - ScaleOperation *scaleOperation = nullptr; - if (doScale) { - scaleOperation = new ScaleRelativeOperation(fromSocket->getDataType()); - scaleOperation->getInputSocket(1)->setResizeMode(ResizeMode::None); - scaleOperation->getInputSocket(2)->setResizeMode(ResizeMode::None); - first = scaleOperation; + ScaleOperation *scale_operation = nullptr; + if (do_scale) { + scale_operation = new ScaleRelativeOperation(from_socket->get_data_type()); + scale_operation->get_input_socket(1)->set_resize_mode(ResizeMode::None); + scale_operation->get_input_socket(2)->set_resize_mode(ResizeMode::None); + first = scale_operation; SetValueOperation *sxop = new SetValueOperation(); - sxop->setValue(scaleX); - builder.addLink(sxop->getOutputSocket(), scaleOperation->getInputSocket(1)); + sxop->set_value(scaleX); + builder.add_link(sxop->get_output_socket(), scale_operation->get_input_socket(1)); SetValueOperation *syop = new SetValueOperation(); - syop->setValue(scaleY); - builder.addLink(syop->getOutputSocket(), scaleOperation->getInputSocket(2)); - builder.addOperation(sxop); - builder.addOperation(syop); + syop->set_value(scaleY); + builder.add_link(syop->get_output_socket(), scale_operation->get_input_socket(2)); + builder.add_operation(sxop); + builder.add_operation(syop); - rcti scale_canvas = fromOperation->get_canvas(); + rcti scale_canvas = from_operation->get_canvas(); if (builder.context().get_execution_model() == eExecutionModel::FullFrame) { ScaleOperation::scale_area(scale_canvas, scaleX, scaleY); - scale_canvas.xmax = scale_canvas.xmin + toOperation->getWidth(); - scale_canvas.ymax = scale_canvas.ymin + toOperation->getHeight(); + scale_canvas.xmax = scale_canvas.xmin + to_operation->get_width(); + scale_canvas.ymax = scale_canvas.ymin + to_operation->get_height(); addX = 0; addY = 0; } - scaleOperation->set_canvas(scale_canvas); + scale_operation->set_canvas(scale_canvas); sxop->set_canvas(scale_canvas); syop->set_canvas(scale_canvas); - builder.addOperation(scaleOperation); + builder.add_operation(scale_operation); } - TranslateOperation *translateOperation = new TranslateOperation(toSocket->getDataType()); - translateOperation->getInputSocket(1)->setResizeMode(ResizeMode::None); - translateOperation->getInputSocket(2)->setResizeMode(ResizeMode::None); + TranslateOperation *translate_operation = new TranslateOperation(to_socket->get_data_type()); + translate_operation->get_input_socket(1)->set_resize_mode(ResizeMode::None); + translate_operation->get_input_socket(2)->set_resize_mode(ResizeMode::None); if (!first) { - first = translateOperation; + first = translate_operation; } SetValueOperation *xop = new SetValueOperation(); - xop->setValue(addX); - builder.addLink(xop->getOutputSocket(), translateOperation->getInputSocket(1)); + xop->set_value(addX); + builder.add_link(xop->get_output_socket(), translate_operation->get_input_socket(1)); SetValueOperation *yop = new SetValueOperation(); - yop->setValue(addY); - builder.addLink(yop->getOutputSocket(), translateOperation->getInputSocket(2)); - builder.addOperation(xop); - builder.addOperation(yop); + yop->set_value(addY); + builder.add_link(yop->get_output_socket(), translate_operation->get_input_socket(2)); + builder.add_operation(xop); + builder.add_operation(yop); - rcti translate_canvas = toOperation->get_canvas(); + rcti translate_canvas = to_operation->get_canvas(); if (mode == ResizeMode::Align) { - translate_canvas.xmax = translate_canvas.xmin + fromWidth; - translate_canvas.ymax = translate_canvas.ymin + fromHeight; + translate_canvas.xmax = translate_canvas.xmin + from_width; + translate_canvas.ymax = translate_canvas.ymin + from_height; } - translateOperation->set_canvas(translate_canvas); + translate_operation->set_canvas(translate_canvas); xop->set_canvas(translate_canvas); yop->set_canvas(translate_canvas); - builder.addOperation(translateOperation); + builder.add_operation(translate_operation); - if (doScale) { - translateOperation->getInputSocket(0)->setResizeMode(ResizeMode::None); - builder.addLink(scaleOperation->getOutputSocket(), translateOperation->getInputSocket(0)); + if (do_scale) { + translate_operation->get_input_socket(0)->set_resize_mode(ResizeMode::None); + builder.add_link(scale_operation->get_output_socket(), + translate_operation->get_input_socket(0)); } /* remove previous link and replace */ - builder.removeInputLink(toSocket); - first->getInputSocket(0)->setResizeMode(ResizeMode::None); - toSocket->setResizeMode(ResizeMode::None); - builder.addLink(fromSocket, first->getInputSocket(0)); - builder.addLink(translateOperation->getOutputSocket(), toSocket); + builder.remove_input_link(to_socket); + first->get_input_socket(0)->set_resize_mode(ResizeMode::None); + to_socket->set_resize_mode(ResizeMode::None); + builder.add_link(from_socket, first->get_input_socket(0)); + builder.add_link(translate_operation->get_output_socket(), to_socket); } } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h index 9cb6b1862b2..39bd44e8a9f 100644 --- a/source/blender/compositor/intern/COM_Converter.h +++ b/source/blender/compositor/intern/COM_Converter.h @@ -65,7 +65,7 @@ NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, * \see InputSocketResizeMode for the possible conversions. */ void COM_convert_canvas(NodeOperationBuilder &builder, - NodeOperationOutput *fromSocket, - NodeOperationInput *toSocket); + NodeOperationOutput *from_socket, + NodeOperationInput *to_socket); } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_Debug.cc b/source/blender/compositor/intern/COM_Debug.cc index 023db368ac9..50a69e55b2b 100644 --- a/source/blender/compositor/intern/COM_Debug.cc +++ b/source/blender/compositor/intern/COM_Debug.cc @@ -80,14 +80,14 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system, std::string fillcolor = "gainsboro"; if (operation->get_flags().is_viewer_operation) { const ViewerOperation *viewer = (const ViewerOperation *)operation; - if (viewer->isActiveViewerOutput()) { + if (viewer->is_active_viewer_output()) { fillcolor = "lightskyblue1"; } else { fillcolor = "lightskyblue3"; } } - else if (operation->isOutputOperation(system->getContext().isRendering())) { + else if (operation->is_output_operation(system->get_context().is_rendering())) { fillcolor = "dodgerblue1"; } else if (operation->get_flags().is_set_operation) { @@ -112,16 +112,16 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system, " [fillcolor=%s,style=filled,shape=record,label=\"{", fillcolor.c_str()); - int totinputs = operation->getNumberOfInputSockets(); + int totinputs = operation->get_number_of_input_sockets(); if (totinputs != 0) { len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{"); for (int k = 0; k < totinputs; k++) { - NodeOperationInput *socket = operation->getInputSocket(k); + NodeOperationInput *socket = operation->get_input_socket(k); if (k != 0) { len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|"); } len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<IN_%p>", socket); - switch (socket->getDataType()) { + switch (socket->get_data_type()) { case DataType::Value: len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value"); break; @@ -156,20 +156,20 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system, operation->get_id(), operation->get_canvas().xmin, operation->get_canvas().ymin, - operation->getWidth(), - operation->getHeight()); + operation->get_width(), + operation->get_height()); - int totoutputs = operation->getNumberOfOutputSockets(); + int totoutputs = operation->get_number_of_output_sockets(); if (totoutputs != 0) { len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{"); for (int k = 0; k < totoutputs; k++) { - NodeOperationOutput *socket = operation->getOutputSocket(k); + NodeOperationOutput *socket = operation->get_output_socket(k); if (k != 0) { len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|"); } len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<OUT_%p>", socket); - switch (socket->getDataType()) { + switch (socket->get_data_type()) { case DataType::Value: { ConstantOperation *constant = operation->get_flags().is_constant_operation ? static_cast<ConstantOperation *>(operation) : @@ -346,7 +346,7 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma for (NodeOperation *operation : system->operations_) { if (operation->get_flags().is_read_buffer_operation) { ReadBufferOperation *read = (ReadBufferOperation *)operation; - WriteBufferOperation *write = read->getMemoryProxy()->getWriteBufferOperation(); + WriteBufferOperation *write = read->get_memory_proxy()->get_write_buffer_operation(); std::vector<std::string> &read_groups = op_groups[read]; std::vector<std::string> &write_groups = op_groups[write]; @@ -366,14 +366,14 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma for (NodeOperation *op : system->operations_) { for (NodeOperationInput &to : op->inputs_) { - NodeOperationOutput *from = to.getLink(); + NodeOperationOutput *from = to.get_link(); if (!from) { continue; } std::string color; - switch (from->getDataType()) { + switch (from->get_data_type()) { case DataType::Value: color = "gray"; break; @@ -385,8 +385,8 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma break; } - NodeOperation *to_op = &to.getOperation(); - NodeOperation *from_op = &from->getOperation(); + NodeOperation *to_op = &to.get_operation(); + NodeOperation *from_op = &from->get_operation(); std::vector<std::string> &from_groups = op_groups[from_op]; std::vector<std::string> &to_groups = op_groups[to_op]; @@ -416,7 +416,7 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma } } - const bool has_execution_groups = system->getContext().get_execution_model() == + const bool has_execution_groups = system->get_context().get_execution_model() == eExecutionModel::Tiled && system->groups_.size() > 0; len += graphviz_legend(str + len, maxlen > len ? maxlen - len : 0, has_execution_groups); @@ -460,8 +460,8 @@ static std::string get_operations_export_dir() void DebugInfo::export_operation(const NodeOperation *op, MemoryBuffer *render) { - const int width = render->getWidth(); - const int height = render->getHeight(); + const int width = render->get_width(); + const int height = render->get_height(); const int num_channels = render->get_num_channels(); ImBuf *ibuf = IMB_allocImBuf(width, height, 8 * num_channels, IB_rectfloat); diff --git a/source/blender/compositor/intern/COM_Debug.h b/source/blender/compositor/intern/COM_Debug.h index f1edd3ea15f..021d6e744fb 100644 --- a/source/blender/compositor/intern/COM_Debug.h +++ b/source/blender/compositor/intern/COM_Debug.h @@ -89,7 +89,7 @@ class DebugInfo { static void node_added(const Node *node) { if (COM_EXPORT_GRAPHVIZ) { - node_names_[node] = std::string(node->getbNode() ? node->getbNode()->name : ""); + node_names_[node] = std::string(node->get_bnode() ? node->get_bnode()->name : ""); } } diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index a38a1cd0a6c..d2198fc14e8 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -64,22 +64,22 @@ ExecutionGroup::ExecutionGroup(int id) y_chunks_len_ = 0; chunks_len_ = 0; chunks_finished_ = 0; - BLI_rcti_init(&viewerBorder_, 0, 0, 0, 0); - executionStartTime_ = 0; + BLI_rcti_init(&viewer_border_, 0, 0, 0, 0); + execution_start_time_ = 0; } std::ostream &operator<<(std::ostream &os, const ExecutionGroup &execution_group) { os << "ExecutionGroup(id=" << execution_group.get_id(); os << ",flags={" << execution_group.get_flags() << "}"; - os << ",operation=" << *execution_group.getOutputOperation() << ""; + os << ",operation=" << *execution_group.get_output_operation() << ""; os << ")"; return os; } -eCompositorPriority ExecutionGroup::getRenderPriority() +eCompositorPriority ExecutionGroup::get_render_priority() { - return this->getOutputOperation()->getRenderPriority(); + return this->get_output_operation()->get_render_priority(); } bool ExecutionGroup::can_contain(NodeOperation &operation) @@ -111,7 +111,7 @@ bool ExecutionGroup::can_contain(NodeOperation &operation) return true; } -bool ExecutionGroup::addOperation(NodeOperation *operation) +bool ExecutionGroup::add_operation(NodeOperation *operation) { if (!can_contain(*operation)) { return false; @@ -130,7 +130,7 @@ bool ExecutionGroup::addOperation(NodeOperation *operation) return true; } -NodeOperation *ExecutionGroup::getOutputOperation() const +NodeOperation *ExecutionGroup::get_output_operation() const { return this ->operations_[0]; /* the first operation of the group is always the output operation. */ @@ -146,7 +146,7 @@ void ExecutionGroup::init_work_packages() work_packages_[index].state = eWorkPackageState::NotScheduled; work_packages_[index].execution_group = this; work_packages_[index].chunk_number = index; - determineChunkRect(&work_packages_[index].rect, index); + determine_chunk_rect(&work_packages_[index].rect, index); } } } @@ -156,23 +156,23 @@ void ExecutionGroup::init_read_buffer_operations() unsigned int max_offset = 0; for (NodeOperation *operation : operations_) { if (operation->get_flags().is_read_buffer_operation) { - ReadBufferOperation *readOperation = static_cast<ReadBufferOperation *>(operation); - read_operations_.append(readOperation); - max_offset = MAX2(max_offset, readOperation->getOffset()); + ReadBufferOperation *read_operation = static_cast<ReadBufferOperation *>(operation); + read_operations_.append(read_operation); + max_offset = MAX2(max_offset, read_operation->get_offset()); } } max_offset++; max_read_buffer_offset_ = max_offset; } -void ExecutionGroup::initExecution() +void ExecutionGroup::init_execution() { init_number_of_chunks(); init_work_packages(); init_read_buffer_operations(); } -void ExecutionGroup::deinitExecution() +void ExecutionGroup::deinit_execution() { work_packages_.clear(); chunks_len_ = 0; @@ -182,13 +182,13 @@ void ExecutionGroup::deinitExecution() bTree_ = nullptr; } -void ExecutionGroup::determineResolution(unsigned int resolution[2]) +void ExecutionGroup::determine_resolution(unsigned int resolution[2]) { - NodeOperation *operation = this->getOutputOperation(); - resolution[0] = operation->getWidth(); - resolution[1] = operation->getHeight(); - this->setResolution(resolution); - BLI_rcti_init(&viewerBorder_, 0, width_, 0, height_); + NodeOperation *operation = this->get_output_operation(); + resolution[0] = operation->get_width(); + resolution[1] = operation->get_height(); + this->set_resolution(resolution); + BLI_rcti_init(&viewer_border_, 0, width_, 0, height_); } void ExecutionGroup::init_number_of_chunks() @@ -199,11 +199,11 @@ void ExecutionGroup::init_number_of_chunks() chunks_len_ = 1; } else { - const float chunkSizef = chunkSize_; - const int border_width = BLI_rcti_size_x(&viewerBorder_); - const int border_height = BLI_rcti_size_y(&viewerBorder_); - x_chunks_len_ = ceil(border_width / chunkSizef); - y_chunks_len_ = ceil(border_height / chunkSizef); + const float chunk_sizef = chunk_size_; + const int border_width = BLI_rcti_size_x(&viewer_border_); + const int border_height = BLI_rcti_size_y(&viewer_border_); + x_chunks_len_ = ceil(border_width / chunk_sizef); + y_chunks_len_ = ceil(border_height / chunk_sizef); chunks_len_ = x_chunks_len_ * y_chunks_len_; } } @@ -215,7 +215,7 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const chunk_order[chunk_index] = chunk_index; } - NodeOperation *operation = this->getOutputOperation(); + NodeOperation *operation = this->get_output_operation(); float centerX = 0.5f; float centerY = 0.5f; ChunkOrdering order_type = ChunkOrdering::Default; @@ -224,11 +224,11 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const ViewerOperation *viewer = (ViewerOperation *)operation; centerX = viewer->getCenterX(); centerY = viewer->getCenterY(); - order_type = viewer->getChunkOrder(); + order_type = viewer->get_chunk_order(); } - const int border_width = BLI_rcti_size_x(&viewerBorder_); - const int border_height = BLI_rcti_size_y(&viewerBorder_); + const int border_width = BLI_rcti_size_x(&viewer_border_); + const int border_height = BLI_rcti_size_y(&viewer_border_); int index; switch (order_type) { case ChunkOrdering::Random: { @@ -245,8 +245,8 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const for (index = 0; index < chunks_len_; index++) { const WorkPackage &work_package = work_packages_[index]; chunk_orders[index].index = index; - chunk_orders[index].x = work_package.rect.xmin - viewerBorder_.xmin; - chunk_orders[index].y = work_package.rect.ymin - viewerBorder_.ymin; + chunk_orders[index].x = work_package.rect.xmin - viewer_border_.xmin; + chunk_orders[index].y = work_package.rect.ymin - viewer_border_.ymin; chunk_orders[index].update_distance(&hotspot, 1); } @@ -282,8 +282,8 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const for (index = 0; index < chunks_len_; index++) { const WorkPackage &work_package = work_packages_[index]; chunk_orders[index].index = index; - chunk_orders[index].x = work_package.rect.xmin - viewerBorder_.xmin; - chunk_orders[index].y = work_package.rect.ymin - viewerBorder_.ymin; + chunk_orders[index].x = work_package.rect.xmin - viewer_border_.xmin; + chunk_orders[index].y = work_package.rect.ymin - viewer_border_.ymin; chunk_orders[index].update_distance(hotspots, 9); } @@ -308,8 +308,8 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const */ void ExecutionGroup::execute(ExecutionSystem *graph) { - const CompositorContext &context = graph->getContext(); - const bNodeTree *bTree = context.getbNodeTree(); + const CompositorContext &context = graph->get_context(); + const bNodeTree *bTree = context.get_bnodetree(); if (width_ == 0 || height_ == 0) { return; } /** \note Break out... no pixels to calculate. */ @@ -321,7 +321,7 @@ void ExecutionGroup::execute(ExecutionSystem *graph) } /** \note Early break out. */ unsigned int chunk_index; - executionStartTime_ = PIL_check_seconds_timer(); + execution_start_time_ = PIL_check_seconds_timer(); chunks_finished_ = 0; bTree_ = bTree; @@ -333,26 +333,26 @@ void ExecutionGroup::execute(ExecutionSystem *graph) bool breaked = false; bool finished = false; - unsigned int startIndex = 0; - const int maxNumberEvaluated = BLI_system_thread_count() * 2; + unsigned int start_index = 0; + const int max_number_evaluated = BLI_system_thread_count() * 2; while (!finished && !breaked) { - bool startEvaluated = false; + bool start_evaluated = false; finished = true; - int numberEvaluated = 0; + int number_evaluated = 0; - for (int index = startIndex; index < chunks_len_ && numberEvaluated < maxNumberEvaluated; + for (int index = start_index; index < chunks_len_ && number_evaluated < max_number_evaluated; index++) { chunk_index = chunk_order[index]; - int yChunk = chunk_index / x_chunks_len_; - int xChunk = chunk_index - (yChunk * x_chunks_len_); + int y_chunk = chunk_index / x_chunks_len_; + int x_chunk = chunk_index - (y_chunk * x_chunks_len_); const WorkPackage &work_package = work_packages_[chunk_index]; switch (work_package.state) { case eWorkPackageState::NotScheduled: { - scheduleChunkWhenPossible(graph, xChunk, yChunk); + schedule_chunk_when_possible(graph, x_chunk, y_chunk); finished = false; - startEvaluated = true; - numberEvaluated++; + start_evaluated = true; + number_evaluated++; if (bTree->update_draw) { bTree->update_draw(bTree->udh); @@ -361,13 +361,13 @@ void ExecutionGroup::execute(ExecutionSystem *graph) } case eWorkPackageState::Scheduled: { finished = false; - startEvaluated = true; - numberEvaluated++; + start_evaluated = true; + number_evaluated++; break; } case eWorkPackageState::Executed: { - if (!startEvaluated) { - startIndex = index + 1; + if (!start_evaluated) { + start_index = index + 1; } } }; @@ -383,51 +383,51 @@ void ExecutionGroup::execute(ExecutionSystem *graph) DebugInfo::graphviz(graph); } -MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber) +MemoryBuffer **ExecutionGroup::get_input_buffers_opencl(int chunk_number) { - WorkPackage &work_package = work_packages_[chunkNumber]; + WorkPackage &work_package = work_packages_[chunk_number]; - MemoryBuffer **memoryBuffers = (MemoryBuffer **)MEM_callocN( + MemoryBuffer **memory_buffers = (MemoryBuffer **)MEM_callocN( sizeof(MemoryBuffer *) * max_read_buffer_offset_, __func__); rcti output; - for (ReadBufferOperation *readOperation : read_operations_) { - MemoryProxy *memoryProxy = readOperation->getMemoryProxy(); - this->determineDependingAreaOfInterest(&work_package.rect, readOperation, &output); - MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer( - *memoryProxy, output); - memoryBuffers[readOperation->getOffset()] = memoryBuffer; - } - return memoryBuffers; + for (ReadBufferOperation *read_operation : read_operations_) { + MemoryProxy *memory_proxy = read_operation->get_memory_proxy(); + this->determine_depending_area_of_interest(&work_package.rect, read_operation, &output); + MemoryBuffer *memory_buffer = + memory_proxy->get_executor()->construct_consolidated_memory_buffer(*memory_proxy, output); + memory_buffers[read_operation->get_offset()] = memory_buffer; + } + return memory_buffers; } -MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy &memoryProxy, - rcti &rect) +MemoryBuffer *ExecutionGroup::construct_consolidated_memory_buffer(MemoryProxy &memory_proxy, + rcti &rect) { - MemoryBuffer *imageBuffer = memoryProxy.getBuffer(); - MemoryBuffer *result = new MemoryBuffer(&memoryProxy, rect, MemoryBufferState::Temporary); - result->fill_from(*imageBuffer); + MemoryBuffer *image_buffer = memory_proxy.get_buffer(); + MemoryBuffer *result = new MemoryBuffer(&memory_proxy, rect, MemoryBufferState::Temporary); + result->fill_from(*image_buffer); return result; } -void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers) +void ExecutionGroup::finalize_chunk_execution(int chunk_number, MemoryBuffer **memory_buffers) { - WorkPackage &work_package = work_packages_[chunkNumber]; + WorkPackage &work_package = work_packages_[chunk_number]; if (work_package.state == eWorkPackageState::Scheduled) { work_package.state = eWorkPackageState::Executed; } atomic_add_and_fetch_u(&chunks_finished_, 1); - if (memoryBuffers) { + if (memory_buffers) { for (unsigned int index = 0; index < max_read_buffer_offset_; index++) { - MemoryBuffer *buffer = memoryBuffers[index]; + MemoryBuffer *buffer = memory_buffers[index]; if (buffer) { - if (buffer->isTemporarily()) { - memoryBuffers[index] = nullptr; + if (buffer->is_temporarily()) { + memory_buffers[index] = nullptr; delete buffer; } } } - MEM_freeN(memoryBuffers); + MEM_freeN(memory_buffers); } if (bTree_) { /* Status report is only performed for top level Execution Groups. */ @@ -442,67 +442,67 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo } } -inline void ExecutionGroup::determineChunkRect(rcti *r_rect, - const unsigned int xChunk, - const unsigned int yChunk) const +inline void ExecutionGroup::determine_chunk_rect(rcti *r_rect, + const unsigned int x_chunk, + const unsigned int y_chunk) const { - const int border_width = BLI_rcti_size_x(&viewerBorder_); - const int border_height = BLI_rcti_size_y(&viewerBorder_); + const int border_width = BLI_rcti_size_x(&viewer_border_); + const int border_height = BLI_rcti_size_y(&viewer_border_); if (flags_.single_threaded) { - BLI_rcti_init(r_rect, viewerBorder_.xmin, border_width, viewerBorder_.ymin, border_height); + BLI_rcti_init(r_rect, viewer_border_.xmin, border_width, viewer_border_.ymin, border_height); } else { - const unsigned int minx = xChunk * chunkSize_ + viewerBorder_.xmin; - const unsigned int miny = yChunk * chunkSize_ + viewerBorder_.ymin; - const unsigned int width = MIN2((unsigned int)viewerBorder_.xmax, width_); - const unsigned int height = MIN2((unsigned int)viewerBorder_.ymax, height_); + const unsigned int minx = x_chunk * chunk_size_ + viewer_border_.xmin; + const unsigned int miny = y_chunk * chunk_size_ + viewer_border_.ymin; + const unsigned int width = MIN2((unsigned int)viewer_border_.xmax, width_); + const unsigned int height = MIN2((unsigned int)viewer_border_.ymax, height_); BLI_rcti_init(r_rect, MIN2(minx, width_), - MIN2(minx + chunkSize_, width), + MIN2(minx + chunk_size_, width), MIN2(miny, height_), - MIN2(miny + chunkSize_, height)); + MIN2(miny + chunk_size_, height)); } } -void ExecutionGroup::determineChunkRect(rcti *r_rect, const unsigned int chunkNumber) const +void ExecutionGroup::determine_chunk_rect(rcti *r_rect, const unsigned int chunk_number) const { - const unsigned int yChunk = chunkNumber / x_chunks_len_; - const unsigned int xChunk = chunkNumber - (yChunk * x_chunks_len_); - determineChunkRect(r_rect, xChunk, yChunk); + const unsigned int y_chunk = chunk_number / x_chunks_len_; + const unsigned int x_chunk = chunk_number - (y_chunk * x_chunks_len_); + determine_chunk_rect(r_rect, x_chunk, y_chunk); } -MemoryBuffer *ExecutionGroup::allocateOutputBuffer(rcti &rect) +MemoryBuffer *ExecutionGroup::allocate_output_buffer(rcti &rect) { /* We assume that this method is only called from complex execution groups. */ - NodeOperation *operation = this->getOutputOperation(); + NodeOperation *operation = this->get_output_operation(); if (operation->get_flags().is_write_buffer_operation) { - WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation; + WriteBufferOperation *write_operation = (WriteBufferOperation *)operation; MemoryBuffer *buffer = new MemoryBuffer( - writeOperation->getMemoryProxy(), rect, MemoryBufferState::Temporary); + write_operation->get_memory_proxy(), rect, MemoryBufferState::Temporary); return buffer; } return nullptr; } -bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area) +bool ExecutionGroup::schedule_area_when_possible(ExecutionSystem *graph, rcti *area) { if (flags_.single_threaded) { - return scheduleChunkWhenPossible(graph, 0, 0); + return schedule_chunk_when_possible(graph, 0, 0); } /* Find all chunks inside the rect * determine `minxchunk`, `minychunk`, `maxxchunk`, `maxychunk` * where x and y are chunk-numbers. */ int indexx, indexy; - int minx = max_ii(area->xmin - viewerBorder_.xmin, 0); - int maxx = min_ii(area->xmax - viewerBorder_.xmin, viewerBorder_.xmax - viewerBorder_.xmin); - int miny = max_ii(area->ymin - viewerBorder_.ymin, 0); - int maxy = min_ii(area->ymax - viewerBorder_.ymin, viewerBorder_.ymax - viewerBorder_.ymin); - int minxchunk = minx / (int)chunkSize_; - int maxxchunk = (maxx + (int)chunkSize_ - 1) / (int)chunkSize_; - int minychunk = miny / (int)chunkSize_; - int maxychunk = (maxy + (int)chunkSize_ - 1) / (int)chunkSize_; + int minx = max_ii(area->xmin - viewer_border_.xmin, 0); + int maxx = min_ii(area->xmax - viewer_border_.xmin, viewer_border_.xmax - viewer_border_.xmin); + int miny = max_ii(area->ymin - viewer_border_.ymin, 0); + int maxy = min_ii(area->ymax - viewer_border_.ymin, viewer_border_.ymax - viewer_border_.ymin); + int minxchunk = minx / (int)chunk_size_; + int maxxchunk = (maxx + (int)chunk_size_ - 1) / (int)chunk_size_; + int minychunk = miny / (int)chunk_size_; + int maxychunk = (maxy + (int)chunk_size_ - 1) / (int)chunk_size_; minxchunk = max_ii(minxchunk, 0); minychunk = max_ii(minychunk, 0); maxxchunk = min_ii(maxxchunk, (int)x_chunks_len_); @@ -511,7 +511,7 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area bool result = true; for (indexx = minxchunk; indexx < maxxchunk; indexx++) { for (indexy = minychunk; indexy < maxychunk; indexy++) { - if (!scheduleChunkWhenPossible(graph, indexx, indexy)) { + if (!schedule_chunk_when_possible(graph, indexx, indexy)) { result = false; } } @@ -520,9 +520,9 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area return result; } -bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber) +bool ExecutionGroup::schedule_chunk(unsigned int chunk_number) { - WorkPackage &work_package = work_packages_[chunkNumber]; + WorkPackage &work_package = work_packages_[chunk_number]; if (work_package.state == eWorkPackageState::NotScheduled) { work_package.state = eWorkPackageState::Scheduled; WorkScheduler::schedule(&work_package); @@ -531,9 +531,9 @@ bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber) return false; } -bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, - const int chunk_x, - const int chunk_y) +bool ExecutionGroup::schedule_chunk_when_possible(ExecutionSystem *graph, + const int chunk_x, + const int chunk_y) { if (chunk_x < 0 || chunk_x >= (int)x_chunks_len_) { return true; @@ -557,42 +557,43 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, for (ReadBufferOperation *read_operation : read_operations_) { BLI_rcti_init(&area, 0, 0, 0, 0); - MemoryProxy *memory_proxy = read_operation->getMemoryProxy(); - determineDependingAreaOfInterest(&work_package.rect, read_operation, &area); - ExecutionGroup *group = memory_proxy->getExecutor(); + MemoryProxy *memory_proxy = read_operation->get_memory_proxy(); + determine_depending_area_of_interest(&work_package.rect, read_operation, &area); + ExecutionGroup *group = memory_proxy->get_executor(); - if (!group->scheduleAreaWhenPossible(graph, &area)) { + if (!group->schedule_area_when_possible(graph, &area)) { can_be_executed = false; } } if (can_be_executed) { - scheduleChunk(chunk_index); + schedule_chunk(chunk_index); } return false; } -void ExecutionGroup::determineDependingAreaOfInterest(rcti *input, - ReadBufferOperation *readOperation, - rcti *output) +void ExecutionGroup::determine_depending_area_of_interest(rcti *input, + ReadBufferOperation *read_operation, + rcti *output) { - this->getOutputOperation()->determineDependingAreaOfInterest(input, readOperation, output); + this->get_output_operation()->determine_depending_area_of_interest( + input, read_operation, output); } -void ExecutionGroup::setViewerBorder(float xmin, float xmax, float ymin, float ymax) +void ExecutionGroup::set_viewer_border(float xmin, float xmax, float ymin, float ymax) { - const NodeOperation &operation = *this->getOutputOperation(); + const NodeOperation &operation = *this->get_output_operation(); if (operation.get_flags().use_viewer_border) { - BLI_rcti_init(&viewerBorder_, xmin * width_, xmax * width_, ymin * height_, ymax * height_); + BLI_rcti_init(&viewer_border_, xmin * width_, xmax * width_, ymin * height_, ymax * height_); } } -void ExecutionGroup::setRenderBorder(float xmin, float xmax, float ymin, float ymax) +void ExecutionGroup::set_render_border(float xmin, float xmax, float ymin, float ymax) { - const NodeOperation &operation = *this->getOutputOperation(); - if (operation.isOutputOperation(true) && operation.get_flags().use_render_border) { - BLI_rcti_init(&viewerBorder_, xmin * width_, xmax * width_, ymin * height_, ymax * height_); + const NodeOperation &operation = *this->get_output_operation(); + if (operation.is_output_operation(true) && operation.get_flags().use_render_border) { + BLI_rcti_init(&viewer_border_, xmin * width_, xmax * width_, ymin * height_, ymax * height_); } } diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h index c0737b2bc02..6d1520f9c24 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.h +++ b/source/blender/compositor/intern/COM_ExecutionGroup.h @@ -109,7 +109,7 @@ class ExecutionGroup { * \brief size of a single chunk, being Width or of height * a chunk is always a square, except at the edges of the MemoryBuffer */ - unsigned int chunkSize_; + unsigned int chunk_size_; /** * \brief number of chunks in the x-axis @@ -158,12 +158,12 @@ class ExecutionGroup { * \brief denotes boundary for border compositing * \note measured in pixel space */ - rcti viewerBorder_; + rcti viewer_border_; /** * \brief start time of execution */ - double executionStartTime_; + double execution_start_time_; // methods /** @@ -175,13 +175,14 @@ class ExecutionGroup { /** * \brief Determine the rect (minx, maxx, miny, maxy) of a chunk at a position. */ - void determineChunkRect(rcti *r_rect, - const unsigned int xChunk, - const unsigned int yChunk) const; + void determine_chunk_rect(rcti *r_rect, + const unsigned int x_chunk, + const unsigned int y_chunk) const; /** - * \brief determine the number of chunks, based on the chunkSize, width and height. - * \note The result are stored in the fields numberOfChunks, numberOfXChunks, numberOfYChunks + * \brief determine the number of chunks, based on the chunk_size, width and height. + * \note The result are stored in the fields number_of_chunks, number_of_xchunks, + * number_of_ychunks */ void init_number_of_chunks(); @@ -190,13 +191,13 @@ class ExecutionGroup { * \note scheduling succeeds when all input requirements are met and the chunks hasn't been * scheduled yet. * \param graph: - * \param xChunk: - * \param yChunk: + * \param x_chunk: + * \param y_chunk: * \return [true:false] * true: package(s) are scheduled * false: scheduling is deferred (depending workpackages are scheduled) */ - bool scheduleChunkWhenPossible(ExecutionSystem *graph, const int chunk_x, const int chunk_y); + bool schedule_chunk_when_possible(ExecutionSystem *graph, const int chunk_x, const int chunk_y); /** * \brief try to schedule a specific area. @@ -208,24 +209,24 @@ class ExecutionGroup { * true: package(s) are scheduled * false: scheduling is deferred (depending workpackages are scheduled) */ - bool scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area); + bool schedule_area_when_possible(ExecutionSystem *graph, rcti *area); /** * \brief add a chunk to the WorkScheduler. * \param chunknumber: */ - bool scheduleChunk(unsigned int chunkNumber); + bool schedule_chunk(unsigned int chunk_number); /** * \brief determine the area of interest of a certain input area * \note This method only evaluates a single ReadBufferOperation * \param input: the input area - * \param readOperation: The ReadBufferOperation where the area needs to be evaluated + * \param read_operation: 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 determine_depending_area_of_interest(rcti *input, + ReadBufferOperation *read_operation, + rcti *output); /** * Return the execution order of the user visible chunks. @@ -258,13 +259,13 @@ class ExecutionGroup { * \param operation: * \return True if the operation was successfully added */ - bool addOperation(NodeOperation *operation); + bool add_operation(NodeOperation *operation); /** * \brief set whether this ExecutionGroup is an output - * \param isOutput: + * \param is_output: */ - void setOutputExecutionGroup(bool is_output) + void set_output_execution_group(bool is_output) { flags_.is_output = is_output; } @@ -273,13 +274,13 @@ class ExecutionGroup { * \brief determine the resolution of this ExecutionGroup * \param resolution: */ - void determineResolution(unsigned int resolution[2]); + void determine_resolution(unsigned int resolution[2]); /** * \brief set the resolution of this executiongroup * \param resolution: */ - void setResolution(unsigned int resolution[2]) + void set_resolution(unsigned int resolution[2]) { width_ = resolution[0]; height_ = resolution[1]; @@ -288,7 +289,7 @@ class ExecutionGroup { /** * \brief get the width of this execution group */ - unsigned int getWidth() const + unsigned int get_width() const { return width_; } @@ -296,7 +297,7 @@ class ExecutionGroup { /** * \brief get the height of this execution group */ - unsigned int getHeight() const + unsigned int get_height() const { return height_; } @@ -305,24 +306,24 @@ class ExecutionGroup { * \brief get the output operation of this ExecutionGroup * \return NodeOperation *output operation */ - NodeOperation *getOutputOperation() const; + NodeOperation *get_output_operation() const; /** * \brief compose multiple chunks into a single chunk * \return Memorybuffer *consolidated chunk */ - MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy &memoryProxy, rcti &rect); + MemoryBuffer *construct_consolidated_memory_buffer(MemoryProxy &memory_proxy, rcti &rect); /** - * \brief initExecution is called just before the execution of the whole graph will be done. - * \note The implementation will calculate the chunkSize of this execution group. + * \brief init_execution is called just before the execution of the whole graph will be done. + * \note The implementation will calculate the chunk_size of this execution group. */ - void initExecution(); + void init_execution(); /** * \brief get all inputbuffers needed to calculate an chunk * \note all inputbuffers must be executed - * \param chunkNumber: the chunk to be calculated + * \param chunk_number: the chunk to be calculated * \return (MemoryBuffer **) the inputbuffers */ MemoryBuffer **getInputBuffersCPU(); @@ -330,31 +331,31 @@ class ExecutionGroup { /** * \brief get all inputbuffers needed to calculate an chunk * \note all inputbuffers must be executed - * \param chunkNumber: the chunk to be calculated + * \param chunk_number: the chunk to be calculated * \return (MemoryBuffer **) the inputbuffers */ - MemoryBuffer **getInputBuffersOpenCL(int chunkNumber); + MemoryBuffer **get_input_buffers_opencl(int chunk_number); /** * \brief allocate the outputbuffer of a chunk - * \param chunkNumber: the number of the chunk in the ExecutionGroup + * \param chunk_number: the number of the chunk in the ExecutionGroup * \param rect: the rect of that chunk - * \see determineChunkRect + * \see determine_chunk_rect */ - MemoryBuffer *allocateOutputBuffer(rcti &rect); + MemoryBuffer *allocate_output_buffer(rcti &rect); /** * \brief after a chunk is executed the needed resources can be freed or unlocked. * \param chunknumber: * \param memorybuffers: */ - void finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers); + void finalize_chunk_execution(int chunk_number, MemoryBuffer **memory_buffers); /** - * \brief deinitExecution is called just after execution the whole graph. + * \brief deinit_execution is called just after execution the whole graph. * \note It will release all needed resources */ - void deinitExecution(); + void deinit_execution(); /** * \brief schedule an ExecutionGroup @@ -377,26 +378,26 @@ class ExecutionGroup { /** * \brief Determine the rect (minx, maxx, miny, maxy) of a chunk. */ - void determineChunkRect(rcti *r_rect, const unsigned int chunkNumber) const; + void determine_chunk_rect(rcti *r_rect, const unsigned int chunk_number) const; - void setChunksize(int chunksize) + void set_chunksize(int chunksize) { - chunkSize_ = chunksize; + chunk_size_ = chunksize; } /** * \brief get the Render priority of this ExecutionGroup * \see ExecutionSystem.execute */ - eCompositorPriority getRenderPriority(); + eCompositorPriority get_render_priority(); /** * \brief set border for viewer operation * \note all the coordinates are assumed to be in normalized space */ - void setViewerBorder(float xmin, float xmax, float ymin, float ymax); + void set_viewer_border(float xmin, float xmax, float ymin, float ymax); - void setRenderBorder(float xmin, float xmax, float ymin, float ymax); + void set_render_border(float xmin, float xmax, float ymin, float ymax); /* allow the DebugInfo class to look at internals */ friend class DebugInfo; diff --git a/source/blender/compositor/intern/COM_ExecutionModel.cc b/source/blender/compositor/intern/COM_ExecutionModel.cc index 0ac99152c9f..b319aaa4b21 100644 --- a/source/blender/compositor/intern/COM_ExecutionModel.cc +++ b/source/blender/compositor/intern/COM_ExecutionModel.cc @@ -24,7 +24,7 @@ namespace blender::compositor { ExecutionModel::ExecutionModel(CompositorContext &context, Span<NodeOperation *> operations) : context_(context), operations_(operations) { - const bNodeTree *node_tree = context_.getbNodeTree(); + const bNodeTree *node_tree = context_.get_bnodetree(); const rctf *viewer_border = &node_tree->viewer_border; border_.use_viewer_border = (node_tree->flag & NTREE_VIEWER_BORDER) && @@ -32,10 +32,10 @@ ExecutionModel::ExecutionModel(CompositorContext &context, Span<NodeOperation *> viewer_border->ymin < viewer_border->ymax; border_.viewer_border = viewer_border; - const RenderData *rd = context_.getRenderData(); + const RenderData *rd = context_.get_render_data(); /* Case when cropping to render border happens is handled in * compositor output and render layer nodes. */ - border_.use_render_border = context.isRendering() && (rd->mode & R_BORDER) && + border_.use_render_border = context.is_rendering() && (rd->mode & R_BORDER) && !(rd->mode & R_CROP); border_.render_border = &rd->border; } diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cc b/source/blender/compositor/intern/COM_ExecutionSystem.cc index 880383853d6..82821a1ddb1 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cc +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cc @@ -38,37 +38,37 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation, - const ColorManagedViewSettings *viewSettings, - const ColorManagedDisplaySettings *displaySettings, - const char *viewName) + const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings, + const char *view_name) { num_work_threads_ = WorkScheduler::get_num_cpu_threads(); - context_.setViewName(viewName); - context_.setScene(scene); - context_.setbNodeTree(editingtree); - context_.setPreviewHash(editingtree->previews); - context_.setFastCalculation(fastcalculation); + context_.set_view_name(view_name); + context_.set_scene(scene); + context_.set_bnodetree(editingtree); + context_.set_preview_hash(editingtree->previews); + context_.set_fast_calculation(fastcalculation); /* initialize the CompositorContext */ if (rendering) { - context_.setQuality((eCompositorQuality)editingtree->render_quality); + context_.set_quality((eCompositorQuality)editingtree->render_quality); } else { - context_.setQuality((eCompositorQuality)editingtree->edit_quality); + context_.set_quality((eCompositorQuality)editingtree->edit_quality); } - context_.setRendering(rendering); + context_.set_rendering(rendering); context_.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() && (editingtree->flag & NTREE_COM_OPENCL)); - context_.setRenderData(rd); - context_.setViewSettings(viewSettings); - context_.setDisplaySettings(displaySettings); + context_.set_render_data(rd); + context_.set_view_settings(view_settings); + context_.set_display_settings(display_settings); BLI_mutex_init(&work_mutex_); BLI_condition_init(&work_finished_cond_); { NodeOperationBuilder builder(&context_, editingtree, this); - builder.convertToOperations(this); + builder.convert_to_operations(this); } switch (context_.get_execution_model()) { @@ -184,7 +184,7 @@ void ExecutionSystem::execute_work(const rcti &work_rect, bool ExecutionSystem::is_breaked() const { - const bNodeTree *btree = context_.getbNodeTree(); + const bNodeTree *btree = context_.get_bnodetree(); return btree->test_break(btree->tbh); } diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index 4a6a0f1bad8..4a3fecaca47 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.h +++ b/source/blender/compositor/intern/COM_ExecutionSystem.h @@ -64,8 +64,8 @@ namespace blender::compositor { * based on settings; like MixNode. based on the selected Mixtype a different operation will be * used. for more information see the page about creating new Nodes. [@subpage newnode] * - * \see ExecutionSystem.convertToOperations - * \see Node.convertToOperations + * \see ExecutionSystem.convert_to_operations + * \see Node.convert_to_operations * \see NodeOperation base class for all operations in the system * * \section EM_Step3 Step3: add additional conversions to the operation system @@ -89,7 +89,7 @@ namespace blender::compositor { * Bottom left of the images are aligned. * * \see COM_convert_data_type Datatype conversions - * \see Converter.convertResolution Image size conversions + * \see Converter.convert_resolution Image size conversions * * \section EM_Step4 Step4: group operations in executions groups * ExecutionGroup are groups of operations that are calculated as being one bigger operation. @@ -112,9 +112,9 @@ namespace blender::compositor { * |cFAA | |cFAA | |cFAA | |cFAA | * +------+ +------+ +-------+ +-------+ * </pre> - * \see ExecutionSystem.groupOperations method doing this step - * \see ExecutionSystem.addReadWriteBufferOperations - * \see NodeOperation.isComplex + * \see ExecutionSystem.group_operations method doing this step + * \see ExecutionSystem.add_read_write_buffer_operations + * \see NodeOperation.is_complex * \see ExecutionGroup class representing the ExecutionGroup */ @@ -175,9 +175,9 @@ class ExecutionSystem { bNodeTree *editingtree, bool rendering, bool fastcalculation, - const ColorManagedViewSettings *viewSettings, - const ColorManagedDisplaySettings *displaySettings, - const char *viewName); + const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings, + const char *view_name); /** * Destructor @@ -198,7 +198,7 @@ class ExecutionSystem { /** * \brief get the reference to the compositor context */ - const CompositorContext &getContext() const + const CompositorContext &get_context() const { return context_; } diff --git a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc index ce00fff5858..80c10aec00a 100644 --- a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc +++ b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc @@ -38,7 +38,7 @@ FullFrameExecutionModel::FullFrameExecutionModel(CompositorContext &context, num_operations_finished_(0) { priorities_.append(eCompositorPriority::High); - if (!context.isFastCalculation()) { + if (!context.is_fast_calculation()) { priorities_.append(eCompositorPriority::Medium); priorities_.append(eCompositorPriority::Low); } @@ -46,7 +46,7 @@ FullFrameExecutionModel::FullFrameExecutionModel(CompositorContext &context, void FullFrameExecutionModel::execute(ExecutionSystem &exec_system) { - const bNodeTree *node_tree = this->context_.getbNodeTree(); + const bNodeTree *node_tree = this->context_.get_bnodetree(); node_tree->stats_draw(node_tree->sdh, TIP_("Compositing | Initializing execution")); DebugInfo::graphviz(&exec_system, "compositor_prior_rendering"); @@ -57,14 +57,14 @@ void FullFrameExecutionModel::execute(ExecutionSystem &exec_system) void FullFrameExecutionModel::determine_areas_to_render_and_reads() { - const bool is_rendering = context_.isRendering(); - const bNodeTree *node_tree = context_.getbNodeTree(); + const bool is_rendering = context_.is_rendering(); + const bNodeTree *node_tree = context_.get_bnodetree(); rcti area; for (eCompositorPriority priority : priorities_) { for (NodeOperation *op : operations_) { - op->setbNodeTree(node_tree); - if (op->isOutputOperation(is_rendering) && op->getRenderPriority() == priority) { + op->set_bnodetree(node_tree); + if (op->is_output_operation(is_rendering) && op->get_render_priority() == priority) { get_output_render_area(op, area); determine_areas_to_render(op, area); determine_reads(op); @@ -81,7 +81,7 @@ Vector<MemoryBuffer *> FullFrameExecutionModel::get_input_buffers(NodeOperation const int output_x, const int output_y) { - const int num_inputs = op->getNumberOfInputSockets(); + const int num_inputs = op->get_number_of_input_sockets(); Vector<MemoryBuffer *> inputs_buffers(num_inputs); for (int i = 0; i < num_inputs; i++) { NodeOperation *input = op->get_input_operation(i); @@ -92,7 +92,7 @@ Vector<MemoryBuffer *> FullFrameExecutionModel::get_input_buffers(NodeOperation rcti rect = buf->get_rect(); BLI_rcti_translate(&rect, offset_x, offset_y); inputs_buffers[i] = new MemoryBuffer( - buf->getBuffer(), buf->get_num_channels(), rect, buf->is_a_single_elem()); + buf->get_buffer(), buf->get_num_channels(), rect, buf->is_a_single_elem()); } return inputs_buffers; } @@ -102,9 +102,10 @@ MemoryBuffer *FullFrameExecutionModel::create_operation_buffer(NodeOperation *op const int output_y) { rcti rect; - BLI_rcti_init(&rect, output_x, output_x + op->getWidth(), output_y, output_y + op->getHeight()); + BLI_rcti_init( + &rect, output_x, output_x + op->get_width(), output_y, output_y + op->get_height()); - const DataType data_type = op->getOutputSocket(0)->getDataType(); + const DataType data_type = op->get_output_socket(0)->get_data_type(); const bool is_a_single_elem = op->get_flags().is_constant_operation; return new MemoryBuffer(data_type, rect, is_a_single_elem); } @@ -115,9 +116,9 @@ void FullFrameExecutionModel::render_operation(NodeOperation *op) constexpr int output_x = 0; constexpr int output_y = 0; - const bool has_outputs = op->getNumberOfOutputSockets() > 0; + const bool has_outputs = op->get_number_of_output_sockets() > 0; MemoryBuffer *op_buf = has_outputs ? create_operation_buffer(op, output_x, output_y) : nullptr; - if (op->getWidth() > 0 && op->getHeight() > 0) { + if (op->get_width() > 0 && op->get_height() > 0) { Vector<MemoryBuffer *> input_bufs = get_input_buffers(op, output_x, output_y); const int op_offset_x = output_x - op->get_canvas().xmin; const int op_offset_y = output_y - op->get_canvas().ymin; @@ -141,19 +142,19 @@ void FullFrameExecutionModel::render_operation(NodeOperation *op) */ void FullFrameExecutionModel::render_operations() { - const bool is_rendering = context_.isRendering(); + const bool is_rendering = context_.is_rendering(); WorkScheduler::start(this->context_); for (eCompositorPriority priority : priorities_) { for (NodeOperation *op : operations_) { - const bool has_size = op->getWidth() > 0 && op->getHeight() > 0; - const bool is_priority_output = op->isOutputOperation(is_rendering) && - op->getRenderPriority() == priority; + const bool has_size = op->get_width() > 0 && op->get_height() > 0; + const bool is_priority_output = op->is_output_operation(is_rendering) && + op->get_render_priority() == priority; if (is_priority_output && has_size) { render_output_dependencies(op); render_operation(op); } - else if (is_priority_output && !has_size && op->isActiveViewerOutput()) { + else if (is_priority_output && !has_size && op->is_active_viewer_output()) { static_cast<ViewerOperation *>(op)->clear_display_buffer(); } } @@ -175,7 +176,7 @@ static Vector<NodeOperation *> get_operation_dependencies(NodeOperation *operati Vector<NodeOperation *> outputs(next_outputs); next_outputs.clear(); for (NodeOperation *output : outputs) { - for (int i = 0; i < output->getNumberOfInputSockets(); i++) { + for (int i = 0; i < output->get_number_of_input_sockets(); i++) { next_outputs.append(output->get_input_operation(i)); } } @@ -190,7 +191,7 @@ static Vector<NodeOperation *> get_operation_dependencies(NodeOperation *operati void FullFrameExecutionModel::render_output_dependencies(NodeOperation *output_op) { - BLI_assert(output_op->isOutputOperation(context_.isRendering())); + BLI_assert(output_op->is_output_operation(context_.is_rendering())); Vector<NodeOperation *> dependencies = get_operation_dependencies(output_op); for (NodeOperation *op : dependencies) { if (!active_buffers_.is_operation_rendered(op)) { @@ -205,7 +206,7 @@ void FullFrameExecutionModel::render_output_dependencies(NodeOperation *output_o void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op, const rcti &output_area) { - BLI_assert(output_op->isOutputOperation(context_.isRendering())); + BLI_assert(output_op->is_output_operation(context_.is_rendering())); Vector<std::pair<NodeOperation *, const rcti>> stack; stack.append({output_op, output_area}); @@ -220,7 +221,7 @@ void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op active_buffers_.register_area(operation, render_area); - const int num_inputs = operation->getNumberOfInputSockets(); + const int num_inputs = operation->get_number_of_input_sockets(); for (int i = 0; i < num_inputs; i++) { NodeOperation *input_op = operation->get_input_operation(i); rcti input_area; @@ -240,13 +241,13 @@ void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op */ void FullFrameExecutionModel::determine_reads(NodeOperation *output_op) { - BLI_assert(output_op->isOutputOperation(context_.isRendering())); + BLI_assert(output_op->is_output_operation(context_.is_rendering())); Vector<NodeOperation *> stack; stack.append(output_op); while (stack.size() > 0) { NodeOperation *operation = stack.pop_last(); - const int num_inputs = operation->getNumberOfInputSockets(); + const int num_inputs = operation->get_number_of_input_sockets(); for (int i = 0; i < num_inputs; i++) { NodeOperation *input_op = operation->get_input_operation(i); if (!active_buffers_.has_registered_reads(input_op)) { @@ -263,7 +264,7 @@ void FullFrameExecutionModel::determine_reads(NodeOperation *output_op) */ void FullFrameExecutionModel::get_output_render_area(NodeOperation *output_op, rcti &r_area) { - BLI_assert(output_op->isOutputOperation(context_.isRendering())); + BLI_assert(output_op->is_output_operation(context_.is_rendering())); /* By default return operation bounds (no border). */ rcti canvas = output_op->get_canvas(); @@ -278,8 +279,8 @@ void FullFrameExecutionModel::get_output_render_area(NodeOperation *output_op, r const rctf *norm_border = has_viewer_border ? border_.viewer_border : border_.render_border; /* Return de-normalized border within canvas. */ - const int w = output_op->getWidth(); - const int h = output_op->getHeight(); + const int w = output_op->get_width(); + const int h = output_op->get_height(); r_area.xmin = canvas.xmin + norm_border->xmin * w; r_area.xmax = canvas.xmin + norm_border->xmax * w; r_area.ymin = canvas.ymin + norm_border->ymin * h; @@ -290,7 +291,7 @@ void FullFrameExecutionModel::get_output_render_area(NodeOperation *output_op, r void FullFrameExecutionModel::operation_finished(NodeOperation *operation) { /* Report inputs reads so that buffers may be freed/reused. */ - const int num_inputs = operation->getNumberOfInputSockets(); + const int num_inputs = operation->get_number_of_input_sockets(); for (int i = 0; i < num_inputs; i++) { active_buffers_.read_finished(operation->get_input_operation(i)); } @@ -301,7 +302,7 @@ void FullFrameExecutionModel::operation_finished(NodeOperation *operation) void FullFrameExecutionModel::update_progress_bar() { - const bNodeTree *tree = context_.getbNodeTree(); + const bNodeTree *tree = context_.get_bnodetree(); if (tree) { const float progress = num_operations_finished_ / static_cast<float>(operations_.size()); tree->progress(tree->prh, progress); diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cc b/source/blender/compositor/intern/COM_MemoryBuffer.cc index 3aefe8a3e2f..96888ea1c96 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cc +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cc @@ -44,32 +44,32 @@ static rcti create_rect(const int width, const int height) return rect; } -MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state) +MemoryBuffer::MemoryBuffer(MemoryProxy *memory_proxy, const rcti &rect, MemoryBufferState state) { rect_ = rect; is_a_single_elem_ = false; - memoryProxy_ = memoryProxy; - num_channels_ = COM_data_type_num_channels(memoryProxy->getDataType()); + memory_proxy_ = memory_proxy; + num_channels_ = COM_data_type_num_channels(memory_proxy->get_data_type()); buffer_ = (float *)MEM_mallocN_aligned( sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer"); owns_data_ = true; state_ = state; - datatype_ = memoryProxy->getDataType(); + datatype_ = memory_proxy->get_data_type(); set_strides(); } -MemoryBuffer::MemoryBuffer(DataType dataType, const rcti &rect, bool is_a_single_elem) +MemoryBuffer::MemoryBuffer(DataType data_type, const rcti &rect, bool is_a_single_elem) { rect_ = rect; is_a_single_elem_ = is_a_single_elem; - memoryProxy_ = nullptr; - num_channels_ = COM_data_type_num_channels(dataType); + memory_proxy_ = nullptr; + num_channels_ = COM_data_type_num_channels(data_type); buffer_ = (float *)MEM_mallocN_aligned( sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer"); owns_data_ = true; state_ = MemoryBufferState::Temporary; - datatype_ = dataType; + datatype_ = data_type; set_strides(); } @@ -95,7 +95,7 @@ MemoryBuffer::MemoryBuffer(float *buffer, { rect_ = rect; is_a_single_elem_ = is_a_single_elem; - memoryProxy_ = nullptr; + memory_proxy_ = nullptr; num_channels_ = num_channels; datatype_ = COM_num_channels_data_type(num_channels); buffer_ = buffer; @@ -107,7 +107,7 @@ MemoryBuffer::MemoryBuffer(float *buffer, MemoryBuffer::MemoryBuffer(const MemoryBuffer &src) : MemoryBuffer(src.datatype_, src.rect_, false) { - memoryProxy_ = src.memoryProxy_; + memory_proxy_ = src.memory_proxy_; /* src may be single elem buffer */ fill_from(src); } @@ -120,7 +120,7 @@ void MemoryBuffer::set_strides() } else { this->elem_stride = num_channels_; - this->row_stride = getWidth() * num_channels_; + this->row_stride = get_width() * num_channels_; } to_positive_x_stride_ = rect_.xmin < 0 ? -rect_.xmin + 1 : (rect_.xmin == 0 ? 1 : 0); to_positive_y_stride_ = rect_.ymin < 0 ? -rect_.ymin + 1 : (rect_.ymin == 0 ? 1 : 0); @@ -140,7 +140,7 @@ BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, c { BuffersIteratorBuilder<float> builder(buffer_, rect_, area, elem_stride); for (MemoryBuffer *input : inputs) { - builder.add_input(input->getBuffer(), input->get_rect(), input->elem_stride); + builder.add_input(input->get_buffer(), input->get_rect(), input->elem_stride); } return builder.build(); } @@ -248,7 +248,7 @@ void MemoryBuffer::copy_from(const MemoryBuffer *src, void MemoryBuffer::copy_from(const uchar *src, const rcti &area) { const int elem_stride = this->get_num_channels(); - const int row_stride = elem_stride * getWidth(); + const int row_stride = elem_stride * get_width(); copy_from(src, area, 0, this->get_num_channels(), elem_stride, row_stride, 0); } @@ -307,7 +307,7 @@ static void colorspace_to_scene_linear(MemoryBuffer *buf, const rcti &area, Colo const int height = BLI_rcti_size_y(&area); float *out = buf->get_elem(area.xmin, area.ymin); /* If area allows continuous memory do conversion in one step. Otherwise per row. */ - if (buf->getWidth() == width) { + if (buf->get_width() == width) { IMB_colormanagement_colorspace_to_scene_linear( out, width, height, buf->get_num_channels(), colorspace, false); } @@ -404,7 +404,7 @@ void MemoryBuffer::fill_from(const MemoryBuffer &src) copy_from(&src, overlap); } -void MemoryBuffer::writePixel(int x, int y, const float color[4]) +void MemoryBuffer::write_pixel(int x, int y, const float color[4]) { if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) { const int offset = get_coords_offset(x, y); @@ -412,7 +412,7 @@ void MemoryBuffer::writePixel(int x, int y, const float color[4]) } } -void MemoryBuffer::addPixel(int x, int y, const float color[4]) +void MemoryBuffer::add_pixel(int x, int y, const float color[4]) { if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) { const int offset = get_coords_offset(x, y); @@ -437,7 +437,7 @@ void MemoryBuffer::read_elem_filtered( const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}}; - float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight(); + float inv_width = 1.0f / (float)this->get_width(), inv_height = 1.0f / (float)this->get_height(); /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives, * but compositor uses pixel space. For now let's just divide the values and * switch compositor to normalized space for EWA later. @@ -446,8 +446,8 @@ void MemoryBuffer::read_elem_filtered( float du_normal[2] = {deriv[0][0] * inv_width, deriv[0][1] * inv_height}; float dv_normal[2] = {deriv[1][0] * inv_width, deriv[1][1] * inv_height}; - BLI_ewa_filter(this->getWidth(), - this->getHeight(), + BLI_ewa_filter(this->get_width(), + this->get_height(), false, true, uv_normal, @@ -473,7 +473,8 @@ void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivat } else { BLI_assert(datatype_ == DataType::Color); - float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight(); + float inv_width = 1.0f / (float)this->get_width(), + inv_height = 1.0f / (float)this->get_height(); /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives, * but compositor uses pixel space. For now let's just divide the values and * switch compositor to normalized space for EWA later. @@ -482,8 +483,8 @@ void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivat float du_normal[2] = {derivatives[0][0] * inv_width, derivatives[0][1] * inv_height}; float dv_normal[2] = {derivatives[1][0] * inv_width, derivatives[1][1] * inv_height}; - BLI_ewa_filter(this->getWidth(), - this->getHeight(), + BLI_ewa_filter(this->get_width(), + this->get_height(), false, true, uv_normal, diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h index 984db4acc2a..33d78c99ca6 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.h +++ b/source/blender/compositor/intern/COM_MemoryBuffer.h @@ -77,7 +77,7 @@ class MemoryBuffer { /** * \brief proxy of the memory (same for all chunks in the same buffer) */ - MemoryProxy *memoryProxy_; + MemoryProxy *memory_proxy_; /** * \brief the type of buffer DataType::Value, DataType::Vector, DataType::Color @@ -125,12 +125,12 @@ class MemoryBuffer { /** * \brief construct new temporarily MemoryBuffer for an area */ - MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state); + MemoryBuffer(MemoryProxy *memory_proxy, const rcti &rect, MemoryBufferState state); /** * \brief construct new temporarily MemoryBuffer for an area */ - MemoryBuffer(DataType datatype, const rcti &rect, bool is_a_single_elem = false); + MemoryBuffer(DataType data_type, const rcti &rect, bool is_a_single_elem = false); MemoryBuffer( float *buffer, int num_channels, int width, int height, bool is_a_single_elem = false); @@ -159,14 +159,14 @@ class MemoryBuffer { float &operator[](int index) { BLI_assert(is_a_single_elem_ ? index < num_channels_ : - index < get_coords_offset(getWidth(), getHeight())); + index < get_coords_offset(get_width(), get_height())); return buffer_[index]; } const float &operator[](int index) const { BLI_assert(is_a_single_elem_ ? index < num_channels_ : - index < get_coords_offset(getWidth(), getHeight())); + index < get_coords_offset(get_width(), get_height())); return buffer_[index]; } @@ -231,7 +231,7 @@ class MemoryBuffer { } /* Do sampling at borders to smooth edges. */ - const float last_x = getWidth() - 1.0f; + const float last_x = get_width() - 1.0f; const float rel_x = get_relative_x(x); float single_x = 0.0f; if (rel_x < 0.0f) { @@ -241,7 +241,7 @@ class MemoryBuffer { single_x = rel_x - last_x; } - const float last_y = getHeight() - 1.0f; + const float last_y = get_height() - 1.0f; const float rel_y = get_relative_y(y); float single_y = 0.0f; if (rel_y < 0.0f) { @@ -257,8 +257,8 @@ class MemoryBuffer { BLI_bilinear_interpolation_fl(buffer_, out, - getWidth(), - getHeight(), + get_width(), + get_height(), num_channels_, get_relative_x(x), get_relative_y(y)); @@ -305,7 +305,7 @@ class MemoryBuffer { const float *get_row_end(int y) const { BLI_assert(has_y(y)); - return buffer_ + (is_a_single_elem() ? num_channels_ : get_coords_offset(getWidth(), y)); + return buffer_ + (is_a_single_elem() ? num_channels_ : get_coords_offset(get_width(), y)); } /** @@ -314,7 +314,7 @@ class MemoryBuffer { */ int get_memory_width() const { - return is_a_single_elem() ? 1 : getWidth(); + return is_a_single_elem() ? 1 : get_width(); } /** @@ -323,7 +323,7 @@ class MemoryBuffer { */ int get_memory_height() const { - return is_a_single_elem() ? 1 : getHeight(); + return is_a_single_elem() ? 1 : get_height(); } uint8_t get_num_channels() const @@ -351,12 +351,12 @@ class MemoryBuffer { BufferArea<float> get_buffer_area(const rcti &area) { - return BufferArea<float>(buffer_, getWidth(), area, elem_stride); + return BufferArea<float>(buffer_, get_width(), area, elem_stride); } BufferArea<const float> get_buffer_area(const rcti &area) const { - return BufferArea<const float>(buffer_, getWidth(), area, elem_stride); + return BufferArea<const float>(buffer_, get_width(), area, elem_stride); } BuffersIterator<float> iterate_with(Span<MemoryBuffer *> inputs); @@ -366,7 +366,7 @@ class MemoryBuffer { * \brief get the data of this MemoryBuffer * \note buffer should already be available in memory */ - float *getBuffer() + float *get_buffer() { return buffer_; } @@ -381,8 +381,8 @@ class MemoryBuffer { inline void wrap_pixel(int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y) { - const int w = getWidth(); - const int h = getHeight(); + const int w = get_width(); + const int h = get_height(); x = x - rect_.xmin; y = y - rect_.ymin; @@ -433,8 +433,8 @@ class MemoryBuffer { MemoryBufferExtend extend_x, MemoryBufferExtend extend_y) const { - const float w = (float)getWidth(); - const float h = (float)getHeight(); + const float w = (float)get_width(); + const float h = (float)get_height(); x = x - rect_.xmin; y = y - rect_.ymin; @@ -505,11 +505,11 @@ class MemoryBuffer { } /* TODO(manzanilla): to be removed with tiled implementation. */ - inline void readNoCheck(float *result, - int x, - int y, - MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, - MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) + inline void read_no_check(float *result, + int x, + int y, + MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, + MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) { int u = x; int v = y; @@ -525,19 +525,19 @@ class MemoryBuffer { memcpy(result, buffer, sizeof(float) * num_channels_); } - void writePixel(int x, int y, const float color[4]); - void addPixel(int x, int y, const float color[4]); - inline void readBilinear(float *result, - float x, - float y, - MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, - MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) const + void write_pixel(int x, int y, const float color[4]); + void add_pixel(int x, int y, const float color[4]); + inline void read_bilinear(float *result, + float x, + float y, + MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, + MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) const { float u = x; float v = y; this->wrap_pixel(u, v, extend_x, extend_y); - if ((extend_x != MemoryBufferExtend::Repeat && (u < 0.0f || u >= getWidth())) || - (extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= getHeight()))) { + if ((extend_x != MemoryBufferExtend::Repeat && (u < 0.0f || u >= get_width())) || + (extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= get_height()))) { copy_vn_fl(result, num_channels_, 0.0f); return; } @@ -547,8 +547,8 @@ class MemoryBuffer { else { BLI_bilinear_interpolation_wrap_fl(buffer_, result, - getWidth(), - getHeight(), + get_width(), + get_height(), num_channels_, u, v, @@ -562,7 +562,7 @@ class MemoryBuffer { /** * \brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk) */ - inline bool isTemporarily() const + inline bool is_temporarily() const { return state_ == MemoryBufferState::Temporary; } @@ -617,8 +617,8 @@ class MemoryBuffer { void fill(const rcti &area, const float *value); void fill(const rcti &area, int channel_offset, const float *value, int value_size); /** - * \brief add the content from otherBuffer to this MemoryBuffer - * \param otherBuffer: source buffer + * \brief add the content from other_buffer to this MemoryBuffer + * \param other_buffer: source buffer * * \note take care when running this on a new buffer since it won't fill in * uninitialized values in areas where the buffers don't overlap. @@ -636,7 +636,7 @@ class MemoryBuffer { /** * \brief get the width of this MemoryBuffer */ - const int getWidth() const + const int get_width() const { return BLI_rcti_size_x(&rect_); } @@ -644,7 +644,7 @@ class MemoryBuffer { /** * \brief get the height of this MemoryBuffer */ - const int getHeight() const + const int get_height() const { return BLI_rcti_size_y(&rect_); } diff --git a/source/blender/compositor/intern/COM_MemoryProxy.cc b/source/blender/compositor/intern/COM_MemoryProxy.cc index 507caa25655..895990bc87f 100644 --- a/source/blender/compositor/intern/COM_MemoryProxy.cc +++ b/source/blender/compositor/intern/COM_MemoryProxy.cc @@ -23,7 +23,7 @@ namespace blender::compositor { MemoryProxy::MemoryProxy(DataType datatype) { - writeBufferOperation_ = nullptr; + write_buffer_operation_ = nullptr; executor_ = nullptr; datatype_ = datatype; } diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h index cf262d72649..89149a47976 100644 --- a/source/blender/compositor/intern/COM_MemoryProxy.h +++ b/source/blender/compositor/intern/COM_MemoryProxy.h @@ -42,7 +42,7 @@ class MemoryProxy { /** * \brief reference to the output operation of the executiongroup */ - WriteBufferOperation *writeBufferOperation_; + WriteBufferOperation *write_buffer_operation_; /** * \brief reference to the executor. the Execution group that can fill a chunk @@ -66,7 +66,7 @@ class MemoryProxy { * \brief set the ExecutionGroup that can be scheduled to calculate a certain chunk. * \param group: the ExecutionGroup to set */ - void setExecutor(ExecutionGroup *executor) + void set_executor(ExecutionGroup *executor) { executor_ = executor; } @@ -74,7 +74,7 @@ class MemoryProxy { /** * \brief get the ExecutionGroup that can be scheduled to calculate a certain chunk. */ - ExecutionGroup *getExecutor() const + ExecutionGroup *get_executor() const { return executor_; } @@ -83,18 +83,18 @@ class MemoryProxy { * \brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy * \param operation: */ - void setWriteBufferOperation(WriteBufferOperation *operation) + void set_write_buffer_operation(WriteBufferOperation *operation) { - writeBufferOperation_ = operation; + write_buffer_operation_ = operation; } /** * \brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy * \return WriteBufferOperation */ - WriteBufferOperation *getWriteBufferOperation() const + WriteBufferOperation *get_write_buffer_operation() const { - return writeBufferOperation_; + return write_buffer_operation_; } /** @@ -110,12 +110,12 @@ class MemoryProxy { /** * \brief get the allocated memory */ - inline MemoryBuffer *getBuffer() + inline MemoryBuffer *get_buffer() { return buffer_; } - inline DataType getDataType() + inline DataType get_data_type() { return datatype_; } diff --git a/source/blender/compositor/intern/COM_MetaData.cc b/source/blender/compositor/intern/COM_MetaData.cc index 5775a7eab65..530634a6e41 100644 --- a/source/blender/compositor/intern/COM_MetaData.cc +++ b/source/blender/compositor/intern/COM_MetaData.cc @@ -29,9 +29,9 @@ void MetaData::add(const blender::StringRef key, const blender::StringRef value) entries_.add(key, value); } -void MetaData::addCryptomatteEntry(const blender::StringRef layer_name, - const blender::StringRefNull key, - const blender::StringRef value) +void MetaData::add_cryptomatte_entry(const blender::StringRef layer_name, + const blender::StringRefNull key, + const blender::StringRef value) { add(blender::bke::cryptomatte::BKE_cryptomatte_meta_data_key(layer_name, key), value); } @@ -40,7 +40,7 @@ void MetaData::addCryptomatteEntry(const blender::StringRef layer_name, * * When a conversion happens it will also add the cryptomatte name key with the given * `layer_name`. */ -void MetaData::replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_name) +void MetaData::replace_hash_neutral_cryptomatte_keys(const blender::StringRef layer_name) { std::string cryptomatte_hash = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_HASH, ""); std::string cryptomatte_conversion = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_CONVERSION, @@ -49,27 +49,28 @@ void MetaData::replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_ if (cryptomatte_hash.length() || cryptomatte_conversion.length() || cryptomatte_manifest.length()) { - addCryptomatteEntry(layer_name, "name", layer_name); + add_cryptomatte_entry(layer_name, "name", layer_name); } if (cryptomatte_hash.length()) { - addCryptomatteEntry(layer_name, "hash", cryptomatte_hash); + add_cryptomatte_entry(layer_name, "hash", cryptomatte_hash); } if (cryptomatte_conversion.length()) { - addCryptomatteEntry(layer_name, "conversion", cryptomatte_conversion); + add_cryptomatte_entry(layer_name, "conversion", cryptomatte_conversion); } if (cryptomatte_manifest.length()) { - addCryptomatteEntry(layer_name, "manifest", cryptomatte_manifest); + add_cryptomatte_entry(layer_name, "manifest", cryptomatte_manifest); } } -void MetaData::addToRenderResult(RenderResult *render_result) const +void MetaData::add_to_render_result(RenderResult *render_result) const { for (Map<std::string, std::string>::Item entry : entries_.items()) { BKE_render_result_stamp_data(render_result, entry.key.c_str(), entry.value.c_str()); } } -void MetaDataExtractCallbackData::addMetaData(blender::StringRef key, blender::StringRefNull value) +void MetaDataExtractCallbackData::add_meta_data(blender::StringRef key, + blender::StringRefNull value) { if (!meta_data) { meta_data = std::make_unique<MetaData>(); @@ -77,7 +78,7 @@ void MetaDataExtractCallbackData::addMetaData(blender::StringRef key, blender::S meta_data->add(key, value); } -void MetaDataExtractCallbackData::setCryptomatteKeys(blender::StringRef cryptomatte_layer_name) +void MetaDataExtractCallbackData::set_cryptomatte_keys(blender::StringRef cryptomatte_layer_name) { manifest_key = blender::bke::cryptomatte::BKE_cryptomatte_meta_data_key(cryptomatte_layer_name, "manifest"); @@ -95,13 +96,13 @@ void MetaDataExtractCallbackData::extract_cryptomatte_meta_data(void *_data, MetaDataExtractCallbackData *data = static_cast<MetaDataExtractCallbackData *>(_data); blender::StringRefNull key(propname); if (key == data->hash_key) { - data->addMetaData(META_DATA_KEY_CRYPTOMATTE_HASH, propvalue); + data->add_meta_data(META_DATA_KEY_CRYPTOMATTE_HASH, propvalue); } else if (key == data->conversion_key) { - data->addMetaData(META_DATA_KEY_CRYPTOMATTE_CONVERSION, propvalue); + data->add_meta_data(META_DATA_KEY_CRYPTOMATTE_CONVERSION, propvalue); } else if (key == data->manifest_key) { - data->addMetaData(META_DATA_KEY_CRYPTOMATTE_MANIFEST, propvalue); + data->add_meta_data(META_DATA_KEY_CRYPTOMATTE_MANIFEST, propvalue); } } diff --git a/source/blender/compositor/intern/COM_MetaData.h b/source/blender/compositor/intern/COM_MetaData.h index a76540dc3af..0bb014525c3 100644 --- a/source/blender/compositor/intern/COM_MetaData.h +++ b/source/blender/compositor/intern/COM_MetaData.h @@ -44,14 +44,14 @@ constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_NAME("cryptomatte/{hash}/ class MetaData { private: Map<std::string, std::string> entries_; - void addCryptomatteEntry(const blender::StringRef layer_name, - const blender::StringRefNull key, - const blender::StringRef value); + void add_cryptomatte_entry(const blender::StringRef layer_name, + const blender::StringRefNull key, + const blender::StringRef value); public: void add(const blender::StringRef key, const blender::StringRef value); - void replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_name); - void addToRenderResult(RenderResult *render_result) const; + void replace_hash_neutral_cryptomatte_keys(const blender::StringRef layer_name); + void add_to_render_result(RenderResult *render_result) const; #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("COM:MetaData") #endif @@ -63,8 +63,8 @@ struct MetaDataExtractCallbackData { std::string conversion_key; std::string manifest_key; - void addMetaData(blender::StringRef key, blender::StringRefNull value); - void setCryptomatteKeys(blender::StringRef cryptomatte_layer_name); + void add_meta_data(blender::StringRef key, blender::StringRefNull value); + void set_cryptomatte_keys(blender::StringRef cryptomatte_layer_name); /* C type callback function (StampCallback). */ static void extract_cryptomatte_meta_data(void *_data, const char *propname, diff --git a/source/blender/compositor/intern/COM_Node.cc b/source/blender/compositor/intern/COM_Node.cc index 7acf91df7d4..58b2b195579 100644 --- a/source/blender/compositor/intern/COM_Node.cc +++ b/source/blender/compositor/intern/COM_Node.cc @@ -28,14 +28,14 @@ namespace blender::compositor { **** Node **** **************/ -Node::Node(bNode *editorNode, bool create_sockets) - : editorNodeTree_(nullptr), - editorNode_(editorNode), - inActiveGroup_(false), - instanceKey_(NODE_INSTANCE_KEY_NONE) +Node::Node(bNode *editor_node, bool create_sockets) + : editor_node_tree_(nullptr), + editor_node_(editor_node), + in_active_group_(false), + instance_key_(NODE_INSTANCE_KEY_NONE) { if (create_sockets) { - bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first; + bNodeSocket *input = (bNodeSocket *)editor_node->inputs.first; while (input != nullptr) { DataType dt = DataType::Value; if (input->type == SOCK_RGBA) { @@ -45,10 +45,10 @@ Node::Node(bNode *editorNode, bool create_sockets) dt = DataType::Vector; } - this->addInputSocket(dt, input); + this->add_input_socket(dt, input); input = input->next; } - bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first; + bNodeSocket *output = (bNodeSocket *)editor_node->outputs.first; while (output != nullptr) { DataType dt = DataType::Value; if (output->type == SOCK_RGBA) { @@ -58,7 +58,7 @@ Node::Node(bNode *editorNode, bool create_sockets) dt = DataType::Vector; } - this->addOutputSocket(dt, output); + this->add_output_socket(dt, output); output = output->next; } } @@ -74,43 +74,43 @@ Node::~Node() } } -void Node::addInputSocket(DataType datatype) +void Node::add_input_socket(DataType datatype) { - this->addInputSocket(datatype, nullptr); + this->add_input_socket(datatype, nullptr); } -void Node::addInputSocket(DataType datatype, bNodeSocket *bSocket) +void Node::add_input_socket(DataType datatype, bNodeSocket *bSocket) { NodeInput *socket = new NodeInput(this, bSocket, datatype); this->inputs.append(socket); } -void Node::addOutputSocket(DataType datatype) +void Node::add_output_socket(DataType datatype) { - this->addOutputSocket(datatype, nullptr); + this->add_output_socket(datatype, nullptr); } -void Node::addOutputSocket(DataType datatype, bNodeSocket *bSocket) +void Node::add_output_socket(DataType datatype, bNodeSocket *bSocket) { NodeOutput *socket = new NodeOutput(this, bSocket, datatype); outputs.append(socket); } -NodeOutput *Node::getOutputSocket(unsigned int index) const +NodeOutput *Node::get_output_socket(unsigned int index) const { return outputs[index]; } -NodeInput *Node::getInputSocket(unsigned int index) const +NodeInput *Node::get_input_socket(unsigned int index) const { return inputs[index]; } -bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex) +bNodeSocket *Node::get_editor_input_socket(int editor_node_input_socket_index) { - bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->inputs.first; + bNodeSocket *bSock = (bNodeSocket *)this->get_bnode()->inputs.first; int index = 0; while (bSock != nullptr) { - if (index == editorNodeInputSocketIndex) { + if (index == editor_node_input_socket_index) { return bSock; } index++; @@ -118,12 +118,12 @@ bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex) } return nullptr; } -bNodeSocket *Node::getEditorOutputSocket(int editorNodeOutputSocketIndex) +bNodeSocket *Node::get_editor_output_socket(int editor_node_output_socket_index) { - bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->outputs.first; + bNodeSocket *bSock = (bNodeSocket *)this->get_bnode()->outputs.first; int index = 0; while (bSock != nullptr) { - if (index == editorNodeOutputSocketIndex) { + if (index == editor_node_output_socket_index) { return bSock; } index++; @@ -137,33 +137,33 @@ bNodeSocket *Node::getEditorOutputSocket(int editorNodeOutputSocketIndex) *******************/ NodeInput::NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype) - : node_(node), editorSocket_(b_socket), datatype_(datatype), link_(nullptr) + : node_(node), editor_socket_(b_socket), datatype_(datatype), link_(nullptr) { } -void NodeInput::setLink(NodeOutput *link) +void NodeInput::set_link(NodeOutput *link) { link_ = link; } -float NodeInput::getEditorValueFloat() const +float NodeInput::get_editor_value_float() const { PointerRNA ptr; - RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr); + RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr); return RNA_float_get(&ptr, "default_value"); } -void NodeInput::getEditorValueColor(float *value) const +void NodeInput::get_editor_value_color(float *value) const { PointerRNA ptr; - RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr); + RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr); return RNA_float_get_array(&ptr, "default_value", value); } -void NodeInput::getEditorValueVector(float *value) const +void NodeInput::get_editor_value_vector(float *value) const { PointerRNA ptr; - RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr); + RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr); return RNA_float_get_array(&ptr, "default_value", value); } @@ -172,28 +172,28 @@ void NodeInput::getEditorValueVector(float *value) const ********************/ NodeOutput::NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype) - : node_(node), editorSocket_(b_socket), datatype_(datatype) + : node_(node), editor_socket_(b_socket), datatype_(datatype) { } -float NodeOutput::getEditorValueFloat() +float NodeOutput::get_editor_value_float() { PointerRNA ptr; - RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr); + RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr); return RNA_float_get(&ptr, "default_value"); } -void NodeOutput::getEditorValueColor(float *value) +void NodeOutput::get_editor_value_color(float *value) { PointerRNA ptr; - RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr); + RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr); return RNA_float_get_array(&ptr, "default_value", value); } -void NodeOutput::getEditorValueVector(float *value) +void NodeOutput::get_editor_value_vector(float *value) { PointerRNA ptr; - RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr); + RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr); return RNA_float_get_array(&ptr, "default_value", value); } diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h index 3d9c62aca67..41283b821bb 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -41,22 +41,22 @@ class Node { /** * \brief stores the reference to the SDNA bNode struct */ - bNodeTree *editorNodeTree_; + bNodeTree *editor_node_tree_; /** * \brief stores the reference to the SDNA bNode struct */ - bNode *editorNode_; + bNode *editor_node_; /** * \brief Is this node part of the active group */ - bool inActiveGroup_; + bool in_active_group_; /** * \brief Instance key to identify the node in an instance hash table */ - bNodeInstanceKey instanceKey_; + bNodeInstanceKey instance_key_; protected: /** @@ -70,23 +70,23 @@ class Node { Vector<NodeOutput *> outputs; public: - Node(bNode *editorNode, bool create_sockets = true); + Node(bNode *editor_node, bool create_sockets = true); virtual ~Node(); /** * \brief get the reference to the SDNA bNode struct */ - bNode *getbNode() const + bNode *get_bnode() const { - return editorNode_; + return editor_node_; } /** * \brief get the reference to the SDNA bNodeTree struct */ - bNodeTree *getbNodeTree() const + bNodeTree *get_bnodetree() const { - return editorNodeTree_; + return editor_node_tree_; } /** @@ -95,24 +95,24 @@ class Node { * node for highlight during execution. * \param bNode: */ - void setbNode(bNode *node) + void set_bnode(bNode *node) { - editorNode_ = node; + editor_node_ = node; } /** * \brief set the reference to the bNodeTree * \param bNodeTree: */ - void setbNodeTree(bNodeTree *nodetree) + void set_bnodetree(bNodeTree *nodetree) { - editorNodeTree_ = nodetree; + editor_node_tree_ = nodetree; } /** * \brief get access to the vector of input sockets */ - const Vector<NodeInput *> &getInputSockets() const + const Vector<NodeInput *> &get_input_sockets() const { return this->inputs; } @@ -120,7 +120,7 @@ class Node { /** * \brief get access to the vector of input sockets */ - const Vector<NodeOutput *> &getOutputSockets() const + const Vector<NodeOutput *> &get_output_sockets() const { return this->outputs; } @@ -130,22 +130,22 @@ class Node { * \param index: * the index of the needed outputsocket */ - NodeOutput *getOutputSocket(const unsigned int index = 0) const; + NodeOutput *get_output_socket(const unsigned int index = 0) const; /** * get the reference to a certain inputsocket * \param index: * the index of the needed inputsocket */ - NodeInput *getInputSocket(const unsigned int index) const; + NodeInput *get_input_socket(const unsigned int index) const; /** * \brief Is this node in the active group (the group that is being edited) - * \param isInActiveGroup: + * \param is_in_active_group: */ - void setIsInActiveGroup(bool value) + void set_is_in_active_group(bool value) { - inActiveGroup_ = value; + in_active_group_ = value; } /** @@ -154,9 +154,9 @@ class Node { * the active group will be the main tree (all nodes that are not part of a group will be active) * \return bool [false:true] */ - inline bool isInActiveGroup() const + inline bool is_in_active_group() const { - return inActiveGroup_; + return in_active_group_; } /** @@ -167,16 +167,16 @@ class Node { * \param system: the ExecutionSystem where the operations need to be added * \param context: reference to the CompositorContext */ - virtual void convertToOperations(NodeConverter &converter, - const CompositorContext &context) const = 0; + virtual void convert_to_operations(NodeConverter &converter, + const CompositorContext &context) const = 0; - void setInstanceKey(bNodeInstanceKey instance_key) + void set_instance_key(bNodeInstanceKey instance_key) { - instanceKey_ = instance_key; + instance_key_ = instance_key; } - bNodeInstanceKey getInstanceKey() const + bNodeInstanceKey get_instance_key() const { - return instanceKey_; + return instance_key_; } protected: @@ -185,19 +185,19 @@ class Node { * \note may only be called in an constructor * \param socket: the NodeInput to add */ - void addInputSocket(DataType datatype); - void addInputSocket(DataType datatype, bNodeSocket *socket); + void add_input_socket(DataType datatype); + void add_input_socket(DataType datatype, bNodeSocket *socket); /** * \brief add an NodeOutput to the collection of output-sockets * \note may only be called in an constructor * \param socket: the NodeOutput to add */ - void addOutputSocket(DataType datatype); - void addOutputSocket(DataType datatype, bNodeSocket *socket); + void add_output_socket(DataType datatype); + void add_output_socket(DataType datatype, bNodeSocket *socket); - bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex); - bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex); + bNodeSocket *get_editor_input_socket(int editor_node_input_socket_index); + bNodeSocket *get_editor_output_socket(int editor_node_output_socket_index); }; /** @@ -207,7 +207,7 @@ class Node { class NodeInput { private: Node *node_; - bNodeSocket *editorSocket_; + bNodeSocket *editor_socket_; DataType datatype_; @@ -220,32 +220,32 @@ class NodeInput { public: NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype); - Node *getNode() const + Node *get_node() const { return node_; } - DataType getDataType() const + DataType get_data_type() const { return datatype_; } - bNodeSocket *getbNodeSocket() const + bNodeSocket *get_bnode_socket() const { - return editorSocket_; + return editor_socket_; } - void setLink(NodeOutput *link); - bool isLinked() const + void set_link(NodeOutput *link); + bool is_linked() const { return link_; } - NodeOutput *getLink() + NodeOutput *get_link() { return link_; } - float getEditorValueFloat() const; - void getEditorValueColor(float *value) const; - void getEditorValueVector(float *value) const; + float get_editor_value_float() const; + void get_editor_value_color(float *value) const; + void get_editor_value_vector(float *value) const; }; /** @@ -255,29 +255,29 @@ class NodeInput { class NodeOutput { private: Node *node_; - bNodeSocket *editorSocket_; + bNodeSocket *editor_socket_; DataType datatype_; public: NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype); - Node *getNode() const + Node *get_node() const { return node_; } - DataType getDataType() const + DataType get_data_type() const { return datatype_; } - bNodeSocket *getbNodeSocket() const + bNodeSocket *get_bnode_socket() const { - return editorSocket_; + return editor_socket_; } - float getEditorValueFloat(); - void getEditorValueColor(float *value); - void getEditorValueVector(float *value); + float get_editor_value_float(); + void get_editor_value_color(float *value); + void get_editor_value_vector(float *value); }; } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_NodeConverter.cc b/source/blender/compositor/intern/COM_NodeConverter.cc index 314b5e9572a..93ec559533b 100644 --- a/source/blender/compositor/intern/COM_NodeConverter.cc +++ b/source/blender/compositor/intern/COM_NodeConverter.cc @@ -33,127 +33,128 @@ NodeConverter::NodeConverter(NodeOperationBuilder *builder) : builder_(builder) { } -void NodeConverter::addOperation(NodeOperation *operation) +void NodeConverter::add_operation(NodeOperation *operation) { - builder_->addOperation(operation); + builder_->add_operation(operation); } -void NodeConverter::mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket) +void NodeConverter::map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket) { - builder_->mapInputSocket(node_socket, operation_socket); + builder_->map_input_socket(node_socket, operation_socket); } -void NodeConverter::mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket) +void NodeConverter::map_output_socket(NodeOutput *node_socket, + NodeOperationOutput *operation_socket) { - builder_->mapOutputSocket(node_socket, operation_socket); + builder_->map_output_socket(node_socket, operation_socket); } -void NodeConverter::addLink(NodeOperationOutput *from, NodeOperationInput *to) +void NodeConverter::add_link(NodeOperationOutput *from, NodeOperationInput *to) { - builder_->addLink(from, to); + builder_->add_link(from, to); } -void NodeConverter::addPreview(NodeOperationOutput *output) +void NodeConverter::add_preview(NodeOperationOutput *output) { - builder_->addPreview(output); + builder_->add_preview(output); } -void NodeConverter::addNodeInputPreview(NodeInput *input) +void NodeConverter::add_node_input_preview(NodeInput *input) { - builder_->addNodeInputPreview(input); + builder_->add_node_input_preview(input); } -NodeOperation *NodeConverter::setInvalidOutput(NodeOutput *output) +NodeOperation *NodeConverter::set_invalid_output(NodeOutput *output) { /* this is a really bad situation - bring on the pink! - so artists know this is bad */ const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f}; SetColorOperation *operation = new SetColorOperation(); - operation->setChannels(warning_color); + operation->set_channels(warning_color); - builder_->addOperation(operation); - builder_->mapOutputSocket(output, operation->getOutputSocket()); + builder_->add_operation(operation); + builder_->map_output_socket(output, operation->get_output_socket()); return operation; } -NodeOperationOutput *NodeConverter::addInputProxy(NodeInput *input, bool use_conversion) +NodeOperationOutput *NodeConverter::add_input_proxy(NodeInput *input, bool use_conversion) { - SocketProxyOperation *proxy = new SocketProxyOperation(input->getDataType(), use_conversion); - builder_->addOperation(proxy); + SocketProxyOperation *proxy = new SocketProxyOperation(input->get_data_type(), use_conversion); + builder_->add_operation(proxy); - builder_->mapInputSocket(input, proxy->getInputSocket(0)); + builder_->map_input_socket(input, proxy->get_input_socket(0)); - return proxy->getOutputSocket(); + return proxy->get_output_socket(); } -NodeOperationInput *NodeConverter::addOutputProxy(NodeOutput *output, bool use_conversion) +NodeOperationInput *NodeConverter::add_output_proxy(NodeOutput *output, bool use_conversion) { - SocketProxyOperation *proxy = new SocketProxyOperation(output->getDataType(), use_conversion); - builder_->addOperation(proxy); + SocketProxyOperation *proxy = new SocketProxyOperation(output->get_data_type(), use_conversion); + builder_->add_operation(proxy); - builder_->mapOutputSocket(output, proxy->getOutputSocket()); + builder_->map_output_socket(output, proxy->get_output_socket()); - return proxy->getInputSocket(0); + return proxy->get_input_socket(0); } -void NodeConverter::addInputValue(NodeOperationInput *input, float value) +void NodeConverter::add_input_value(NodeOperationInput *input, float value) { SetValueOperation *operation = new SetValueOperation(); - operation->setValue(value); + operation->set_value(value); - builder_->addOperation(operation); - builder_->addLink(operation->getOutputSocket(), input); + builder_->add_operation(operation); + builder_->add_link(operation->get_output_socket(), input); } -void NodeConverter::addInputColor(NodeOperationInput *input, const float value[4]) +void NodeConverter::add_input_color(NodeOperationInput *input, const float value[4]) { SetColorOperation *operation = new SetColorOperation(); - operation->setChannels(value); + operation->set_channels(value); - builder_->addOperation(operation); - builder_->addLink(operation->getOutputSocket(), input); + builder_->add_operation(operation); + builder_->add_link(operation->get_output_socket(), input); } -void NodeConverter::addInputVector(NodeOperationInput *input, const float value[3]) +void NodeConverter::add_input_vector(NodeOperationInput *input, const float value[3]) { SetVectorOperation *operation = new SetVectorOperation(); - operation->setVector(value); + operation->set_vector(value); - builder_->addOperation(operation); - builder_->addLink(operation->getOutputSocket(), input); + builder_->add_operation(operation); + builder_->add_link(operation->get_output_socket(), input); } -void NodeConverter::addOutputValue(NodeOutput *output, float value) +void NodeConverter::add_output_value(NodeOutput *output, float value) { SetValueOperation *operation = new SetValueOperation(); - operation->setValue(value); + operation->set_value(value); - builder_->addOperation(operation); - builder_->mapOutputSocket(output, operation->getOutputSocket()); + builder_->add_operation(operation); + builder_->map_output_socket(output, operation->get_output_socket()); } -void NodeConverter::addOutputColor(NodeOutput *output, const float value[4]) +void NodeConverter::add_output_color(NodeOutput *output, const float value[4]) { SetColorOperation *operation = new SetColorOperation(); - operation->setChannels(value); + operation->set_channels(value); - builder_->addOperation(operation); - builder_->mapOutputSocket(output, operation->getOutputSocket()); + builder_->add_operation(operation); + builder_->map_output_socket(output, operation->get_output_socket()); } -void NodeConverter::addOutputVector(NodeOutput *output, const float value[3]) +void NodeConverter::add_output_vector(NodeOutput *output, const float value[3]) { SetVectorOperation *operation = new SetVectorOperation(); - operation->setVector(value); + operation->set_vector(value); - builder_->addOperation(operation); - builder_->mapOutputSocket(output, operation->getOutputSocket()); + builder_->add_operation(operation); + builder_->map_output_socket(output, operation->get_output_socket()); } -void NodeConverter::registerViewer(ViewerOperation *viewer) +void NodeConverter::register_viewer(ViewerOperation *viewer) { - builder_->registerViewer(viewer); + builder_->register_viewer(viewer); } ViewerOperation *NodeConverter::active_viewer() const diff --git a/source/blender/compositor/intern/COM_NodeConverter.h b/source/blender/compositor/intern/COM_NodeConverter.h index afbd53fa67d..9193a28a77f 100644 --- a/source/blender/compositor/intern/COM_NodeConverter.h +++ b/source/blender/compositor/intern/COM_NodeConverter.h @@ -36,7 +36,7 @@ class ViewerOperation; /** * Interface type for converting a \a Node into \a NodeOperation. - * This is passed to \a Node::convertToOperation methods and allows them + * This is passed to \a Node::convert_to_operation methods and allows them * to register any number of operations, create links between them, * and map original node sockets to their inputs or outputs. */ @@ -48,7 +48,7 @@ class NodeConverter { * Insert a new operation into the operations graph. * The operation must be created by the node. */ - void addOperation(NodeOperation *operation); + void add_operation(NodeOperation *operation); /** * Map input socket of the node to an operation socket. @@ -57,7 +57,7 @@ class NodeConverter { * * \note A \a Node input can be mapped to multiple \a NodeOperation inputs. */ - void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket); + void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket); /** * Map output socket of the node to an operation socket. * Links between nodes will then generate equivalent links between @@ -66,51 +66,51 @@ class NodeConverter { * \note A \a Node output can only be mapped to one \a NodeOperation output. * Any existing operation output mapping will be replaced. */ - void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket); + void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket); /** * Create a proxy operation for a node input. * This operation will be removed later and replaced * by direct links between the connected operations. */ - NodeOperationOutput *addInputProxy(NodeInput *input, bool use_conversion); + NodeOperationOutput *add_input_proxy(NodeInput *input, bool use_conversion); /** * Create a proxy operation for a node output. * This operation will be removed later and replaced * by direct links between the connected operations. */ - NodeOperationInput *addOutputProxy(NodeOutput *output, bool use_conversion); + NodeOperationInput *add_output_proxy(NodeOutput *output, bool use_conversion); /** Define a constant input value. */ - void addInputValue(NodeOperationInput *input, float value); + void add_input_value(NodeOperationInput *input, float value); /** Define a constant input color. */ - void addInputColor(NodeOperationInput *input, const float value[4]); + void add_input_color(NodeOperationInput *input, const float value[4]); /** Define a constant input vector. */ - void addInputVector(NodeOperationInput *input, const float value[3]); + void add_input_vector(NodeOperationInput *input, const float value[3]); /** Define a constant output value. */ - void addOutputValue(NodeOutput *output, float value); + void add_output_value(NodeOutput *output, float value); /** Define a constant output color. */ - void addOutputColor(NodeOutput *output, const float value[4]); + void add_output_color(NodeOutput *output, const float value[4]); /** Define a constant output vector. */ - void addOutputVector(NodeOutput *output, const float value[3]); + void add_output_vector(NodeOutput *output, const float value[3]); /** Add an explicit link between two operations. */ - void addLink(NodeOperationOutput *from, NodeOperationInput *to); + void add_link(NodeOperationOutput *from, NodeOperationInput *to); /** Add a preview operation for a operation output. */ - void addPreview(NodeOperationOutput *output); + void add_preview(NodeOperationOutput *output); /** Add a preview operation for a node input. */ - void addNodeInputPreview(NodeInput *input); + void add_node_input_preview(NodeInput *input); /** * When a node has no valid data * \note missing image / group pointer, or missing renderlayer from EXR */ - NodeOperation *setInvalidOutput(NodeOutput *output); + NodeOperation *set_invalid_output(NodeOutput *output); /** Define a viewer operation as the active output, if possible */ - void registerViewer(ViewerOperation *viewer); + void register_viewer(ViewerOperation *viewer); /** The currently active viewer output operation */ ViewerOperation *active_viewer() const; diff --git a/source/blender/compositor/intern/COM_NodeGraph.cc b/source/blender/compositor/intern/COM_NodeGraph.cc index a06c9349bb7..64684b772d9 100644 --- a/source/blender/compositor/intern/COM_NodeGraph.cc +++ b/source/blender/compositor/intern/COM_NodeGraph.cc @@ -71,21 +71,21 @@ void NodeGraph::add_node(Node *node, bNodeInstanceKey key, bool is_active_group) { - node->setbNodeTree(b_ntree); - node->setInstanceKey(key); - node->setIsInActiveGroup(is_active_group); + node->set_bnodetree(b_ntree); + node->set_instance_key(key); + node->set_is_in_active_group(is_active_group); nodes_.append(node); DebugInfo::node_added(node); } -void NodeGraph::add_link(NodeOutput *fromSocket, NodeInput *toSocket) +void NodeGraph::add_link(NodeOutput *from_socket, NodeInput *to_socket) { - links_.append(Link(fromSocket, toSocket)); + links_.append(Link(from_socket, to_socket)); /* register with the input */ - toSocket->setLink(fromSocket); + to_socket->set_link(from_socket); } void NodeGraph::add_bNodeTree(const CompositorContext &context, @@ -93,7 +93,7 @@ void NodeGraph::add_bNodeTree(const CompositorContext &context, bNodeTree *tree, bNodeInstanceKey parent_key) { - const bNodeTree *basetree = context.getbNodeTree(); + const bNodeTree *basetree = context.get_bnodetree(); /* Update viewers in the active edit-tree as well the base tree (for backdrop). */ bool is_active_group = (parent_key.value == basetree->active_viewer_key.value); @@ -124,7 +124,7 @@ void NodeGraph::add_bNode(const CompositorContext &context, } /* replace slow nodes with proxies for fast execution */ - if (context.isFastCalculation() && !COM_bnode_is_fast_node(*b_node)) { + if (context.is_fast_calculation() && !COM_bnode_is_fast_node(*b_node)) { add_proxies_skip(b_ntree, b_node, key, is_active_group); return; } @@ -149,8 +149,8 @@ NodeOutput *NodeGraph::find_output(const NodeRange &node_range, bNodeSocket *b_s { for (Vector<Node *>::iterator it = node_range.first; it != node_range.second; ++it) { Node *node = *it; - for (NodeOutput *output : node->getOutputSockets()) { - if (output->getbNodeSocket() == b_socket) { + for (NodeOutput *output : node->get_output_sockets()) { + if (output->get_bnode_socket() == b_socket) { return output; } } @@ -180,8 +180,8 @@ void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink for (Vector<Node *>::iterator it = node_range.first; it != node_range.second; ++it) { Node *node = *it; - for (NodeInput *input : node->getInputSockets()) { - if (input->getbNodeSocket() == b_nodelink->tosock && !input->isLinked()) { + for (NodeInput *input : node->get_input_sockets()) { + if (input->get_bnode_socket() == b_nodelink->tosock && !input->is_linked()) { add_link(output, input); } } @@ -258,7 +258,7 @@ void NodeGraph::add_proxies_group_outputs(const CompositorContext &context, b_sock_io = b_sock_io->next) { bNodeSocket *b_sock_group = find_b_node_output(b_node, b_sock_io->identifier); if (b_sock_group) { - if (context.isGroupnodeBufferEnabled() && + if (context.is_groupnode_buffer_enabled() && context.get_execution_model() == eExecutionModel::Tiled) { SocketBufferNode *buffer = new SocketBufferNode(b_node_io, b_sock_io, b_sock_group); add_node(buffer, b_group_tree, key, is_active_group); @@ -279,7 +279,7 @@ void NodeGraph::add_proxies_group(const CompositorContext &context, /* missing node group datablock can happen with library linking */ if (!b_group_tree) { - /* This error case its handled in convertToOperations() + /* This error case its handled in convert_to_operations() * so we don't get un-converted sockets. */ return; } diff --git a/source/blender/compositor/intern/COM_NodeGraph.h b/source/blender/compositor/intern/COM_NodeGraph.h index cc628ebb724..476b99033c9 100644 --- a/source/blender/compositor/intern/COM_NodeGraph.h +++ b/source/blender/compositor/intern/COM_NodeGraph.h @@ -71,7 +71,7 @@ class NodeGraph { static bNodeSocket *find_b_node_output(bNode *b_node, const char *identifier); void add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group); - void add_link(NodeOutput *fromSocket, NodeInput *toSocket); + void add_link(NodeOutput *from_socket, NodeInput *to_socket); void add_bNodeTree(const CompositorContext &context, int nodes_start, diff --git a/source/blender/compositor/intern/COM_NodeOperation.cc b/source/blender/compositor/intern/COM_NodeOperation.cc index 0bfc088e4bf..41c645b9eea 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cc +++ b/source/blender/compositor/intern/COM_NodeOperation.cc @@ -40,7 +40,7 @@ NodeOperation::NodeOperation() /** Get constant value when operation is constant, otherwise return default_value. */ float NodeOperation::get_constant_value_default(float default_value) { - BLI_assert(outputs_.size() > 0 && getOutputSocket()->getDataType() == DataType::Value); + BLI_assert(outputs_.size() > 0 && get_output_socket()->get_data_type() == DataType::Value); return *get_constant_elem_default(&default_value); } @@ -74,23 +74,23 @@ std::optional<NodeOperationHash> NodeOperation::generate_hash() hash_params(canvas_.ymin, canvas_.ymax); if (outputs_.size() > 0) { BLI_assert(outputs_.size() == 1); - hash_param(this->getOutputSocket()->getDataType()); + hash_param(this->get_output_socket()->get_data_type()); } NodeOperationHash hash; hash.params_hash_ = params_hash_; hash.parents_hash_ = 0; for (NodeOperationInput &socket : inputs_) { - if (!socket.isConnected()) { + if (!socket.is_connected()) { continue; } - NodeOperation &input = socket.getLink()->getOperation(); + NodeOperation &input = socket.get_link()->get_operation(); const bool is_constant = input.get_flags().is_constant_operation; combine_hashes(hash.parents_hash_, get_default_hash(is_constant)); if (is_constant) { const float *elem = ((ConstantOperation *)&input)->get_constant_elem(); - const int num_channels = COM_data_type_num_channels(socket.getDataType()); + const int num_channels = COM_data_type_num_channels(socket.get_data_type()); for (const int i : IndexRange(num_channels)) { combine_hashes(hash.parents_hash_, get_default_hash(elem[i])); } @@ -106,22 +106,22 @@ std::optional<NodeOperationHash> NodeOperation::generate_hash() return hash; } -NodeOperationOutput *NodeOperation::getOutputSocket(unsigned int index) +NodeOperationOutput *NodeOperation::get_output_socket(unsigned int index) { return &outputs_[index]; } -NodeOperationInput *NodeOperation::getInputSocket(unsigned int index) +NodeOperationInput *NodeOperation::get_input_socket(unsigned int index) { return &inputs_[index]; } -void NodeOperation::addInputSocket(DataType datatype, ResizeMode resize_mode) +void NodeOperation::add_input_socket(DataType datatype, ResizeMode resize_mode) { inputs_.append(NodeOperationInput(this, datatype, resize_mode)); } -void NodeOperation::addOutputSocket(DataType datatype) +void NodeOperation::add_output_socket(DataType datatype) { outputs_.append(NodeOperationOutput(this, datatype)); } @@ -157,7 +157,7 @@ void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area) continue; } NodeOperationInput &input = inputs_[index]; - if (input.isConnected()) { + if (input.is_connected()) { input.determine_canvas(local_preferred_area, unused_area); } } @@ -172,32 +172,32 @@ void NodeOperation::init_data() { /* Pass. */ } -void NodeOperation::initExecution() +void NodeOperation::init_execution() { /* pass */ } -void NodeOperation::initMutex() +void NodeOperation::init_mutex() { BLI_mutex_init(&mutex_); } -void NodeOperation::lockMutex() +void NodeOperation::lock_mutex() { BLI_mutex_lock(&mutex_); } -void NodeOperation::unlockMutex() +void NodeOperation::unlock_mutex() { BLI_mutex_unlock(&mutex_); } -void NodeOperation::deinitMutex() +void NodeOperation::deinit_mutex() { BLI_mutex_end(&mutex_); } -void NodeOperation::deinitExecution() +void NodeOperation::deinit_execution() { /* pass */ } @@ -223,48 +223,48 @@ void NodeOperation::unset_canvas() flags.is_canvas_set = false; } -SocketReader *NodeOperation::getInputSocketReader(unsigned int inputSocketIndex) +SocketReader *NodeOperation::get_input_socket_reader(unsigned int index) { - return this->getInputSocket(inputSocketIndex)->getReader(); + return this->get_input_socket(index)->get_reader(); } -NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex) +NodeOperation *NodeOperation::get_input_operation(int index) { - NodeOperationInput *input = getInputSocket(inputSocketIndex); - if (input && input->isConnected()) { - return &input->getLink()->getOperation(); + NodeOperationInput *input = get_input_socket(index); + if (input && input->is_connected()) { + return &input->get_link()->get_operation(); } return nullptr; } -bool NodeOperation::determineDependingAreaOfInterest(rcti *input, - ReadBufferOperation *readOperation, - rcti *output) +bool NodeOperation::determine_depending_area_of_interest(rcti *input, + ReadBufferOperation *read_operation, + rcti *output) { if (inputs_.size() == 0) { BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax); return false; } - rcti tempOutput; + rcti temp_output; bool first = true; - for (int i = 0; i < getNumberOfInputSockets(); i++) { - NodeOperation *inputOperation = this->getInputOperation(i); - if (inputOperation && - inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) { + for (int i = 0; i < get_number_of_input_sockets(); i++) { + NodeOperation *input_operation = this->get_input_operation(i); + if (input_operation && input_operation->determine_depending_area_of_interest( + input, read_operation, &temp_output)) { if (first) { - output->xmin = tempOutput.xmin; - output->ymin = tempOutput.ymin; - output->xmax = tempOutput.xmax; - output->ymax = tempOutput.ymax; + output->xmin = temp_output.xmin; + output->ymin = temp_output.ymin; + output->xmax = temp_output.xmax; + output->ymax = temp_output.ymax; first = false; } else { - output->xmin = MIN2(output->xmin, tempOutput.xmin); - output->ymin = MIN2(output->ymin, tempOutput.ymin); - output->xmax = MAX2(output->xmax, tempOutput.xmax); - output->ymax = MAX2(output->ymax, tempOutput.ymax); + output->xmin = MIN2(output->xmin, temp_output.xmin); + output->ymin = MIN2(output->ymin, temp_output.ymin); + output->xmax = MAX2(output->xmax, temp_output.xmax); + output->ymax = MAX2(output->ymax, temp_output.ymax); } } } @@ -297,7 +297,7 @@ void NodeOperation::get_area_of_interest(const int input_idx, else { /* Non full-frame operations never implement this method. To ensure correctness assume * whole area is used. */ - NodeOperation *input_op = getInputOperation(input_idx); + NodeOperation *input_op = get_input_operation(input_idx); r_input_area = input_op->get_canvas(); } } @@ -306,8 +306,8 @@ void NodeOperation::get_area_of_interest(NodeOperation *input_op, const rcti &output_area, rcti &r_input_area) { - for (int i = 0; i < getNumberOfInputSockets(); i++) { - if (input_op == getInputOperation(i)) { + for (int i = 0; i < get_number_of_input_sockets(); i++) { + if (input_op == get_input_operation(i)) { get_area_of_interest(i, output_area, r_input_area); return; } @@ -340,11 +340,11 @@ void NodeOperation::render_full_frame(MemoryBuffer *output_buf, Span<rcti> areas, Span<MemoryBuffer *> inputs_bufs) { - initExecution(); + init_execution(); for (const rcti &area : areas) { update_memory_buffer(output_buf, area, inputs_bufs); } - deinitExecution(); + deinit_execution(); } /** @@ -356,18 +356,18 @@ void NodeOperation::render_full_frame_fallback(MemoryBuffer *output_buf, { Vector<NodeOperationOutput *> orig_input_links = replace_inputs_with_buffers(inputs_bufs); - initExecution(); - const bool is_output_operation = getNumberOfOutputSockets() == 0; + init_execution(); + const bool is_output_operation = get_number_of_output_sockets() == 0; if (!is_output_operation && output_buf->is_a_single_elem()) { float *output_elem = output_buf->get_elem(0, 0); - readSampled(output_elem, 0, 0, PixelSampler::Nearest); + read_sampled(output_elem, 0, 0, PixelSampler::Nearest); } else { for (const rcti &rect : areas) { exec_system_->execute_work(rect, [=](const rcti &split_rect) { rcti tile_rect = split_rect; if (is_output_operation) { - executeRegion(&tile_rect, 0); + execute_region(&tile_rect, 0); } else { render_tile(output_buf, &tile_rect); @@ -375,7 +375,7 @@ void NodeOperation::render_full_frame_fallback(MemoryBuffer *output_buf, }); } } - deinitExecution(); + deinit_execution(); remove_buffers_and_restore_original_inputs(orig_input_links); } @@ -383,7 +383,7 @@ void NodeOperation::render_full_frame_fallback(MemoryBuffer *output_buf, void NodeOperation::render_tile(MemoryBuffer *output_buf, rcti *tile_rect) { const bool is_complex = get_flags().complex; - void *tile_data = is_complex ? initializeTileData(tile_rect) : nullptr; + void *tile_data = is_complex ? initialize_tile_data(tile_rect) : nullptr; const int elem_stride = output_buf->elem_stride; for (int y = tile_rect->ymin; y < tile_rect->ymax; y++) { float *output_elem = output_buf->get_elem(tile_rect->xmin, y); @@ -395,13 +395,13 @@ void NodeOperation::render_tile(MemoryBuffer *output_buf, rcti *tile_rect) } else { for (int x = tile_rect->xmin; x < tile_rect->xmax; x++) { - readSampled(output_elem, x, y, PixelSampler::Nearest); + read_sampled(output_elem, x, y, PixelSampler::Nearest); output_elem += elem_stride; } } } if (tile_data) { - deinitializeTileData(tile_rect, tile_data); + deinitialize_tile_data(tile_rect, tile_data); } } @@ -411,14 +411,15 @@ void NodeOperation::render_tile(MemoryBuffer *output_buf, rcti *tile_rect) Vector<NodeOperationOutput *> NodeOperation::replace_inputs_with_buffers( Span<MemoryBuffer *> inputs_bufs) { - BLI_assert(inputs_bufs.size() == getNumberOfInputSockets()); + BLI_assert(inputs_bufs.size() == get_number_of_input_sockets()); Vector<NodeOperationOutput *> orig_links(inputs_bufs.size()); for (int i = 0; i < inputs_bufs.size(); i++) { - NodeOperationInput *input_socket = getInputSocket(i); - BufferOperation *buffer_op = new BufferOperation(inputs_bufs[i], input_socket->getDataType()); - orig_links[i] = input_socket->getLink(); - input_socket->setLink(buffer_op->getOutputSocket()); - buffer_op->initExecution(); + NodeOperationInput *input_socket = get_input_socket(i); + BufferOperation *buffer_op = new BufferOperation(inputs_bufs[i], + input_socket->get_data_type()); + orig_links[i] = input_socket->get_link(); + input_socket->set_link(buffer_op->get_output_socket()); + buffer_op->init_execution(); } return orig_links; } @@ -426,14 +427,14 @@ Vector<NodeOperationOutput *> NodeOperation::replace_inputs_with_buffers( void NodeOperation::remove_buffers_and_restore_original_inputs( Span<NodeOperationOutput *> original_inputs_links) { - BLI_assert(original_inputs_links.size() == getNumberOfInputSockets()); + BLI_assert(original_inputs_links.size() == get_number_of_input_sockets()); for (int i = 0; i < original_inputs_links.size(); i++) { NodeOperation *buffer_op = get_input_operation(i); BLI_assert(buffer_op != nullptr); BLI_assert(typeid(*buffer_op) == typeid(BufferOperation)); - buffer_op->deinitExecution(); - NodeOperationInput *input_socket = getInputSocket(i); - input_socket->setLink(original_inputs_links[i]); + buffer_op->deinit_execution(); + NodeOperationInput *input_socket = get_input_socket(i); + input_socket->set_link(original_inputs_links[i]); delete buffer_op; } } @@ -444,15 +445,17 @@ void NodeOperation::remove_buffers_and_restore_original_inputs( **** OpInput **** *****************/ -NodeOperationInput::NodeOperationInput(NodeOperation *op, DataType datatype, ResizeMode resizeMode) - : operation_(op), datatype_(datatype), resizeMode_(resizeMode), link_(nullptr) +NodeOperationInput::NodeOperationInput(NodeOperation *op, + DataType datatype, + ResizeMode resize_mode) + : operation_(op), datatype_(datatype), resize_mode_(resize_mode), link_(nullptr) { } -SocketReader *NodeOperationInput::getReader() +SocketReader *NodeOperationInput::get_reader() { - if (isConnected()) { - return &link_->getOperation(); + if (is_connected()) { + return &link_->get_operation(); } return nullptr; @@ -481,7 +484,7 @@ NodeOperationOutput::NodeOperationOutput(NodeOperation *op, DataType datatype) void NodeOperationOutput::determine_canvas(const rcti &preferred_area, rcti &r_area) { - NodeOperation &operation = getOperation(); + NodeOperation &operation = get_operation(); if (operation.get_flags().is_canvas_set) { r_area = operation.get_canvas(); } @@ -558,9 +561,9 @@ std::ostream &operator<<(std::ostream &os, const NodeOperation &node_operation) os << ",flags={" << flags << "}"; if (flags.is_read_buffer_operation) { const ReadBufferOperation *read_operation = (const ReadBufferOperation *)&node_operation; - const MemoryProxy *proxy = read_operation->getMemoryProxy(); + const MemoryProxy *proxy = read_operation->get_memory_proxy(); if (proxy) { - const WriteBufferOperation *write_operation = proxy->getWriteBufferOperation(); + const WriteBufferOperation *write_operation = proxy->get_write_buffer_operation(); if (write_operation) { os << ",write=" << (NodeOperation &)*write_operation; } diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index af9d62b4276..3c172faca50 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -91,7 +91,7 @@ class NodeOperationInput { DataType datatype_; /** Resize mode of this socket */ - ResizeMode resizeMode_; + ResizeMode resize_mode_; /** Connected output */ NodeOperationOutput *link_; @@ -99,40 +99,40 @@ class NodeOperationInput { public: NodeOperationInput(NodeOperation *op, DataType datatype, - ResizeMode resizeMode = ResizeMode::Center); + ResizeMode resize_mode = ResizeMode::Center); - NodeOperation &getOperation() const + NodeOperation &get_operation() const { return *operation_; } - DataType getDataType() const + DataType get_data_type() const { return datatype_; } - void setLink(NodeOperationOutput *link) + void set_link(NodeOperationOutput *link) { link_ = link; } - NodeOperationOutput *getLink() const + NodeOperationOutput *get_link() const { return link_; } - bool isConnected() const + bool is_connected() const { return link_; } - void setResizeMode(ResizeMode resizeMode) + void set_resize_mode(ResizeMode resize_mode) { - resizeMode_ = resizeMode; + resize_mode_ = resize_mode; } - ResizeMode getResizeMode() const + ResizeMode get_resize_mode() const { - return resizeMode_; + return resize_mode_; } - SocketReader *getReader(); + SocketReader *get_reader(); bool determine_canvas(const rcti &preferred_area, rcti &r_area); @@ -153,11 +153,11 @@ class NodeOperationOutput { public: NodeOperationOutput(NodeOperation *op, DataType datatype); - NodeOperation &getOperation() const + NodeOperation &get_operation() const { return *operation_; } - DataType getDataType() const + DataType get_data_type() const { return datatype_; } @@ -334,9 +334,9 @@ class NodeOperation { * \note only use when you really know what you are doing. * this mutex is used to share data among chunks in the same operation * \see TonemapOperation for an example of usage - * \see NodeOperation.initMutex initializes this mutex - * \see NodeOperation.deinitMutex deinitializes this mutex - * \see NodeOperation.getMutex retrieve a pointer to this mutex. + * \see NodeOperation.init_mutex initializes this mutex + * \see NodeOperation.deinit_mutex deinitializes this mutex + * \see NodeOperation.get_mutex retrieve a pointer to this mutex. */ ThreadMutex mutex_; @@ -395,28 +395,23 @@ class NodeOperation { std::optional<NodeOperationHash> generate_hash(); - unsigned int getNumberOfInputSockets() const + unsigned int get_number_of_input_sockets() const { return inputs_.size(); } - unsigned int getNumberOfOutputSockets() const + unsigned int get_number_of_output_sockets() const { return outputs_.size(); } - NodeOperationOutput *getOutputSocket(unsigned int index = 0); - NodeOperationInput *getInputSocket(unsigned int index); + NodeOperationOutput *get_output_socket(unsigned int index = 0); + NodeOperationInput *get_input_socket(unsigned int index); - NodeOperation *get_input_operation(int index) - { - /* TODO: Rename protected getInputOperation to get_input_operation and make it public replacing - * this method. */ - return getInputOperation(index); - } + NodeOperation *get_input_operation(int index); virtual void determine_canvas(const rcti &preferred_area, rcti &r_area); /** - * \brief isOutputOperation determines whether this operation is an output of the + * \brief is_output_operation determines whether this operation is an output of the * ExecutionSystem during rendering or editing. * * Default behavior if not overridden, this operation will not be evaluated as being an output @@ -430,7 +425,7 @@ class NodeOperation { * * \return bool the result of this method */ - virtual bool isOutputOperation(bool /*rendering*/) const + virtual bool is_output_operation(bool /*rendering*/) const { return false; } @@ -440,7 +435,7 @@ class NodeOperation { execution_model_ = model; } - void setbNodeTree(const bNodeTree *tree) + void set_bnodetree(const bNodeTree *tree) { btree_ = tree; } @@ -452,20 +447,20 @@ class NodeOperation { /** * Initializes operation data needed after operations are linked and resolutions determined. For - * rendering heap memory data use initExecution(). + * rendering heap memory data use init_execution(). */ virtual void init_data(); - virtual void initExecution(); + virtual void init_execution(); /** * \brief when a chunk is executed by a CPUDevice, this method is called * \ingroup execution * \param rect: the rectangle of the chunk (location and size) - * \param chunkNumber: the chunkNumber to be calculated - * \param memoryBuffers: all input MemoryBuffer's needed + * \param chunk_number: the chunk_number to be calculated + * \param memory_buffers: all input MemoryBuffer's needed */ - virtual void executeRegion(rcti * /*rect*/, unsigned int /*chunkNumber*/) + virtual void execute_region(rcti * /*rect*/, unsigned int /*chunk_number*/) { } @@ -477,15 +472,15 @@ class NodeOperation { * \param program: the OpenCL program containing all compositor kernels * \param queue: the OpenCL command queue of the device the chunk is executed on * \param rect: the rectangle of the chunk (location and size) - * \param chunkNumber: the chunkNumber to be calculated - * \param memoryBuffers: all input MemoryBuffer's needed - * \param outputBuffer: the outputbuffer to write to + * \param chunk_number: the chunk_number to be calculated + * \param memory_buffers: all input MemoryBuffer's needed + * \param output_buffer: the outputbuffer to write to */ - virtual void executeOpenCLRegion(OpenCLDevice * /*device*/, - rcti * /*rect*/, - unsigned int /*chunkNumber*/, - MemoryBuffer ** /*memoryBuffers*/, - MemoryBuffer * /*outputBuffer*/) + virtual void execute_opencl_region(OpenCLDevice * /*device*/, + rcti * /*rect*/, + unsigned int /*chunk_number*/, + MemoryBuffer ** /*memory_buffers*/, + MemoryBuffer * /*output_buffer*/) { } @@ -496,23 +491,23 @@ class NodeOperation { * \param context: the OpenCL context * \param program: the OpenCL program containing all compositor kernels * \param queue: the OpenCL command queue of the device the chunk is executed on - * \param outputMemoryBuffer: the allocated memory buffer in main CPU memory - * \param clOutputBuffer: the allocated memory buffer in OpenCLDevice memory - * \param inputMemoryBuffers: all input MemoryBuffer's needed - * \param clMemToCleanUp: all created cl_mem references must be added to this list. + * \param output_memory_buffer: the allocated memory buffer in main CPU memory + * \param cl_output_buffer: the allocated memory buffer in OpenCLDevice memory + * \param input_memory_buffers: all input MemoryBuffer's needed + * \param cl_mem_to_clean_up: 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. + * \param cl_kernels_to_clean_up: all created cl_kernel references must be added to this list. * Framework will clean this after execution */ - virtual void executeOpenCL(OpenCLDevice * /*device*/, - MemoryBuffer * /*outputMemoryBuffer*/, - cl_mem /*clOutputBuffer*/, - MemoryBuffer ** /*inputMemoryBuffers*/, - std::list<cl_mem> * /*clMemToCleanUp*/, - std::list<cl_kernel> * /*clKernelsToCleanUp*/) + virtual void execute_opencl(OpenCLDevice * /*device*/, + MemoryBuffer * /*output_memory_buffer*/, + cl_mem /*cl_output_buffer*/, + MemoryBuffer ** /*input_memory_buffers*/, + std::list<cl_mem> * /*cl_mem_to_clean_up*/, + std::list<cl_kernel> * /*cl_kernels_to_clean_up*/) { } - virtual void deinitExecution(); + virtual void deinit_execution(); void set_canvas(const rcti &canvas_area); const rcti &get_canvas() const; @@ -525,14 +520,14 @@ class NodeOperation { * \return [true:false] * \see BaseViewerOperation */ - virtual bool isActiveViewerOutput() const + virtual bool is_active_viewer_output() const { return false; } - virtual bool determineDependingAreaOfInterest(rcti *input, - ReadBufferOperation *readOperation, - rcti *output); + virtual bool determine_depending_area_of_interest(rcti *input, + ReadBufferOperation *read_operation, + rcti *output); /** * \brief set the index of the input socket that will determine the canvas of this @@ -554,58 +549,58 @@ class NodeOperation { * \note only applicable for output operations like ViewerOperation * \return eCompositorPriority */ - virtual eCompositorPriority getRenderPriority() const + virtual eCompositorPriority get_render_priority() const { return eCompositorPriority::Low; } - inline bool isBraked() const + inline bool is_braked() const { return btree_->test_break(btree_->tbh); } - inline void updateDraw() + inline void update_draw() { if (btree_->update_draw) { btree_->update_draw(btree_->udh); } } - unsigned int getWidth() const + unsigned int get_width() const { return BLI_rcti_size_x(&get_canvas()); } - unsigned int getHeight() const + unsigned int get_height() const { return BLI_rcti_size_y(&get_canvas()); } - inline void readSampled(float result[4], float x, float y, PixelSampler sampler) + inline void read_sampled(float result[4], float x, float y, PixelSampler sampler) { - executePixelSampled(result, x, y, sampler); + execute_pixel_sampled(result, x, y, sampler); } - inline void readFiltered(float result[4], float x, float y, float dx[2], float dy[2]) + inline void read_filtered(float result[4], float x, float y, float dx[2], float dy[2]) { - executePixelFiltered(result, x, y, dx, dy); + execute_pixel_filtered(result, x, y, dx, dy); } - inline void read(float result[4], int x, int y, void *chunkData) + inline void read(float result[4], int x, int y, void *chunk_data) { - executePixel(result, x, y, chunkData); + execute_pixel(result, x, y, chunk_data); } - virtual void *initializeTileData(rcti * /*rect*/) + virtual void *initialize_tile_data(rcti * /*rect*/) { return 0; } - virtual void deinitializeTileData(rcti * /*rect*/, void * /*data*/) + virtual void deinitialize_tile_data(rcti * /*rect*/, void * /*data*/) { } - virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer ** /*memoryBuffers*/) + virtual MemoryBuffer *get_input_memory_buffer(MemoryBuffer ** /*memory_buffers*/) { return 0; } @@ -614,7 +609,7 @@ class NodeOperation { * Return the meta data associated with this branch. * * The return parameter holds an instance or is an nullptr. */ - virtual std::unique_ptr<MetaData> getMetaData() + virtual std::unique_ptr<MetaData> get_meta_data() { return std::unique_ptr<MetaData>(); } @@ -672,28 +667,27 @@ class NodeOperation { combine_hashes(params_hash_, get_default_hash_3(param1, param2, param3)); } - void addInputSocket(DataType datatype, ResizeMode resize_mode = ResizeMode::Center); - void addOutputSocket(DataType datatype); + void add_input_socket(DataType datatype, ResizeMode resize_mode = ResizeMode::Center); + void add_output_socket(DataType datatype); /* TODO(manzanilla): to be removed with tiled implementation. */ - void setWidth(unsigned int width) + void set_width(unsigned int width) { canvas_.xmax = canvas_.xmin + width; this->flags.is_canvas_set = true; } - void setHeight(unsigned int height) + void set_height(unsigned int height) { canvas_.ymax = canvas_.ymin + height; this->flags.is_canvas_set = true; } - SocketReader *getInputSocketReader(unsigned int inputSocketindex); - NodeOperation *getInputOperation(unsigned int inputSocketindex); + SocketReader *get_input_socket_reader(unsigned int index); - void deinitMutex(); - void initMutex(); - void lockMutex(); - void unlockMutex(); + void deinit_mutex(); + void init_mutex(); + void lock_mutex(); + void unlock_mutex(); /** * \brief set whether this operation is complex @@ -701,7 +695,7 @@ class NodeOperation { * Complex operations are typically doing many reads to calculate the output of a single pixel. * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true. */ - void setComplex(bool complex) + void set_complex(bool complex) { this->flags.complex = complex; } @@ -712,12 +706,12 @@ class NodeOperation { * \param result: is a float[4] array to store the result * \param x: the x-coordinate of the pixel to calculate in image space * \param y: the y-coordinate of the pixel to calculate in image space - * \param inputBuffers: chunks that can be read by their ReadBufferOperation. + * \param input_buffers: chunks that can be read by their ReadBufferOperation. */ - virtual void executePixelSampled(float /*output*/[4], - float /*x*/, - float /*y*/, - PixelSampler /*sampler*/) + virtual void execute_pixel_sampled(float /*output*/[4], + float /*x*/, + float /*y*/, + PixelSampler /*sampler*/) { } @@ -727,12 +721,12 @@ class NodeOperation { * \param result: is a float[4] array to store the result * \param x: the x-coordinate of the pixel to calculate in image space * \param y: the y-coordinate of the pixel to calculate in image space - * \param inputBuffers: chunks that can be read by their ReadBufferOperation. - * \param chunkData: chunk specific data a during execution time. + * \param input_buffers: chunks that can be read by their ReadBufferOperation. + * \param chunk_data: chunk specific data a during execution time. */ - virtual void executePixel(float output[4], int x, int y, void * /*chunkData*/) + virtual void execute_pixel(float output[4], int x, int y, void * /*chunk_data*/) { - executePixelSampled(output, x, y, PixelSampler::Nearest); + execute_pixel_sampled(output, x, y, PixelSampler::Nearest); } /** @@ -743,9 +737,9 @@ class NodeOperation { * \param y: the y-coordinate of the pixel to calculate in image space * \param dx: * \param dy: - * \param inputBuffers: chunks that can be read by their ReadBufferOperation. + * \param input_buffers: chunks that can be read by their ReadBufferOperation. */ - virtual void executePixelFiltered( + virtual void execute_pixel_filtered( float /*output*/[4], float /*x*/, float /*y*/, float /*dx*/[2], float /*dy*/[2]) { } diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc index 708bda30636..5dc66fea670 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc @@ -45,7 +45,7 @@ NodeOperationBuilder::NodeOperationBuilder(const CompositorContext *context, graph_.from_bNodeTree(*context, b_nodetree); } -void NodeOperationBuilder::convertToOperations(ExecutionSystem *system) +void NodeOperationBuilder::convert_to_operations(ExecutionSystem *system) { /* interface handle for nodes */ NodeConverter converter(this); @@ -54,7 +54,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system) current_node_ = node; DebugInfo::node_to_operations(node); - node->convertToOperations(converter, *context_); + node->convert_to_operations(converter, *context_); } current_node_ = nullptr; @@ -86,7 +86,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system) } for (NodeOperationInput *op_to : op_to_list) { - addLink(op_from, op_to); + add_link(op_from, op_to); } } @@ -130,12 +130,12 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system) system->set_operations(operations_, groups_); } -void NodeOperationBuilder::addOperation(NodeOperation *operation) +void NodeOperationBuilder::add_operation(NodeOperation *operation) { operation->set_id(operations_.size()); operations_.append(operation); if (current_node_) { - operation->set_name(current_node_->getbNode()->name); + operation->set_name(current_node_->get_bnode()->name); } operation->set_execution_model(context_->get_execution_model()); operation->set_execution_system(exec_system_); @@ -144,9 +144,9 @@ void NodeOperationBuilder::addOperation(NodeOperation *operation) void NodeOperationBuilder::replace_operation_with_constant(NodeOperation *operation, ConstantOperation *constant_operation) { - BLI_assert(constant_operation->getNumberOfInputSockets() == 0); + BLI_assert(constant_operation->get_number_of_input_sockets() == 0); unlink_inputs_and_relink_outputs(operation, constant_operation); - addOperation(constant_operation); + add_operation(constant_operation); } void NodeOperationBuilder::unlink_inputs_and_relink_outputs(NodeOperation *unlinked_op, @@ -155,61 +155,61 @@ void NodeOperationBuilder::unlink_inputs_and_relink_outputs(NodeOperation *unlin int i = 0; while (i < links_.size()) { Link &link = links_[i]; - if (&link.to()->getOperation() == unlinked_op) { - link.to()->setLink(nullptr); + if (&link.to()->get_operation() == unlinked_op) { + link.to()->set_link(nullptr); links_.remove(i); continue; } - if (&link.from()->getOperation() == unlinked_op) { - link.to()->setLink(linked_op->getOutputSocket()); - links_[i] = Link(linked_op->getOutputSocket(), link.to()); + if (&link.from()->get_operation() == unlinked_op) { + link.to()->set_link(linked_op->get_output_socket()); + links_[i] = Link(linked_op->get_output_socket(), link.to()); } i++; } } -void NodeOperationBuilder::mapInputSocket(NodeInput *node_socket, - NodeOperationInput *operation_socket) +void NodeOperationBuilder::map_input_socket(NodeInput *node_socket, + NodeOperationInput *operation_socket) { BLI_assert(current_node_); - BLI_assert(node_socket->getNode() == current_node_); + BLI_assert(node_socket->get_node() == current_node_); /* NOTE: this maps operation sockets to node sockets. - * for resolving links the map will be inverted first in convertToOperations, + * for resolving links the map will be inverted first in convert_to_operations, * to get a list of links for each node input socket. */ input_map_.add_new(operation_socket, node_socket); } -void NodeOperationBuilder::mapOutputSocket(NodeOutput *node_socket, - NodeOperationOutput *operation_socket) +void NodeOperationBuilder::map_output_socket(NodeOutput *node_socket, + NodeOperationOutput *operation_socket) { BLI_assert(current_node_); - BLI_assert(node_socket->getNode() == current_node_); + BLI_assert(node_socket->get_node() == current_node_); output_map_.add_new(node_socket, operation_socket); } -void NodeOperationBuilder::addLink(NodeOperationOutput *from, NodeOperationInput *to) +void NodeOperationBuilder::add_link(NodeOperationOutput *from, NodeOperationInput *to) { - if (to->isConnected()) { + if (to->is_connected()) { return; } links_.append(Link(from, to)); /* register with the input */ - to->setLink(from); + to->set_link(from); } -void NodeOperationBuilder::removeInputLink(NodeOperationInput *to) +void NodeOperationBuilder::remove_input_link(NodeOperationInput *to) { int index = 0; for (Link &link : links_) { if (link.to() == to) { /* unregister with the input */ - to->setLink(nullptr); + to->set_link(nullptr); links_.remove(index); return; @@ -222,67 +222,67 @@ PreviewOperation *NodeOperationBuilder::make_preview_operation() const { BLI_assert(current_node_); - if (!(current_node_->getbNode()->flag & NODE_PREVIEW)) { + if (!(current_node_->get_bnode()->flag & NODE_PREVIEW)) { return nullptr; } /* previews only in the active group */ - if (!current_node_->isInActiveGroup()) { + if (!current_node_->is_in_active_group()) { return nullptr; } /* do not calculate previews of hidden nodes */ - if (current_node_->getbNode()->flag & NODE_HIDDEN) { + if (current_node_->get_bnode()->flag & NODE_HIDDEN) { return nullptr; } - bNodeInstanceHash *previews = context_->getPreviewHash(); + bNodeInstanceHash *previews = context_->get_preview_hash(); if (previews) { - PreviewOperation *operation = new PreviewOperation(context_->getViewSettings(), - context_->getDisplaySettings(), - current_node_->getbNode()->preview_xsize, - current_node_->getbNode()->preview_ysize); - operation->setbNodeTree(context_->getbNodeTree()); - operation->verifyPreview(previews, current_node_->getInstanceKey()); + PreviewOperation *operation = new PreviewOperation(context_->get_view_settings(), + context_->get_display_settings(), + current_node_->get_bnode()->preview_xsize, + current_node_->get_bnode()->preview_ysize); + operation->set_bnodetree(context_->get_bnodetree()); + operation->verify_preview(previews, current_node_->get_instance_key()); return operation; } return nullptr; } -void NodeOperationBuilder::addPreview(NodeOperationOutput *output) +void NodeOperationBuilder::add_preview(NodeOperationOutput *output) { PreviewOperation *operation = make_preview_operation(); if (operation) { - addOperation(operation); + add_operation(operation); - addLink(output, operation->getInputSocket(0)); + add_link(output, operation->get_input_socket(0)); } } -void NodeOperationBuilder::addNodeInputPreview(NodeInput *input) +void NodeOperationBuilder::add_node_input_preview(NodeInput *input) { PreviewOperation *operation = make_preview_operation(); if (operation) { - addOperation(operation); + add_operation(operation); - mapInputSocket(input, operation->getInputSocket(0)); + map_input_socket(input, operation->get_input_socket(0)); } } -void NodeOperationBuilder::registerViewer(ViewerOperation *viewer) +void NodeOperationBuilder::register_viewer(ViewerOperation *viewer) { if (active_viewer_) { - if (current_node_->isInActiveGroup()) { + if (current_node_->is_in_active_group()) { /* deactivate previous viewer */ - active_viewer_->setActive(false); + active_viewer_->set_active(false); active_viewer_ = viewer; - viewer->setActive(true); + viewer->set_active(true); } } else { - if (current_node_->getbNodeTree() == context_->getbNodeTree()) { + if (current_node_->get_bnodetree() == context_->get_bnodetree()) { active_viewer_ = viewer; - viewer->setActive(true); + viewer->set_active(true); } } } @@ -296,25 +296,25 @@ void NodeOperationBuilder::add_datatype_conversions() Vector<Link> convert_links; for (const Link &link : links_) { /* proxy operations can skip data type conversion */ - NodeOperation *from_op = &link.from()->getOperation(); - NodeOperation *to_op = &link.to()->getOperation(); + NodeOperation *from_op = &link.from()->get_operation(); + NodeOperation *to_op = &link.to()->get_operation(); if (!(from_op->get_flags().use_datatype_conversion || to_op->get_flags().use_datatype_conversion)) { continue; } - if (link.from()->getDataType() != link.to()->getDataType()) { + if (link.from()->get_data_type() != link.to()->get_data_type()) { convert_links.append(link); } } for (const Link &link : convert_links) { NodeOperation *converter = COM_convert_data_type(*link.from(), *link.to()); if (converter) { - addOperation(converter); + add_operation(converter); - removeInputLink(link.to()); - addLink(link.from(), converter->getInputSocket(0)); - addLink(converter->getOutputSocket(0), link.to()); + remove_input_link(link.to()); + add_link(link.from(), converter->get_input_socket(0)); + add_link(converter->get_output_socket(0), link.to()); } } } @@ -326,9 +326,9 @@ void NodeOperationBuilder::add_operation_input_constants() */ Vector<NodeOperationInput *> pending_inputs; for (NodeOperation *op : operations_) { - for (int k = 0; k < op->getNumberOfInputSockets(); ++k) { - NodeOperationInput *input = op->getInputSocket(k); - if (!input->isConnected()) { + for (int k = 0; k < op->get_number_of_input_sockets(); ++k) { + NodeOperationInput *input = op->get_input_socket(k); + if (!input->is_connected()) { pending_inputs.append(input); } } @@ -341,50 +341,50 @@ void NodeOperationBuilder::add_operation_input_constants() void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input, const NodeInput *node_input) { - switch (input->getDataType()) { + switch (input->get_data_type()) { case DataType::Value: { float value; - if (node_input && node_input->getbNodeSocket()) { - value = node_input->getEditorValueFloat(); + if (node_input && node_input->get_bnode_socket()) { + value = node_input->get_editor_value_float(); } else { value = 0.0f; } SetValueOperation *op = new SetValueOperation(); - op->setValue(value); - addOperation(op); - addLink(op->getOutputSocket(), input); + op->set_value(value); + add_operation(op); + add_link(op->get_output_socket(), input); break; } case DataType::Color: { float value[4]; - if (node_input && node_input->getbNodeSocket()) { - node_input->getEditorValueColor(value); + if (node_input && node_input->get_bnode_socket()) { + node_input->get_editor_value_color(value); } else { zero_v4(value); } SetColorOperation *op = new SetColorOperation(); - op->setChannels(value); - addOperation(op); - addLink(op->getOutputSocket(), input); + op->set_channels(value); + add_operation(op); + add_link(op->get_output_socket(), input); break; } case DataType::Vector: { float value[3]; - if (node_input && node_input->getbNodeSocket()) { - node_input->getEditorValueVector(value); + if (node_input && node_input->get_bnode_socket()) { + node_input->get_editor_value_vector(value); } else { zero_v3(value); } SetVectorOperation *op = new SetVectorOperation(); - op->setVector(value); - addOperation(op); - addLink(op->getOutputSocket(), input); + op->set_vector(value); + add_operation(op); + add_link(op->get_output_socket(), input); break; } } @@ -395,8 +395,8 @@ void NodeOperationBuilder::resolve_proxies() Vector<Link> proxy_links; for (const Link &link : links_) { /* don't replace links from proxy to proxy, since we may need them for replacing others! */ - if (link.from()->getOperation().get_flags().is_proxy_operation && - !link.to()->getOperation().get_flags().is_proxy_operation) { + if (link.from()->get_operation().get_flags().is_proxy_operation && + !link.to()->get_operation().get_flags().is_proxy_operation) { proxy_links.append(link); } } @@ -406,15 +406,15 @@ void NodeOperationBuilder::resolve_proxies() NodeOperationOutput *from = link.from(); do { /* walk upstream bypassing the proxy operation */ - from = from->getOperation().getInputSocket(0)->getLink(); - } while (from && from->getOperation().get_flags().is_proxy_operation); + from = from->get_operation().get_input_socket(0)->get_link(); + } while (from && from->get_operation().get_flags().is_proxy_operation); - removeInputLink(to); + remove_input_link(to); /* we may not have a final proxy input link, * in that case it just gets dropped */ if (from) { - addLink(from, to); + add_link(from, to); } } } @@ -424,7 +424,8 @@ void NodeOperationBuilder::determine_canvases() /* Determine all canvas areas of the operations. */ const rcti &preferred_area = COM_AREA_NONE; for (NodeOperation *op : operations_) { - if (op->isOutputOperation(context_->isRendering()) && !op->get_flags().is_preview_operation) { + if (op->is_output_operation(context_->is_rendering()) && + !op->get_flags().is_preview_operation) { rcti canvas = COM_AREA_NONE; op->determine_canvas(preferred_area, canvas); op->set_canvas(canvas); @@ -432,7 +433,8 @@ void NodeOperationBuilder::determine_canvases() } for (NodeOperation *op : operations_) { - if (op->isOutputOperation(context_->isRendering()) && op->get_flags().is_preview_operation) { + if (op->is_output_operation(context_->is_rendering()) && + op->get_flags().is_preview_operation) { rcti canvas = COM_AREA_NONE; op->determine_canvas(preferred_area, canvas); op->set_canvas(canvas); @@ -443,12 +445,12 @@ void NodeOperationBuilder::determine_canvases() { Vector<Link> convert_links; for (const Link &link : links_) { - if (link.to()->getResizeMode() != ResizeMode::None) { - const rcti &from_canvas = link.from()->getOperation().get_canvas(); - const rcti &to_canvas = link.to()->getOperation().get_canvas(); + if (link.to()->get_resize_mode() != ResizeMode::None) { + const rcti &from_canvas = link.from()->get_operation().get_canvas(); + const rcti &to_canvas = link.to()->get_operation().get_canvas(); bool needs_conversion; - if (link.to()->getResizeMode() == ResizeMode::Align) { + if (link.to()->get_resize_mode() == ResizeMode::Align) { needs_conversion = from_canvas.xmin != to_canvas.xmin || from_canvas.ymin != to_canvas.ymin; } @@ -528,7 +530,7 @@ WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation { for (const Link &link : links_) { if (link.from() == output) { - NodeOperation &op = link.to()->getOperation(); + NodeOperation &op = link.to()->get_operation(); if (op.get_flags().is_write_buffer_operation) { return (WriteBufferOperation *)(&op); } @@ -540,39 +542,39 @@ WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation void NodeOperationBuilder::add_input_buffers(NodeOperation * /*operation*/, NodeOperationInput *input) { - if (!input->isConnected()) { + if (!input->is_connected()) { return; } - NodeOperationOutput *output = input->getLink(); - if (output->getOperation().get_flags().is_read_buffer_operation) { + NodeOperationOutput *output = input->get_link(); + if (output->get_operation().get_flags().is_read_buffer_operation) { /* input is already buffered, no need to add another */ return; } /* this link will be replaced below */ - removeInputLink(input); + remove_input_link(input); /* check of other end already has write operation, otherwise add a new one */ WriteBufferOperation *writeoperation = find_attached_write_buffer_operation(output); if (!writeoperation) { - writeoperation = new WriteBufferOperation(output->getDataType()); - writeoperation->setbNodeTree(context_->getbNodeTree()); - addOperation(writeoperation); + writeoperation = new WriteBufferOperation(output->get_data_type()); + writeoperation->set_bnodetree(context_->get_bnodetree()); + add_operation(writeoperation); - addLink(output, writeoperation->getInputSocket(0)); + add_link(output, writeoperation->get_input_socket(0)); - writeoperation->readResolutionFromInputSocket(); + writeoperation->read_resolution_from_input_socket(); } /* add readbuffer op for the input */ - ReadBufferOperation *readoperation = new ReadBufferOperation(output->getDataType()); - readoperation->setMemoryProxy(writeoperation->getMemoryProxy()); - this->addOperation(readoperation); + ReadBufferOperation *readoperation = new ReadBufferOperation(output->get_data_type()); + readoperation->set_memory_proxy(writeoperation->get_memory_proxy()); + this->add_operation(readoperation); - addLink(readoperation->getOutputSocket(), input); + add_link(readoperation->get_output_socket(), input); - readoperation->readResolutionFromWriteBuffer(); + readoperation->read_resolution_from_write_buffer(); } void NodeOperationBuilder::add_output_buffers(NodeOperation *operation, @@ -584,44 +586,44 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation, return; } - WriteBufferOperation *writeOperation = nullptr; + WriteBufferOperation *write_operation = nullptr; for (NodeOperationInput *target : targets) { /* try to find existing write buffer operation */ - if (target->getOperation().get_flags().is_write_buffer_operation) { - BLI_assert(writeOperation == nullptr); /* there should only be one write op connected */ - writeOperation = (WriteBufferOperation *)(&target->getOperation()); + if (target->get_operation().get_flags().is_write_buffer_operation) { + BLI_assert(write_operation == nullptr); /* there should only be one write op connected */ + write_operation = (WriteBufferOperation *)(&target->get_operation()); } else { /* remove all links to other nodes */ - removeInputLink(target); + remove_input_link(target); } } /* if no write buffer operation exists yet, create a new one */ - if (!writeOperation) { - writeOperation = new WriteBufferOperation(operation->getOutputSocket()->getDataType()); - writeOperation->setbNodeTree(context_->getbNodeTree()); - addOperation(writeOperation); + if (!write_operation) { + write_operation = new WriteBufferOperation(operation->get_output_socket()->get_data_type()); + write_operation->set_bnodetree(context_->get_bnodetree()); + add_operation(write_operation); - addLink(output, writeOperation->getInputSocket(0)); + add_link(output, write_operation->get_input_socket(0)); } - writeOperation->readResolutionFromInputSocket(); + write_operation->read_resolution_from_input_socket(); /* add readbuffer op for every former connected input */ for (NodeOperationInput *target : targets) { - if (&target->getOperation() == writeOperation) { + if (&target->get_operation() == write_operation) { continue; /* skip existing write op links */ } ReadBufferOperation *readoperation = new ReadBufferOperation( - operation->getOutputSocket()->getDataType()); - readoperation->setMemoryProxy(writeOperation->getMemoryProxy()); - addOperation(readoperation); + operation->get_output_socket()->get_data_type()); + readoperation->set_memory_proxy(write_operation->get_memory_proxy()); + add_operation(readoperation); - addLink(readoperation->getOutputSocket(), target); + add_link(readoperation->get_output_socket(), target); - readoperation->readResolutionFromWriteBuffer(); + readoperation->read_resolution_from_write_buffer(); } } @@ -640,12 +642,12 @@ void NodeOperationBuilder::add_complex_operation_buffers() for (NodeOperation *op : complex_ops) { DebugInfo::operation_read_write_buffer(op); - for (int index = 0; index < op->getNumberOfInputSockets(); index++) { - add_input_buffers(op, op->getInputSocket(index)); + for (int index = 0; index < op->get_number_of_input_sockets(); index++) { + add_input_buffers(op, op->get_input_socket(index)); } - for (int index = 0; index < op->getNumberOfOutputSockets(); index++) { - add_output_buffers(op, op->getOutputSocket(index)); + for (int index = 0; index < op->get_number_of_output_sockets(); index++) { + add_output_buffers(op, op->get_output_socket(index)); } } } @@ -659,18 +661,18 @@ static void find_reachable_operations_recursive(Tags &reachable, NodeOperation * } reachable.insert(op); - for (int i = 0; i < op->getNumberOfInputSockets(); i++) { - NodeOperationInput *input = op->getInputSocket(i); - if (input->isConnected()) { - find_reachable_operations_recursive(reachable, &input->getLink()->getOperation()); + for (int i = 0; i < op->get_number_of_input_sockets(); i++) { + NodeOperationInput *input = op->get_input_socket(i); + if (input->is_connected()) { + find_reachable_operations_recursive(reachable, &input->get_link()->get_operation()); } } /* associated write-buffer operations are executed as well */ if (op->get_flags().is_read_buffer_operation) { ReadBufferOperation *read_op = (ReadBufferOperation *)op; - MemoryProxy *memproxy = read_op->getMemoryProxy(); - find_reachable_operations_recursive(reachable, memproxy->getWriteBufferOperation()); + MemoryProxy *memproxy = read_op->get_memory_proxy(); + find_reachable_operations_recursive(reachable, memproxy->get_write_buffer_operation()); } } @@ -679,7 +681,7 @@ void NodeOperationBuilder::prune_operations() Tags reachable; for (NodeOperation *op : operations_) { /* output operations are primary executed operations */ - if (op->isOutputOperation(context_->isRendering())) { + if (op->is_output_operation(context_->is_rendering())) { find_reachable_operations_recursive(reachable, op); } } @@ -708,10 +710,10 @@ static void sort_operations_recursive(Vector<NodeOperation *> &sorted, } visited.insert(op); - for (int i = 0; i < op->getNumberOfInputSockets(); i++) { - NodeOperationInput *input = op->getInputSocket(i); - if (input->isConnected()) { - sort_operations_recursive(sorted, visited, &input->getLink()->getOperation()); + for (int i = 0; i < op->get_number_of_input_sockets(); i++) { + NodeOperationInput *input = op->get_input_socket(i); + if (input->is_connected()) { + sort_operations_recursive(sorted, visited, &input->get_link()->get_operation()); } } @@ -738,15 +740,15 @@ static void add_group_operations_recursive(Tags &visited, NodeOperation *op, Exe } visited.insert(op); - if (!group->addOperation(op)) { + if (!group->add_operation(op)) { return; } /* add all eligible input ops to the group */ - for (int i = 0; i < op->getNumberOfInputSockets(); i++) { - NodeOperationInput *input = op->getInputSocket(i); - if (input->isConnected()) { - add_group_operations_recursive(visited, &input->getLink()->getOperation(), group); + for (int i = 0; i < op->get_number_of_input_sockets(); i++) { + NodeOperationInput *input = op->get_input_socket(i); + if (input->is_connected()) { + add_group_operations_recursive(visited, &input->get_link()->get_operation(), group); } } } @@ -765,19 +767,19 @@ ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op) void NodeOperationBuilder::group_operations() { for (NodeOperation *op : operations_) { - if (op->isOutputOperation(context_->isRendering())) { + if (op->is_output_operation(context_->is_rendering())) { ExecutionGroup *group = make_group(op); - group->setOutputExecutionGroup(true); + group->set_output_execution_group(true); } /* add new groups for associated memory proxies where needed */ if (op->get_flags().is_read_buffer_operation) { ReadBufferOperation *read_op = (ReadBufferOperation *)op; - MemoryProxy *memproxy = read_op->getMemoryProxy(); + MemoryProxy *memproxy = read_op->get_memory_proxy(); - if (memproxy->getExecutor() == nullptr) { - ExecutionGroup *group = make_group(memproxy->getWriteBufferOperation()); - memproxy->setExecutor(group); + if (memproxy->get_executor() == nullptr) { + ExecutionGroup *group = make_group(memproxy->get_write_buffer_operation()); + memproxy->set_executor(group); } } } @@ -804,15 +806,15 @@ std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder &builder) os << "\n"; for (const NodeOperationBuilder::Link &link : builder.get_links()) { - os << " op" << link.from()->getOperation().get_id() << " -> op" - << link.to()->getOperation().get_id() << ";\n"; + os << " op" << link.from()->get_operation().get_id() << " -> op" + << link.to()->get_operation().get_id() << ";\n"; } for (const NodeOperation *operation : builder.get_operations()) { if (operation->get_flags().is_read_buffer_operation) { const ReadBufferOperation &read_operation = static_cast<const ReadBufferOperation &>( *operation); const WriteBufferOperation &write_operation = - *read_operation.getMemoryProxy()->getWriteBufferOperation(); + *read_operation.get_memory_proxy()->get_write_buffer_operation(); os << " op" << write_operation.get_id() << " -> op" << read_operation.get_id() << ";\n"; } } @@ -824,7 +826,7 @@ std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder &builder) std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder::Link &link) { - os << link.from()->getOperation().get_id() << " -> " << link.to()->getOperation().get_id(); + os << link.from()->get_operation().get_id() << " -> " << link.to()->get_operation().get_id(); return os; } diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.h b/source/blender/compositor/intern/COM_NodeOperationBuilder.h index 21e2f4ce95d..fcb2dd3800e 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.h +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.h @@ -96,27 +96,27 @@ class NodeOperationBuilder { return *context_; } - void convertToOperations(ExecutionSystem *system); + void convert_to_operations(ExecutionSystem *system); - void addOperation(NodeOperation *operation); + void add_operation(NodeOperation *operation); void replace_operation_with_constant(NodeOperation *operation, ConstantOperation *constant_operation); /** Map input socket of the current node to an operation socket */ - void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket); + void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket); /** Map output socket of the current node to an operation socket */ - void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket); + void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket); - void addLink(NodeOperationOutput *from, NodeOperationInput *to); - void removeInputLink(NodeOperationInput *to); + void add_link(NodeOperationOutput *from, NodeOperationInput *to); + void remove_input_link(NodeOperationInput *to); /** Add a preview operation for a operation output */ - void addPreview(NodeOperationOutput *output); + void add_preview(NodeOperationOutput *output); /** Add a preview operation for a node input */ - void addNodeInputPreview(NodeInput *input); + void add_node_input_preview(NodeInput *input); /** Define a viewer operation as the active output, if possible */ - void registerViewer(ViewerOperation *viewer); + void register_viewer(ViewerOperation *viewer); /** The currently active viewer output operation */ ViewerOperation *active_viewer() const { diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cc b/source/blender/compositor/intern/COM_OpenCLDevice.cc index af55890cba7..9a274abf806 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.cc +++ b/source/blender/compositor/intern/COM_OpenCLDevice.cc @@ -40,13 +40,13 @@ const cl_image_format IMAGE_FORMAT_VALUE = { OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program, - cl_int vendorId) + cl_int vendor_id) { device_ = device; context_ = context; program_ = program; queue_ = nullptr; - vendorID_ = vendorId; + vendor_id_ = vendor_id; cl_int error; queue_ = clCreateCommandQueue(context_, device_, 0, &error); @@ -57,7 +57,7 @@ OpenCLDevice::OpenCLDevice(OpenCLDevice &&other) noexcept device_(other.device_), program_(other.program_), queue_(other.queue_), - vendorID_(other.vendorID_) + vendor_id_(other.vendor_id_) { other.queue_ = nullptr; } @@ -71,37 +71,38 @@ OpenCLDevice::~OpenCLDevice() void OpenCLDevice::execute(WorkPackage *work_package) { - const unsigned int chunkNumber = work_package->chunk_number; - ExecutionGroup *executionGroup = work_package->execution_group; + const unsigned int chunk_number = work_package->chunk_number; + ExecutionGroup *execution_group = work_package->execution_group; - MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber); - MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(work_package->rect); + MemoryBuffer **input_buffers = execution_group->get_input_buffers_opencl(chunk_number); + MemoryBuffer *output_buffer = execution_group->allocate_output_buffer(work_package->rect); - executionGroup->getOutputOperation()->executeOpenCLRegion( - this, &work_package->rect, chunkNumber, inputBuffers, outputBuffer); + execution_group->get_output_operation()->execute_opencl_region( + this, &work_package->rect, chunk_number, input_buffers, output_buffer); - delete outputBuffer; + delete output_buffer; - executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers); + execution_group->finalize_chunk_execution(chunk_number, input_buffers); } -cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, - int parameterIndex, - int offsetIndex, - std::list<cl_mem> *cleanup, - MemoryBuffer **inputMemoryBuffers, - SocketReader *reader) +cl_mem OpenCLDevice::COM_cl_attach_memory_buffer_to_kernel_parameter( + cl_kernel kernel, + int parameter_index, + int offset_index, + std::list<cl_mem> *cleanup, + MemoryBuffer **input_memory_buffers, + SocketReader *reader) { - return COM_clAttachMemoryBufferToKernelParameter(kernel, - parameterIndex, - offsetIndex, - cleanup, - inputMemoryBuffers, - (ReadBufferOperation *)reader); + return COM_cl_attach_memory_buffer_to_kernel_parameter(kernel, + parameter_index, + offset_index, + cleanup, + input_memory_buffers, + (ReadBufferOperation *)reader); } -const cl_image_format *OpenCLDevice::determineImageFormat(MemoryBuffer *memoryBuffer) +const cl_image_format *OpenCLDevice::determine_image_format(MemoryBuffer *memory_buffer) { - switch (memoryBuffer->get_num_channels()) { + switch (memory_buffer->get_num_channels()) { case 1: return &IMAGE_FORMAT_VALUE; break; @@ -118,92 +119,91 @@ const cl_image_format *OpenCLDevice::determineImageFormat(MemoryBuffer *memoryBu return &IMAGE_FORMAT_COLOR; } -cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, - int parameterIndex, - int offsetIndex, - std::list<cl_mem> *cleanup, - MemoryBuffer **inputMemoryBuffers, - ReadBufferOperation *reader) +cl_mem OpenCLDevice::COM_cl_attach_memory_buffer_to_kernel_parameter( + cl_kernel kernel, + int parameter_index, + int offset_index, + std::list<cl_mem> *cleanup, + MemoryBuffer **input_memory_buffers, + ReadBufferOperation *reader) { cl_int error; - MemoryBuffer *result = reader->getInputMemoryBuffer(inputMemoryBuffers); + MemoryBuffer *result = reader->get_input_memory_buffer(input_memory_buffers); - const cl_image_format *imageFormat = determineImageFormat(result); + const cl_image_format *image_format = determine_image_format(result); - cl_mem clBuffer = clCreateImage2D(context_, - CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, - imageFormat, - result->getWidth(), - result->getHeight(), - 0, - result->getBuffer(), - &error); + cl_mem cl_buffer = clCreateImage2D(context_, + CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, + image_format, + result->get_width(), + result->get_height(), + 0, + result->get_buffer(), + &error); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } if (error == CL_SUCCESS) { - cleanup->push_back(clBuffer); + cleanup->push_back(cl_buffer); } - error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer); + error = clSetKernelArg(kernel, parameter_index, sizeof(cl_mem), &cl_buffer); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result); - return clBuffer; + COM_cl_attach_memory_buffer_offset_to_kernel_parameter(kernel, offset_index, result); + return cl_buffer; } -void OpenCLDevice::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, - int offsetIndex, - MemoryBuffer *memoryBuffer) +void OpenCLDevice::COM_cl_attach_memory_buffer_offset_to_kernel_parameter( + cl_kernel kernel, int offset_index, MemoryBuffer *memory_buffer) { - if (offsetIndex != -1) { + if (offset_index != -1) { cl_int error; - const rcti &rect = memoryBuffer->get_rect(); + const rcti &rect = memory_buffer->get_rect(); cl_int2 offset = {{rect.xmin, rect.ymin}}; - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + error = clSetKernelArg(kernel, offset_index, sizeof(cl_int2), &offset); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } } } -void OpenCLDevice::COM_clAttachSizeToKernelParameter(cl_kernel kernel, - int offsetIndex, - NodeOperation *operation) +void OpenCLDevice::COM_cl_attach_size_to_kernel_parameter(cl_kernel kernel, + int offset_index, + NodeOperation *operation) { - if (offsetIndex != -1) { + if (offset_index != -1) { cl_int error; - cl_int2 offset = {{(cl_int)operation->getWidth(), (cl_int)operation->getHeight()}}; + cl_int2 offset = {{(cl_int)operation->get_width(), (cl_int)operation->get_height()}}; - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + error = clSetKernelArg(kernel, offset_index, sizeof(cl_int2), &offset); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } } } -void OpenCLDevice::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, - int parameterIndex, - cl_mem clOutputMemoryBuffer) +void OpenCLDevice::COM_cl_attach_output_memory_buffer_to_kernel_parameter( + cl_kernel kernel, int parameter_index, cl_mem cl_output_memory_buffer) { cl_int error; - error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clOutputMemoryBuffer); + error = clSetKernelArg(kernel, parameter_index, sizeof(cl_mem), &cl_output_memory_buffer); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } } -void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer) +void OpenCLDevice::COM_cl_enqueue_range(cl_kernel kernel, MemoryBuffer *output_memory_buffer) { cl_int error; const size_t size[] = { - (size_t)outputMemoryBuffer->getWidth(), - (size_t)outputMemoryBuffer->getHeight(), + (size_t)output_memory_buffer->get_width(), + (size_t)output_memory_buffer->get_height(), }; error = clEnqueueNDRangeKernel(queue_, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr); @@ -212,44 +212,44 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemo } } -void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, - MemoryBuffer *outputMemoryBuffer, - int offsetIndex, - NodeOperation *operation) +void OpenCLDevice::COM_cl_enqueue_range(cl_kernel kernel, + MemoryBuffer *output_memory_buffer, + int offset_index, + NodeOperation *operation) { cl_int error; - const int width = outputMemoryBuffer->getWidth(); - const int height = outputMemoryBuffer->getHeight(); + const int width = output_memory_buffer->get_width(); + const int height = output_memory_buffer->get_height(); int offsetx; int offsety; - int localSize = 1024; + int local_size = 1024; size_t size[2]; cl_int2 offset; - if (vendorID_ == NVIDIA) { - localSize = 32; + if (vendor_id_ == NVIDIA) { + local_size = 32; } bool breaked = false; - for (offsety = 0; offsety < height && (!breaked); offsety += localSize) { + for (offsety = 0; offsety < height && (!breaked); offsety += local_size) { offset.s[1] = offsety; - if (offsety + localSize < height) { - size[1] = localSize; + if (offsety + local_size < height) { + size[1] = local_size; } else { size[1] = height - offsety; } - for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) { - if (offsetx + localSize < width) { - size[0] = localSize; + for (offsetx = 0; offsetx < width && (!breaked); offsetx += local_size) { + if (offsetx + local_size < width) { + size[0] = local_size; } else { size[0] = width - offsetx; } offset.s[0] = offsetx; - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + error = clSetKernelArg(kernel, offset_index, sizeof(cl_int2), &offset); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } @@ -259,15 +259,15 @@ void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } clFlush(queue_); - if (operation->isBraked()) { + if (operation->is_braked()) { breaked = false; } } } } -cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname, - std::list<cl_kernel> *clKernelsToCleanUp) +cl_kernel OpenCLDevice::COM_cl_create_kernel(const char *kernelname, + std::list<cl_kernel> *cl_kernels_to_clean_up) { cl_int error; cl_kernel kernel = clCreateKernel(program_, kernelname, &error); @@ -275,8 +275,8 @@ cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname, printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } else { - if (clKernelsToCleanUp) { - clKernelsToCleanUp->push_back(kernel); + if (cl_kernels_to_clean_up) { + cl_kernels_to_clean_up->push_back(kernel); } } return kernel; diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h index ca5a95f4a48..44a25747407 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.h +++ b/source/blender/compositor/intern/COM_OpenCLDevice.h @@ -63,7 +63,7 @@ class OpenCLDevice : public Device { /** * \brief opencl vendor ID */ - cl_int vendorID_; + cl_int vendor_id_; public: /** @@ -73,7 +73,7 @@ class OpenCLDevice : public Device { * \param program: * \param vendorID: */ - OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId); + OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendor_id); OpenCLDevice(OpenCLDevice &&other) noexcept; @@ -89,45 +89,46 @@ class OpenCLDevice : public Device { * \brief determine an image format * \param memorybuffer: */ - static const cl_image_format *determineImageFormat(MemoryBuffer *memoryBuffer); + static const cl_image_format *determine_image_format(MemoryBuffer *memory_buffer); - cl_context getContext() + cl_context get_context() { return context_; } - cl_command_queue getQueue() + cl_command_queue get_queue() { return queue_; } - cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, - int parameterIndex, - int offsetIndex, - std::list<cl_mem> *cleanup, - MemoryBuffer **inputMemoryBuffers, - SocketReader *reader); - cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, - int parameterIndex, - int offsetIndex, - std::list<cl_mem> *cleanup, - MemoryBuffer **inputMemoryBuffers, - ReadBufferOperation *reader); - void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, - int offsetIndex, - MemoryBuffer *memoryBuffers); - void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, - int parameterIndex, - cl_mem clOutputMemoryBuffer); - void COM_clAttachSizeToKernelParameter(cl_kernel kernel, - int offsetIndex, - NodeOperation *operation); - void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer); - void COM_clEnqueueRange(cl_kernel kernel, - MemoryBuffer *outputMemoryBuffer, - int offsetIndex, - NodeOperation *operation); - cl_kernel COM_clCreateKernel(const char *kernelname, std::list<cl_kernel> *clKernelsToCleanUp); + cl_mem COM_cl_attach_memory_buffer_to_kernel_parameter(cl_kernel kernel, + int parameter_index, + int offset_index, + std::list<cl_mem> *cleanup, + MemoryBuffer **input_memory_buffers, + SocketReader *reader); + cl_mem COM_cl_attach_memory_buffer_to_kernel_parameter(cl_kernel kernel, + int parameter_index, + int offset_index, + std::list<cl_mem> *cleanup, + MemoryBuffer **input_memory_buffers, + ReadBufferOperation *reader); + void COM_cl_attach_memory_buffer_offset_to_kernel_parameter(cl_kernel kernel, + int offset_index, + MemoryBuffer *memory_buffers); + void COM_cl_attach_output_memory_buffer_to_kernel_parameter(cl_kernel kernel, + int parameter_index, + cl_mem cl_output_memory_buffer); + void COM_cl_attach_size_to_kernel_parameter(cl_kernel kernel, + int offset_index, + NodeOperation *operation); + void COM_cl_enqueue_range(cl_kernel kernel, MemoryBuffer *output_memory_buffer); + void COM_cl_enqueue_range(cl_kernel kernel, + MemoryBuffer *output_memory_buffer, + int offset_index, + NodeOperation *operation); + cl_kernel COM_cl_create_kernel(const char *kernelname, + std::list<cl_kernel> *cl_kernels_to_clean_up); }; } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.cc b/source/blender/compositor/intern/COM_SingleThreadedOperation.cc index 83e3f033b32..fab6c352a02 100644 --- a/source/blender/compositor/intern/COM_SingleThreadedOperation.cc +++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.cc @@ -22,42 +22,42 @@ namespace blender::compositor { SingleThreadedOperation::SingleThreadedOperation() { - cachedInstance_ = nullptr; + cached_instance_ = nullptr; flags.complex = true; flags.single_threaded = true; } -void SingleThreadedOperation::initExecution() +void SingleThreadedOperation::init_execution() { - initMutex(); + init_mutex(); } -void SingleThreadedOperation::executePixel(float output[4], int x, int y, void * /*data*/) +void SingleThreadedOperation::execute_pixel(float output[4], int x, int y, void * /*data*/) { - cachedInstance_->readNoCheck(output, x, y); + cached_instance_->read_no_check(output, x, y); } -void SingleThreadedOperation::deinitExecution() +void SingleThreadedOperation::deinit_execution() { - deinitMutex(); - if (cachedInstance_) { - delete cachedInstance_; - cachedInstance_ = nullptr; + deinit_mutex(); + if (cached_instance_) { + delete cached_instance_; + cached_instance_ = nullptr; } } -void *SingleThreadedOperation::initializeTileData(rcti *rect) +void *SingleThreadedOperation::initialize_tile_data(rcti *rect) { - if (cachedInstance_) { - return cachedInstance_; + if (cached_instance_) { + return cached_instance_; } - lockMutex(); - if (cachedInstance_ == nullptr) { + lock_mutex(); + if (cached_instance_ == nullptr) { // - cachedInstance_ = createMemoryBuffer(rect); + cached_instance_ = create_memory_buffer(rect); } - unlockMutex(); - return cachedInstance_; + unlock_mutex(); + return cached_instance_; } } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.h b/source/blender/compositor/intern/COM_SingleThreadedOperation.h index 3f90ce96e00..7588e654f75 100644 --- a/source/blender/compositor/intern/COM_SingleThreadedOperation.h +++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.h @@ -24,12 +24,12 @@ namespace blender::compositor { class SingleThreadedOperation : public NodeOperation { private: - MemoryBuffer *cachedInstance_; + MemoryBuffer *cached_instance_; protected: - inline bool isCached() + inline bool is_cached() { - return cachedInstance_ != nullptr; + return cached_instance_ != nullptr; } public: @@ -38,21 +38,21 @@ class SingleThreadedOperation : public NodeOperation { /** * The inner loop of this operation. */ - void executePixel(float output[4], int x, int y, void *data) override; + void execute_pixel(float output[4], int x, int y, void *data) override; /** * Initialize the execution */ - void initExecution() override; + void init_execution() override; /** * Deinitialize the execution */ - void deinitExecution() override; + void deinit_execution() override; - void *initializeTileData(rcti *rect) override; + void *initialize_tile_data(rcti *rect) override; - virtual MemoryBuffer *createMemoryBuffer(rcti *rect) = 0; + virtual MemoryBuffer *create_memory_buffer(rcti *rect) = 0; }; } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_TiledExecutionModel.cc b/source/blender/compositor/intern/COM_TiledExecutionModel.cc index a081b80349d..e9f7310cead 100644 --- a/source/blender/compositor/intern/COM_TiledExecutionModel.cc +++ b/source/blender/compositor/intern/COM_TiledExecutionModel.cc @@ -35,24 +35,24 @@ TiledExecutionModel::TiledExecutionModel(CompositorContext &context, Span<ExecutionGroup *> groups) : ExecutionModel(context, operations), groups_(groups) { - const bNodeTree *node_tree = context.getbNodeTree(); + const bNodeTree *node_tree = context.get_bnodetree(); node_tree->stats_draw(node_tree->sdh, TIP_("Compositing | Determining resolution")); unsigned int resolution[2]; for (ExecutionGroup *group : groups_) { resolution[0] = 0; resolution[1] = 0; - group->determineResolution(resolution); + group->determine_resolution(resolution); if (border_.use_render_border) { const rctf *render_border = border_.render_border; - group->setRenderBorder( + group->set_render_border( render_border->xmin, render_border->xmax, render_border->ymin, render_border->ymax); } if (border_.use_viewer_border) { const rctf *viewer_border = border_.viewer_border; - group->setViewerBorder( + group->set_viewer_border( viewer_border->xmin, viewer_border->xmax, viewer_border->ymin, viewer_border->ymax); } } @@ -63,8 +63,8 @@ static void update_read_buffer_offset(Span<NodeOperation *> operations) unsigned int order = 0; for (NodeOperation *operation : operations) { if (operation->get_flags().is_read_buffer_operation) { - ReadBufferOperation *readOperation = (ReadBufferOperation *)operation; - readOperation->setOffset(order); + ReadBufferOperation *read_operation = (ReadBufferOperation *)operation; + read_operation->set_offset(order); order++; } } @@ -75,8 +75,8 @@ static void init_write_operations_for_execution(Span<NodeOperation *> operations { for (NodeOperation *operation : operations) { if (operation->get_flags().is_write_buffer_operation) { - operation->setbNodeTree(bTree); - operation->initExecution(); + operation->set_bnodetree(bTree); + operation->init_execution(); } } } @@ -85,8 +85,8 @@ static void link_write_buffers(Span<NodeOperation *> operations) { for (NodeOperation *operation : operations) { if (operation->get_flags().is_read_buffer_operation) { - ReadBufferOperation *readOperation = static_cast<ReadBufferOperation *>(operation); - readOperation->updateMemoryBuffer(); + ReadBufferOperation *read_operation = static_cast<ReadBufferOperation *>(operation); + read_operation->update_memory_buffer(); } } } @@ -96,8 +96,8 @@ static void init_non_write_operations_for_execution(Span<NodeOperation *> operat { for (NodeOperation *operation : operations) { if (!operation->get_flags().is_write_buffer_operation) { - operation->setbNodeTree(bTree); - operation->initExecution(); + operation->set_bnodetree(bTree); + operation->init_execution(); } } } @@ -106,27 +106,27 @@ static void init_execution_groups_for_execution(Span<ExecutionGroup *> groups, const int chunk_size) { for (ExecutionGroup *execution_group : groups) { - execution_group->setChunksize(chunk_size); - execution_group->initExecution(); + execution_group->set_chunksize(chunk_size); + execution_group->init_execution(); } } void TiledExecutionModel::execute(ExecutionSystem &exec_system) { - const bNodeTree *editingtree = this->context_.getbNodeTree(); + const bNodeTree *editingtree = this->context_.get_bnodetree(); editingtree->stats_draw(editingtree->sdh, TIP_("Compositing | Initializing execution")); update_read_buffer_offset(operations_); - init_write_operations_for_execution(operations_, context_.getbNodeTree()); + init_write_operations_for_execution(operations_, context_.get_bnodetree()); link_write_buffers(operations_); - init_non_write_operations_for_execution(operations_, context_.getbNodeTree()); - init_execution_groups_for_execution(groups_, context_.getChunksize()); + init_non_write_operations_for_execution(operations_, context_.get_bnodetree()); + init_execution_groups_for_execution(groups_, context_.get_chunksize()); WorkScheduler::start(context_); execute_groups(eCompositorPriority::High, exec_system); - if (!context_.isFastCalculation()) { + if (!context_.is_fast_calculation()) { execute_groups(eCompositorPriority::Medium, exec_system); execute_groups(eCompositorPriority::Low, exec_system); } @@ -136,11 +136,11 @@ void TiledExecutionModel::execute(ExecutionSystem &exec_system) editingtree->stats_draw(editingtree->sdh, TIP_("Compositing | De-initializing execution")); for (NodeOperation *operation : operations_) { - operation->deinitExecution(); + operation->deinit_execution(); } for (ExecutionGroup *execution_group : groups_) { - execution_group->deinitExecution(); + execution_group->deinit_execution(); } } @@ -149,7 +149,7 @@ void TiledExecutionModel::execute_groups(eCompositorPriority priority, { for (ExecutionGroup *execution_group : groups_) { if (execution_group->get_flags().is_output && - execution_group->getRenderPriority() == priority) { + execution_group->get_render_priority() == priority) { execution_group->execute(&exec_system); } } diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h index 5ea3237d412..1fe50b9ecf3 100644 --- a/source/blender/compositor/intern/COM_WorkPackage.h +++ b/source/blender/compositor/intern/COM_WorkPackage.h @@ -43,7 +43,7 @@ struct WorkPackage { eWorkPackageState state = eWorkPackageState::NotScheduled; /** - * \brief executionGroup with the operations-setup to be evaluated + * \brief execution_group with the operations-setup to be evaluated */ ExecutionGroup *execution_group; diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cc b/source/blender/compositor/intern/COM_WorkScheduler.cc index 22f60ec17fe..c88cc556e72 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cc +++ b/source/blender/compositor/intern/COM_WorkScheduler.cc @@ -104,10 +104,10 @@ static struct { /** \name OpenCL Scheduling * \{ */ -static void CL_CALLBACK clContextError(const char *errinfo, - const void * /*private_info*/, - size_t /*cb*/, - void * /*user_data*/) +static void CL_CALLBACK cl_context_error(const char *errinfo, + const void * /*private_info*/, + size_t /*cb*/, + void * /*user_data*/) { printf("OPENCL error: %s\n", errinfo); } @@ -126,7 +126,7 @@ static void *thread_execute_gpu(void *data) static void opencl_start(const CompositorContext &context) { - if (context.getHasActiveOpenCLDevices()) { + if (context.get_has_active_opencl_devices()) { g_work_scheduler.opencl.queue = BLI_thread_queue_init(); BLI_threadpool_init(&g_work_scheduler.opencl.threads, thread_execute_gpu, @@ -186,35 +186,35 @@ static void opencl_initialize(const bool use_opencl) } if (clCreateContextFromType) { - cl_uint numberOfPlatforms = 0; + cl_uint number_of_platforms = 0; cl_int error; - error = clGetPlatformIDs(0, nullptr, &numberOfPlatforms); + error = clGetPlatformIDs(0, nullptr, &number_of_platforms); if (error == -1001) { } /* GPU not supported */ else if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } if (G.f & G_DEBUG) { - printf("%u number of platforms\n", numberOfPlatforms); + printf("%u number of platforms\n", number_of_platforms); } cl_platform_id *platforms = (cl_platform_id *)MEM_mallocN( - sizeof(cl_platform_id) * numberOfPlatforms, __func__); - error = clGetPlatformIDs(numberOfPlatforms, platforms, nullptr); - unsigned int indexPlatform; - for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) { - cl_platform_id platform = platforms[indexPlatform]; - cl_uint numberOfDevices = 0; - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, nullptr, &numberOfDevices); - if (numberOfDevices <= 0) { + sizeof(cl_platform_id) * number_of_platforms, __func__); + error = clGetPlatformIDs(number_of_platforms, platforms, nullptr); + unsigned int index_platform; + for (index_platform = 0; index_platform < number_of_platforms; index_platform++) { + cl_platform_id platform = platforms[index_platform]; + cl_uint number_of_devices = 0; + clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, nullptr, &number_of_devices); + if (number_of_devices <= 0) { continue; } cl_device_id *cldevices = (cl_device_id *)MEM_mallocN( - sizeof(cl_device_id) * numberOfDevices, __func__); - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, nullptr); + sizeof(cl_device_id) * number_of_devices, __func__); + clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, number_of_devices, cldevices, nullptr); g_work_scheduler.opencl.context = clCreateContext( - nullptr, numberOfDevices, cldevices, clContextError, nullptr, &error); + nullptr, number_of_devices, cldevices, cl_context_error, nullptr, &error); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } @@ -222,7 +222,7 @@ static void opencl_initialize(const bool use_opencl) g_work_scheduler.opencl.program = clCreateProgramWithSource( g_work_scheduler.opencl.context, 1, cl_str, nullptr, &error); error = clBuildProgram(g_work_scheduler.opencl.program, - numberOfDevices, + number_of_devices, cldevices, nullptr, nullptr, @@ -255,9 +255,9 @@ static void opencl_initialize(const bool use_opencl) MEM_freeN(build_log); } else { - unsigned int indexDevices; - for (indexDevices = 0; indexDevices < numberOfDevices; indexDevices++) { - cl_device_id device = cldevices[indexDevices]; + unsigned int index_devices; + for (index_devices = 0; index_devices < number_of_devices; index_devices++) { + cl_device_id device = cldevices[index_devices]; cl_int vendorID = 0; cl_int error2 = clGetDeviceInfo( device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, nullptr); diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h index d0fa3286a3b..2c60a6f2a8a 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.h +++ b/source/blender/compositor/intern/COM_WorkScheduler.h @@ -81,7 +81,7 @@ struct WorkScheduler { * \brief Are there OpenCL capable GPU devices initialized? * the result of this method is stored in the CompositorContext * A node can generate a different operation tree when OpenCLDevices exists. - * \see CompositorContext.getHasActiveOpenCLDevices + * \see CompositorContext.get_has_active_opencl_devices */ static bool has_gpu_devices(); diff --git a/source/blender/compositor/intern/COM_compositor.cc b/source/blender/compositor/intern/COM_compositor.cc index ed32a477384..be70ae792cb 100644 --- a/source/blender/compositor/intern/COM_compositor.cc +++ b/source/blender/compositor/intern/COM_compositor.cc @@ -64,9 +64,9 @@ void COM_execute(RenderData *render_data, Scene *scene, bNodeTree *node_tree, int rendering, - const ColorManagedViewSettings *viewSettings, - const ColorManagedDisplaySettings *displaySettings, - const char *viewName) + const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings, + const char *view_name) { /* Initialize mutex, TODO: this mutex init is actually not thread safe and * should be done somewhere as part of blender startup, all the other @@ -95,8 +95,14 @@ void COM_execute(RenderData *render_data, /* Execute. */ const bool twopass = (node_tree->flag & NTREE_TWO_PASS) && !rendering; if (twopass) { - blender::compositor::ExecutionSystem fast_pass( - render_data, scene, node_tree, rendering, true, viewSettings, displaySettings, viewName); + blender::compositor::ExecutionSystem fast_pass(render_data, + scene, + node_tree, + rendering, + true, + view_settings, + display_settings, + view_name); fast_pass.execute(); if (node_tree->test_break(node_tree->tbh)) { @@ -106,7 +112,7 @@ void COM_execute(RenderData *render_data, } blender::compositor::ExecutionSystem system( - render_data, scene, node_tree, rendering, false, viewSettings, displaySettings, viewName); + render_data, scene, node_tree, rendering, false, view_settings, display_settings, view_name); system.execute(); BLI_mutex_unlock(&g_compositor.mutex); |