1
1

Compare commits

...

4 Commits

Author SHA1 Message Date
4a22faf15a Cleanup: Convert camelCase naming to snake_case in Compositor
To follow the style guide.
2021-10-08 01:29:02 +02:00
12a5a60557 Cleanup: Use _ suffix for non-public members in Compositor
To follow the style guide.
2021-10-08 01:29:02 +02:00
a808c5ae65 Cleanup: Remove this-> for m_ prefixed members in Compositor
The prefix is already explicit.
2021-10-08 01:13:07 +02:00
c0995c27a8 Cleanup: Remove unused includes in Compositor
And move unneeded includes in frequently used headers 
to source files. 

Slightly reduces compilation time.
2021-10-08 01:13:07 +02:00
470 changed files with 13176 additions and 13646 deletions

View File

@@ -74,8 +74,8 @@ extern "C" {
* *
* during the preparation of the execution All ReadBufferOperation will receive an offset. * during the preparation of the execution All ReadBufferOperation will receive an offset.
* This offset is used during execution as an optimization trick * This offset is used during execution as an optimization trick
* Next all operations will be initialized for execution \see NodeOperation.initExecution * Next all operations will be initialized for execution \see NodeOperation.init_execution
* Next all ExecutionGroup's will be initialized for execution \see ExecutionGroup.initExecution * Next all ExecutionGroup's will be initialized for execution \see ExecutionGroup.init_execution
* this all is controlled from \see ExecutionSystem.execute * this all is controlled from \see ExecutionSystem.execute
* *
* \section priority Render priority * \section priority Render priority
@@ -92,7 +92,7 @@ extern "C" {
* When match the ExecutionGroup will be executed (this happens in serial) * When match the ExecutionGroup will be executed (this happens in serial)
* *
* \see ExecutionSystem.execute control of the Render priority * \see ExecutionSystem.execute control of the Render priority
* \see NodeOperation.getRenderPriority receive the render priority * \see NodeOperation.get_render_priority receive the render priority
* \see ExecutionGroup.execute the main loop to execute a whole ExecutionGroup * \see ExecutionGroup.execute the main loop to execute a whole ExecutionGroup
* *
* \section order Chunk order * \section order Chunk order
@@ -121,7 +121,7 @@ extern "C" {
* Chunk is finished. * Chunk is finished.
* *
* \see ExecutionGroup.execute * \see ExecutionGroup.execute
* \see ViewerOperation.getChunkOrder * \see ViewerOperation.get_chunk_order
* \see ChunkOrdering * \see ChunkOrdering
* *
* \section interest Area of interest * \section interest Area of interest
@@ -152,13 +152,13 @@ extern "C" {
* *
* In the above example ExecutionGroup B has an outputoperation (ViewerOperation) * In the above example ExecutionGroup B has an outputoperation (ViewerOperation)
* and is being executed. * and is being executed.
* The first chunk is evaluated [@ref ExecutionGroup.scheduleChunkWhenPossible], * The first chunk is evaluated [@ref ExecutionGroup.schedule_chunk_when_possible],
* but not all input chunks are available. * but not all input chunks are available.
* The relevant ExecutionGroup (that can calculate the missing chunks; ExecutionGroup A) * The relevant ExecutionGroup (that can calculate the missing chunks; ExecutionGroup A)
* is asked to calculate the area ExecutionGroup B is missing. * is asked to calculate the area ExecutionGroup B is missing.
* [@ref ExecutionGroup.scheduleAreaWhenPossible] * [@ref ExecutionGroup.schedule_area_when_possible]
* ExecutionGroup B checks what chunks the area spans, and tries to schedule these chunks. * ExecutionGroup B checks what chunks the area spans, and tries to schedule these chunks.
* If all input data is available these chunks are scheduled [@ref ExecutionGroup.scheduleChunk] * If all input data is available these chunks are scheduled [@ref ExecutionGroup.schedule_chunk]
* *
* <pre> * <pre>
* *
@@ -171,18 +171,18 @@ extern "C" {
* O------------------------------->O | * O------------------------------->O |
* . O | * . O |
* . O-------\ | * . O-------\ |
* . . | ExecutionGroup.scheduleChunkWhenPossible * . . | ExecutionGroup.schedule_chunk_when_possible
* . . O----/ (*) | * . . O----/ (*) |
* . . O | * . . O |
* . . O | * . . O |
* . . O ExecutionGroup.scheduleAreaWhenPossible| * . . O ExecutionGroup.schedule_area_when_possible|
* . . O---------------------------------------->O * . . O---------------------------------------->O
* . . . O----------\ ExecutionGroup.scheduleChunkWhenPossible * . . . O----------\ ExecutionGroup.schedule_chunk_when_possible
* . . . . | (*) * . . . . | (*)
* . . . . O-------/ * . . . . O-------/
* . . . . O * . . . . O
* . . . . O * . . . . O
* . . . . O-------\ ExecutionGroup.scheduleChunk * . . . . O-------\ ExecutionGroup.schedule_chunk
* . . . . . | * . . . . . |
* . . . . . O----/ * . . . . . O----/
* . . . . O<=O * . . . . O<=O
@@ -198,7 +198,7 @@ extern "C" {
* This happens until all chunks of (ExecutionGroup B) are finished executing or the user break's the process. * This happens until all chunks of (ExecutionGroup B) are finished executing or the user break's the process.
* *
* NodeOperation like the ScaleOperation can influence the area of interest by reimplementing the * NodeOperation like the ScaleOperation can influence the area of interest by reimplementing the
* [@ref NodeOperation.determineAreaOfInterest] method * [@ref NodeOperation.determine_area_of_interest] method
* *
* <pre> * <pre>
* *
@@ -221,13 +221,13 @@ extern "C" {
* *
* \see ExecutionGroup.execute Execute a complete ExecutionGroup. * \see ExecutionGroup.execute Execute a complete ExecutionGroup.
* Halts until finished or breaked by user * Halts until finished or breaked by user
* \see ExecutionGroup.scheduleChunkWhenPossible Tries to schedule a single chunk, * \see ExecutionGroup.schedule_chunk_when_possible Tries to schedule a single chunk,
* checks if all input data is available. Can trigger dependent chunks to be calculated * checks if all input data is available. Can trigger dependent chunks to be calculated
* \see ExecutionGroup.scheduleAreaWhenPossible * \see ExecutionGroup.schedule_area_when_possible
* Tries to schedule an area. This can be multiple chunks * Tries to schedule an area. This can be multiple chunks
* (is called from [@ref ExecutionGroup.scheduleChunkWhenPossible]) * (is called from [@ref ExecutionGroup.schedule_chunk_when_possible])
* \see ExecutionGroup.scheduleChunk Schedule a chunk on the WorkScheduler * \see ExecutionGroup.schedule_chunk Schedule a chunk on the WorkScheduler
* \see NodeOperation.determineDependingAreaOfInterest Influence the area of interest of a chunk. * \see NodeOperation.determine_depending_area_of_interest Influence the area of interest of a chunk.
* \see WriteBufferOperation Operation to write to a MemoryProxy/MemoryBuffer * \see WriteBufferOperation Operation to write to a MemoryProxy/MemoryBuffer
* \see ReadBufferOperation Operation to read from a MemoryProxy/MemoryBuffer * \see ReadBufferOperation Operation to read from a MemoryProxy/MemoryBuffer
* \see MemoryProxy proxy for information about memory image * \see MemoryProxy proxy for information about memory image
@@ -283,16 +283,16 @@ extern "C" {
* The OutputOperation of the ExecutionGroup is called to execute the area of the outputbuffer. * The OutputOperation of the ExecutionGroup is called to execute the area of the outputbuffer.
* *
* \see ExecutionGroup * \see ExecutionGroup
* \see NodeOperation.executeRegion executes a single chunk of a NodeOperation * \see NodeOperation.execute_region executes a single chunk of a NodeOperation
* \see CPUDevice.execute * \see CPUDevice.execute
* *
* \subsection GPUDevice OpenCLDevice * \subsection GPUDevice OpenCLDevice
* *
* To be completed! * To be completed!
* \see NodeOperation.executeOpenCLRegion * \see NodeOperation.execute_opencl_region
* \see OpenCLDevice.execute * \see OpenCLDevice.execute
* *
* \section executePixel executing a pixel * \section execute_pixel executing a pixel
* Finally the last step, the node functionality :) * Finally the last step, the node functionality :)
*/ */
@@ -312,10 +312,10 @@ extern "C" {
* (true) or editing (false). * (true) or editing (false).
* based on this setting the system will work differently: * based on this setting the system will work differently:
* - during rendering only Composite & the File output node will be calculated * - during rendering only Composite & the File output node will be calculated
* \see NodeOperation.isOutputProgram(int rendering) of the specific operations * \see NodeOperation.is_output_program(int rendering) of the specific operations
* *
* - during editing all output nodes will be calculated * - during editing all output nodes will be calculated
* \see NodeOperation.isOutputProgram(int rendering) of the specific operations * \see NodeOperation.is_output_program(int rendering) of the specific operations
* *
* - another quality setting can be used bNodeTree. * - another quality setting can be used bNodeTree.
* The quality is determined by the bNodeTree fields. * The quality is determined by the bNodeTree fields.
@@ -326,10 +326,10 @@ extern "C" {
* - output nodes can have different priorities in the WorkScheduler. * - output nodes can have different priorities in the WorkScheduler.
* This is implemented in the COM_execute function. * This is implemented in the COM_execute function.
* *
* \param viewSettings: * \param view_settings:
* reference to view settings used for color management * reference to view settings used for color management
* *
* \param displaySettings: * \param display_settings:
* reference to display settings used for color management * reference to display settings used for color management
* *
* OCIO_TODO: this options only used in rare cases, namely in output file node, * OCIO_TODO: this options only used in rare cases, namely in output file node,
@@ -343,13 +343,13 @@ void COM_execute(RenderData *render_data,
Scene *scene, Scene *scene,
bNodeTree *node_tree, bNodeTree *node_tree,
int rendering, int rendering,
const ColorManagedViewSettings *viewSettings, const ColorManagedViewSettings *view_settings,
const ColorManagedDisplaySettings *displaySettings, const ColorManagedDisplaySettings *display_settings,
const char *viewName); const char *view_name);
/** /**
* \brief Deinitialize the compositor caches and allocated memory. * \brief Deinitialize the compositor caches and allocated memory.
* Use COM_clearCaches to only free the caches. * Use COM_clear_caches to only free the caches.
*/ */
void COM_deinitialize(void); void COM_deinitialize(void);
@@ -357,7 +357,7 @@ void COM_deinitialize(void);
* \brief Clear all compositor caches. (Compositor system will still remain available). * \brief Clear all compositor caches. (Compositor system will still remain available).
* To deinitialize the compositor use the COM_deinitialize method. * To deinitialize the compositor use the COM_deinitialize method.
*/ */
// void COM_clearCaches(void); // NOT YET WRITTEN // void COM_clear_caches(void); // NOT YET WRITTEN
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -19,8 +19,8 @@
#pragma once #pragma once
#include "BLI_float2.hh" #include "BLI_float2.hh"
#include "BLI_index_range.hh"
#include "BLI_rect.h" #include "DNA_vec_types.h"
namespace blender::compositor { namespace blender::compositor {

View File

@@ -25,7 +25,7 @@ BufferOperation::BufferOperation(MemoryBuffer *buffer, DataType data_type)
buffer_ = buffer; buffer_ = buffer;
inflated_buffer_ = nullptr; inflated_buffer_ = nullptr;
set_canvas(buffer->get_rect()); set_canvas(buffer->get_rect());
addOutputSocket(data_type); add_output_socket(data_type);
flags.is_constant_operation = buffer_->is_a_single_elem(); flags.is_constant_operation = buffer_->is_a_single_elem();
flags.is_fullframe_operation = false; flags.is_fullframe_operation = false;
} }
@@ -33,39 +33,42 @@ BufferOperation::BufferOperation(MemoryBuffer *buffer, DataType data_type)
const float *BufferOperation::get_constant_elem() const float *BufferOperation::get_constant_elem()
{ {
BLI_assert(buffer_->is_a_single_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()) { 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) { if (buffer_->is_a_single_elem() == false) {
return buffer_; return buffer_;
} }
lockMutex(); lock_mutex();
if (!inflated_buffer_) { if (!inflated_buffer_) {
inflated_buffer_ = buffer_->inflate(); inflated_buffer_ = buffer_->inflate();
} }
unlockMutex(); unlock_mutex();
return inflated_buffer_; return inflated_buffer_;
} }
void BufferOperation::deinitExecution() void BufferOperation::deinit_execution()
{ {
if (buffer_->is_a_single_elem()) { if (buffer_->is_a_single_elem()) {
deinitMutex(); deinit_mutex();
} }
delete inflated_buffer_; 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) { switch (sampler) {
case PixelSampler::Nearest: case PixelSampler::Nearest:
@@ -73,16 +76,16 @@ void BufferOperation::executePixelSampled(float output[4], float x, float y, Pix
break; break;
case PixelSampler::Bilinear: case PixelSampler::Bilinear:
default: default:
buffer_->readBilinear(output, x, y); buffer_->read_bilinear(output, x, y);
break; break;
case PixelSampler::Bicubic: case PixelSampler::Bicubic:
/* No bicubic. Same implementation as ReadBufferOperation. */ /* No bicubic. Same implementation as ReadBufferOperation. */
buffer_->readBilinear(output, x, y); buffer_->read_bilinear(output, x, y);
break; break;
} }
} }
void BufferOperation::executePixelFiltered( void BufferOperation::execute_pixel_filtered(
float output[4], float x, float y, float dx[2], float dy[2]) float output[4], float x, float y, float dx[2], float dy[2])
{ {
const float uv[2] = {x, y}; const float uv[2] = {x, y};

View File

@@ -31,11 +31,12 @@ class BufferOperation : public ConstantOperation {
BufferOperation(MemoryBuffer *buffer, DataType data_type); BufferOperation(MemoryBuffer *buffer, DataType data_type);
const float *get_constant_elem() override; const float *get_constant_elem() override;
void *initializeTileData(rcti *rect) override; void *initialize_tile_data(rcti *rect) override;
void initExecution() override; void init_execution() override;
void deinitExecution() override; void deinit_execution() override;
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override; void execute_pixel_sampled(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 execute_pixel_filtered(
float output[4], float x, float y, float dx[2], float dy[2]) override;
}; };
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -19,7 +19,6 @@
#pragma once #pragma once
#include "BLI_assert.h" #include "BLI_assert.h"
#include "BLI_rect.h"
#include <iterator> #include <iterator>

View File

@@ -19,12 +19,11 @@
#include "COM_CPUDevice.h" #include "COM_CPUDevice.h"
#include "COM_ExecutionGroup.h" #include "COM_ExecutionGroup.h"
#include "COM_NodeOperation.h"
#include "BLI_rect.h"
namespace blender::compositor { namespace blender::compositor {
CPUDevice::CPUDevice(int thread_id) : m_thread_id(thread_id) CPUDevice::CPUDevice(int thread_id) : thread_id_(thread_id)
{ {
} }
@@ -32,11 +31,11 @@ void CPUDevice::execute(WorkPackage *work_package)
{ {
switch (work_package->type) { switch (work_package->type) {
case eWorkPackageType::Tile: { case eWorkPackageType::Tile: {
const unsigned int chunkNumber = work_package->chunk_number; const unsigned int chunk_number = work_package->chunk_number;
ExecutionGroup *executionGroup = work_package->execution_group; ExecutionGroup *execution_group = work_package->execution_group;
executionGroup->getOutputOperation()->executeRegion(&work_package->rect, chunkNumber); execution_group->get_output_operation()->execute_region(&work_package->rect, chunk_number);
executionGroup->finalizeChunkExecution(chunkNumber, nullptr); execution_group->finalize_chunk_execution(chunk_number, nullptr);
break; break;
} }
case eWorkPackageType::CustomFunction: { case eWorkPackageType::CustomFunction: {

View File

@@ -39,11 +39,11 @@ class CPUDevice : public Device {
int thread_id() int thread_id()
{ {
return m_thread_id; return thread_id_;
} }
protected: protected:
int m_thread_id; int thread_id_;
}; };
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -16,9 +16,9 @@
* Copyright 2011, Blender Foundation. * Copyright 2011, Blender Foundation.
*/ */
#include "COM_ChunkOrder.h" #include <cfloat>
#include "BLI_math.h" #include "COM_ChunkOrder.h"
namespace blender::compositor { namespace blender::compositor {

View File

@@ -17,43 +17,38 @@
*/ */
#include "COM_CompositorContext.h" #include "COM_CompositorContext.h"
#include "COM_defines.h"
#include <cstdio>
#include "BLI_assert.h"
#include "DNA_userdef_types.h"
namespace blender::compositor { namespace blender::compositor {
CompositorContext::CompositorContext() CompositorContext::CompositorContext()
{ {
this->m_scene = nullptr; scene_ = nullptr;
this->m_rd = nullptr; rd_ = nullptr;
this->m_quality = eCompositorQuality::High; quality_ = eCompositorQuality::High;
this->m_hasActiveOpenCLDevices = false; hasActiveOpenCLDevices_ = false;
this->m_fastCalculation = false; fast_calculation_ = false;
this->m_viewSettings = nullptr; view_settings_ = nullptr;
this->m_displaySettings = nullptr; display_settings_ = nullptr;
this->m_bnodetree = nullptr; bnodetree_ = nullptr;
} }
int CompositorContext::getFramenumber() const int CompositorContext::get_framenumber() const
{ {
BLI_assert(m_rd); BLI_assert(rd_);
return m_rd->cfra; return rd_->cfra;
} }
Size2f CompositorContext::get_render_size() const Size2f CompositorContext::get_render_size() const
{ {
return {getRenderData()->xsch * getRenderPercentageAsFactor(), return {get_render_data()->xsch * get_render_percentage_as_factor(),
getRenderData()->ysch * getRenderPercentageAsFactor()}; get_render_data()->ysch * get_render_percentage_as_factor()};
} }
eExecutionModel CompositorContext::get_execution_model() const eExecutionModel CompositorContext::get_execution_model() const
{ {
if (U.experimental.use_full_frame_compositor) { if (U.experimental.use_full_frame_compositor) {
BLI_assert(m_bnodetree != nullptr); BLI_assert(bnodetree_ != nullptr);
switch (m_bnodetree->execution_mode) { switch (bnodetree_->execution_mode) {
case 1: case 1:
return eExecutionModel::FullFrame; return eExecutionModel::FullFrame;
case 0: case 0:

View File

@@ -18,16 +18,13 @@
#pragma once #pragma once
#include "BLI_rect.h"
#include "COM_Enums.h" #include "COM_Enums.h"
#include "DNA_color_types.h" #include "DNA_color_types.h"
#include "DNA_node_types.h" #include "DNA_node_types.h"
#include "DNA_scene_types.h" #include "DNA_scene_types.h"
#include <string> struct bNodeInstanceHash;
#include <vector>
namespace blender::compositor { namespace blender::compositor {
@@ -41,55 +38,55 @@ class CompositorContext {
* editor) This field is initialized in ExecutionSystem and must only be read from that point * editor) This field is initialized in ExecutionSystem and must only be read from that point
* on. \see ExecutionSystem * on. \see ExecutionSystem
*/ */
bool m_rendering; bool rendering_;
/** /**
* \brief The quality of the composite. * \brief The quality of the composite.
* This field is initialized in ExecutionSystem and must only be read from that point on. * This field is initialized in ExecutionSystem and must only be read from that point on.
* \see ExecutionSystem * \see ExecutionSystem
*/ */
eCompositorQuality m_quality; eCompositorQuality quality_;
Scene *m_scene; Scene *scene_;
/** /**
* \brief Reference to the render data that is being composited. * \brief Reference to the render data that is being composited.
* This field is initialized in ExecutionSystem and must only be read from that point on. * This field is initialized in ExecutionSystem and must only be read from that point on.
* \see ExecutionSystem * \see ExecutionSystem
*/ */
RenderData *m_rd; RenderData *rd_;
/** /**
* \brief reference to the bNodeTree * \brief reference to the bNodeTree
* This field is initialized in ExecutionSystem and must only be read from that point on. * This field is initialized in ExecutionSystem and must only be read from that point on.
* \see ExecutionSystem * \see ExecutionSystem
*/ */
bNodeTree *m_bnodetree; bNodeTree *bnodetree_;
/** /**
* \brief Preview image hash table * \brief Preview image hash table
* This field is initialized in ExecutionSystem and must only be read from that point on. * This field is initialized in ExecutionSystem and must only be read from that point on.
*/ */
bNodeInstanceHash *m_previews; bNodeInstanceHash *previews_;
/** /**
* \brief does this system have active opencl devices? * \brief does this system have active opencl devices?
*/ */
bool m_hasActiveOpenCLDevices; bool hasActiveOpenCLDevices_;
/** /**
* \brief Skip slow nodes * \brief Skip slow nodes
*/ */
bool m_fastCalculation; bool fast_calculation_;
/* \brief color management settings */ /* \brief color management settings */
const ColorManagedViewSettings *m_viewSettings; const ColorManagedViewSettings *view_settings_;
const ColorManagedDisplaySettings *m_displaySettings; const ColorManagedDisplaySettings *display_settings_;
/** /**
* \brief active rendering view name * \brief active rendering view name
*/ */
const char *m_viewName; const char *view_name_;
public: public:
/** /**
@@ -100,192 +97,192 @@ class CompositorContext {
/** /**
* \brief set the rendering field of the context * \brief set the rendering field of the context
*/ */
void setRendering(bool rendering) void set_rendering(bool rendering)
{ {
this->m_rendering = rendering; rendering_ = rendering;
} }
/** /**
* \brief get the rendering field of the context * \brief get the rendering field of the context
*/ */
bool isRendering() const bool is_rendering() const
{ {
return this->m_rendering; return rendering_;
} }
/** /**
* \brief set the scene of the context * \brief set the scene of the context
*/ */
void setRenderData(RenderData *rd) void set_render_data(RenderData *rd)
{ {
this->m_rd = rd; rd_ = rd;
} }
/** /**
* \brief set the bnodetree of the context * \brief set the bnodetree of the context
*/ */
void setbNodeTree(bNodeTree *bnodetree) void set_bnodetree(bNodeTree *bnodetree)
{ {
this->m_bnodetree = bnodetree; bnodetree_ = bnodetree;
} }
/** /**
* \brief get the bnodetree of the context * \brief get the bnodetree of the context
*/ */
const bNodeTree *getbNodeTree() const const bNodeTree *get_bnodetree() const
{ {
return this->m_bnodetree; return bnodetree_;
} }
/** /**
* \brief get the scene of the context * \brief get the scene of the context
*/ */
const RenderData *getRenderData() const const RenderData *get_render_data() const
{ {
return this->m_rd; return rd_;
} }
void setScene(Scene *scene) void set_scene(Scene *scene)
{ {
m_scene = scene; scene_ = scene;
} }
Scene *getScene() const Scene *get_scene() const
{ {
return m_scene; return scene_;
} }
/** /**
* \brief set the preview image hash table * \brief set the preview image hash table
*/ */
void setPreviewHash(bNodeInstanceHash *previews) void set_preview_hash(bNodeInstanceHash *previews)
{ {
this->m_previews = previews; previews_ = previews;
} }
/** /**
* \brief get the preview image hash table * \brief get the preview image hash table
*/ */
bNodeInstanceHash *getPreviewHash() const bNodeInstanceHash *get_preview_hash() const
{ {
return this->m_previews; return previews_;
} }
/** /**
* \brief set view settings of color management * \brief set view settings of color management
*/ */
void setViewSettings(const ColorManagedViewSettings *viewSettings) void set_view_settings(const ColorManagedViewSettings *view_settings)
{ {
this->m_viewSettings = viewSettings; view_settings_ = view_settings;
} }
/** /**
* \brief get view settings of color management * \brief get view settings of color management
*/ */
const ColorManagedViewSettings *getViewSettings() const const ColorManagedViewSettings *get_view_settings() const
{ {
return this->m_viewSettings; return view_settings_;
} }
/** /**
* \brief set display settings of color management * \brief set display settings of color management
*/ */
void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) void set_display_settings(const ColorManagedDisplaySettings *display_settings)
{ {
this->m_displaySettings = displaySettings; display_settings_ = display_settings;
} }
/** /**
* \brief get display settings of color management * \brief get display settings of color management
*/ */
const ColorManagedDisplaySettings *getDisplaySettings() const const ColorManagedDisplaySettings *get_display_settings() const
{ {
return this->m_displaySettings; return display_settings_;
} }
/** /**
* \brief set the quality * \brief set the quality
*/ */
void setQuality(eCompositorQuality quality) void set_quality(eCompositorQuality quality)
{ {
this->m_quality = quality; quality_ = quality;
} }
/** /**
* \brief get the quality * \brief get the quality
*/ */
eCompositorQuality getQuality() const eCompositorQuality get_quality() const
{ {
return this->m_quality; return quality_;
} }
/** /**
* \brief get the current frame-number of the scene in this context * \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 this->m_hasActiveOpenCLDevices; return hasActiveOpenCLDevices_;
} }
/** /**
* \brief set has this system active openclDevices? * \brief set has this system active opencl_devices?
*/ */
void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices) void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices)
{ {
this->m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices; hasActiveOpenCLDevices_ = hasAvtiveOpenCLDevices;
} }
/** Whether it has a view with a specific name and not the default one. */ /** Whether it has a view with a specific name and not the default one. */
bool has_explicit_view() const bool has_explicit_view() const
{ {
return m_viewName && m_viewName[0] != '\0'; return view_name_ && view_name_[0] != '\0';
} }
/** /**
* \brief get the active rendering view * \brief get the active rendering view
*/ */
const char *getViewName() const const char *get_view_name() const
{ {
return this->m_viewName; return view_name_;
} }
/** /**
* \brief set the active rendering view * \brief set the active rendering view
*/ */
void setViewName(const char *viewName) void set_view_name(const char *view_name)
{ {
this->m_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)
{ {
this->m_fastCalculation = fastCalculation; fast_calculation_ = fast_calculation;
} }
bool isFastCalculation() const bool is_fast_calculation() const
{ {
return this->m_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. * \brief Get the render percentage as a factor.
* The compositor uses a factor i.o. a percentage. * The compositor uses a factor i.o. a percentage.
*/ */
float getRenderPercentageAsFactor() const float get_render_percentage_as_factor() const
{ {
return m_rd->size * 0.01f; return rd_->size * 0.01f;
} }
Size2f get_render_size() const; Size2f get_render_size() const;

View File

@@ -16,10 +16,11 @@
* Copyright 2021, Blender Foundation. * Copyright 2021, Blender Foundation.
*/ */
#include "BLI_rect.h" #include "BLI_map.hh"
#include "BLI_set.hh"
#include "COM_ConstantFolder.h" #include "COM_ConstantFolder.h"
#include "COM_ConstantOperation.h" #include "COM_NodeOperationBuilder.h"
#include "COM_SetColorOperation.h" #include "COM_SetColorOperation.h"
#include "COM_SetValueOperation.h" #include "COM_SetValueOperation.h"
#include "COM_SetVectorOperation.h" #include "COM_SetVectorOperation.h"
@@ -43,7 +44,7 @@ ConstantFolder::ConstantFolder(NodeOperationBuilder &operations_builder)
static bool is_constant_foldable(NodeOperation *operation) static bool is_constant_foldable(NodeOperation *operation)
{ {
if (operation->get_flags().can_be_constant && !operation->get_flags().is_constant_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); NodeOperation *input = operation->get_input_operation(i);
if (!input->get_flags().is_constant_operation || if (!input->get_flags().is_constant_operation ||
!static_cast<ConstantOperation *>(input)->can_get_constant_elem()) { !static_cast<ConstantOperation *>(input)->can_get_constant_elem()) {
@@ -71,17 +72,17 @@ static ConstantOperation *create_constant_operation(DataType data_type, const fl
switch (data_type) { switch (data_type) {
case DataType::Color: { case DataType::Color: {
SetColorOperation *color_op = new SetColorOperation(); SetColorOperation *color_op = new SetColorOperation();
color_op->setChannels(constant_elem); color_op->set_channels(constant_elem);
return color_op; return color_op;
} }
case DataType::Vector: { case DataType::Vector: {
SetVectorOperation *vector_op = new SetVectorOperation(); SetVectorOperation *vector_op = new SetVectorOperation();
vector_op->setVector(constant_elem); vector_op->set_vector(constant_elem);
return vector_op; return vector_op;
} }
case DataType::Value: { case DataType::Value: {
SetValueOperation *value_op = new SetValueOperation(); SetValueOperation *value_op = new SetValueOperation();
value_op->setValue(*constant_elem); value_op->set_value(*constant_elem);
return value_op; return value_op;
} }
default: { default: {
@@ -93,7 +94,7 @@ static ConstantOperation *create_constant_operation(DataType data_type, const fl
ConstantOperation *ConstantFolder::fold_operation(NodeOperation *operation) 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_); MemoryBuffer fold_buf(data_type, first_elem_area_);
Vector<MemoryBuffer *> input_bufs = get_constant_input_buffers(operation); Vector<MemoryBuffer *> input_bufs = get_constant_input_buffers(operation);
operation->init_data(); operation->init_data();
@@ -101,7 +102,8 @@ ConstantOperation *ConstantFolder::fold_operation(NodeOperation *operation)
MemoryBuffer *constant_buf = create_constant_buffer(data_type); MemoryBuffer *constant_buf = create_constant_buffer(data_type);
constant_buf->copy_from(&fold_buf, first_elem_area_); 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); operations_builder_.replace_operation_with_constant(operation, constant_op);
constant_buffers_.add_new(constant_op, constant_buf); constant_buffers_.add_new(constant_op, constant_buf);
return constant_op; return constant_op;
@@ -116,14 +118,15 @@ MemoryBuffer *ConstantFolder::create_constant_buffer(const DataType data_type)
Vector<MemoryBuffer *> ConstantFolder::get_constant_input_buffers(NodeOperation *operation) 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); Vector<MemoryBuffer *> inputs_bufs(num_inputs);
for (int i = 0; i < num_inputs; i++) { for (int i = 0; i < num_inputs; i++) {
BLI_assert(operation->get_input_operation(i)->get_flags().is_constant_operation); BLI_assert(operation->get_input_operation(i)->get_flags().is_constant_operation);
ConstantOperation *constant_op = static_cast<ConstantOperation *>( ConstantOperation *constant_op = static_cast<ConstantOperation *>(
operation->get_input_operation(i)); operation->get_input_operation(i));
MemoryBuffer *constant_buf = constant_buffers_.lookup_or_add_cb(constant_op, [=] { 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_}, {}); constant_op->render(buf, {first_elem_area_}, {});
return buf; return buf;
}); });
@@ -185,8 +188,8 @@ void ConstantFolder::get_operation_output_operations(NodeOperation *operation,
{ {
const Vector<Link> &links = operations_builder_.get_links(); const Vector<Link> &links = operations_builder_.get_links();
for (const Link &link : links) { for (const Link &link : links) {
if (&link.from()->getOperation() == operation) { if (&link.from()->get_operation() == operation) {
r_outputs.append(&link.to()->getOperation()); r_outputs.append(&link.to()->get_operation());
} }
} }
} }

View File

@@ -18,16 +18,12 @@
#pragma once #pragma once
#include "BLI_map.hh"
#include "BLI_set.hh"
#include "BLI_vector.hh"
#include "COM_NodeOperationBuilder.h"
#include "COM_defines.h" #include "COM_defines.h"
namespace blender::compositor { namespace blender::compositor {
class NodeOperation; class NodeOperation;
class NodeOperationBuilder;
class ConstantOperation; class ConstantOperation;
class MemoryBuffer; class MemoryBuffer;

View File

@@ -22,7 +22,6 @@
#include "BKE_node.h" #include "BKE_node.h"
#include "COM_NodeOperation.h"
#include "COM_NodeOperationBuilder.h" #include "COM_NodeOperationBuilder.h"
#include "COM_AlphaOverNode.h" #include "COM_AlphaOverNode.h"
@@ -62,7 +61,6 @@
#include "COM_DistanceMatteNode.h" #include "COM_DistanceMatteNode.h"
#include "COM_DoubleEdgeMaskNode.h" #include "COM_DoubleEdgeMaskNode.h"
#include "COM_EllipseMaskNode.h" #include "COM_EllipseMaskNode.h"
#include "COM_ExecutionSystem.h"
#include "COM_FilterNode.h" #include "COM_FilterNode.h"
#include "COM_FlipNode.h" #include "COM_FlipNode.h"
#include "COM_GammaNode.h" #include "COM_GammaNode.h"
@@ -435,8 +433,8 @@ Node *COM_convert_bnode(bNode *b_node)
/* TODO(jbakker): make this an std::optional<NodeOperation>. */ /* TODO(jbakker): make this an std::optional<NodeOperation>. */
NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, const NodeOperationInput &to) NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, const NodeOperationInput &to)
{ {
const DataType src_data_type = from.getDataType(); const DataType src_data_type = from.get_data_type();
const DataType dst_data_type = to.getDataType(); const DataType dst_data_type = to.get_data_type();
if (src_data_type == DataType::Value && dst_data_type == DataType::Color) { if (src_data_type == DataType::Value && dst_data_type == DataType::Color) {
return new ConvertValueToColorOperation(); return new ConvertValueToColorOperation();
@@ -461,24 +459,24 @@ NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, const Node
} }
void COM_convert_canvas(NodeOperationBuilder &builder, void COM_convert_canvas(NodeOperationBuilder &builder,
NodeOperationOutput *fromSocket, NodeOperationOutput *from_socket,
NodeOperationInput *toSocket) NodeOperationInput *to_socket)
{ {
/* Data type conversions are executed before resolutions to ensure convert operations have /* 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. */ * 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); BLI_assert(mode != ResizeMode::None);
NodeOperation *toOperation = &toSocket->getOperation(); NodeOperation *to_operation = &to_socket->get_operation();
const float toWidth = toOperation->getWidth(); const float to_width = to_operation->get_width();
const float toHeight = toOperation->getHeight(); const float to_height = to_operation->get_height();
NodeOperation *fromOperation = &fromSocket->getOperation(); NodeOperation *from_operation = &from_socket->get_operation();
const float fromWidth = fromOperation->getWidth(); const float from_width = from_operation->get_width();
const float fromHeight = fromOperation->getHeight(); const float from_height = from_operation->get_height();
bool doCenter = false; bool do_center = false;
bool doScale = false; bool do_scale = false;
float scaleX = 0; float scaleX = 0;
float scaleY = 0; float scaleY = 0;
@@ -487,23 +485,23 @@ void COM_convert_canvas(NodeOperationBuilder &builder,
case ResizeMode::Align: case ResizeMode::Align:
break; break;
case ResizeMode::Center: case ResizeMode::Center:
doCenter = true; do_center = true;
break; break;
case ResizeMode::FitWidth: case ResizeMode::FitWidth:
doCenter = true; do_center = true;
doScale = true; do_scale = true;
scaleX = scaleY = toWidth / fromWidth; scaleX = scaleY = to_width / from_width;
break; break;
case ResizeMode::FitHeight: case ResizeMode::FitHeight:
doCenter = true; do_center = true;
doScale = true; do_scale = true;
scaleX = scaleY = toHeight / fromHeight; scaleX = scaleY = to_height / from_height;
break; break;
case ResizeMode::FitAny: case ResizeMode::FitAny:
doCenter = true; do_center = true;
doScale = true; do_scale = true;
scaleX = toWidth / fromWidth; scaleX = to_width / from_width;
scaleY = toHeight / fromHeight; scaleY = to_height / from_height;
if (scaleX < scaleY) { if (scaleX < scaleY) {
scaleX = scaleY; scaleX = scaleY;
} }
@@ -512,81 +510,82 @@ void COM_convert_canvas(NodeOperationBuilder &builder,
} }
break; break;
case ResizeMode::Stretch: case ResizeMode::Stretch:
doCenter = true; do_center = true;
doScale = true; do_scale = true;
scaleX = toWidth / fromWidth; scaleX = to_width / from_width;
scaleY = toHeight / fromHeight; scaleY = to_height / from_height;
break; break;
} }
float addX = doCenter ? (toWidth - fromWidth) / 2.0f : 0.0f; float addX = do_center ? (to_width - from_width) / 2.0f : 0.0f;
float addY = doCenter ? (toHeight - fromHeight) / 2.0f : 0.0f; float addY = do_center ? (to_height - from_height) / 2.0f : 0.0f;
NodeOperation *first = nullptr; NodeOperation *first = nullptr;
ScaleOperation *scaleOperation = nullptr; ScaleOperation *scale_operation = nullptr;
if (doScale) { if (do_scale) {
scaleOperation = new ScaleRelativeOperation(fromSocket->getDataType()); scale_operation = new ScaleRelativeOperation(from_socket->get_data_type());
scaleOperation->getInputSocket(1)->setResizeMode(ResizeMode::None); scale_operation->get_input_socket(1)->set_resize_mode(ResizeMode::None);
scaleOperation->getInputSocket(2)->setResizeMode(ResizeMode::None); scale_operation->get_input_socket(2)->set_resize_mode(ResizeMode::None);
first = scaleOperation; first = scale_operation;
SetValueOperation *sxop = new SetValueOperation(); SetValueOperation *sxop = new SetValueOperation();
sxop->setValue(scaleX); sxop->set_value(scaleX);
builder.addLink(sxop->getOutputSocket(), scaleOperation->getInputSocket(1)); builder.add_link(sxop->get_output_socket(), scale_operation->get_input_socket(1));
SetValueOperation *syop = new SetValueOperation(); SetValueOperation *syop = new SetValueOperation();
syop->setValue(scaleY); syop->set_value(scaleY);
builder.addLink(syop->getOutputSocket(), scaleOperation->getInputSocket(2)); builder.add_link(syop->get_output_socket(), scale_operation->get_input_socket(2));
builder.addOperation(sxop); builder.add_operation(sxop);
builder.addOperation(syop); 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) { if (builder.context().get_execution_model() == eExecutionModel::FullFrame) {
ScaleOperation::scale_area(scale_canvas, scaleX, scaleY); ScaleOperation::scale_area(scale_canvas, scaleX, scaleY);
scale_canvas.xmax = scale_canvas.xmin + toOperation->getWidth(); scale_canvas.xmax = scale_canvas.xmin + to_operation->get_width();
scale_canvas.ymax = scale_canvas.ymin + toOperation->getHeight(); scale_canvas.ymax = scale_canvas.ymin + to_operation->get_height();
addX = 0; addX = 0;
addY = 0; addY = 0;
} }
scaleOperation->set_canvas(scale_canvas); scale_operation->set_canvas(scale_canvas);
sxop->set_canvas(scale_canvas); sxop->set_canvas(scale_canvas);
syop->set_canvas(scale_canvas); syop->set_canvas(scale_canvas);
builder.addOperation(scaleOperation); builder.add_operation(scale_operation);
} }
TranslateOperation *translateOperation = new TranslateOperation(toSocket->getDataType()); TranslateOperation *translate_operation = new TranslateOperation(to_socket->get_data_type());
translateOperation->getInputSocket(1)->setResizeMode(ResizeMode::None); translate_operation->get_input_socket(1)->set_resize_mode(ResizeMode::None);
translateOperation->getInputSocket(2)->setResizeMode(ResizeMode::None); translate_operation->get_input_socket(2)->set_resize_mode(ResizeMode::None);
if (!first) { if (!first) {
first = translateOperation; first = translate_operation;
} }
SetValueOperation *xop = new SetValueOperation(); SetValueOperation *xop = new SetValueOperation();
xop->setValue(addX); xop->set_value(addX);
builder.addLink(xop->getOutputSocket(), translateOperation->getInputSocket(1)); builder.add_link(xop->get_output_socket(), translate_operation->get_input_socket(1));
SetValueOperation *yop = new SetValueOperation(); SetValueOperation *yop = new SetValueOperation();
yop->setValue(addY); yop->set_value(addY);
builder.addLink(yop->getOutputSocket(), translateOperation->getInputSocket(2)); builder.add_link(yop->get_output_socket(), translate_operation->get_input_socket(2));
builder.addOperation(xop); builder.add_operation(xop);
builder.addOperation(yop); builder.add_operation(yop);
rcti translate_canvas = toOperation->get_canvas(); rcti translate_canvas = to_operation->get_canvas();
if (mode == ResizeMode::Align) { if (mode == ResizeMode::Align) {
translate_canvas.xmax = translate_canvas.xmin + fromWidth; translate_canvas.xmax = translate_canvas.xmin + from_width;
translate_canvas.ymax = translate_canvas.ymin + fromHeight; translate_canvas.ymax = translate_canvas.ymin + from_height;
} }
translateOperation->set_canvas(translate_canvas); translate_operation->set_canvas(translate_canvas);
xop->set_canvas(translate_canvas); xop->set_canvas(translate_canvas);
yop->set_canvas(translate_canvas); yop->set_canvas(translate_canvas);
builder.addOperation(translateOperation); builder.add_operation(translate_operation);
if (doScale) { if (do_scale) {
translateOperation->getInputSocket(0)->setResizeMode(ResizeMode::None); translate_operation->get_input_socket(0)->set_resize_mode(ResizeMode::None);
builder.addLink(scaleOperation->getOutputSocket(), translateOperation->getInputSocket(0)); builder.add_link(scale_operation->get_output_socket(),
translate_operation->get_input_socket(0));
} }
/* remove previous link and replace */ /* remove previous link and replace */
builder.removeInputLink(toSocket); builder.remove_input_link(to_socket);
first->getInputSocket(0)->setResizeMode(ResizeMode::None); first->get_input_socket(0)->set_resize_mode(ResizeMode::None);
toSocket->setResizeMode(ResizeMode::None); to_socket->set_resize_mode(ResizeMode::None);
builder.addLink(fromSocket, first->getInputSocket(0)); builder.add_link(from_socket, first->get_input_socket(0));
builder.addLink(translateOperation->getOutputSocket(), toSocket); builder.add_link(translate_operation->get_output_socket(), to_socket);
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -18,8 +18,6 @@
#pragma once #pragma once
#include "COM_NodeOperation.h"
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h" # include "MEM_guardedalloc.h"
#endif #endif
@@ -29,6 +27,7 @@ struct bNode;
namespace blender::compositor { namespace blender::compositor {
class Node; class Node;
class NodeOperation;
class NodeOperationInput; class NodeOperationInput;
class NodeOperationOutput; class NodeOperationOutput;
class NodeOperationBuilder; class NodeOperationBuilder;
@@ -66,7 +65,7 @@ NodeOperation *COM_convert_data_type(const NodeOperationOutput &from,
* \see InputSocketResizeMode for the possible conversions. * \see InputSocketResizeMode for the possible conversions.
*/ */
void COM_convert_canvas(NodeOperationBuilder &builder, void COM_convert_canvas(NodeOperationBuilder &builder,
NodeOperationOutput *fromSocket, NodeOperationOutput *from_socket,
NodeOperationInput *toSocket); NodeOperationInput *to_socket);
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -18,26 +18,16 @@
#include "COM_Debug.h" #include "COM_Debug.h"
#include <map>
#include <typeinfo>
#include <vector>
extern "C" { extern "C" {
#include "BLI_fileops.h" #include "BLI_fileops.h"
#include "BLI_path_util.h" #include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_sys_types.h"
#include "BKE_appdir.h" #include "BKE_appdir.h"
#include "BKE_node.h"
#include "DNA_node_types.h"
#include "IMB_imbuf.h" #include "IMB_imbuf.h"
#include "IMB_imbuf_types.h" #include "IMB_imbuf_types.h"
} }
#include "COM_ExecutionSystem.h" #include "COM_ExecutionGroup.h"
#include "COM_Node.h"
#include "COM_ReadBufferOperation.h" #include "COM_ReadBufferOperation.h"
#include "COM_SetValueOperation.h" #include "COM_SetValueOperation.h"
#include "COM_ViewerOperation.h" #include "COM_ViewerOperation.h"
@@ -45,12 +35,12 @@ extern "C" {
namespace blender::compositor { namespace blender::compositor {
int DebugInfo::m_file_index = 0; int DebugInfo::file_index_ = 0;
DebugInfo::NodeNameMap DebugInfo::m_node_names; DebugInfo::NodeNameMap DebugInfo::node_names_;
DebugInfo::OpNameMap DebugInfo::m_op_names; DebugInfo::OpNameMap DebugInfo::op_names_;
std::string DebugInfo::m_current_node_name; std::string DebugInfo::current_node_name_;
std::string DebugInfo::m_current_op_name; std::string DebugInfo::current_op_name_;
DebugInfo::GroupStateMap DebugInfo::m_group_states; DebugInfo::GroupStateMap DebugInfo::group_states_;
static std::string operation_class_name(const NodeOperation *op) static std::string operation_class_name(const NodeOperation *op)
{ {
@@ -63,8 +53,8 @@ static std::string operation_class_name(const NodeOperation *op)
std::string DebugInfo::node_name(const Node *node) std::string DebugInfo::node_name(const Node *node)
{ {
NodeNameMap::const_iterator it = m_node_names.find(node); NodeNameMap::const_iterator it = node_names_.find(node);
if (it != m_node_names.end()) { if (it != node_names_.end()) {
return it->second; return it->second;
} }
return ""; return "";
@@ -72,8 +62,8 @@ std::string DebugInfo::node_name(const Node *node)
std::string DebugInfo::operation_name(const NodeOperation *op) std::string DebugInfo::operation_name(const NodeOperation *op)
{ {
OpNameMap::const_iterator it = m_op_names.find(op); OpNameMap::const_iterator it = op_names_.find(op);
if (it != m_op_names.end()) { if (it != op_names_.end()) {
return it->second; return it->second;
} }
return ""; return "";
@@ -90,14 +80,14 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
std::string fillcolor = "gainsboro"; std::string fillcolor = "gainsboro";
if (operation->get_flags().is_viewer_operation) { if (operation->get_flags().is_viewer_operation) {
const ViewerOperation *viewer = (const ViewerOperation *)operation; const ViewerOperation *viewer = (const ViewerOperation *)operation;
if (viewer->isActiveViewerOutput()) { if (viewer->is_active_viewer_output()) {
fillcolor = "lightskyblue1"; fillcolor = "lightskyblue1";
} }
else { else {
fillcolor = "lightskyblue3"; fillcolor = "lightskyblue3";
} }
} }
else if (operation->isOutputOperation(system->getContext().isRendering())) { else if (operation->is_output_operation(system->get_context().is_rendering())) {
fillcolor = "dodgerblue1"; fillcolor = "dodgerblue1";
} }
else if (operation->get_flags().is_set_operation) { else if (operation->get_flags().is_set_operation) {
@@ -122,16 +112,16 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
" [fillcolor=%s,style=filled,shape=record,label=\"{", " [fillcolor=%s,style=filled,shape=record,label=\"{",
fillcolor.c_str()); fillcolor.c_str());
int totinputs = operation->getNumberOfInputSockets(); int totinputs = operation->get_number_of_input_sockets();
if (totinputs != 0) { if (totinputs != 0) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{");
for (int k = 0; k < totinputs; k++) { for (int k = 0; k < totinputs; k++) {
NodeOperationInput *socket = operation->getInputSocket(k); NodeOperationInput *socket = operation->get_input_socket(k);
if (k != 0) { if (k != 0) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
} }
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<IN_%p>", socket); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<IN_%p>", socket);
switch (socket->getDataType()) { switch (socket->get_data_type()) {
case DataType::Value: case DataType::Value:
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value");
break; break;
@@ -166,20 +156,20 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
operation->get_id(), operation->get_id(),
operation->get_canvas().xmin, operation->get_canvas().xmin,
operation->get_canvas().ymin, operation->get_canvas().ymin,
operation->getWidth(), operation->get_width(),
operation->getHeight()); operation->get_height());
int totoutputs = operation->getNumberOfOutputSockets(); int totoutputs = operation->get_number_of_output_sockets();
if (totoutputs != 0) { if (totoutputs != 0) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|"); len += snprintf(str + len, maxlen > len ? maxlen - len : 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++) { for (int k = 0; k < totoutputs; k++) {
NodeOperationOutput *socket = operation->getOutputSocket(k); NodeOperationOutput *socket = operation->get_output_socket(k);
if (k != 0) { if (k != 0) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
} }
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<OUT_%p>", socket); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<OUT_%p>", socket);
switch (socket->getDataType()) { switch (socket->get_data_type()) {
case DataType::Value: { case DataType::Value: {
ConstantOperation *constant = operation->get_flags().is_constant_operation ? ConstantOperation *constant = operation->get_flags().is_constant_operation ?
static_cast<ConstantOperation *>(operation) : static_cast<ConstantOperation *>(operation) :
@@ -310,25 +300,25 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
std::map<NodeOperation *, std::vector<std::string>> op_groups; std::map<NodeOperation *, std::vector<std::string>> op_groups;
int index = 0; int index = 0;
for (const ExecutionGroup *group : system->m_groups) { for (const ExecutionGroup *group : system->groups_) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// GROUP: %d\r\n", index); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// GROUP: %d\r\n", index);
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "subgraph cluster_%d{\r\n", index); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "subgraph cluster_%d{\r\n", index);
/* used as a check for executing group */ /* used as a check for executing group */
if (m_group_states[group] == EG_WAIT) { if (group_states_[group] == EG_WAIT) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=dashed\r\n"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=dashed\r\n");
} }
else if (m_group_states[group] == EG_RUNNING) { else if (group_states_[group] == EG_RUNNING) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=filled\r\n"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=filled\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=firebrick1\r\n"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=firebrick1\r\n");
} }
else if (m_group_states[group] == EG_FINISHED) { else if (group_states_[group] == EG_FINISHED) {
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=filled\r\n"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=filled\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n");
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=chartreuse4\r\n"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=chartreuse4\r\n");
} }
for (NodeOperation *operation : group->m_operations) { for (NodeOperation *operation : group->operations_) {
sprintf(strbuf, "_%p", group); sprintf(strbuf, "_%p", group);
op_groups[operation].push_back(std::string(strbuf)); op_groups[operation].push_back(std::string(strbuf));
@@ -342,7 +332,7 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
} }
/* operations not included in any group */ /* operations not included in any group */
for (NodeOperation *operation : system->m_operations) { for (NodeOperation *operation : system->operations_) {
if (op_groups.find(operation) != op_groups.end()) { if (op_groups.find(operation) != op_groups.end()) {
continue; continue;
} }
@@ -353,10 +343,10 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
system, operation, nullptr, str + len, maxlen > len ? maxlen - len : 0); system, operation, nullptr, str + len, maxlen > len ? maxlen - len : 0);
} }
for (NodeOperation *operation : system->m_operations) { for (NodeOperation *operation : system->operations_) {
if (operation->get_flags().is_read_buffer_operation) { if (operation->get_flags().is_read_buffer_operation) {
ReadBufferOperation *read = (ReadBufferOperation *)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> &read_groups = op_groups[read];
std::vector<std::string> &write_groups = op_groups[write]; std::vector<std::string> &write_groups = op_groups[write];
@@ -374,16 +364,16 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
} }
} }
for (NodeOperation *op : system->m_operations) { for (NodeOperation *op : system->operations_) {
for (NodeOperationInput &to : op->m_inputs) { for (NodeOperationInput &to : op->inputs_) {
NodeOperationOutput *from = to.getLink(); NodeOperationOutput *from = to.get_link();
if (!from) { if (!from) {
continue; continue;
} }
std::string color; std::string color;
switch (from->getDataType()) { switch (from->get_data_type()) {
case DataType::Value: case DataType::Value:
color = "gray"; color = "gray";
break; break;
@@ -395,8 +385,8 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
break; break;
} }
NodeOperation *to_op = &to.getOperation(); NodeOperation *to_op = &to.get_operation();
NodeOperation *from_op = &from->getOperation(); NodeOperation *from_op = &from->get_operation();
std::vector<std::string> &from_groups = op_groups[from_op]; std::vector<std::string> &from_groups = op_groups[from_op];
std::vector<std::string> &to_groups = op_groups[to_op]; std::vector<std::string> &to_groups = op_groups[to_op];
@@ -426,9 +416,9 @@ 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 && eExecutionModel::Tiled &&
system->m_groups.size() > 0; system->groups_.size() > 0;
len += graphviz_legend(str + len, maxlen > len ? maxlen - len : 0, has_execution_groups); len += graphviz_legend(str + len, maxlen > len ? maxlen - len : 0, has_execution_groups);
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
@@ -447,13 +437,13 @@ void DebugInfo::graphviz(const ExecutionSystem *system, StringRefNull name)
char filename[FILE_MAX]; char filename[FILE_MAX];
if (name.is_empty()) { if (name.is_empty()) {
BLI_snprintf(basename, sizeof(basename), "compositor_%d.dot", m_file_index); BLI_snprintf(basename, sizeof(basename), "compositor_%d.dot", file_index_);
} }
else { else {
BLI_strncpy(basename, (name + ".dot").c_str(), sizeof(basename)); BLI_strncpy(basename, (name + ".dot").c_str(), sizeof(basename));
} }
BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), basename); BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), basename);
m_file_index++; file_index_++;
std::cout << "Writing compositor debug to: " << filename << "\n"; std::cout << "Writing compositor debug to: " << filename << "\n";
@@ -470,8 +460,8 @@ static std::string get_operations_export_dir()
void DebugInfo::export_operation(const NodeOperation *op, MemoryBuffer *render) void DebugInfo::export_operation(const NodeOperation *op, MemoryBuffer *render)
{ {
const int width = render->getWidth(); const int width = render->get_width();
const int height = render->getHeight(); const int height = render->get_height();
const int num_channels = render->get_num_channels(); const int num_channels = render->get_num_channels();
ImBuf *ibuf = IMB_allocImBuf(width, height, 8 * num_channels, IB_rectfloat); ImBuf *ibuf = IMB_allocImBuf(width, height, 8 * num_channels, IB_rectfloat);

View File

@@ -21,9 +21,11 @@
#include <map> #include <map>
#include <string> #include <string>
#include "BLI_vector.hh"
#include "COM_ExecutionSystem.h" #include "COM_ExecutionSystem.h"
#include "COM_NodeOperation.h" #include "COM_MemoryBuffer.h"
#include "COM_defines.h" #include "COM_Node.h"
namespace blender::compositor { namespace blender::compositor {
@@ -34,6 +36,7 @@ static constexpr bool COM_GRAPHVIZ_SHOW_NODE_NAME = false;
static constexpr bool COM_EXPORT_OPERATION_BUFFERS = false; static constexpr bool COM_EXPORT_OPERATION_BUFFERS = false;
class Node; class Node;
class NodeOperation;
class ExecutionSystem; class ExecutionSystem;
class ExecutionGroup; class ExecutionGroup;
@@ -49,33 +52,33 @@ class DebugInfo {
static std::string operation_name(const NodeOperation *op); static std::string operation_name(const NodeOperation *op);
private: private:
static int m_file_index; static int file_index_;
/** Map nodes to usable names for debug output. */ /** Map nodes to usable names for debug output. */
static NodeNameMap m_node_names; static NodeNameMap node_names_;
/** Map operations to usable names for debug output. */ /** Map operations to usable names for debug output. */
static OpNameMap m_op_names; static OpNameMap op_names_;
/** Base name for all operations added by a node. */ /** Base name for all operations added by a node. */
static std::string m_current_node_name; static std::string current_node_name_;
/** Base name for automatic sub-operations. */ /** Base name for automatic sub-operations. */
static std::string m_current_op_name; static std::string current_op_name_;
/** For visualizing group states. */ /** For visualizing group states. */
static GroupStateMap m_group_states; static GroupStateMap group_states_;
public: public:
static void convert_started() static void convert_started()
{ {
if (COM_EXPORT_GRAPHVIZ) { if (COM_EXPORT_GRAPHVIZ) {
m_op_names.clear(); op_names_.clear();
} }
} }
static void execute_started(const ExecutionSystem *system) static void execute_started(const ExecutionSystem *system)
{ {
if (COM_EXPORT_GRAPHVIZ) { if (COM_EXPORT_GRAPHVIZ) {
m_file_index = 1; file_index_ = 1;
m_group_states.clear(); group_states_.clear();
for (ExecutionGroup *execution_group : system->m_groups) { for (ExecutionGroup *execution_group : system->groups_) {
m_group_states[execution_group] = EG_WAIT; group_states_[execution_group] = EG_WAIT;
} }
} }
if (COM_EXPORT_OPERATION_BUFFERS) { if (COM_EXPORT_OPERATION_BUFFERS) {
@@ -86,41 +89,41 @@ class DebugInfo {
static void node_added(const Node *node) static void node_added(const Node *node)
{ {
if (COM_EXPORT_GRAPHVIZ) { if (COM_EXPORT_GRAPHVIZ) {
m_node_names[node] = std::string(node->getbNode() ? node->getbNode()->name : ""); node_names_[node] = std::string(node->get_bnode() ? node->get_bnode()->name : "");
} }
} }
static void node_to_operations(const Node *node) static void node_to_operations(const Node *node)
{ {
if (COM_EXPORT_GRAPHVIZ) { if (COM_EXPORT_GRAPHVIZ) {
m_current_node_name = m_node_names[node]; current_node_name_ = node_names_[node];
} }
} }
static void operation_added(const NodeOperation *operation) static void operation_added(const NodeOperation *operation)
{ {
if (COM_EXPORT_GRAPHVIZ) { if (COM_EXPORT_GRAPHVIZ) {
m_op_names[operation] = m_current_node_name; op_names_[operation] = current_node_name_;
} }
}; };
static void operation_read_write_buffer(const NodeOperation *operation) static void operation_read_write_buffer(const NodeOperation *operation)
{ {
if (COM_EXPORT_GRAPHVIZ) { if (COM_EXPORT_GRAPHVIZ) {
m_current_op_name = m_op_names[operation]; current_op_name_ = op_names_[operation];
} }
}; };
static void execution_group_started(const ExecutionGroup *group) static void execution_group_started(const ExecutionGroup *group)
{ {
if (COM_EXPORT_GRAPHVIZ) { if (COM_EXPORT_GRAPHVIZ) {
m_group_states[group] = EG_RUNNING; group_states_[group] = EG_RUNNING;
} }
}; };
static void execution_group_finished(const ExecutionGroup *group) static void execution_group_finished(const ExecutionGroup *group)
{ {
if (COM_EXPORT_GRAPHVIZ) { if (COM_EXPORT_GRAPHVIZ) {
m_group_states[group] = EG_FINISHED; group_states_[group] = EG_FINISHED;
} }
}; };

View File

@@ -18,10 +18,10 @@
#pragma once #pragma once
#include "COM_WorkPackage.h"
namespace blender::compositor { namespace blender::compositor {
struct WorkPackage;
/** /**
* \brief Abstract class for device implementations to be used by the Compositor. * \brief Abstract class for device implementations to be used by the Compositor.
* devices are queried, initialized and used by the WorkScheduler. * devices are queried, initialized and used by the WorkScheduler.

View File

@@ -17,7 +17,6 @@
*/ */
#include "COM_Enums.h" #include "COM_Enums.h"
#include "BLI_rect.h"
namespace blender::compositor { namespace blender::compositor {

View File

@@ -16,36 +16,21 @@
* Copyright 2011, Blender Foundation. * Copyright 2011, Blender Foundation.
*/ */
#include <algorithm> #include "COM_ExecutionGroup.h"
#include <cmath>
#include <cstdlib>
#include <sstream>
#include "atomic_ops.h"
#include "COM_ChunkOrder.h" #include "COM_ChunkOrder.h"
#include "COM_Debug.h" #include "COM_Debug.h"
#include "COM_ExecutionGroup.h"
#include "COM_ExecutionSystem.h"
#include "COM_ReadBufferOperation.h" #include "COM_ReadBufferOperation.h"
#include "COM_ViewerOperation.h" #include "COM_ViewerOperation.h"
#include "COM_WorkScheduler.h" #include "COM_WorkScheduler.h"
#include "COM_WriteBufferOperation.h" #include "COM_WriteBufferOperation.h"
#include "COM_defines.h" #include "COM_defines.h"
#include "BLI_math.h"
#include "BLI_rand.hh" #include "BLI_rand.hh"
#include "BLI_string.h"
#include "BLT_translation.h" #include "BLT_translation.h"
#include "MEM_guardedalloc.h"
#include "PIL_time.h" #include "PIL_time.h"
#include "WM_api.h"
#include "WM_types.h"
namespace blender::compositor { namespace blender::compositor {
std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags) std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags)
@@ -70,36 +55,36 @@ std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags)
ExecutionGroup::ExecutionGroup(int id) ExecutionGroup::ExecutionGroup(int id)
{ {
m_id = id; id_ = id;
this->m_bTree = nullptr; bTree_ = nullptr;
this->m_height = 0; height_ = 0;
this->m_width = 0; width_ = 0;
this->m_max_read_buffer_offset = 0; max_read_buffer_offset_ = 0;
this->m_x_chunks_len = 0; x_chunks_len_ = 0;
this->m_y_chunks_len = 0; y_chunks_len_ = 0;
this->m_chunks_len = 0; chunks_len_ = 0;
this->m_chunks_finished = 0; chunks_finished_ = 0;
BLI_rcti_init(&this->m_viewerBorder, 0, 0, 0, 0); BLI_rcti_init(&viewer_border_, 0, 0, 0, 0);
this->m_executionStartTime = 0; execution_start_time_ = 0;
} }
std::ostream &operator<<(std::ostream &os, const ExecutionGroup &execution_group) std::ostream &operator<<(std::ostream &os, const ExecutionGroup &execution_group)
{ {
os << "ExecutionGroup(id=" << execution_group.get_id(); os << "ExecutionGroup(id=" << execution_group.get_id();
os << ",flags={" << execution_group.get_flags() << "}"; os << ",flags={" << execution_group.get_flags() << "}";
os << ",operation=" << *execution_group.getOutputOperation() << ""; os << ",operation=" << *execution_group.get_output_operation() << "";
os << ")"; os << ")";
return 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) bool ExecutionGroup::can_contain(NodeOperation &operation)
{ {
if (!m_flags.initialized) { if (!flags_.initialized) {
return true; return true;
} }
@@ -114,7 +99,7 @@ bool ExecutionGroup::can_contain(NodeOperation &operation)
} }
/* complex groups don't allow further ops (except read buffer and values, see above) */ /* complex groups don't allow further ops (except read buffer and values, see above) */
if (m_flags.complex) { if (flags_.complex) {
return false; return false;
} }
/* complex ops can't be added to other groups (except their own, which they initialize, see /* complex ops can't be added to other groups (except their own, which they initialize, see
@@ -126,7 +111,7 @@ bool ExecutionGroup::can_contain(NodeOperation &operation)
return true; return true;
} }
bool ExecutionGroup::addOperation(NodeOperation *operation) bool ExecutionGroup::add_operation(NodeOperation *operation)
{ {
if (!can_contain(*operation)) { if (!can_contain(*operation)) {
return false; return false;
@@ -134,34 +119,34 @@ bool ExecutionGroup::addOperation(NodeOperation *operation)
if (!operation->get_flags().is_read_buffer_operation && if (!operation->get_flags().is_read_buffer_operation &&
!operation->get_flags().is_write_buffer_operation) { !operation->get_flags().is_write_buffer_operation) {
m_flags.complex = operation->get_flags().complex; flags_.complex = operation->get_flags().complex;
m_flags.open_cl = operation->get_flags().open_cl; flags_.open_cl = operation->get_flags().open_cl;
m_flags.single_threaded = operation->get_flags().single_threaded; flags_.single_threaded = operation->get_flags().single_threaded;
m_flags.initialized = true; flags_.initialized = true;
} }
m_operations.append(operation); operations_.append(operation);
return true; return true;
} }
NodeOperation *ExecutionGroup::getOutputOperation() const NodeOperation *ExecutionGroup::get_output_operation() const
{ {
return this return this
->m_operations[0]; /* the first operation of the group is always the output operation. */ ->operations_[0]; /* the first operation of the group is always the output operation. */
} }
void ExecutionGroup::init_work_packages() void ExecutionGroup::init_work_packages()
{ {
m_work_packages.clear(); work_packages_.clear();
if (this->m_chunks_len != 0) { if (chunks_len_ != 0) {
m_work_packages.resize(this->m_chunks_len); work_packages_.resize(chunks_len_);
for (unsigned int index = 0; index < m_chunks_len; index++) { for (unsigned int index = 0; index < chunks_len_; index++) {
m_work_packages[index].type = eWorkPackageType::Tile; work_packages_[index].type = eWorkPackageType::Tile;
m_work_packages[index].state = eWorkPackageState::NotScheduled; work_packages_[index].state = eWorkPackageState::NotScheduled;
m_work_packages[index].execution_group = this; work_packages_[index].execution_group = this;
m_work_packages[index].chunk_number = index; work_packages_[index].chunk_number = index;
determineChunkRect(&m_work_packages[index].rect, index); determine_chunk_rect(&work_packages_[index].rect, index);
} }
} }
} }
@@ -169,68 +154,68 @@ void ExecutionGroup::init_work_packages()
void ExecutionGroup::init_read_buffer_operations() void ExecutionGroup::init_read_buffer_operations()
{ {
unsigned int max_offset = 0; unsigned int max_offset = 0;
for (NodeOperation *operation : m_operations) { for (NodeOperation *operation : operations_) {
if (operation->get_flags().is_read_buffer_operation) { if (operation->get_flags().is_read_buffer_operation) {
ReadBufferOperation *readOperation = static_cast<ReadBufferOperation *>(operation); ReadBufferOperation *read_operation = static_cast<ReadBufferOperation *>(operation);
this->m_read_operations.append(readOperation); read_operations_.append(read_operation);
max_offset = MAX2(max_offset, readOperation->getOffset()); max_offset = MAX2(max_offset, read_operation->get_offset());
} }
} }
max_offset++; max_offset++;
this->m_max_read_buffer_offset = max_offset; max_read_buffer_offset_ = max_offset;
} }
void ExecutionGroup::initExecution() void ExecutionGroup::init_execution()
{ {
init_number_of_chunks(); init_number_of_chunks();
init_work_packages(); init_work_packages();
init_read_buffer_operations(); init_read_buffer_operations();
} }
void ExecutionGroup::deinitExecution() void ExecutionGroup::deinit_execution()
{ {
m_work_packages.clear(); work_packages_.clear();
this->m_chunks_len = 0; chunks_len_ = 0;
this->m_x_chunks_len = 0; x_chunks_len_ = 0;
this->m_y_chunks_len = 0; y_chunks_len_ = 0;
this->m_read_operations.clear(); read_operations_.clear();
this->m_bTree = nullptr; bTree_ = nullptr;
} }
void ExecutionGroup::determineResolution(unsigned int resolution[2]) void ExecutionGroup::determine_resolution(unsigned int resolution[2])
{ {
NodeOperation *operation = this->getOutputOperation(); NodeOperation *operation = this->get_output_operation();
resolution[0] = operation->getWidth(); resolution[0] = operation->get_width();
resolution[1] = operation->getHeight(); resolution[1] = operation->get_height();
this->setResolution(resolution); this->set_resolution(resolution);
BLI_rcti_init(&this->m_viewerBorder, 0, this->m_width, 0, this->m_height); BLI_rcti_init(&viewer_border_, 0, width_, 0, height_);
} }
void ExecutionGroup::init_number_of_chunks() void ExecutionGroup::init_number_of_chunks()
{ {
if (this->m_flags.single_threaded) { if (flags_.single_threaded) {
this->m_x_chunks_len = 1; x_chunks_len_ = 1;
this->m_y_chunks_len = 1; y_chunks_len_ = 1;
this->m_chunks_len = 1; chunks_len_ = 1;
} }
else { else {
const float chunkSizef = this->m_chunkSize; const float chunk_sizef = chunk_size_;
const int border_width = BLI_rcti_size_x(&this->m_viewerBorder); const int border_width = BLI_rcti_size_x(&viewer_border_);
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder); const int border_height = BLI_rcti_size_y(&viewer_border_);
this->m_x_chunks_len = ceil(border_width / chunkSizef); x_chunks_len_ = ceil(border_width / chunk_sizef);
this->m_y_chunks_len = ceil(border_height / chunkSizef); y_chunks_len_ = ceil(border_height / chunk_sizef);
this->m_chunks_len = this->m_x_chunks_len * this->m_y_chunks_len; chunks_len_ = x_chunks_len_ * y_chunks_len_;
} }
} }
blender::Array<unsigned int> ExecutionGroup::get_execution_order() const blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
{ {
blender::Array<unsigned int> chunk_order(m_chunks_len); blender::Array<unsigned int> chunk_order(chunks_len_);
for (int chunk_index = 0; chunk_index < this->m_chunks_len; chunk_index++) { for (int chunk_index = 0; chunk_index < chunks_len_; chunk_index++) {
chunk_order[chunk_index] = chunk_index; chunk_order[chunk_index] = chunk_index;
} }
NodeOperation *operation = this->getOutputOperation(); NodeOperation *operation = this->get_output_operation();
float centerX = 0.5f; float centerX = 0.5f;
float centerY = 0.5f; float centerY = 0.5f;
ChunkOrdering order_type = ChunkOrdering::Default; ChunkOrdering order_type = ChunkOrdering::Default;
@@ -239,11 +224,11 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
ViewerOperation *viewer = (ViewerOperation *)operation; ViewerOperation *viewer = (ViewerOperation *)operation;
centerX = viewer->getCenterX(); centerX = viewer->getCenterX();
centerY = viewer->getCenterY(); centerY = viewer->getCenterY();
order_type = viewer->getChunkOrder(); order_type = viewer->get_chunk_order();
} }
const int border_width = BLI_rcti_size_x(&this->m_viewerBorder); const int border_width = BLI_rcti_size_x(&viewer_border_);
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder); const int border_height = BLI_rcti_size_y(&viewer_border_);
int index; int index;
switch (order_type) { switch (order_type) {
case ChunkOrdering::Random: { case ChunkOrdering::Random: {
@@ -256,17 +241,17 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
} }
case ChunkOrdering::CenterOut: { case ChunkOrdering::CenterOut: {
ChunkOrderHotspot hotspot(border_width * centerX, border_height * centerY, 0.0f); ChunkOrderHotspot hotspot(border_width * centerX, border_height * centerY, 0.0f);
blender::Array<ChunkOrder> chunk_orders(m_chunks_len); blender::Array<ChunkOrder> chunk_orders(chunks_len_);
for (index = 0; index < this->m_chunks_len; index++) { for (index = 0; index < chunks_len_; index++) {
const WorkPackage &work_package = m_work_packages[index]; const WorkPackage &work_package = work_packages_[index];
chunk_orders[index].index = index; chunk_orders[index].index = index;
chunk_orders[index].x = work_package.rect.xmin - this->m_viewerBorder.xmin; chunk_orders[index].x = work_package.rect.xmin - viewer_border_.xmin;
chunk_orders[index].y = work_package.rect.ymin - this->m_viewerBorder.ymin; chunk_orders[index].y = work_package.rect.ymin - viewer_border_.ymin;
chunk_orders[index].update_distance(&hotspot, 1); chunk_orders[index].update_distance(&hotspot, 1);
} }
std::sort(&chunk_orders[0], &chunk_orders[this->m_chunks_len - 1]); std::sort(&chunk_orders[0], &chunk_orders[chunks_len_ - 1]);
for (index = 0; index < this->m_chunks_len; index++) { for (index = 0; index < chunks_len_; index++) {
chunk_order[index] = chunk_orders[index].index; chunk_order[index] = chunk_orders[index].index;
} }
@@ -279,7 +264,7 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
unsigned int my = border_height / 2; unsigned int my = border_height / 2;
unsigned int bx = mx + 2 * tx; unsigned int bx = mx + 2 * tx;
unsigned int by = my + 2 * ty; unsigned int by = my + 2 * ty;
float addition = this->m_chunks_len / COM_RULE_OF_THIRDS_DIVIDER; float addition = chunks_len_ / COM_RULE_OF_THIRDS_DIVIDER;
ChunkOrderHotspot hotspots[9]{ ChunkOrderHotspot hotspots[9]{
ChunkOrderHotspot(mx, my, addition * 0), ChunkOrderHotspot(mx, my, addition * 0),
@@ -293,18 +278,18 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
ChunkOrderHotspot(mx, by, addition * 8), ChunkOrderHotspot(mx, by, addition * 8),
}; };
blender::Array<ChunkOrder> chunk_orders(m_chunks_len); blender::Array<ChunkOrder> chunk_orders(chunks_len_);
for (index = 0; index < this->m_chunks_len; index++) { for (index = 0; index < chunks_len_; index++) {
const WorkPackage &work_package = m_work_packages[index]; const WorkPackage &work_package = work_packages_[index];
chunk_orders[index].index = index; chunk_orders[index].index = index;
chunk_orders[index].x = work_package.rect.xmin - this->m_viewerBorder.xmin; chunk_orders[index].x = work_package.rect.xmin - viewer_border_.xmin;
chunk_orders[index].y = work_package.rect.ymin - this->m_viewerBorder.ymin; chunk_orders[index].y = work_package.rect.ymin - viewer_border_.ymin;
chunk_orders[index].update_distance(hotspots, 9); chunk_orders[index].update_distance(hotspots, 9);
} }
std::sort(&chunk_orders[0], &chunk_orders[this->m_chunks_len]); std::sort(&chunk_orders[0], &chunk_orders[chunks_len_]);
for (index = 0; index < this->m_chunks_len; index++) { for (index = 0; index < chunks_len_; index++) {
chunk_order[index] = chunk_orders[index].index; chunk_order[index] = chunk_orders[index].index;
} }
@@ -323,23 +308,23 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
*/ */
void ExecutionGroup::execute(ExecutionSystem *graph) void ExecutionGroup::execute(ExecutionSystem *graph)
{ {
const CompositorContext &context = graph->getContext(); const CompositorContext &context = graph->get_context();
const bNodeTree *bTree = context.getbNodeTree(); const bNodeTree *bTree = context.get_bnodetree();
if (this->m_width == 0 || this->m_height == 0) { if (width_ == 0 || height_ == 0) {
return; return;
} /** \note Break out... no pixels to calculate. */ } /** \note Break out... no pixels to calculate. */
if (bTree->test_break && bTree->test_break(bTree->tbh)) { if (bTree->test_break && bTree->test_break(bTree->tbh)) {
return; return;
} /** \note Early break out for blur and preview nodes. */ } /** \note Early break out for blur and preview nodes. */
if (this->m_chunks_len == 0) { if (chunks_len_ == 0) {
return; return;
} /** \note Early break out. */ } /** \note Early break out. */
unsigned int chunk_index; unsigned int chunk_index;
this->m_executionStartTime = PIL_check_seconds_timer(); execution_start_time_ = PIL_check_seconds_timer();
this->m_chunks_finished = 0; chunks_finished_ = 0;
this->m_bTree = bTree; bTree_ = bTree;
blender::Array<unsigned int> chunk_order = get_execution_order(); blender::Array<unsigned int> chunk_order = get_execution_order();
@@ -348,27 +333,26 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
bool breaked = false; bool breaked = false;
bool finished = false; bool finished = false;
unsigned int startIndex = 0; unsigned int start_index = 0;
const int maxNumberEvaluated = BLI_system_thread_count() * 2; const int max_number_evaluated = BLI_system_thread_count() * 2;
while (!finished && !breaked) { while (!finished && !breaked) {
bool startEvaluated = false; bool start_evaluated = false;
finished = true; finished = true;
int numberEvaluated = 0; int number_evaluated = 0;
for (int index = startIndex; for (int index = start_index; index < chunks_len_ && number_evaluated < max_number_evaluated;
index < this->m_chunks_len && numberEvaluated < maxNumberEvaluated;
index++) { index++) {
chunk_index = chunk_order[index]; chunk_index = chunk_order[index];
int yChunk = chunk_index / this->m_x_chunks_len; int y_chunk = chunk_index / x_chunks_len_;
int xChunk = chunk_index - (yChunk * this->m_x_chunks_len); int x_chunk = chunk_index - (y_chunk * x_chunks_len_);
const WorkPackage &work_package = m_work_packages[chunk_index]; const WorkPackage &work_package = work_packages_[chunk_index];
switch (work_package.state) { switch (work_package.state) {
case eWorkPackageState::NotScheduled: { case eWorkPackageState::NotScheduled: {
scheduleChunkWhenPossible(graph, xChunk, yChunk); schedule_chunk_when_possible(graph, x_chunk, y_chunk);
finished = false; finished = false;
startEvaluated = true; start_evaluated = true;
numberEvaluated++; number_evaluated++;
if (bTree->update_draw) { if (bTree->update_draw) {
bTree->update_draw(bTree->udh); bTree->update_draw(bTree->udh);
@@ -377,13 +361,13 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
} }
case eWorkPackageState::Scheduled: { case eWorkPackageState::Scheduled: {
finished = false; finished = false;
startEvaluated = true; start_evaluated = true;
numberEvaluated++; number_evaluated++;
break; break;
} }
case eWorkPackageState::Executed: { case eWorkPackageState::Executed: {
if (!startEvaluated) { if (!start_evaluated) {
startIndex = index + 1; start_index = index + 1;
} }
} }
}; };
@@ -399,139 +383,135 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
DebugInfo::graphviz(graph); DebugInfo::graphviz(graph);
} }
MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber) MemoryBuffer **ExecutionGroup::get_input_buffers_opencl(int chunk_number)
{ {
WorkPackage &work_package = m_work_packages[chunkNumber]; WorkPackage &work_package = work_packages_[chunk_number];
MemoryBuffer **memoryBuffers = (MemoryBuffer **)MEM_callocN( MemoryBuffer **memory_buffers = (MemoryBuffer **)MEM_callocN(
sizeof(MemoryBuffer *) * this->m_max_read_buffer_offset, __func__); sizeof(MemoryBuffer *) * max_read_buffer_offset_, __func__);
rcti output; rcti output;
for (ReadBufferOperation *readOperation : m_read_operations) { for (ReadBufferOperation *read_operation : read_operations_) {
MemoryProxy *memoryProxy = readOperation->getMemoryProxy(); MemoryProxy *memory_proxy = read_operation->get_memory_proxy();
this->determineDependingAreaOfInterest(&work_package.rect, readOperation, &output); this->determine_depending_area_of_interest(&work_package.rect, read_operation, &output);
MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer( MemoryBuffer *memory_buffer =
*memoryProxy, output); memory_proxy->get_executor()->construct_consolidated_memory_buffer(*memory_proxy, output);
memoryBuffers[readOperation->getOffset()] = memoryBuffer; memory_buffers[read_operation->get_offset()] = memory_buffer;
} }
return memoryBuffers; return memory_buffers;
} }
MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy &memoryProxy, MemoryBuffer *ExecutionGroup::construct_consolidated_memory_buffer(MemoryProxy &memory_proxy,
rcti &rect) rcti &rect)
{ {
MemoryBuffer *imageBuffer = memoryProxy.getBuffer(); MemoryBuffer *image_buffer = memory_proxy.get_buffer();
MemoryBuffer *result = new MemoryBuffer(&memoryProxy, rect, MemoryBufferState::Temporary); MemoryBuffer *result = new MemoryBuffer(&memory_proxy, rect, MemoryBufferState::Temporary);
result->fill_from(*imageBuffer); result->fill_from(*image_buffer);
return result; return result;
} }
void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers) void ExecutionGroup::finalize_chunk_execution(int chunk_number, MemoryBuffer **memory_buffers)
{ {
WorkPackage &work_package = m_work_packages[chunkNumber]; WorkPackage &work_package = work_packages_[chunk_number];
if (work_package.state == eWorkPackageState::Scheduled) { if (work_package.state == eWorkPackageState::Scheduled) {
work_package.state = eWorkPackageState::Executed; work_package.state = eWorkPackageState::Executed;
} }
atomic_add_and_fetch_u(&this->m_chunks_finished, 1); atomic_add_and_fetch_u(&chunks_finished_, 1);
if (memoryBuffers) { if (memory_buffers) {
for (unsigned int index = 0; index < this->m_max_read_buffer_offset; index++) { for (unsigned int index = 0; index < max_read_buffer_offset_; index++) {
MemoryBuffer *buffer = memoryBuffers[index]; MemoryBuffer *buffer = memory_buffers[index];
if (buffer) { if (buffer) {
if (buffer->isTemporarily()) { if (buffer->is_temporarily()) {
memoryBuffers[index] = nullptr; memory_buffers[index] = nullptr;
delete buffer; delete buffer;
} }
} }
} }
MEM_freeN(memoryBuffers); MEM_freeN(memory_buffers);
} }
if (this->m_bTree) { if (bTree_) {
/* Status report is only performed for top level Execution Groups. */ /* Status report is only performed for top level Execution Groups. */
float progress = this->m_chunks_finished; float progress = chunks_finished_;
progress /= this->m_chunks_len; progress /= chunks_len_;
this->m_bTree->progress(this->m_bTree->prh, progress); bTree_->progress(bTree_->prh, progress);
char buf[128]; char buf[128];
BLI_snprintf(buf, BLI_snprintf(
sizeof(buf), buf, sizeof(buf), TIP_("Compositing | Tile %u-%u"), chunks_finished_, chunks_len_);
TIP_("Compositing | Tile %u-%u"), bTree_->stats_draw(bTree_->sdh, buf);
this->m_chunks_finished,
this->m_chunks_len);
this->m_bTree->stats_draw(this->m_bTree->sdh, buf);
} }
} }
inline void ExecutionGroup::determineChunkRect(rcti *r_rect, inline void ExecutionGroup::determine_chunk_rect(rcti *r_rect,
const unsigned int xChunk, const unsigned int x_chunk,
const unsigned int yChunk) const const unsigned int y_chunk) const
{ {
const int border_width = BLI_rcti_size_x(&this->m_viewerBorder); const int border_width = BLI_rcti_size_x(&viewer_border_);
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder); const int border_height = BLI_rcti_size_y(&viewer_border_);
if (this->m_flags.single_threaded) { if (flags_.single_threaded) {
BLI_rcti_init( BLI_rcti_init(r_rect, viewer_border_.xmin, border_width, viewer_border_.ymin, border_height);
r_rect, this->m_viewerBorder.xmin, border_width, this->m_viewerBorder.ymin, border_height);
} }
else { else {
const unsigned int minx = xChunk * this->m_chunkSize + this->m_viewerBorder.xmin; const unsigned int minx = x_chunk * chunk_size_ + viewer_border_.xmin;
const unsigned int miny = yChunk * this->m_chunkSize + this->m_viewerBorder.ymin; const unsigned int miny = y_chunk * chunk_size_ + viewer_border_.ymin;
const unsigned int width = MIN2((unsigned int)this->m_viewerBorder.xmax, this->m_width); const unsigned int width = MIN2((unsigned int)viewer_border_.xmax, width_);
const unsigned int height = MIN2((unsigned int)this->m_viewerBorder.ymax, this->m_height); const unsigned int height = MIN2((unsigned int)viewer_border_.ymax, height_);
BLI_rcti_init(r_rect, BLI_rcti_init(r_rect,
MIN2(minx, this->m_width), MIN2(minx, width_),
MIN2(minx + this->m_chunkSize, width), MIN2(minx + chunk_size_, width),
MIN2(miny, this->m_height), MIN2(miny, height_),
MIN2(miny + this->m_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 / this->m_x_chunks_len; const unsigned int y_chunk = chunk_number / x_chunks_len_;
const unsigned int xChunk = chunkNumber - (yChunk * this->m_x_chunks_len); const unsigned int x_chunk = chunk_number - (y_chunk * x_chunks_len_);
determineChunkRect(r_rect, xChunk, yChunk); 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. */ /* 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) { if (operation->get_flags().is_write_buffer_operation) {
WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation; WriteBufferOperation *write_operation = (WriteBufferOperation *)operation;
MemoryBuffer *buffer = new MemoryBuffer( MemoryBuffer *buffer = new MemoryBuffer(
writeOperation->getMemoryProxy(), rect, MemoryBufferState::Temporary); write_operation->get_memory_proxy(), rect, MemoryBufferState::Temporary);
return buffer; return buffer;
} }
return nullptr; return nullptr;
} }
bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area) bool ExecutionGroup::schedule_area_when_possible(ExecutionSystem *graph, rcti *area)
{ {
if (this->m_flags.single_threaded) { if (flags_.single_threaded) {
return scheduleChunkWhenPossible(graph, 0, 0); return schedule_chunk_when_possible(graph, 0, 0);
} }
/* Find all chunks inside the rect /* Find all chunks inside the rect
* determine `minxchunk`, `minychunk`, `maxxchunk`, `maxychunk` * determine `minxchunk`, `minychunk`, `maxxchunk`, `maxychunk`
* where x and y are chunk-numbers. */ * where x and y are chunk-numbers. */
int indexx, indexy; int indexx, indexy;
int minx = max_ii(area->xmin - m_viewerBorder.xmin, 0); int minx = max_ii(area->xmin - viewer_border_.xmin, 0);
int maxx = min_ii(area->xmax - m_viewerBorder.xmin, m_viewerBorder.xmax - m_viewerBorder.xmin); int maxx = min_ii(area->xmax - viewer_border_.xmin, viewer_border_.xmax - viewer_border_.xmin);
int miny = max_ii(area->ymin - m_viewerBorder.ymin, 0); int miny = max_ii(area->ymin - viewer_border_.ymin, 0);
int maxy = min_ii(area->ymax - m_viewerBorder.ymin, m_viewerBorder.ymax - m_viewerBorder.ymin); int maxy = min_ii(area->ymax - viewer_border_.ymin, viewer_border_.ymax - viewer_border_.ymin);
int minxchunk = minx / (int)m_chunkSize; int minxchunk = minx / (int)chunk_size_;
int maxxchunk = (maxx + (int)m_chunkSize - 1) / (int)m_chunkSize; int maxxchunk = (maxx + (int)chunk_size_ - 1) / (int)chunk_size_;
int minychunk = miny / (int)m_chunkSize; int minychunk = miny / (int)chunk_size_;
int maxychunk = (maxy + (int)m_chunkSize - 1) / (int)m_chunkSize; int maxychunk = (maxy + (int)chunk_size_ - 1) / (int)chunk_size_;
minxchunk = max_ii(minxchunk, 0); minxchunk = max_ii(minxchunk, 0);
minychunk = max_ii(minychunk, 0); minychunk = max_ii(minychunk, 0);
maxxchunk = min_ii(maxxchunk, (int)m_x_chunks_len); maxxchunk = min_ii(maxxchunk, (int)x_chunks_len_);
maxychunk = min_ii(maxychunk, (int)m_y_chunks_len); maxychunk = min_ii(maxychunk, (int)y_chunks_len_);
bool result = true; bool result = true;
for (indexx = minxchunk; indexx < maxxchunk; indexx++) { for (indexx = minxchunk; indexx < maxxchunk; indexx++) {
for (indexy = minychunk; indexy < maxychunk; indexy++) { for (indexy = minychunk; indexy < maxychunk; indexy++) {
if (!scheduleChunkWhenPossible(graph, indexx, indexy)) { if (!schedule_chunk_when_possible(graph, indexx, indexy)) {
result = false; result = false;
} }
} }
@@ -540,9 +520,9 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area
return result; return result;
} }
bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber) bool ExecutionGroup::schedule_chunk(unsigned int chunk_number)
{ {
WorkPackage &work_package = m_work_packages[chunkNumber]; WorkPackage &work_package = work_packages_[chunk_number];
if (work_package.state == eWorkPackageState::NotScheduled) { if (work_package.state == eWorkPackageState::NotScheduled) {
work_package.state = eWorkPackageState::Scheduled; work_package.state = eWorkPackageState::Scheduled;
WorkScheduler::schedule(&work_package); WorkScheduler::schedule(&work_package);
@@ -551,20 +531,20 @@ bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber)
return false; return false;
} }
bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, bool ExecutionGroup::schedule_chunk_when_possible(ExecutionSystem *graph,
const int chunk_x, const int chunk_x,
const int chunk_y) const int chunk_y)
{ {
if (chunk_x < 0 || chunk_x >= (int)this->m_x_chunks_len) { if (chunk_x < 0 || chunk_x >= (int)x_chunks_len_) {
return true; return true;
} }
if (chunk_y < 0 || chunk_y >= (int)this->m_y_chunks_len) { if (chunk_y < 0 || chunk_y >= (int)y_chunks_len_) {
return true; return true;
} }
/* Check if chunk is already executed or scheduled and not yet executed. */ /* Check if chunk is already executed or scheduled and not yet executed. */
const int chunk_index = chunk_y * this->m_x_chunks_len + chunk_x; const int chunk_index = chunk_y * x_chunks_len_ + chunk_x;
WorkPackage &work_package = m_work_packages[chunk_index]; WorkPackage &work_package = work_packages_[chunk_index];
if (work_package.state == eWorkPackageState::Executed) { if (work_package.state == eWorkPackageState::Executed) {
return true; return true;
} }
@@ -575,52 +555,45 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph,
bool can_be_executed = true; bool can_be_executed = true;
rcti area; rcti area;
for (ReadBufferOperation *read_operation : m_read_operations) { for (ReadBufferOperation *read_operation : read_operations_) {
BLI_rcti_init(&area, 0, 0, 0, 0); BLI_rcti_init(&area, 0, 0, 0, 0);
MemoryProxy *memory_proxy = read_operation->getMemoryProxy(); MemoryProxy *memory_proxy = read_operation->get_memory_proxy();
determineDependingAreaOfInterest(&work_package.rect, read_operation, &area); determine_depending_area_of_interest(&work_package.rect, read_operation, &area);
ExecutionGroup *group = memory_proxy->getExecutor(); ExecutionGroup *group = memory_proxy->get_executor();
if (!group->scheduleAreaWhenPossible(graph, &area)) { if (!group->schedule_area_when_possible(graph, &area)) {
can_be_executed = false; can_be_executed = false;
} }
} }
if (can_be_executed) { if (can_be_executed) {
scheduleChunk(chunk_index); schedule_chunk(chunk_index);
} }
return false; return false;
} }
void ExecutionGroup::determineDependingAreaOfInterest(rcti *input, void ExecutionGroup::determine_depending_area_of_interest(rcti *input,
ReadBufferOperation *readOperation, ReadBufferOperation *read_operation,
rcti *output) 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) { if (operation.get_flags().use_viewer_border) {
BLI_rcti_init(&this->m_viewerBorder, BLI_rcti_init(&viewer_border_, xmin * width_, xmax * width_, ymin * height_, ymax * height_);
xmin * this->m_width,
xmax * this->m_width,
ymin * this->m_height,
ymax * this->m_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(); const NodeOperation &operation = *this->get_output_operation();
if (operation.isOutputOperation(true) && operation.get_flags().use_render_border) { if (operation.is_output_operation(true) && operation.get_flags().use_render_border) {
BLI_rcti_init(&this->m_viewerBorder, BLI_rcti_init(&viewer_border_, xmin * width_, xmax * width_, ymin * height_, ymax * height_);
xmin * this->m_width,
xmax * this->m_width,
ymin * this->m_height,
ymax * this->m_height);
} }
} }

View File

@@ -22,25 +22,24 @@
# include "MEM_guardedalloc.h" # include "MEM_guardedalloc.h"
#endif #endif
#include <iostream>
#include "BLI_array.hh" #include "BLI_array.hh"
#include "BLI_rect.h"
#include "BLI_vector.hh" #include "BLI_vector.hh"
#include "COM_CompositorContext.h" #include "COM_Enums.h"
#include "COM_Device.h"
#include "COM_MemoryProxy.h"
#include "COM_Node.h"
#include "COM_NodeOperation.h"
#include "COM_WorkPackage.h" #include "COM_WorkPackage.h"
#include <vector>
#include "DNA_node_types.h"
#include "DNA_vec_types.h"
namespace blender::compositor { namespace blender::compositor {
class ExecutionSystem; class ExecutionSystem;
class NodeOperation;
class MemoryProxy; class MemoryProxy;
class MemoryBuffer; class MemoryBuffer;
class ReadBufferOperation; class ReadBufferOperation;
class Device;
struct ExecutionGroupFlags { struct ExecutionGroupFlags {
bool initialized : 1; bool initialized : 1;
@@ -87,84 +86,84 @@ class ExecutionGroup {
/** /**
* Id of the execution group. For debugging purposes. * Id of the execution group. For debugging purposes.
*/ */
int m_id; int id_;
/** /**
* \brief list of operations in this ExecutionGroup * \brief list of operations in this ExecutionGroup
*/ */
Vector<NodeOperation *> m_operations; Vector<NodeOperation *> operations_;
ExecutionGroupFlags m_flags; ExecutionGroupFlags flags_;
/** /**
* \brief Width of the output * \brief Width of the output
*/ */
unsigned int m_width; unsigned int width_;
/** /**
* \brief Height of the output * \brief Height of the output
*/ */
unsigned int m_height; unsigned int height_;
/** /**
* \brief size of a single chunk, being Width or of height * \brief size of a single chunk, being Width or of height
* a chunk is always a square, except at the edges of the MemoryBuffer * a chunk is always a square, except at the edges of the MemoryBuffer
*/ */
unsigned int m_chunkSize; unsigned int chunk_size_;
/** /**
* \brief number of chunks in the x-axis * \brief number of chunks in the x-axis
*/ */
unsigned int m_x_chunks_len; unsigned int x_chunks_len_;
/** /**
* \brief number of chunks in the y-axis * \brief number of chunks in the y-axis
*/ */
unsigned int m_y_chunks_len; unsigned int y_chunks_len_;
/** /**
* \brief total number of chunks * \brief total number of chunks
*/ */
unsigned int m_chunks_len; unsigned int chunks_len_;
/** /**
* \brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup. * \brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup.
* \note this is used to construct the MemoryBuffers that will be passed during execution. * \note this is used to construct the MemoryBuffers that will be passed during execution.
*/ */
unsigned int m_max_read_buffer_offset; unsigned int max_read_buffer_offset_;
/** /**
* \brief All read operations of this execution group. * \brief All read operations of this execution group.
*/ */
Vector<ReadBufferOperation *> m_read_operations; Vector<ReadBufferOperation *> read_operations_;
/** /**
* \brief reference to the original bNodeTree, * \brief reference to the original bNodeTree,
* this field is only set for the 'top' execution group. * this field is only set for the 'top' execution group.
* \note can only be used to call the callbacks for progress, status and break. * \note can only be used to call the callbacks for progress, status and break.
*/ */
const bNodeTree *m_bTree; const bNodeTree *bTree_;
/** /**
* \brief total number of chunks that have been calculated for this ExecutionGroup * \brief total number of chunks that have been calculated for this ExecutionGroup
*/ */
unsigned int m_chunks_finished; unsigned int chunks_finished_;
/** /**
* \brief m_work_packages holds all unit of work. * \brief work_packages_ holds all unit of work.
*/ */
Vector<WorkPackage> m_work_packages; Vector<WorkPackage> work_packages_;
/** /**
* \brief denotes boundary for border compositing * \brief denotes boundary for border compositing
* \note measured in pixel space * \note measured in pixel space
*/ */
rcti m_viewerBorder; rcti viewer_border_;
/** /**
* \brief start time of execution * \brief start time of execution
*/ */
double m_executionStartTime; double execution_start_time_;
// methods // methods
/** /**
@@ -176,13 +175,14 @@ class ExecutionGroup {
/** /**
* \brief Determine the rect (minx, maxx, miny, maxy) of a chunk at a position. * \brief Determine the rect (minx, maxx, miny, maxy) of a chunk at a position.
*/ */
void determineChunkRect(rcti *r_rect, void determine_chunk_rect(rcti *r_rect,
const unsigned int xChunk, const unsigned int x_chunk,
const unsigned int yChunk) const; const unsigned int y_chunk) const;
/** /**
* \brief determine the number of chunks, based on the chunkSize, width and height. * \brief determine the number of chunks, based on the chunk_size, width and height.
* \note The result are stored in the fields numberOfChunks, numberOfXChunks, numberOfYChunks * \note The result are stored in the fields number_of_chunks, number_of_xchunks,
* number_of_ychunks
*/ */
void init_number_of_chunks(); void init_number_of_chunks();
@@ -191,13 +191,13 @@ class ExecutionGroup {
* \note scheduling succeeds when all input requirements are met and the chunks hasn't been * \note scheduling succeeds when all input requirements are met and the chunks hasn't been
* scheduled yet. * scheduled yet.
* \param graph: * \param graph:
* \param xChunk: * \param x_chunk:
* \param yChunk: * \param y_chunk:
* \return [true:false] * \return [true:false]
* true: package(s) are scheduled * true: package(s) are scheduled
* false: scheduling is deferred (depending workpackages 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. * \brief try to schedule a specific area.
@@ -209,23 +209,23 @@ class ExecutionGroup {
* true: package(s) are scheduled * true: package(s) are scheduled
* false: scheduling is deferred (depending workpackages 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. * \brief add a chunk to the WorkScheduler.
* \param chunknumber: * \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 * \brief determine the area of interest of a certain input area
* \note This method only evaluates a single ReadBufferOperation * \note This method only evaluates a single ReadBufferOperation
* \param input: the input area * \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 * \param output: the area needed of the ReadBufferOperation. Result
*/ */
void determineDependingAreaOfInterest(rcti *input, void determine_depending_area_of_interest(rcti *input,
ReadBufferOperation *readOperation, ReadBufferOperation *read_operation,
rcti *output); rcti *output);
/** /**
@@ -242,12 +242,12 @@ class ExecutionGroup {
int get_id() const int get_id() const
{ {
return m_id; return id_;
} }
const ExecutionGroupFlags get_flags() const const ExecutionGroupFlags get_flags() const
{ {
return m_flags; return flags_;
} }
// methods // methods
@@ -259,71 +259,71 @@ class ExecutionGroup {
* \param operation: * \param operation:
* \return True if the operation was successfully added * \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 * \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)
{ {
this->m_flags.is_output = is_output; flags_.is_output = is_output;
} }
/** /**
* \brief determine the resolution of this ExecutionGroup * \brief determine the resolution of this ExecutionGroup
* \param resolution: * \param resolution:
*/ */
void determineResolution(unsigned int resolution[2]); void determine_resolution(unsigned int resolution[2]);
/** /**
* \brief set the resolution of this executiongroup * \brief set the resolution of this executiongroup
* \param resolution: * \param resolution:
*/ */
void setResolution(unsigned int resolution[2]) void set_resolution(unsigned int resolution[2])
{ {
this->m_width = resolution[0]; width_ = resolution[0];
this->m_height = resolution[1]; height_ = resolution[1];
} }
/** /**
* \brief get the width of this execution group * \brief get the width of this execution group
*/ */
unsigned int getWidth() const unsigned int get_width() const
{ {
return m_width; return width_;
} }
/** /**
* \brief get the height of this execution group * \brief get the height of this execution group
*/ */
unsigned int getHeight() const unsigned int get_height() const
{ {
return m_height; return height_;
} }
/** /**
* \brief get the output operation of this ExecutionGroup * \brief get the output operation of this ExecutionGroup
* \return NodeOperation *output operation * \return NodeOperation *output operation
*/ */
NodeOperation *getOutputOperation() const; NodeOperation *get_output_operation() const;
/** /**
* \brief compose multiple chunks into a single chunk * \brief compose multiple chunks into a single chunk
* \return Memorybuffer *consolidated 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. * \brief init_execution is called just before the execution of the whole graph will be done.
* \note The implementation will calculate the chunkSize of this execution group. * \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 * \brief get all inputbuffers needed to calculate an chunk
* \note all inputbuffers must be executed * \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 * \return (MemoryBuffer **) the inputbuffers
*/ */
MemoryBuffer **getInputBuffersCPU(); MemoryBuffer **getInputBuffersCPU();
@@ -331,31 +331,31 @@ class ExecutionGroup {
/** /**
* \brief get all inputbuffers needed to calculate an chunk * \brief get all inputbuffers needed to calculate an chunk
* \note all inputbuffers must be executed * \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 * \return (MemoryBuffer **) the inputbuffers
*/ */
MemoryBuffer **getInputBuffersOpenCL(int chunkNumber); MemoryBuffer **get_input_buffers_opencl(int chunk_number);
/** /**
* \brief allocate the outputbuffer of a chunk * \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 * \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. * \brief after a chunk is executed the needed resources can be freed or unlocked.
* \param chunknumber: * \param chunknumber:
* \param memorybuffers: * \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 * \note It will release all needed resources
*/ */
void deinitExecution(); void deinit_execution();
/** /**
* \brief schedule an ExecutionGroup * \brief schedule an ExecutionGroup
@@ -378,26 +378,26 @@ class ExecutionGroup {
/** /**
* \brief Determine the rect (minx, maxx, miny, maxy) of a chunk. * \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)
{ {
this->m_chunkSize = chunksize; chunk_size_ = chunksize;
} }
/** /**
* \brief get the Render priority of this ExecutionGroup * \brief get the Render priority of this ExecutionGroup
* \see ExecutionSystem.execute * \see ExecutionSystem.execute
*/ */
eCompositorPriority getRenderPriority(); eCompositorPriority get_render_priority();
/** /**
* \brief set border for viewer operation * \brief set border for viewer operation
* \note all the coordinates are assumed to be in normalized space * \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 */ /* allow the DebugInfo class to look at internals */
friend class DebugInfo; friend class DebugInfo;

View File

@@ -17,13 +17,14 @@
*/ */
#include "COM_ExecutionModel.h" #include "COM_ExecutionModel.h"
#include "COM_CompositorContext.h"
namespace blender::compositor { namespace blender::compositor {
ExecutionModel::ExecutionModel(CompositorContext &context, Span<NodeOperation *> operations) ExecutionModel::ExecutionModel(CompositorContext &context, Span<NodeOperation *> operations)
: context_(context), operations_(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; const rctf *viewer_border = &node_tree->viewer_border;
border_.use_viewer_border = (node_tree->flag & NTREE_VIEWER_BORDER) && border_.use_viewer_border = (node_tree->flag & NTREE_VIEWER_BORDER) &&
@@ -31,10 +32,10 @@ ExecutionModel::ExecutionModel(CompositorContext &context, Span<NodeOperation *>
viewer_border->ymin < viewer_border->ymax; viewer_border->ymin < viewer_border->ymax;
border_.viewer_border = viewer_border; 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 /* Case when cropping to render border happens is handled in
* compositor output and render layer nodes. */ * 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); !(rd->mode & R_CROP);
border_.render_border = &rd->border; border_.render_border = &rd->border;
} }

View File

@@ -18,12 +18,9 @@
#pragma once #pragma once
#include "BLI_rect.h" #include "BLI_span.hh"
#include "BLI_vector.hh"
#include "COM_ExecutionSystem.h" #include "DNA_vec_types.h"
#include <functional>
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h" # include "MEM_guardedalloc.h"
@@ -31,6 +28,8 @@
namespace blender::compositor { namespace blender::compositor {
class CompositorContext;
class ExecutionSystem;
class NodeOperation; class NodeOperation;
/** /**

View File

@@ -18,14 +18,13 @@
#include "COM_ExecutionSystem.h" #include "COM_ExecutionSystem.h"
#include "BLI_utildefines.h"
#include "PIL_time.h"
#include "COM_Debug.h" #include "COM_Debug.h"
#include "COM_ExecutionGroup.h"
#include "COM_FullFrameExecutionModel.h" #include "COM_FullFrameExecutionModel.h"
#include "COM_NodeOperation.h" #include "COM_NodeOperation.h"
#include "COM_NodeOperationBuilder.h" #include "COM_NodeOperationBuilder.h"
#include "COM_TiledExecutionModel.h" #include "COM_TiledExecutionModel.h"
#include "COM_WorkPackage.h"
#include "COM_WorkScheduler.h" #include "COM_WorkScheduler.h"
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
@@ -39,45 +38,45 @@ ExecutionSystem::ExecutionSystem(RenderData *rd,
bNodeTree *editingtree, bNodeTree *editingtree,
bool rendering, bool rendering,
bool fastcalculation, bool fastcalculation,
const ColorManagedViewSettings *viewSettings, const ColorManagedViewSettings *view_settings,
const ColorManagedDisplaySettings *displaySettings, const ColorManagedDisplaySettings *display_settings,
const char *viewName) const char *view_name)
{ {
num_work_threads_ = WorkScheduler::get_num_cpu_threads(); num_work_threads_ = WorkScheduler::get_num_cpu_threads();
this->m_context.setViewName(viewName); context_.set_view_name(view_name);
this->m_context.setScene(scene); context_.set_scene(scene);
this->m_context.setbNodeTree(editingtree); context_.set_bnodetree(editingtree);
this->m_context.setPreviewHash(editingtree->previews); context_.set_preview_hash(editingtree->previews);
this->m_context.setFastCalculation(fastcalculation); context_.set_fast_calculation(fastcalculation);
/* initialize the CompositorContext */ /* initialize the CompositorContext */
if (rendering) { if (rendering) {
this->m_context.setQuality((eCompositorQuality)editingtree->render_quality); context_.set_quality((eCompositorQuality)editingtree->render_quality);
} }
else { else {
this->m_context.setQuality((eCompositorQuality)editingtree->edit_quality); context_.set_quality((eCompositorQuality)editingtree->edit_quality);
} }
this->m_context.setRendering(rendering); context_.set_rendering(rendering);
this->m_context.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() && context_.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() &&
(editingtree->flag & NTREE_COM_OPENCL)); (editingtree->flag & NTREE_COM_OPENCL));
this->m_context.setRenderData(rd); context_.set_render_data(rd);
this->m_context.setViewSettings(viewSettings); context_.set_view_settings(view_settings);
this->m_context.setDisplaySettings(displaySettings); context_.set_display_settings(display_settings);
BLI_mutex_init(&work_mutex_); BLI_mutex_init(&work_mutex_);
BLI_condition_init(&work_finished_cond_); BLI_condition_init(&work_finished_cond_);
{ {
NodeOperationBuilder builder(&m_context, editingtree, this); NodeOperationBuilder builder(&context_, editingtree, this);
builder.convertToOperations(this); builder.convert_to_operations(this);
} }
switch (m_context.get_execution_model()) { switch (context_.get_execution_model()) {
case eExecutionModel::Tiled: case eExecutionModel::Tiled:
execution_model_ = new TiledExecutionModel(m_context, m_operations, m_groups); execution_model_ = new TiledExecutionModel(context_, operations_, groups_);
break; break;
case eExecutionModel::FullFrame: case eExecutionModel::FullFrame:
execution_model_ = new FullFrameExecutionModel(m_context, active_buffers_, m_operations); execution_model_ = new FullFrameExecutionModel(context_, active_buffers_, operations_);
break; break;
default: default:
BLI_assert_msg(0, "Non implemented execution model"); BLI_assert_msg(0, "Non implemented execution model");
@@ -92,28 +91,28 @@ ExecutionSystem::~ExecutionSystem()
delete execution_model_; delete execution_model_;
for (NodeOperation *operation : m_operations) { for (NodeOperation *operation : operations_) {
delete operation; delete operation;
} }
this->m_operations.clear(); operations_.clear();
for (ExecutionGroup *group : m_groups) { for (ExecutionGroup *group : groups_) {
delete group; delete group;
} }
this->m_groups.clear(); groups_.clear();
} }
void ExecutionSystem::set_operations(const Vector<NodeOperation *> &operations, void ExecutionSystem::set_operations(const Vector<NodeOperation *> &operations,
const Vector<ExecutionGroup *> &groups) const Vector<ExecutionGroup *> &groups)
{ {
m_operations = operations; operations_ = operations;
m_groups = groups; groups_ = groups;
} }
void ExecutionSystem::execute() void ExecutionSystem::execute()
{ {
DebugInfo::execute_started(this); DebugInfo::execute_started(this);
for (NodeOperation *op : m_operations) { for (NodeOperation *op : operations_) {
op->init_data(); op->init_data();
} }
execution_model_->execute(*this); execution_model_->execute(*this);
@@ -185,7 +184,7 @@ void ExecutionSystem::execute_work(const rcti &work_rect,
bool ExecutionSystem::is_breaked() const bool ExecutionSystem::is_breaked() const
{ {
const bNodeTree *btree = m_context.getbNodeTree(); const bNodeTree *btree = context_.get_bnodetree();
return btree->test_break(btree->tbh); return btree->test_break(btree->tbh);
} }

View File

@@ -16,22 +16,23 @@
* Copyright 2011, Blender Foundation. * Copyright 2011, Blender Foundation.
*/ */
class ExecutionGroup;
#pragma once #pragma once
#include "BKE_text.h" #include <functional>
#include "COM_ExecutionGroup.h" #include "atomic_ops.h"
#include "COM_Node.h"
#include "COM_NodeOperation.h" #include "BLI_index_range.hh"
#include "BLI_threads.h"
#include "BLI_vector.hh"
#include "COM_CompositorContext.h"
#include "COM_SharedOperationBuffers.h" #include "COM_SharedOperationBuffers.h"
#include "DNA_color_types.h" #include "DNA_color_types.h"
#include "DNA_node_types.h" #include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "BLI_vector.hh" #include "DNA_vec_types.h"
#include "atomic_ops.h"
namespace blender::compositor { namespace blender::compositor {
@@ -63,8 +64,8 @@ namespace blender::compositor {
* based on settings; like MixNode. based on the selected Mixtype a different operation will be * 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] * used. for more information see the page about creating new Nodes. [@subpage newnode]
* *
* \see ExecutionSystem.convertToOperations * \see ExecutionSystem.convert_to_operations
* \see Node.convertToOperations * \see Node.convert_to_operations
* \see NodeOperation base class for all operations in the system * \see NodeOperation base class for all operations in the system
* *
* \section EM_Step3 Step3: add additional conversions to the operation system * \section EM_Step3 Step3: add additional conversions to the operation system
@@ -88,7 +89,7 @@ namespace blender::compositor {
* Bottom left of the images are aligned. * Bottom left of the images are aligned.
* *
* \see COM_convert_data_type Datatype conversions * \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 * \section EM_Step4 Step4: group operations in executions groups
* ExecutionGroup are groups of operations that are calculated as being one bigger operation. * ExecutionGroup are groups of operations that are calculated as being one bigger operation.
@@ -111,14 +112,16 @@ namespace blender::compositor {
* |cFAA | |cFAA | |cFAA | |cFAA | * |cFAA | |cFAA | |cFAA | |cFAA |
* +------+ +------+ +-------+ +-------+ * +------+ +------+ +-------+ +-------+
* </pre> * </pre>
* \see ExecutionSystem.groupOperations method doing this step * \see ExecutionSystem.group_operations method doing this step
* \see ExecutionSystem.addReadWriteBufferOperations * \see ExecutionSystem.add_read_write_buffer_operations
* \see NodeOperation.isComplex * \see NodeOperation.is_complex
* \see ExecutionGroup class representing the ExecutionGroup * \see ExecutionGroup class representing the ExecutionGroup
*/ */
/* Forward declarations. */ /* Forward declarations. */
class ExecutionGroup;
class ExecutionModel; class ExecutionModel;
class NodeOperation;
/** /**
* \brief the ExecutionSystem contains the whole compositor tree. * \brief the ExecutionSystem contains the whole compositor tree.
@@ -134,17 +137,17 @@ class ExecutionSystem {
/** /**
* \brief the context used during execution * \brief the context used during execution
*/ */
CompositorContext m_context; CompositorContext context_;
/** /**
* \brief vector of operations * \brief vector of operations
*/ */
Vector<NodeOperation *> m_operations; Vector<NodeOperation *> operations_;
/** /**
* \brief vector of groups * \brief vector of groups
*/ */
Vector<ExecutionGroup *> m_groups; Vector<ExecutionGroup *> groups_;
/** /**
* Active execution model implementation. * Active execution model implementation.
@@ -172,9 +175,9 @@ class ExecutionSystem {
bNodeTree *editingtree, bNodeTree *editingtree,
bool rendering, bool rendering,
bool fastcalculation, bool fastcalculation,
const ColorManagedViewSettings *viewSettings, const ColorManagedViewSettings *view_settings,
const ColorManagedDisplaySettings *displaySettings, const ColorManagedDisplaySettings *display_settings,
const char *viewName); const char *view_name);
/** /**
* Destructor * Destructor
@@ -195,9 +198,9 @@ class ExecutionSystem {
/** /**
* \brief get the reference to the compositor context * \brief get the reference to the compositor context
*/ */
const CompositorContext &getContext() const const CompositorContext &get_context() const
{ {
return this->m_context; return context_;
} }
SharedOperationBuffers &get_active_buffers() SharedOperationBuffers &get_active_buffers()

View File

@@ -17,14 +17,13 @@
*/ */
#include "COM_FullFrameExecutionModel.h" #include "COM_FullFrameExecutionModel.h"
#include "COM_Debug.h"
#include "COM_ExecutionGroup.h"
#include "COM_ReadBufferOperation.h"
#include "COM_ViewerOperation.h"
#include "COM_WorkScheduler.h"
#include "BLT_translation.h" #include "BLT_translation.h"
#include "COM_Debug.h"
#include "COM_ViewerOperation.h"
#include "COM_WorkScheduler.h"
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h" # include "MEM_guardedalloc.h"
#endif #endif
@@ -39,7 +38,7 @@ FullFrameExecutionModel::FullFrameExecutionModel(CompositorContext &context,
num_operations_finished_(0) num_operations_finished_(0)
{ {
priorities_.append(eCompositorPriority::High); priorities_.append(eCompositorPriority::High);
if (!context.isFastCalculation()) { if (!context.is_fast_calculation()) {
priorities_.append(eCompositorPriority::Medium); priorities_.append(eCompositorPriority::Medium);
priorities_.append(eCompositorPriority::Low); priorities_.append(eCompositorPriority::Low);
} }
@@ -47,7 +46,7 @@ FullFrameExecutionModel::FullFrameExecutionModel(CompositorContext &context,
void FullFrameExecutionModel::execute(ExecutionSystem &exec_system) 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")); node_tree->stats_draw(node_tree->sdh, TIP_("Compositing | Initializing execution"));
DebugInfo::graphviz(&exec_system, "compositor_prior_rendering"); DebugInfo::graphviz(&exec_system, "compositor_prior_rendering");
@@ -58,14 +57,14 @@ void FullFrameExecutionModel::execute(ExecutionSystem &exec_system)
void FullFrameExecutionModel::determine_areas_to_render_and_reads() void FullFrameExecutionModel::determine_areas_to_render_and_reads()
{ {
const bool is_rendering = context_.isRendering(); const bool is_rendering = context_.is_rendering();
const bNodeTree *node_tree = context_.getbNodeTree(); const bNodeTree *node_tree = context_.get_bnodetree();
rcti area; rcti area;
for (eCompositorPriority priority : priorities_) { for (eCompositorPriority priority : priorities_) {
for (NodeOperation *op : operations_) { for (NodeOperation *op : operations_) {
op->setbNodeTree(node_tree); op->set_bnodetree(node_tree);
if (op->isOutputOperation(is_rendering) && op->getRenderPriority() == priority) { if (op->is_output_operation(is_rendering) && op->get_render_priority() == priority) {
get_output_render_area(op, area); get_output_render_area(op, area);
determine_areas_to_render(op, area); determine_areas_to_render(op, area);
determine_reads(op); determine_reads(op);
@@ -82,7 +81,7 @@ Vector<MemoryBuffer *> FullFrameExecutionModel::get_input_buffers(NodeOperation
const int output_x, const int output_x,
const int output_y) 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); Vector<MemoryBuffer *> inputs_buffers(num_inputs);
for (int i = 0; i < num_inputs; i++) { for (int i = 0; i < num_inputs; i++) {
NodeOperation *input = op->get_input_operation(i); NodeOperation *input = op->get_input_operation(i);
@@ -93,7 +92,7 @@ Vector<MemoryBuffer *> FullFrameExecutionModel::get_input_buffers(NodeOperation
rcti rect = buf->get_rect(); rcti rect = buf->get_rect();
BLI_rcti_translate(&rect, offset_x, offset_y); BLI_rcti_translate(&rect, offset_x, offset_y);
inputs_buffers[i] = new MemoryBuffer( 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; return inputs_buffers;
} }
@@ -103,9 +102,10 @@ MemoryBuffer *FullFrameExecutionModel::create_operation_buffer(NodeOperation *op
const int output_y) const int output_y)
{ {
rcti rect; 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; const bool is_a_single_elem = op->get_flags().is_constant_operation;
return new MemoryBuffer(data_type, rect, is_a_single_elem); return new MemoryBuffer(data_type, rect, is_a_single_elem);
} }
@@ -116,9 +116,9 @@ void FullFrameExecutionModel::render_operation(NodeOperation *op)
constexpr int output_x = 0; constexpr int output_x = 0;
constexpr int output_y = 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; 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); 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_x = output_x - op->get_canvas().xmin;
const int op_offset_y = output_y - op->get_canvas().ymin; const int op_offset_y = output_y - op->get_canvas().ymin;
@@ -142,19 +142,19 @@ void FullFrameExecutionModel::render_operation(NodeOperation *op)
*/ */
void FullFrameExecutionModel::render_operations() void FullFrameExecutionModel::render_operations()
{ {
const bool is_rendering = context_.isRendering(); const bool is_rendering = context_.is_rendering();
WorkScheduler::start(this->context_); WorkScheduler::start(this->context_);
for (eCompositorPriority priority : priorities_) { for (eCompositorPriority priority : priorities_) {
for (NodeOperation *op : operations_) { for (NodeOperation *op : operations_) {
const bool has_size = op->getWidth() > 0 && op->getHeight() > 0; const bool has_size = op->get_width() > 0 && op->get_height() > 0;
const bool is_priority_output = op->isOutputOperation(is_rendering) && const bool is_priority_output = op->is_output_operation(is_rendering) &&
op->getRenderPriority() == priority; op->get_render_priority() == priority;
if (is_priority_output && has_size) { if (is_priority_output && has_size) {
render_output_dependencies(op); render_output_dependencies(op);
render_operation(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(); static_cast<ViewerOperation *>(op)->clear_display_buffer();
} }
} }
@@ -176,7 +176,7 @@ static Vector<NodeOperation *> get_operation_dependencies(NodeOperation *operati
Vector<NodeOperation *> outputs(next_outputs); Vector<NodeOperation *> outputs(next_outputs);
next_outputs.clear(); next_outputs.clear();
for (NodeOperation *output : outputs) { 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)); next_outputs.append(output->get_input_operation(i));
} }
} }
@@ -191,7 +191,7 @@ static Vector<NodeOperation *> get_operation_dependencies(NodeOperation *operati
void FullFrameExecutionModel::render_output_dependencies(NodeOperation *output_op) 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); Vector<NodeOperation *> dependencies = get_operation_dependencies(output_op);
for (NodeOperation *op : dependencies) { for (NodeOperation *op : dependencies) {
if (!active_buffers_.is_operation_rendered(op)) { if (!active_buffers_.is_operation_rendered(op)) {
@@ -206,7 +206,7 @@ void FullFrameExecutionModel::render_output_dependencies(NodeOperation *output_o
void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op, void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op,
const rcti &output_area) 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; Vector<std::pair<NodeOperation *, const rcti>> stack;
stack.append({output_op, output_area}); stack.append({output_op, output_area});
@@ -221,7 +221,7 @@ void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op
active_buffers_.register_area(operation, render_area); 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++) { for (int i = 0; i < num_inputs; i++) {
NodeOperation *input_op = operation->get_input_operation(i); NodeOperation *input_op = operation->get_input_operation(i);
rcti input_area; rcti input_area;
@@ -241,13 +241,13 @@ void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op
*/ */
void FullFrameExecutionModel::determine_reads(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; Vector<NodeOperation *> stack;
stack.append(output_op); stack.append(output_op);
while (stack.size() > 0) { while (stack.size() > 0) {
NodeOperation *operation = stack.pop_last(); 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++) { for (int i = 0; i < num_inputs; i++) {
NodeOperation *input_op = operation->get_input_operation(i); NodeOperation *input_op = operation->get_input_operation(i);
if (!active_buffers_.has_registered_reads(input_op)) { if (!active_buffers_.has_registered_reads(input_op)) {
@@ -264,7 +264,7 @@ void FullFrameExecutionModel::determine_reads(NodeOperation *output_op)
*/ */
void FullFrameExecutionModel::get_output_render_area(NodeOperation *output_op, rcti &r_area) 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). */ /* By default return operation bounds (no border). */
rcti canvas = output_op->get_canvas(); rcti canvas = output_op->get_canvas();
@@ -279,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; const rctf *norm_border = has_viewer_border ? border_.viewer_border : border_.render_border;
/* Return de-normalized border within canvas. */ /* Return de-normalized border within canvas. */
const int w = output_op->getWidth(); const int w = output_op->get_width();
const int h = output_op->getHeight(); const int h = output_op->get_height();
r_area.xmin = canvas.xmin + norm_border->xmin * w; r_area.xmin = canvas.xmin + norm_border->xmin * w;
r_area.xmax = canvas.xmin + norm_border->xmax * w; r_area.xmax = canvas.xmin + norm_border->xmax * w;
r_area.ymin = canvas.ymin + norm_border->ymin * h; r_area.ymin = canvas.ymin + norm_border->ymin * h;
@@ -291,7 +291,7 @@ void FullFrameExecutionModel::get_output_render_area(NodeOperation *output_op, r
void FullFrameExecutionModel::operation_finished(NodeOperation *operation) void FullFrameExecutionModel::operation_finished(NodeOperation *operation)
{ {
/* Report inputs reads so that buffers may be freed/reused. */ /* 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++) { for (int i = 0; i < num_inputs; i++) {
active_buffers_.read_finished(operation->get_input_operation(i)); active_buffers_.read_finished(operation->get_input_operation(i));
} }
@@ -302,7 +302,7 @@ void FullFrameExecutionModel::operation_finished(NodeOperation *operation)
void FullFrameExecutionModel::update_progress_bar() void FullFrameExecutionModel::update_progress_bar()
{ {
const bNodeTree *tree = context_.getbNodeTree(); const bNodeTree *tree = context_.get_bnodetree();
if (tree) { if (tree) {
const float progress = num_operations_finished_ / static_cast<float>(operations_.size()); const float progress = num_operations_finished_ / static_cast<float>(operations_.size());
tree->progress(tree->prh, progress); tree->progress(tree->prh, progress);

View File

@@ -18,6 +18,9 @@
#pragma once #pragma once
#include "BLI_vector.hh"
#include "COM_Enums.h"
#include "COM_ExecutionModel.h" #include "COM_ExecutionModel.h"
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
@@ -27,7 +30,11 @@
namespace blender::compositor { namespace blender::compositor {
/* Forward declarations. */ /* Forward declarations. */
class ExecutionGroup; class CompositorContext;
class ExecutionSystem;
class MemoryBuffer;
class NodeOperation;
class SharedOperationBuffers;
/** /**
* Fully renders operations in order from inputs to outputs. * Fully renders operations in order from inputs to outputs.

View File

@@ -18,9 +18,10 @@
#include "COM_MemoryBuffer.h" #include "COM_MemoryBuffer.h"
#include "COM_MemoryProxy.h"
#include "IMB_colormanagement.h" #include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h" #include "IMB_imbuf_types.h"
#include "MEM_guardedalloc.h"
#define ASSERT_BUFFER_CONTAINS_AREA(buf, area) \ #define ASSERT_BUFFER_CONTAINS_AREA(buf, area) \
BLI_assert(BLI_rcti_inside_rcti(&(buf)->get_rect(), &(area))) BLI_assert(BLI_rcti_inside_rcti(&(buf)->get_rect(), &(area)))
@@ -43,32 +44,32 @@ static rcti create_rect(const int width, const int height)
return rect; return rect;
} }
MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state) MemoryBuffer::MemoryBuffer(MemoryProxy *memory_proxy, const rcti &rect, MemoryBufferState state)
{ {
m_rect = rect; rect_ = rect;
this->m_is_a_single_elem = false; is_a_single_elem_ = false;
this->m_memoryProxy = memoryProxy; memory_proxy_ = memory_proxy;
this->m_num_channels = COM_data_type_num_channels(memoryProxy->getDataType()); num_channels_ = COM_data_type_num_channels(memory_proxy->get_data_type());
this->m_buffer = (float *)MEM_mallocN_aligned( buffer_ = (float *)MEM_mallocN_aligned(
sizeof(float) * buffer_len() * this->m_num_channels, 16, "COM_MemoryBuffer"); sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer");
owns_data_ = true; owns_data_ = true;
this->m_state = state; state_ = state;
this->m_datatype = memoryProxy->getDataType(); datatype_ = memory_proxy->get_data_type();
set_strides(); 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)
{ {
m_rect = rect; rect_ = rect;
this->m_is_a_single_elem = is_a_single_elem; is_a_single_elem_ = is_a_single_elem;
this->m_memoryProxy = nullptr; memory_proxy_ = nullptr;
this->m_num_channels = COM_data_type_num_channels(dataType); num_channels_ = COM_data_type_num_channels(data_type);
this->m_buffer = (float *)MEM_mallocN_aligned( buffer_ = (float *)MEM_mallocN_aligned(
sizeof(float) * buffer_len() * this->m_num_channels, 16, "COM_MemoryBuffer"); sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer");
owns_data_ = true; owns_data_ = true;
this->m_state = MemoryBufferState::Temporary; state_ = MemoryBufferState::Temporary;
this->m_datatype = dataType; datatype_ = data_type;
set_strides(); set_strides();
} }
@@ -92,55 +93,54 @@ MemoryBuffer::MemoryBuffer(float *buffer,
const rcti &rect, const rcti &rect,
const bool is_a_single_elem) const bool is_a_single_elem)
{ {
m_rect = rect; rect_ = rect;
m_is_a_single_elem = is_a_single_elem; is_a_single_elem_ = is_a_single_elem;
m_memoryProxy = nullptr; memory_proxy_ = nullptr;
m_num_channels = num_channels; num_channels_ = num_channels;
m_datatype = COM_num_channels_data_type(num_channels); datatype_ = COM_num_channels_data_type(num_channels);
m_buffer = buffer; buffer_ = buffer;
owns_data_ = false; owns_data_ = false;
m_state = MemoryBufferState::Temporary; state_ = MemoryBufferState::Temporary;
set_strides(); set_strides();
} }
MemoryBuffer::MemoryBuffer(const MemoryBuffer &src) MemoryBuffer::MemoryBuffer(const MemoryBuffer &src) : MemoryBuffer(src.datatype_, src.rect_, false)
: MemoryBuffer(src.m_datatype, src.m_rect, false)
{ {
m_memoryProxy = src.m_memoryProxy; memory_proxy_ = src.memory_proxy_;
/* src may be single elem buffer */ /* src may be single elem buffer */
fill_from(src); fill_from(src);
} }
void MemoryBuffer::set_strides() void MemoryBuffer::set_strides()
{ {
if (m_is_a_single_elem) { if (is_a_single_elem_) {
this->elem_stride = 0; this->elem_stride = 0;
this->row_stride = 0; this->row_stride = 0;
} }
else { else {
this->elem_stride = m_num_channels; this->elem_stride = num_channels_;
this->row_stride = getWidth() * m_num_channels; this->row_stride = get_width() * num_channels_;
} }
to_positive_x_stride_ = m_rect.xmin < 0 ? -m_rect.xmin + 1 : (m_rect.xmin == 0 ? 1 : 0); to_positive_x_stride_ = rect_.xmin < 0 ? -rect_.xmin + 1 : (rect_.xmin == 0 ? 1 : 0);
to_positive_y_stride_ = m_rect.ymin < 0 ? -m_rect.ymin + 1 : (m_rect.ymin == 0 ? 1 : 0); to_positive_y_stride_ = rect_.ymin < 0 ? -rect_.ymin + 1 : (rect_.ymin == 0 ? 1 : 0);
} }
void MemoryBuffer::clear() void MemoryBuffer::clear()
{ {
memset(m_buffer, 0, buffer_len() * m_num_channels * sizeof(float)); memset(buffer_, 0, buffer_len() * num_channels_ * sizeof(float));
} }
BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs) BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs)
{ {
return iterate_with(inputs, m_rect); return iterate_with(inputs, rect_);
} }
BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, const rcti &area) BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, const rcti &area)
{ {
BuffersIteratorBuilder<float> builder(m_buffer, m_rect, area, elem_stride); BuffersIteratorBuilder<float> builder(buffer_, rect_, area, elem_stride);
for (MemoryBuffer *input : inputs) { 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(); return builder.build();
} }
@@ -152,20 +152,20 @@ BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, c
MemoryBuffer *MemoryBuffer::inflate() const MemoryBuffer *MemoryBuffer::inflate() const
{ {
BLI_assert(is_a_single_elem()); BLI_assert(is_a_single_elem());
MemoryBuffer *inflated = new MemoryBuffer(this->m_datatype, this->m_rect, false); MemoryBuffer *inflated = new MemoryBuffer(datatype_, rect_, false);
inflated->copy_from(this, this->m_rect); inflated->copy_from(this, rect_);
return inflated; return inflated;
} }
float MemoryBuffer::get_max_value() const float MemoryBuffer::get_max_value() const
{ {
float result = this->m_buffer[0]; float result = buffer_[0];
const unsigned int size = this->buffer_len(); const unsigned int size = this->buffer_len();
unsigned int i; unsigned int i;
const float *fp_src = this->m_buffer; const float *fp_src = buffer_;
for (i = 0; i < size; i++, fp_src += this->m_num_channels) { for (i = 0; i < size; i++, fp_src += num_channels_) {
float value = *fp_src; float value = *fp_src;
if (value > result) { if (value > result) {
result = value; result = value;
@@ -180,10 +180,10 @@ float MemoryBuffer::get_max_value(const rcti &rect) const
rcti rect_clamp; rcti rect_clamp;
/* first clamp the rect by the bounds or we get un-initialized values */ /* first clamp the rect by the bounds or we get un-initialized values */
BLI_rcti_isect(&rect, &this->m_rect, &rect_clamp); BLI_rcti_isect(&rect, &rect_, &rect_clamp);
if (!BLI_rcti_is_empty(&rect_clamp)) { if (!BLI_rcti_is_empty(&rect_clamp)) {
MemoryBuffer temp_buffer(this->m_datatype, rect_clamp); MemoryBuffer temp_buffer(datatype_, rect_clamp);
temp_buffer.fill_from(*this); temp_buffer.fill_from(*this);
return temp_buffer.get_max_value(); return temp_buffer.get_max_value();
} }
@@ -194,9 +194,9 @@ float MemoryBuffer::get_max_value(const rcti &rect) const
MemoryBuffer::~MemoryBuffer() MemoryBuffer::~MemoryBuffer()
{ {
if (this->m_buffer && owns_data_) { if (buffer_ && owns_data_) {
MEM_freeN(this->m_buffer); MEM_freeN(buffer_);
this->m_buffer = nullptr; buffer_ = nullptr;
} }
} }
@@ -248,7 +248,7 @@ void MemoryBuffer::copy_from(const MemoryBuffer *src,
void MemoryBuffer::copy_from(const uchar *src, const rcti &area) void MemoryBuffer::copy_from(const uchar *src, const rcti &area)
{ {
const int elem_stride = this->get_num_channels(); 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); 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); const int height = BLI_rcti_size_y(&area);
float *out = buf->get_elem(area.xmin, area.ymin); float *out = buf->get_elem(area.xmin, area.ymin);
/* If area allows continuous memory do conversion in one step. Otherwise per row. */ /* 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( IMB_colormanagement_colorspace_to_scene_linear(
out, width, height, buf->get_num_channels(), colorspace, false); out, width, height, buf->get_num_channels(), colorspace, false);
} }
@@ -397,30 +397,28 @@ void MemoryBuffer::fill(const rcti &area,
void MemoryBuffer::fill_from(const MemoryBuffer &src) void MemoryBuffer::fill_from(const MemoryBuffer &src)
{ {
rcti overlap; rcti overlap;
overlap.xmin = MAX2(this->m_rect.xmin, src.m_rect.xmin); overlap.xmin = MAX2(rect_.xmin, src.rect_.xmin);
overlap.xmax = MIN2(this->m_rect.xmax, src.m_rect.xmax); overlap.xmax = MIN2(rect_.xmax, src.rect_.xmax);
overlap.ymin = MAX2(this->m_rect.ymin, src.m_rect.ymin); overlap.ymin = MAX2(rect_.ymin, src.rect_.ymin);
overlap.ymax = MIN2(this->m_rect.ymax, src.m_rect.ymax); overlap.ymax = MIN2(rect_.ymax, src.rect_.ymax);
copy_from(&src, overlap); 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 >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin && if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) {
y < this->m_rect.ymax) {
const int offset = get_coords_offset(x, y); const int offset = get_coords_offset(x, y);
memcpy(&this->m_buffer[offset], color, sizeof(float) * this->m_num_channels); memcpy(&buffer_[offset], color, sizeof(float) * num_channels_);
} }
} }
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 >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin && if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) {
y < this->m_rect.ymax) {
const int offset = get_coords_offset(x, y); const int offset = get_coords_offset(x, y);
float *dst = &this->m_buffer[offset]; float *dst = &buffer_[offset];
const float *src = color; const float *src = color;
for (int i = 0; i < this->m_num_channels; i++, dst++, src++) { for (int i = 0; i < num_channels_; i++, dst++, src++) {
*dst += *src; *dst += *src;
} }
} }
@@ -435,11 +433,11 @@ static void read_ewa_elem(void *userdata, int x, int y, float result[4])
void MemoryBuffer::read_elem_filtered( void MemoryBuffer::read_elem_filtered(
const float x, const float y, float dx[2], float dy[2], float *out) const const float x, const float y, float dx[2], float dy[2], float *out) const
{ {
BLI_assert(this->m_datatype == DataType::Color); BLI_assert(datatype_ == DataType::Color);
const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}}; 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, /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
* but compositor uses pixel space. For now let's just divide the values and * but compositor uses pixel space. For now let's just divide the values and
* switch compositor to normalized space for EWA later. * switch compositor to normalized space for EWA later.
@@ -448,8 +446,8 @@ void MemoryBuffer::read_elem_filtered(
float du_normal[2] = {deriv[0][0] * inv_width, deriv[0][1] * inv_height}; 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}; float dv_normal[2] = {deriv[1][0] * inv_width, deriv[1][1] * inv_height};
BLI_ewa_filter(this->getWidth(), BLI_ewa_filter(this->get_width(),
this->getHeight(), this->get_height(),
false, false,
true, true,
uv_normal, uv_normal,
@@ -470,12 +468,13 @@ static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4]
/* TODO(manzanilla): to be removed with tiled implementation. */ /* TODO(manzanilla): to be removed with tiled implementation. */
void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2]) void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2])
{ {
if (m_is_a_single_elem) { if (is_a_single_elem_) {
memcpy(result, m_buffer, sizeof(float) * this->m_num_channels); memcpy(result, buffer_, sizeof(float) * num_channels_);
} }
else { else {
BLI_assert(this->m_datatype == DataType::Color); 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, /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
* but compositor uses pixel space. For now let's just divide the values and * but compositor uses pixel space. For now let's just divide the values and
* switch compositor to normalized space for EWA later. * switch compositor to normalized space for EWA later.
@@ -484,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 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}; float dv_normal[2] = {derivatives[1][0] * inv_width, derivatives[1][1] * inv_height};
BLI_ewa_filter(this->getWidth(), BLI_ewa_filter(this->get_width(),
this->getHeight(), this->get_height(),
false, false,
true, true,
uv_normal, uv_normal,

View File

@@ -21,12 +21,13 @@
#include "COM_BufferArea.h" #include "COM_BufferArea.h"
#include "COM_BufferRange.h" #include "COM_BufferRange.h"
#include "COM_BuffersIterator.h" #include "COM_BuffersIterator.h"
#include "COM_ExecutionGroup.h" #include "COM_Enums.h"
#include "COM_MemoryProxy.h"
#include "BLI_math.h" #include "BLI_math_interp.h"
#include "BLI_rect.h" #include "BLI_rect.h"
struct ImBuf;
namespace blender::compositor { namespace blender::compositor {
/** /**
@@ -76,38 +77,38 @@ class MemoryBuffer {
/** /**
* \brief proxy of the memory (same for all chunks in the same buffer) * \brief proxy of the memory (same for all chunks in the same buffer)
*/ */
MemoryProxy *m_memoryProxy; MemoryProxy *memory_proxy_;
/** /**
* \brief the type of buffer DataType::Value, DataType::Vector, DataType::Color * \brief the type of buffer DataType::Value, DataType::Vector, DataType::Color
*/ */
DataType m_datatype; DataType datatype_;
/** /**
* \brief region of this buffer inside relative to the MemoryProxy * \brief region of this buffer inside relative to the MemoryProxy
*/ */
rcti m_rect; rcti rect_;
/** /**
* \brief state of the buffer * \brief state of the buffer
*/ */
MemoryBufferState m_state; MemoryBufferState state_;
/** /**
* \brief the actual float buffer/data * \brief the actual float buffer/data
*/ */
float *m_buffer; float *buffer_;
/** /**
* \brief the number of channels of a single value in the buffer. * \brief the number of channels of a single value in the buffer.
* For value buffers this is 1, vector 3 and color 4 * For value buffers this is 1, vector 3 and color 4
*/ */
uint8_t m_num_channels; uint8_t num_channels_;
/** /**
* Whether buffer is a single element in memory. * Whether buffer is a single element in memory.
*/ */
bool m_is_a_single_elem; bool is_a_single_elem_;
/** /**
* Whether MemoryBuffer owns buffer data. * Whether MemoryBuffer owns buffer data.
@@ -124,12 +125,12 @@ class MemoryBuffer {
/** /**
* \brief construct new temporarily MemoryBuffer for an area * \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 * \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( MemoryBuffer(
float *buffer, int num_channels, int width, int height, bool is_a_single_elem = false); float *buffer, int num_channels, int width, int height, bool is_a_single_elem = false);
@@ -152,21 +153,21 @@ class MemoryBuffer {
*/ */
bool is_a_single_elem() const bool is_a_single_elem() const
{ {
return m_is_a_single_elem; return is_a_single_elem_;
} }
float &operator[](int index) float &operator[](int index)
{ {
BLI_assert(m_is_a_single_elem ? index < m_num_channels : BLI_assert(is_a_single_elem_ ? index < num_channels_ :
index < get_coords_offset(getWidth(), getHeight())); index < get_coords_offset(get_width(), get_height()));
return m_buffer[index]; return buffer_[index];
} }
const float &operator[](int index) const const float &operator[](int index) const
{ {
BLI_assert(m_is_a_single_elem ? index < m_num_channels : BLI_assert(is_a_single_elem_ ? index < num_channels_ :
index < get_coords_offset(getWidth(), getHeight())); index < get_coords_offset(get_width(), get_height()));
return m_buffer[index]; return buffer_[index];
} }
/** /**
@@ -174,7 +175,7 @@ class MemoryBuffer {
*/ */
intptr_t get_coords_offset(int x, int y) const intptr_t get_coords_offset(int x, int y) const
{ {
return ((intptr_t)y - m_rect.ymin) * row_stride + ((intptr_t)x - m_rect.xmin) * elem_stride; return ((intptr_t)y - rect_.ymin) * row_stride + ((intptr_t)x - rect_.xmin) * elem_stride;
} }
/** /**
@@ -183,7 +184,7 @@ class MemoryBuffer {
float *get_elem(int x, int y) float *get_elem(int x, int y)
{ {
BLI_assert(has_coords(x, y)); BLI_assert(has_coords(x, y));
return m_buffer + get_coords_offset(x, y); return buffer_ + get_coords_offset(x, y);
} }
/** /**
@@ -192,7 +193,7 @@ class MemoryBuffer {
const float *get_elem(int x, int y) const const float *get_elem(int x, int y) const
{ {
BLI_assert(has_coords(x, y)); BLI_assert(has_coords(x, y));
return m_buffer + get_coords_offset(x, y); return buffer_ + get_coords_offset(x, y);
} }
void read_elem(int x, int y, float *out) const void read_elem(int x, int y, float *out) const
@@ -218,21 +219,19 @@ class MemoryBuffer {
void read_elem_bilinear(float x, float y, float *out) const void read_elem_bilinear(float x, float y, float *out) const
{ {
/* Only clear past +/-1 borders to be able to smooth edges. */ /* Only clear past +/-1 borders to be able to smooth edges. */
if (x <= m_rect.xmin - 1.0f || x >= m_rect.xmax || y <= m_rect.ymin - 1.0f || if (x <= rect_.xmin - 1.0f || x >= rect_.xmax || y <= rect_.ymin - 1.0f || y >= rect_.ymax) {
y >= m_rect.ymax) {
clear_elem(out); clear_elem(out);
return; return;
} }
if (m_is_a_single_elem) { if (is_a_single_elem_) {
if (x >= m_rect.xmin && x < m_rect.xmax - 1.0f && y >= m_rect.ymin && if (x >= rect_.xmin && x < rect_.xmax - 1.0f && y >= rect_.ymin && y < rect_.ymax - 1.0f) {
y < m_rect.ymax - 1.0f) { memcpy(out, buffer_, get_elem_bytes_len());
memcpy(out, m_buffer, get_elem_bytes_len());
return; return;
} }
/* Do sampling at borders to smooth edges. */ /* 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); const float rel_x = get_relative_x(x);
float single_x = 0.0f; float single_x = 0.0f;
if (rel_x < 0.0f) { if (rel_x < 0.0f) {
@@ -242,7 +241,7 @@ class MemoryBuffer {
single_x = rel_x - last_x; 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); const float rel_y = get_relative_y(y);
float single_y = 0.0f; float single_y = 0.0f;
if (rel_y < 0.0f) { if (rel_y < 0.0f) {
@@ -252,15 +251,15 @@ class MemoryBuffer {
single_y = rel_y - last_y; single_y = rel_y - last_y;
} }
BLI_bilinear_interpolation_fl(m_buffer, out, 1, 1, m_num_channels, single_x, single_y); BLI_bilinear_interpolation_fl(buffer_, out, 1, 1, num_channels_, single_x, single_y);
return; return;
} }
BLI_bilinear_interpolation_fl(m_buffer, BLI_bilinear_interpolation_fl(buffer_,
out, out,
getWidth(), get_width(),
getHeight(), get_height(),
m_num_channels, num_channels_,
get_relative_x(x), get_relative_x(x),
get_relative_y(y)); get_relative_y(y));
} }
@@ -287,8 +286,8 @@ class MemoryBuffer {
*/ */
float &get_value(int x, int y, int channel) float &get_value(int x, int y, int channel)
{ {
BLI_assert(has_coords(x, y) && channel >= 0 && channel < m_num_channels); BLI_assert(has_coords(x, y) && channel >= 0 && channel < num_channels_);
return m_buffer[get_coords_offset(x, y) + channel]; return buffer_[get_coords_offset(x, y) + channel];
} }
/** /**
@@ -296,8 +295,8 @@ class MemoryBuffer {
*/ */
const float &get_value(int x, int y, int channel) const const float &get_value(int x, int y, int channel) const
{ {
BLI_assert(has_coords(x, y) && channel >= 0 && channel < m_num_channels); BLI_assert(has_coords(x, y) && channel >= 0 && channel < num_channels_);
return m_buffer[get_coords_offset(x, y) + channel]; return buffer_[get_coords_offset(x, y) + channel];
} }
/** /**
@@ -306,7 +305,7 @@ class MemoryBuffer {
const float *get_row_end(int y) const const float *get_row_end(int y) const
{ {
BLI_assert(has_y(y)); BLI_assert(has_y(y));
return m_buffer + (is_a_single_elem() ? m_num_channels : get_coords_offset(getWidth(), y)); return buffer_ + (is_a_single_elem() ? num_channels_ : get_coords_offset(get_width(), y));
} }
/** /**
@@ -315,7 +314,7 @@ class MemoryBuffer {
*/ */
int get_memory_width() const int get_memory_width() const
{ {
return is_a_single_elem() ? 1 : getWidth(); return is_a_single_elem() ? 1 : get_width();
} }
/** /**
@@ -324,17 +323,17 @@ class MemoryBuffer {
*/ */
int get_memory_height() const 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 uint8_t get_num_channels() const
{ {
return this->m_num_channels; return num_channels_;
} }
uint8_t get_elem_bytes_len() const uint8_t get_elem_bytes_len() const
{ {
return this->m_num_channels * sizeof(float); return num_channels_ * sizeof(float);
} }
/** /**
@@ -342,22 +341,22 @@ class MemoryBuffer {
*/ */
BufferRange<float> as_range() BufferRange<float> as_range()
{ {
return BufferRange<float>(m_buffer, 0, buffer_len(), elem_stride); return BufferRange<float>(buffer_, 0, buffer_len(), elem_stride);
} }
BufferRange<const float> as_range() const BufferRange<const float> as_range() const
{ {
return BufferRange<const float>(m_buffer, 0, buffer_len(), elem_stride); return BufferRange<const float>(buffer_, 0, buffer_len(), elem_stride);
} }
BufferArea<float> get_buffer_area(const rcti &area) BufferArea<float> get_buffer_area(const rcti &area)
{ {
return BufferArea<float>(m_buffer, getWidth(), area, elem_stride); return BufferArea<float>(buffer_, get_width(), area, elem_stride);
} }
BufferArea<const float> get_buffer_area(const rcti &area) const BufferArea<const float> get_buffer_area(const rcti &area) const
{ {
return BufferArea<const float>(m_buffer, getWidth(), area, elem_stride); return BufferArea<const float>(buffer_, get_width(), area, elem_stride);
} }
BuffersIterator<float> iterate_with(Span<MemoryBuffer *> inputs); BuffersIterator<float> iterate_with(Span<MemoryBuffer *> inputs);
@@ -367,25 +366,25 @@ class MemoryBuffer {
* \brief get the data of this MemoryBuffer * \brief get the data of this MemoryBuffer
* \note buffer should already be available in memory * \note buffer should already be available in memory
*/ */
float *getBuffer() float *get_buffer()
{ {
return this->m_buffer; return buffer_;
} }
float *release_ownership_buffer() float *release_ownership_buffer()
{ {
owns_data_ = false; owns_data_ = false;
return this->m_buffer; return buffer_;
} }
MemoryBuffer *inflate() const; MemoryBuffer *inflate() const;
inline void wrap_pixel(int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y) inline void wrap_pixel(int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
{ {
const int w = getWidth(); const int w = get_width();
const int h = getHeight(); const int h = get_height();
x = x - m_rect.xmin; x = x - rect_.xmin;
y = y - m_rect.ymin; y = y - rect_.ymin;
switch (extend_x) { switch (extend_x) {
case MemoryBufferExtend::Clip: case MemoryBufferExtend::Clip:
@@ -425,8 +424,8 @@ class MemoryBuffer {
break; break;
} }
x = x + m_rect.xmin; x = x + rect_.xmin;
y = y + m_rect.ymin; y = y + rect_.ymin;
} }
inline void wrap_pixel(float &x, inline void wrap_pixel(float &x,
@@ -434,10 +433,10 @@ class MemoryBuffer {
MemoryBufferExtend extend_x, MemoryBufferExtend extend_x,
MemoryBufferExtend extend_y) const MemoryBufferExtend extend_y) const
{ {
const float w = (float)getWidth(); const float w = (float)get_width();
const float h = (float)getHeight(); const float h = (float)get_height();
x = x - m_rect.xmin; x = x - rect_.xmin;
y = y - m_rect.ymin; y = y - rect_.ymin;
switch (extend_x) { switch (extend_x) {
case MemoryBufferExtend::Clip: case MemoryBufferExtend::Clip:
@@ -477,8 +476,8 @@ class MemoryBuffer {
break; break;
} }
x = x + m_rect.xmin; x = x + rect_.xmin;
y = y + m_rect.ymin; y = y + rect_.ymin;
} }
/* TODO(manzanilla): to be removed with tiled implementation. For applying #MemoryBufferExtend /* TODO(manzanilla): to be removed with tiled implementation. For applying #MemoryBufferExtend
@@ -489,24 +488,24 @@ class MemoryBuffer {
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, MemoryBufferExtend extend_x = MemoryBufferExtend::Clip,
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) MemoryBufferExtend extend_y = MemoryBufferExtend::Clip)
{ {
bool clip_x = (extend_x == MemoryBufferExtend::Clip && (x < m_rect.xmin || x >= m_rect.xmax)); bool clip_x = (extend_x == MemoryBufferExtend::Clip && (x < rect_.xmin || x >= rect_.xmax));
bool clip_y = (extend_y == MemoryBufferExtend::Clip && (y < m_rect.ymin || y >= m_rect.ymax)); bool clip_y = (extend_y == MemoryBufferExtend::Clip && (y < rect_.ymin || y >= rect_.ymax));
if (clip_x || clip_y) { if (clip_x || clip_y) {
/* clip result outside rect is zero */ /* clip result outside rect is zero */
memset(result, 0, this->m_num_channels * sizeof(float)); memset(result, 0, num_channels_ * sizeof(float));
} }
else { else {
int u = x; int u = x;
int v = y; int v = y;
this->wrap_pixel(u, v, extend_x, extend_y); this->wrap_pixel(u, v, extend_x, extend_y);
const int offset = get_coords_offset(u, v); const int offset = get_coords_offset(u, v);
float *buffer = &this->m_buffer[offset]; float *buffer = &buffer_[offset];
memcpy(result, buffer, sizeof(float) * this->m_num_channels); memcpy(result, buffer, sizeof(float) * num_channels_);
} }
} }
/* TODO(manzanilla): to be removed with tiled implementation. */ /* TODO(manzanilla): to be removed with tiled implementation. */
inline void readNoCheck(float *result, inline void read_no_check(float *result,
int x, int x,
int y, int y,
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, MemoryBufferExtend extend_x = MemoryBufferExtend::Clip,
@@ -519,16 +518,16 @@ class MemoryBuffer {
const int offset = get_coords_offset(u, v); const int offset = get_coords_offset(u, v);
BLI_assert(offset >= 0); BLI_assert(offset >= 0);
BLI_assert(offset < this->buffer_len() * this->m_num_channels); BLI_assert(offset < this->buffer_len() * num_channels_);
BLI_assert(!(extend_x == MemoryBufferExtend::Clip && (u < m_rect.xmin || u >= m_rect.xmax)) && BLI_assert(!(extend_x == MemoryBufferExtend::Clip && (u < rect_.xmin || u >= rect_.xmax)) &&
!(extend_y == MemoryBufferExtend::Clip && (v < m_rect.ymin || v >= m_rect.ymax))); !(extend_y == MemoryBufferExtend::Clip && (v < rect_.ymin || v >= rect_.ymax)));
float *buffer = &this->m_buffer[offset]; float *buffer = &buffer_[offset];
memcpy(result, buffer, sizeof(float) * this->m_num_channels); memcpy(result, buffer, sizeof(float) * num_channels_);
} }
void writePixel(int x, int y, const float color[4]); void write_pixel(int x, int y, const float color[4]);
void addPixel(int x, int y, const float color[4]); void add_pixel(int x, int y, const float color[4]);
inline void readBilinear(float *result, inline void read_bilinear(float *result,
float x, float x,
float y, float y,
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, MemoryBufferExtend extend_x = MemoryBufferExtend::Clip,
@@ -537,20 +536,20 @@ class MemoryBuffer {
float u = x; float u = x;
float v = y; float v = y;
this->wrap_pixel(u, v, extend_x, extend_y); this->wrap_pixel(u, v, extend_x, extend_y);
if ((extend_x != MemoryBufferExtend::Repeat && (u < 0.0f || u >= getWidth())) || if ((extend_x != MemoryBufferExtend::Repeat && (u < 0.0f || u >= get_width())) ||
(extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= getHeight()))) { (extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= get_height()))) {
copy_vn_fl(result, this->m_num_channels, 0.0f); copy_vn_fl(result, num_channels_, 0.0f);
return; return;
} }
if (m_is_a_single_elem) { if (is_a_single_elem_) {
memcpy(result, m_buffer, sizeof(float) * this->m_num_channels); memcpy(result, buffer_, sizeof(float) * num_channels_);
} }
else { else {
BLI_bilinear_interpolation_wrap_fl(this->m_buffer, BLI_bilinear_interpolation_wrap_fl(buffer_,
result, result,
getWidth(), get_width(),
getHeight(), get_height(),
this->m_num_channels, num_channels_,
u, u,
v, v,
extend_x == MemoryBufferExtend::Repeat, extend_x == MemoryBufferExtend::Repeat,
@@ -563,9 +562,9 @@ class MemoryBuffer {
/** /**
* \brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk) * \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 this->m_state == MemoryBufferState::Temporary; return state_ == MemoryBufferState::Temporary;
} }
void copy_from(const MemoryBuffer *src, const rcti &area); void copy_from(const MemoryBuffer *src, const rcti &area);
@@ -618,8 +617,8 @@ class MemoryBuffer {
void fill(const rcti &area, const float *value); void fill(const rcti &area, const float *value);
void fill(const rcti &area, int channel_offset, const float *value, int value_size); void fill(const rcti &area, int channel_offset, const float *value, int value_size);
/** /**
* \brief add the content from otherBuffer to this MemoryBuffer * \brief add the content from other_buffer to this MemoryBuffer
* \param otherBuffer: source buffer * \param other_buffer: source buffer
* *
* \note take care when running this on a new buffer since it won't fill in * \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. * uninitialized values in areas where the buffers don't overlap.
@@ -631,23 +630,23 @@ class MemoryBuffer {
*/ */
const rcti &get_rect() const const rcti &get_rect() const
{ {
return this->m_rect; return rect_;
} }
/** /**
* \brief get the width of this MemoryBuffer * \brief get the width of this MemoryBuffer
*/ */
const int getWidth() const const int get_width() const
{ {
return BLI_rcti_size_x(&m_rect); return BLI_rcti_size_x(&rect_);
} }
/** /**
* \brief get the height of this MemoryBuffer * \brief get the height of this MemoryBuffer
*/ */
const int getHeight() const const int get_height() const
{ {
return BLI_rcti_size_y(&m_rect); return BLI_rcti_size_y(&rect_);
} }
/** /**
@@ -667,17 +666,17 @@ class MemoryBuffer {
void clear_elem(float *out) const void clear_elem(float *out) const
{ {
memset(out, 0, this->m_num_channels * sizeof(float)); memset(out, 0, num_channels_ * sizeof(float));
} }
template<typename T> T get_relative_x(T x) const template<typename T> T get_relative_x(T x) const
{ {
return x - m_rect.xmin; return x - rect_.xmin;
} }
template<typename T> T get_relative_y(T y) const template<typename T> T get_relative_y(T y) const
{ {
return y - m_rect.ymin; return y - rect_.ymin;
} }
template<typename T> bool has_coords(T x, T y) const template<typename T> bool has_coords(T x, T y) const
@@ -687,12 +686,12 @@ class MemoryBuffer {
template<typename T> bool has_x(T x) const template<typename T> bool has_x(T x) const
{ {
return x >= m_rect.xmin && x < m_rect.xmax; return x >= rect_.xmin && x < rect_.xmax;
} }
template<typename T> bool has_y(T y) const template<typename T> bool has_y(T y) const
{ {
return y >= m_rect.ymin && y < m_rect.ymax; return y >= rect_.ymin && y < rect_.ymax;
} }
/* Fast `floor(..)` functions. The caller should check result is within buffer bounds. /* Fast `floor(..)` functions. The caller should check result is within buffer bounds.

View File

@@ -17,18 +17,15 @@
*/ */
#include "COM_MemoryProxy.h" #include "COM_MemoryProxy.h"
#include "COM_MemoryBuffer.h" #include "COM_MemoryBuffer.h"
#include "BLI_rect.h"
namespace blender::compositor { namespace blender::compositor {
MemoryProxy::MemoryProxy(DataType datatype) MemoryProxy::MemoryProxy(DataType datatype)
{ {
this->m_writeBufferOperation = nullptr; write_buffer_operation_ = nullptr;
this->m_executor = nullptr; executor_ = nullptr;
this->m_datatype = datatype; datatype_ = datatype;
} }
void MemoryProxy::allocate(unsigned int width, unsigned int height) void MemoryProxy::allocate(unsigned int width, unsigned int height)
@@ -39,14 +36,14 @@ void MemoryProxy::allocate(unsigned int width, unsigned int height)
result.ymin = 0; result.ymin = 0;
result.ymax = height; result.ymax = height;
this->m_buffer = new MemoryBuffer(this, result, MemoryBufferState::Default); buffer_ = new MemoryBuffer(this, result, MemoryBufferState::Default);
} }
void MemoryProxy::free() void MemoryProxy::free()
{ {
if (this->m_buffer) { if (buffer_) {
delete this->m_buffer; delete buffer_;
this->m_buffer = nullptr; buffer_ = nullptr;
} }
} }

View File

@@ -42,22 +42,22 @@ class MemoryProxy {
/** /**
* \brief reference to the output operation of the executiongroup * \brief reference to the output operation of the executiongroup
*/ */
WriteBufferOperation *m_writeBufferOperation; WriteBufferOperation *write_buffer_operation_;
/** /**
* \brief reference to the executor. the Execution group that can fill a chunk * \brief reference to the executor. the Execution group that can fill a chunk
*/ */
ExecutionGroup *m_executor; ExecutionGroup *executor_;
/** /**
* \brief the allocated memory * \brief the allocated memory
*/ */
MemoryBuffer *m_buffer; MemoryBuffer *buffer_;
/** /**
* \brief datatype of this MemoryProxy * \brief datatype of this MemoryProxy
*/ */
DataType m_datatype; DataType datatype_;
public: public:
MemoryProxy(DataType type); MemoryProxy(DataType type);
@@ -66,35 +66,35 @@ class MemoryProxy {
* \brief set the ExecutionGroup that can be scheduled to calculate a certain chunk. * \brief set the ExecutionGroup that can be scheduled to calculate a certain chunk.
* \param group: the ExecutionGroup to set * \param group: the ExecutionGroup to set
*/ */
void setExecutor(ExecutionGroup *executor) void set_executor(ExecutionGroup *executor)
{ {
this->m_executor = executor; executor_ = executor;
} }
/** /**
* \brief get the ExecutionGroup that can be scheduled to calculate a certain chunk. * \brief get the ExecutionGroup that can be scheduled to calculate a certain chunk.
*/ */
ExecutionGroup *getExecutor() const ExecutionGroup *get_executor() const
{ {
return this->m_executor; return executor_;
} }
/** /**
* \brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy * \brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy
* \param operation: * \param operation:
*/ */
void setWriteBufferOperation(WriteBufferOperation *operation) void set_write_buffer_operation(WriteBufferOperation *operation)
{ {
this->m_writeBufferOperation = operation; write_buffer_operation_ = operation;
} }
/** /**
* \brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy * \brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy
* \return WriteBufferOperation * \return WriteBufferOperation
*/ */
WriteBufferOperation *getWriteBufferOperation() const WriteBufferOperation *get_write_buffer_operation() const
{ {
return this->m_writeBufferOperation; return write_buffer_operation_;
} }
/** /**
@@ -110,14 +110,14 @@ class MemoryProxy {
/** /**
* \brief get the allocated memory * \brief get the allocated memory
*/ */
inline MemoryBuffer *getBuffer() inline MemoryBuffer *get_buffer()
{ {
return this->m_buffer; return buffer_;
} }
inline DataType getDataType() inline DataType get_data_type()
{ {
return this->m_datatype; return datatype_;
} }
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC

View File

@@ -22,8 +22,6 @@
#include "RE_pipeline.h" #include "RE_pipeline.h"
#include <string_view>
namespace blender::compositor { namespace blender::compositor {
void MetaData::add(const blender::StringRef key, const blender::StringRef value) void MetaData::add(const blender::StringRef key, const blender::StringRef value)
@@ -31,7 +29,7 @@ void MetaData::add(const blender::StringRef key, const blender::StringRef value)
entries_.add(key, value); entries_.add(key, value);
} }
void MetaData::addCryptomatteEntry(const blender::StringRef layer_name, void MetaData::add_cryptomatte_entry(const blender::StringRef layer_name,
const blender::StringRefNull key, const blender::StringRefNull key,
const blender::StringRef value) const blender::StringRef value)
{ {
@@ -42,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 * When a conversion happens it will also add the cryptomatte name key with the given
* `layer_name`. */ * `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_hash = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_HASH, "");
std::string cryptomatte_conversion = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_CONVERSION, std::string cryptomatte_conversion = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_CONVERSION,
@@ -51,27 +49,28 @@ void MetaData::replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_
if (cryptomatte_hash.length() || cryptomatte_conversion.length() || if (cryptomatte_hash.length() || cryptomatte_conversion.length() ||
cryptomatte_manifest.length()) { cryptomatte_manifest.length()) {
addCryptomatteEntry(layer_name, "name", layer_name); add_cryptomatte_entry(layer_name, "name", layer_name);
} }
if (cryptomatte_hash.length()) { if (cryptomatte_hash.length()) {
addCryptomatteEntry(layer_name, "hash", cryptomatte_hash); add_cryptomatte_entry(layer_name, "hash", cryptomatte_hash);
} }
if (cryptomatte_conversion.length()) { if (cryptomatte_conversion.length()) {
addCryptomatteEntry(layer_name, "conversion", cryptomatte_conversion); add_cryptomatte_entry(layer_name, "conversion", cryptomatte_conversion);
} }
if (cryptomatte_manifest.length()) { 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()) { 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()); 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) { if (!meta_data) {
meta_data = std::make_unique<MetaData>(); meta_data = std::make_unique<MetaData>();
@@ -79,7 +78,7 @@ void MetaDataExtractCallbackData::addMetaData(blender::StringRef key, blender::S
meta_data->add(key, value); 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_key = blender::bke::cryptomatte::BKE_cryptomatte_meta_data_key(cryptomatte_layer_name,
"manifest"); "manifest");
@@ -97,13 +96,13 @@ void MetaDataExtractCallbackData::extract_cryptomatte_meta_data(void *_data,
MetaDataExtractCallbackData *data = static_cast<MetaDataExtractCallbackData *>(_data); MetaDataExtractCallbackData *data = static_cast<MetaDataExtractCallbackData *>(_data);
blender::StringRefNull key(propname); blender::StringRefNull key(propname);
if (key == data->hash_key) { 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) { 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) { else if (key == data->manifest_key) {
data->addMetaData(META_DATA_KEY_CRYPTOMATTE_MANIFEST, propvalue); data->add_meta_data(META_DATA_KEY_CRYPTOMATTE_MANIFEST, propvalue);
} }
} }

View File

@@ -44,14 +44,14 @@ constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_NAME("cryptomatte/{hash}/
class MetaData { class MetaData {
private: private:
Map<std::string, std::string> entries_; Map<std::string, std::string> entries_;
void addCryptomatteEntry(const blender::StringRef layer_name, void add_cryptomatte_entry(const blender::StringRef layer_name,
const blender::StringRefNull key, const blender::StringRefNull key,
const blender::StringRef value); const blender::StringRef value);
public: public:
void add(const blender::StringRef key, const blender::StringRef value); void add(const blender::StringRef key, const blender::StringRef value);
void replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_name); void replace_hash_neutral_cryptomatte_keys(const blender::StringRef layer_name);
void addToRenderResult(RenderResult *render_result) const; void add_to_render_result(RenderResult *render_result) const;
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:MetaData") MEM_CXX_CLASS_ALLOC_FUNCS("COM:MetaData")
#endif #endif
@@ -63,8 +63,8 @@ struct MetaDataExtractCallbackData {
std::string conversion_key; std::string conversion_key;
std::string manifest_key; std::string manifest_key;
void addMetaData(blender::StringRef key, blender::StringRefNull value); void add_meta_data(blender::StringRef key, blender::StringRefNull value);
void setCryptomatteKeys(blender::StringRef cryptomatte_layer_name); void set_cryptomatte_keys(blender::StringRef cryptomatte_layer_name);
/* C type callback function (StampCallback). */ /* C type callback function (StampCallback). */
static void extract_cryptomatte_meta_data(void *_data, static void extract_cryptomatte_meta_data(void *_data,
const char *propname, const char *propname,

View File

@@ -18,6 +18,8 @@
#pragma once #pragma once
#include "BLI_array.h"
#include "COM_MultiThreadedOperation.h" #include "COM_MultiThreadedOperation.h"
namespace blender::compositor { namespace blender::compositor {

View File

@@ -16,20 +16,10 @@
* Copyright 2011, Blender Foundation. * Copyright 2011, Blender Foundation.
*/ */
#include <cstring>
#include "BKE_node.h" #include "BKE_node.h"
#include "RNA_access.h" #include "RNA_access.h"
#include "COM_ExecutionSystem.h"
#include "COM_NodeOperation.h"
#include "COM_TranslateOperation.h"
#include "COM_SocketProxyNode.h"
#include "COM_defines.h"
#include "COM_Node.h" /* own include */ #include "COM_Node.h" /* own include */
namespace blender::compositor { namespace blender::compositor {
@@ -38,14 +28,14 @@ namespace blender::compositor {
**** Node **** **** Node ****
**************/ **************/
Node::Node(bNode *editorNode, bool create_sockets) Node::Node(bNode *editor_node, bool create_sockets)
: m_editorNodeTree(nullptr), : editor_node_tree_(nullptr),
m_editorNode(editorNode), editor_node_(editor_node),
m_inActiveGroup(false), in_active_group_(false),
m_instanceKey(NODE_INSTANCE_KEY_NONE) instance_key_(NODE_INSTANCE_KEY_NONE)
{ {
if (create_sockets) { if (create_sockets) {
bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first; bNodeSocket *input = (bNodeSocket *)editor_node->inputs.first;
while (input != nullptr) { while (input != nullptr) {
DataType dt = DataType::Value; DataType dt = DataType::Value;
if (input->type == SOCK_RGBA) { if (input->type == SOCK_RGBA) {
@@ -55,10 +45,10 @@ Node::Node(bNode *editorNode, bool create_sockets)
dt = DataType::Vector; dt = DataType::Vector;
} }
this->addInputSocket(dt, input); this->add_input_socket(dt, input);
input = input->next; input = input->next;
} }
bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first; bNodeSocket *output = (bNodeSocket *)editor_node->outputs.first;
while (output != nullptr) { while (output != nullptr) {
DataType dt = DataType::Value; DataType dt = DataType::Value;
if (output->type == SOCK_RGBA) { if (output->type == SOCK_RGBA) {
@@ -68,7 +58,7 @@ Node::Node(bNode *editorNode, bool create_sockets)
dt = DataType::Vector; dt = DataType::Vector;
} }
this->addOutputSocket(dt, output); this->add_output_socket(dt, output);
output = output->next; output = output->next;
} }
} }
@@ -84,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); NodeInput *socket = new NodeInput(this, bSocket, datatype);
this->inputs.append(socket); 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); NodeOutput *socket = new NodeOutput(this, bSocket, datatype);
outputs.append(socket); outputs.append(socket);
} }
NodeOutput *Node::getOutputSocket(unsigned int index) const NodeOutput *Node::get_output_socket(unsigned int index) const
{ {
return outputs[index]; return outputs[index];
} }
NodeInput *Node::getInputSocket(unsigned int index) const NodeInput *Node::get_input_socket(unsigned int index) const
{ {
return inputs[index]; 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; int index = 0;
while (bSock != nullptr) { while (bSock != nullptr) {
if (index == editorNodeInputSocketIndex) { if (index == editor_node_input_socket_index) {
return bSock; return bSock;
} }
index++; index++;
@@ -128,12 +118,12 @@ bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
} }
return nullptr; 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; int index = 0;
while (bSock != nullptr) { while (bSock != nullptr) {
if (index == editorNodeOutputSocketIndex) { if (index == editor_node_output_socket_index) {
return bSock; return bSock;
} }
index++; index++;
@@ -147,33 +137,33 @@ bNodeSocket *Node::getEditorOutputSocket(int editorNodeOutputSocketIndex)
*******************/ *******************/
NodeInput::NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype) NodeInput::NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype)
: m_node(node), m_editorSocket(b_socket), m_datatype(datatype), m_link(nullptr) : node_(node), editor_socket_(b_socket), datatype_(datatype), link_(nullptr)
{ {
} }
void NodeInput::setLink(NodeOutput *link) void NodeInput::set_link(NodeOutput *link)
{ {
m_link = link; link_ = link;
} }
float NodeInput::getEditorValueFloat() const float NodeInput::get_editor_value_float() const
{ {
PointerRNA ptr; 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"); return RNA_float_get(&ptr, "default_value");
} }
void NodeInput::getEditorValueColor(float *value) const void NodeInput::get_editor_value_color(float *value) const
{ {
PointerRNA ptr; 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); 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; 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); return RNA_float_get_array(&ptr, "default_value", value);
} }
@@ -182,28 +172,28 @@ void NodeInput::getEditorValueVector(float *value) const
********************/ ********************/
NodeOutput::NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype) NodeOutput::NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype)
: m_node(node), m_editorSocket(b_socket), m_datatype(datatype) : node_(node), editor_socket_(b_socket), datatype_(datatype)
{ {
} }
float NodeOutput::getEditorValueFloat() float NodeOutput::get_editor_value_float()
{ {
PointerRNA ptr; 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"); return RNA_float_get(&ptr, "default_value");
} }
void NodeOutput::getEditorValueColor(float *value) void NodeOutput::get_editor_value_color(float *value)
{ {
PointerRNA ptr; 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); return RNA_float_get_array(&ptr, "default_value", value);
} }
void NodeOutput::getEditorValueVector(float *value) void NodeOutput::get_editor_value_vector(float *value)
{ {
PointerRNA ptr; 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); return RNA_float_get_array(&ptr, "default_value", value);
} }

View File

@@ -22,9 +22,6 @@
#include "DNA_node_types.h" #include "DNA_node_types.h"
#include <algorithm>
#include <string>
/* common node includes /* common node includes
* added here so node files don't have to include themselves * added here so node files don't have to include themselves
*/ */
@@ -44,22 +41,22 @@ class Node {
/** /**
* \brief stores the reference to the SDNA bNode struct * \brief stores the reference to the SDNA bNode struct
*/ */
bNodeTree *m_editorNodeTree; bNodeTree *editor_node_tree_;
/** /**
* \brief stores the reference to the SDNA bNode struct * \brief stores the reference to the SDNA bNode struct
*/ */
bNode *m_editorNode; bNode *editor_node_;
/** /**
* \brief Is this node part of the active group * \brief Is this node part of the active group
*/ */
bool m_inActiveGroup; bool in_active_group_;
/** /**
* \brief Instance key to identify the node in an instance hash table * \brief Instance key to identify the node in an instance hash table
*/ */
bNodeInstanceKey m_instanceKey; bNodeInstanceKey instance_key_;
protected: protected:
/** /**
@@ -73,23 +70,23 @@ class Node {
Vector<NodeOutput *> outputs; Vector<NodeOutput *> outputs;
public: public:
Node(bNode *editorNode, bool create_sockets = true); Node(bNode *editor_node, bool create_sockets = true);
virtual ~Node(); virtual ~Node();
/** /**
* \brief get the reference to the SDNA bNode struct * \brief get the reference to the SDNA bNode struct
*/ */
bNode *getbNode() const bNode *get_bnode() const
{ {
return m_editorNode; return editor_node_;
} }
/** /**
* \brief get the reference to the SDNA bNodeTree struct * \brief get the reference to the SDNA bNodeTree struct
*/ */
bNodeTree *getbNodeTree() const bNodeTree *get_bnodetree() const
{ {
return m_editorNodeTree; return editor_node_tree_;
} }
/** /**
@@ -98,24 +95,24 @@ class Node {
* node for highlight during execution. * node for highlight during execution.
* \param bNode: * \param bNode:
*/ */
void setbNode(bNode *node) void set_bnode(bNode *node)
{ {
this->m_editorNode = node; editor_node_ = node;
} }
/** /**
* \brief set the reference to the bNodeTree * \brief set the reference to the bNodeTree
* \param bNodeTree: * \param bNodeTree:
*/ */
void setbNodeTree(bNodeTree *nodetree) void set_bnodetree(bNodeTree *nodetree)
{ {
this->m_editorNodeTree = nodetree; editor_node_tree_ = nodetree;
} }
/** /**
* \brief get access to the vector of input sockets * \brief get access to the vector of input sockets
*/ */
const Vector<NodeInput *> &getInputSockets() const const Vector<NodeInput *> &get_input_sockets() const
{ {
return this->inputs; return this->inputs;
} }
@@ -123,7 +120,7 @@ class Node {
/** /**
* \brief get access to the vector of input sockets * \brief get access to the vector of input sockets
*/ */
const Vector<NodeOutput *> &getOutputSockets() const const Vector<NodeOutput *> &get_output_sockets() const
{ {
return this->outputs; return this->outputs;
} }
@@ -133,22 +130,22 @@ class Node {
* \param index: * \param index:
* the index of the needed outputsocket * 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 * get the reference to a certain inputsocket
* \param index: * \param index:
* the index of the needed inputsocket * 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) * \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)
{ {
this->m_inActiveGroup = value; in_active_group_ = value;
} }
/** /**
@@ -157,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) * the active group will be the main tree (all nodes that are not part of a group will be active)
* \return bool [false:true] * \return bool [false:true]
*/ */
inline bool isInActiveGroup() const inline bool is_in_active_group() const
{ {
return this->m_inActiveGroup; return in_active_group_;
} }
/** /**
@@ -170,16 +167,16 @@ class Node {
* \param system: the ExecutionSystem where the operations need to be added * \param system: the ExecutionSystem where the operations need to be added
* \param context: reference to the CompositorContext * \param context: reference to the CompositorContext
*/ */
virtual void convertToOperations(NodeConverter &converter, virtual void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const = 0; const CompositorContext &context) const = 0;
void setInstanceKey(bNodeInstanceKey instance_key) void set_instance_key(bNodeInstanceKey instance_key)
{ {
m_instanceKey = instance_key; instance_key_ = instance_key;
} }
bNodeInstanceKey getInstanceKey() const bNodeInstanceKey get_instance_key() const
{ {
return m_instanceKey; return instance_key_;
} }
protected: protected:
@@ -188,19 +185,19 @@ class Node {
* \note may only be called in an constructor * \note may only be called in an constructor
* \param socket: the NodeInput to add * \param socket: the NodeInput to add
*/ */
void addInputSocket(DataType datatype); void add_input_socket(DataType datatype);
void addInputSocket(DataType datatype, bNodeSocket *socket); void add_input_socket(DataType datatype, bNodeSocket *socket);
/** /**
* \brief add an NodeOutput to the collection of output-sockets * \brief add an NodeOutput to the collection of output-sockets
* \note may only be called in an constructor * \note may only be called in an constructor
* \param socket: the NodeOutput to add * \param socket: the NodeOutput to add
*/ */
void addOutputSocket(DataType datatype); void add_output_socket(DataType datatype);
void addOutputSocket(DataType datatype, bNodeSocket *socket); void add_output_socket(DataType datatype, bNodeSocket *socket);
bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex); bNodeSocket *get_editor_input_socket(int editor_node_input_socket_index);
bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex); bNodeSocket *get_editor_output_socket(int editor_node_output_socket_index);
}; };
/** /**
@@ -209,46 +206,46 @@ class Node {
*/ */
class NodeInput { class NodeInput {
private: private:
Node *m_node; Node *node_;
bNodeSocket *m_editorSocket; bNodeSocket *editor_socket_;
DataType m_datatype; DataType datatype_;
/** /**
* \brief link connected to this NodeInput. * \brief link connected to this NodeInput.
* An input socket can only have a single link * An input socket can only have a single link
*/ */
NodeOutput *m_link; NodeOutput *link_;
public: public:
NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype); NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype);
Node *getNode() const Node *get_node() const
{ {
return this->m_node; return node_;
} }
DataType getDataType() const DataType get_data_type() const
{ {
return m_datatype; return datatype_;
} }
bNodeSocket *getbNodeSocket() const bNodeSocket *get_bnode_socket() const
{ {
return this->m_editorSocket; return editor_socket_;
} }
void setLink(NodeOutput *link); void set_link(NodeOutput *link);
bool isLinked() const bool is_linked() const
{ {
return m_link; return link_;
} }
NodeOutput *getLink() NodeOutput *get_link()
{ {
return m_link; return link_;
} }
float getEditorValueFloat() const; float get_editor_value_float() const;
void getEditorValueColor(float *value) const; void get_editor_value_color(float *value) const;
void getEditorValueVector(float *value) const; void get_editor_value_vector(float *value) const;
}; };
/** /**
@@ -257,30 +254,30 @@ class NodeInput {
*/ */
class NodeOutput { class NodeOutput {
private: private:
Node *m_node; Node *node_;
bNodeSocket *m_editorSocket; bNodeSocket *editor_socket_;
DataType m_datatype; DataType datatype_;
public: public:
NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype); NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype);
Node *getNode() const Node *get_node() const
{ {
return this->m_node; return node_;
} }
DataType getDataType() const DataType get_data_type() const
{ {
return m_datatype; return datatype_;
} }
bNodeSocket *getbNodeSocket() const bNodeSocket *get_bnode_socket() const
{ {
return this->m_editorSocket; return editor_socket_;
} }
float getEditorValueFloat(); float get_editor_value_float();
void getEditorValueColor(float *value); void get_editor_value_color(float *value);
void getEditorValueVector(float *value); void get_editor_value_vector(float *value);
}; };
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -18,9 +18,7 @@
#include "BLI_utildefines.h" #include "BLI_utildefines.h"
#include "COM_Debug.h" #include "COM_Node.h"
#include "COM_NodeOperation.h"
#include "COM_NodeOperationBuilder.h" #include "COM_NodeOperationBuilder.h"
#include "COM_SetColorOperation.h" #include "COM_SetColorOperation.h"
#include "COM_SetValueOperation.h" #include "COM_SetValueOperation.h"
@@ -31,136 +29,137 @@
namespace blender::compositor { namespace blender::compositor {
NodeConverter::NodeConverter(NodeOperationBuilder *builder) : m_builder(builder) NodeConverter::NodeConverter(NodeOperationBuilder *builder) : builder_(builder)
{ {
} }
void NodeConverter::addOperation(NodeOperation *operation) void NodeConverter::add_operation(NodeOperation *operation)
{ {
m_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)
{ {
m_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)
{ {
m_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)
{ {
m_builder->addLink(from, to); builder_->add_link(from, to);
} }
void NodeConverter::addPreview(NodeOperationOutput *output) void NodeConverter::add_preview(NodeOperationOutput *output)
{ {
m_builder->addPreview(output); builder_->add_preview(output);
} }
void NodeConverter::addNodeInputPreview(NodeInput *input) void NodeConverter::add_node_input_preview(NodeInput *input)
{ {
m_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 */ /* 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}; const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
SetColorOperation *operation = new SetColorOperation(); SetColorOperation *operation = new SetColorOperation();
operation->setChannels(warning_color); operation->set_channels(warning_color);
m_builder->addOperation(operation); builder_->add_operation(operation);
m_builder->mapOutputSocket(output, operation->getOutputSocket()); builder_->map_output_socket(output, operation->get_output_socket());
return operation; 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); SocketProxyOperation *proxy = new SocketProxyOperation(input->get_data_type(), use_conversion);
m_builder->addOperation(proxy); builder_->add_operation(proxy);
m_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); SocketProxyOperation *proxy = new SocketProxyOperation(output->get_data_type(), use_conversion);
m_builder->addOperation(proxy); builder_->add_operation(proxy);
m_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(); SetValueOperation *operation = new SetValueOperation();
operation->setValue(value); operation->set_value(value);
m_builder->addOperation(operation); builder_->add_operation(operation);
m_builder->addLink(operation->getOutputSocket(), input); 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(); SetColorOperation *operation = new SetColorOperation();
operation->setChannels(value); operation->set_channels(value);
m_builder->addOperation(operation); builder_->add_operation(operation);
m_builder->addLink(operation->getOutputSocket(), input); 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(); SetVectorOperation *operation = new SetVectorOperation();
operation->setVector(value); operation->set_vector(value);
m_builder->addOperation(operation); builder_->add_operation(operation);
m_builder->addLink(operation->getOutputSocket(), input); 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(); SetValueOperation *operation = new SetValueOperation();
operation->setValue(value); operation->set_value(value);
m_builder->addOperation(operation); builder_->add_operation(operation);
m_builder->mapOutputSocket(output, operation->getOutputSocket()); 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(); SetColorOperation *operation = new SetColorOperation();
operation->setChannels(value); operation->set_channels(value);
m_builder->addOperation(operation); builder_->add_operation(operation);
m_builder->mapOutputSocket(output, operation->getOutputSocket()); 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(); SetVectorOperation *operation = new SetVectorOperation();
operation->setVector(value); operation->set_vector(value);
m_builder->addOperation(operation); builder_->add_operation(operation);
m_builder->mapOutputSocket(output, operation->getOutputSocket()); builder_->map_output_socket(output, operation->get_output_socket());
} }
void NodeConverter::registerViewer(ViewerOperation *viewer) void NodeConverter::register_viewer(ViewerOperation *viewer)
{ {
m_builder->registerViewer(viewer); builder_->register_viewer(viewer);
} }
ViewerOperation *NodeConverter::active_viewer() const ViewerOperation *NodeConverter::active_viewer() const
{ {
return m_builder->active_viewer(); return builder_->active_viewer();
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -36,7 +36,7 @@ class ViewerOperation;
/** /**
* Interface type for converting a \a Node into \a NodeOperation. * 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, * to register any number of operations, create links between them,
* and map original node sockets to their inputs or outputs. * and map original node sockets to their inputs or outputs.
*/ */
@@ -48,7 +48,7 @@ class NodeConverter {
* Insert a new operation into the operations graph. * Insert a new operation into the operations graph.
* The operation must be created by the node. * 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. * 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. * \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. * Map output socket of the node to an operation socket.
* Links between nodes will then generate equivalent links between * Links between nodes will then generate equivalent links between
@@ -66,57 +66,57 @@ class NodeConverter {
* \note A \a Node output can only be mapped to one \a NodeOperation output. * \note A \a Node output can only be mapped to one \a NodeOperation output.
* Any existing operation output mapping will be replaced. * 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. * Create a proxy operation for a node input.
* This operation will be removed later and replaced * This operation will be removed later and replaced
* by direct links between the connected operations. * 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. * Create a proxy operation for a node output.
* This operation will be removed later and replaced * This operation will be removed later and replaced
* by direct links between the connected operations. * 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. */ /** Define a constant input value. */
void addInputValue(NodeOperationInput *input, float value); void add_input_value(NodeOperationInput *input, float value);
/** Define a constant input color. */ /** 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. */ /** 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. */ /** Define a constant output value. */
void addOutputValue(NodeOutput *output, float value); void add_output_value(NodeOutput *output, float value);
/** Define a constant output color. */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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 * When a node has no valid data
* \note missing image / group pointer, or missing renderlayer from EXR * \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 */ /** 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 */ /** The currently active viewer output operation */
ViewerOperation *active_viewer() const; ViewerOperation *active_viewer() const;
private: private:
/** The internal builder for storing the results of the graph construction. */ /** The internal builder for storing the results of the graph construction. */
NodeOperationBuilder *m_builder; NodeOperationBuilder *builder_;
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompiler") MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompiler")

View File

@@ -18,17 +18,12 @@
#include <cstring> #include <cstring>
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "DNA_node_types.h" #include "DNA_node_types.h"
#include "BKE_node.h" #include "BKE_node.h"
#include "COM_CompositorContext.h"
#include "COM_Converter.h" #include "COM_Converter.h"
#include "COM_Debug.h" #include "COM_Debug.h"
#include "COM_Node.h"
#include "COM_SocketProxyNode.h" #include "COM_SocketProxyNode.h"
#include "COM_NodeGraph.h" /* own include */ #include "COM_NodeGraph.h" /* own include */
@@ -41,8 +36,8 @@ namespace blender::compositor {
NodeGraph::~NodeGraph() NodeGraph::~NodeGraph()
{ {
while (m_nodes.size()) { while (nodes_.size()) {
delete m_nodes.pop_last(); delete nodes_.pop_last();
} }
} }
@@ -76,21 +71,21 @@ void NodeGraph::add_node(Node *node,
bNodeInstanceKey key, bNodeInstanceKey key,
bool is_active_group) bool is_active_group)
{ {
node->setbNodeTree(b_ntree); node->set_bnodetree(b_ntree);
node->setInstanceKey(key); node->set_instance_key(key);
node->setIsInActiveGroup(is_active_group); node->set_is_in_active_group(is_active_group);
m_nodes.append(node); nodes_.append(node);
DebugInfo::node_added(node); DebugInfo::node_added(node);
} }
void NodeGraph::add_link(NodeOutput *fromSocket, NodeInput *toSocket) void NodeGraph::add_link(NodeOutput *from_socket, NodeInput *to_socket)
{ {
m_links.append(Link(fromSocket, toSocket)); links_.append(Link(from_socket, to_socket));
/* register with the input */ /* register with the input */
toSocket->setLink(fromSocket); to_socket->set_link(from_socket);
} }
void NodeGraph::add_bNodeTree(const CompositorContext &context, void NodeGraph::add_bNodeTree(const CompositorContext &context,
@@ -98,7 +93,7 @@ void NodeGraph::add_bNodeTree(const CompositorContext &context,
bNodeTree *tree, bNodeTree *tree,
bNodeInstanceKey parent_key) 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). */ /* 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); bool is_active_group = (parent_key.value == basetree->active_viewer_key.value);
@@ -109,7 +104,7 @@ void NodeGraph::add_bNodeTree(const CompositorContext &context,
add_bNode(context, tree, node, key, is_active_group); add_bNode(context, tree, node, key, is_active_group);
} }
NodeRange node_range(m_nodes.begin() + nodes_start, m_nodes.end()); NodeRange node_range(nodes_.begin() + nodes_start, nodes_.end());
/* Add all node-links of the tree to the link list. */ /* Add all node-links of the tree to the link list. */
for (bNodeLink *nodelink = (bNodeLink *)tree->links.first; nodelink; nodelink = nodelink->next) { for (bNodeLink *nodelink = (bNodeLink *)tree->links.first; nodelink; nodelink = nodelink->next) {
add_bNodeLink(node_range, nodelink); add_bNodeLink(node_range, nodelink);
@@ -129,7 +124,7 @@ void NodeGraph::add_bNode(const CompositorContext &context,
} }
/* replace slow nodes with proxies for fast execution */ /* 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); add_proxies_skip(b_ntree, b_node, key, is_active_group);
return; return;
} }
@@ -154,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) { for (Vector<Node *>::iterator it = node_range.first; it != node_range.second; ++it) {
Node *node = *it; Node *node = *it;
for (NodeOutput *output : node->getOutputSockets()) { for (NodeOutput *output : node->get_output_sockets()) {
if (output->getbNodeSocket() == b_socket) { if (output->get_bnode_socket() == b_socket) {
return output; return output;
} }
} }
@@ -185,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) { for (Vector<Node *>::iterator it = node_range.first; it != node_range.second; ++it) {
Node *node = *it; Node *node = *it;
for (NodeInput *input : node->getInputSockets()) { for (NodeInput *input : node->get_input_sockets()) {
if (input->getbNodeSocket() == b_nodelink->tosock && !input->isLinked()) { if (input->get_bnode_socket() == b_nodelink->tosock && !input->is_linked()) {
add_link(output, input); add_link(output, input);
} }
} }
@@ -263,7 +258,7 @@ void NodeGraph::add_proxies_group_outputs(const CompositorContext &context,
b_sock_io = b_sock_io->next) { b_sock_io = b_sock_io->next) {
bNodeSocket *b_sock_group = find_b_node_output(b_node, b_sock_io->identifier); bNodeSocket *b_sock_group = find_b_node_output(b_node, b_sock_io->identifier);
if (b_sock_group) { if (b_sock_group) {
if (context.isGroupnodeBufferEnabled() && if (context.is_groupnode_buffer_enabled() &&
context.get_execution_model() == eExecutionModel::Tiled) { context.get_execution_model() == eExecutionModel::Tiled) {
SocketBufferNode *buffer = new SocketBufferNode(b_node_io, b_sock_io, b_sock_group); SocketBufferNode *buffer = new SocketBufferNode(b_node_io, b_sock_io, b_sock_group);
add_node(buffer, b_group_tree, key, is_active_group); add_node(buffer, b_group_tree, key, is_active_group);
@@ -284,13 +279,13 @@ void NodeGraph::add_proxies_group(const CompositorContext &context,
/* missing node group datablock can happen with library linking */ /* missing node group datablock can happen with library linking */
if (!b_group_tree) { 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. */ * so we don't get un-converted sockets. */
return; return;
} }
/* use node list size before adding proxies, so they can be connected in add_bNodeTree */ /* use node list size before adding proxies, so they can be connected in add_bNodeTree */
int nodes_start = m_nodes.size(); int nodes_start = nodes_.size();
/* create proxy nodes for group input/output nodes */ /* create proxy nodes for group input/output nodes */
for (bNode *b_node_io = (bNode *)b_group_tree->nodes.first; b_node_io; for (bNode *b_node_io = (bNode *)b_group_tree->nodes.first; b_node_io;

View File

@@ -18,11 +18,6 @@
#pragma once #pragma once
#include "BLI_vector.hh"
#include <map>
#include <set>
#include "DNA_node_types.h" #include "DNA_node_types.h"
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
@@ -52,19 +47,19 @@ class NodeGraph {
}; };
private: private:
Vector<Node *> m_nodes; Vector<Node *> nodes_;
Vector<Link> m_links; Vector<Link> links_;
public: public:
~NodeGraph(); ~NodeGraph();
const Vector<Node *> &nodes() const const Vector<Node *> &nodes() const
{ {
return m_nodes; return nodes_;
} }
const Vector<Link> &links() const const Vector<Link> &links() const
{ {
return m_links; return links_;
} }
void from_bNodeTree(const CompositorContext &context, bNodeTree *tree); void from_bNodeTree(const CompositorContext &context, bNodeTree *tree);
@@ -76,7 +71,7 @@ class NodeGraph {
static bNodeSocket *find_b_node_output(bNode *b_node, const char *identifier); 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_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, void add_bNodeTree(const CompositorContext &context,
int nodes_start, int nodes_start,

View File

@@ -17,13 +17,10 @@
*/ */
#include <cstdio> #include <cstdio>
#include <memory>
#include <typeinfo>
#include "COM_BufferOperation.h" #include "COM_BufferOperation.h"
#include "COM_ExecutionSystem.h" #include "COM_ExecutionSystem.h"
#include "COM_ReadBufferOperation.h" #include "COM_ReadBufferOperation.h"
#include "COM_defines.h"
#include "COM_NodeOperation.h" /* own include */ #include "COM_NodeOperation.h" /* own include */
@@ -37,20 +34,20 @@ NodeOperation::NodeOperation()
{ {
canvas_input_index_ = 0; canvas_input_index_ = 0;
canvas_ = COM_AREA_NONE; canvas_ = COM_AREA_NONE;
this->m_btree = nullptr; btree_ = nullptr;
} }
/** Get constant value when operation is constant, otherwise return default_value. */ /** Get constant value when operation is constant, otherwise return default_value. */
float NodeOperation::get_constant_value_default(float default_value) float NodeOperation::get_constant_value_default(float default_value)
{ {
BLI_assert(m_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); return *get_constant_elem_default(&default_value);
} }
/** Get constant elem when operation is constant, otherwise return default_elem. */ /** Get constant elem when operation is constant, otherwise return default_elem. */
const float *NodeOperation::get_constant_elem_default(const float *default_elem) const float *NodeOperation::get_constant_elem_default(const float *default_elem)
{ {
BLI_assert(m_outputs.size() > 0); BLI_assert(outputs_.size() > 0);
if (get_flags().is_constant_operation) { if (get_flags().is_constant_operation) {
return static_cast<ConstantOperation *>(this)->get_constant_elem(); return static_cast<ConstantOperation *>(this)->get_constant_elem();
} }
@@ -75,25 +72,25 @@ std::optional<NodeOperationHash> NodeOperation::generate_hash()
} }
hash_params(canvas_.ymin, canvas_.ymax); hash_params(canvas_.ymin, canvas_.ymax);
if (m_outputs.size() > 0) { if (outputs_.size() > 0) {
BLI_assert(m_outputs.size() == 1); BLI_assert(outputs_.size() == 1);
hash_param(this->getOutputSocket()->getDataType()); hash_param(this->get_output_socket()->get_data_type());
} }
NodeOperationHash hash; NodeOperationHash hash;
hash.params_hash_ = params_hash_; hash.params_hash_ = params_hash_;
hash.parents_hash_ = 0; hash.parents_hash_ = 0;
for (NodeOperationInput &socket : m_inputs) { for (NodeOperationInput &socket : inputs_) {
if (!socket.isConnected()) { if (!socket.is_connected()) {
continue; continue;
} }
NodeOperation &input = socket.getLink()->getOperation(); NodeOperation &input = socket.get_link()->get_operation();
const bool is_constant = input.get_flags().is_constant_operation; const bool is_constant = input.get_flags().is_constant_operation;
combine_hashes(hash.parents_hash_, get_default_hash(is_constant)); combine_hashes(hash.parents_hash_, get_default_hash(is_constant));
if (is_constant) { if (is_constant) {
const float *elem = ((ConstantOperation *)&input)->get_constant_elem(); 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)) { for (const int i : IndexRange(num_channels)) {
combine_hashes(hash.parents_hash_, get_default_hash(elem[i])); combine_hashes(hash.parents_hash_, get_default_hash(elem[i]));
} }
@@ -109,31 +106,31 @@ std::optional<NodeOperationHash> NodeOperation::generate_hash()
return hash; return hash;
} }
NodeOperationOutput *NodeOperation::getOutputSocket(unsigned int index) NodeOperationOutput *NodeOperation::get_output_socket(unsigned int index)
{ {
return &m_outputs[index]; return &outputs_[index];
} }
NodeOperationInput *NodeOperation::getInputSocket(unsigned int index) NodeOperationInput *NodeOperation::get_input_socket(unsigned int index)
{ {
return &m_inputs[index]; return &inputs_[index];
} }
void NodeOperation::addInputSocket(DataType datatype, ResizeMode resize_mode) void NodeOperation::add_input_socket(DataType datatype, ResizeMode resize_mode)
{ {
m_inputs.append(NodeOperationInput(this, datatype, resize_mode)); inputs_.append(NodeOperationInput(this, datatype, resize_mode));
} }
void NodeOperation::addOutputSocket(DataType datatype) void NodeOperation::add_output_socket(DataType datatype)
{ {
m_outputs.append(NodeOperationOutput(this, datatype)); outputs_.append(NodeOperationOutput(this, datatype));
} }
void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area) void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
{ {
unsigned int used_canvas_index = 0; unsigned int used_canvas_index = 0;
if (canvas_input_index_ == RESOLUTION_INPUT_ANY) { if (canvas_input_index_ == RESOLUTION_INPUT_ANY) {
for (NodeOperationInput &input : m_inputs) { for (NodeOperationInput &input : inputs_) {
rcti any_area = COM_AREA_NONE; rcti any_area = COM_AREA_NONE;
const bool determined = input.determine_canvas(preferred_area, any_area); const bool determined = input.determine_canvas(preferred_area, any_area);
if (determined) { if (determined) {
@@ -143,8 +140,8 @@ void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
used_canvas_index += 1; used_canvas_index += 1;
} }
} }
else if (canvas_input_index_ < m_inputs.size()) { else if (canvas_input_index_ < inputs_.size()) {
NodeOperationInput &input = m_inputs[canvas_input_index_]; NodeOperationInput &input = inputs_[canvas_input_index_];
input.determine_canvas(preferred_area, r_area); input.determine_canvas(preferred_area, r_area);
used_canvas_index = canvas_input_index_; used_canvas_index = canvas_input_index_;
} }
@@ -155,12 +152,12 @@ void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
rcti unused_area; rcti unused_area;
const rcti &local_preferred_area = r_area; const rcti &local_preferred_area = r_area;
for (unsigned int index = 0; index < m_inputs.size(); index++) { for (unsigned int index = 0; index < inputs_.size(); index++) {
if (index == used_canvas_index) { if (index == used_canvas_index) {
continue; continue;
} }
NodeOperationInput &input = m_inputs[index]; NodeOperationInput &input = inputs_[index];
if (input.isConnected()) { if (input.is_connected()) {
input.determine_canvas(local_preferred_area, unused_area); input.determine_canvas(local_preferred_area, unused_area);
} }
} }
@@ -175,32 +172,32 @@ void NodeOperation::init_data()
{ {
/* Pass. */ /* Pass. */
} }
void NodeOperation::initExecution() void NodeOperation::init_execution()
{ {
/* pass */ /* pass */
} }
void NodeOperation::initMutex() void NodeOperation::init_mutex()
{ {
BLI_mutex_init(&this->m_mutex); BLI_mutex_init(&mutex_);
} }
void NodeOperation::lockMutex() void NodeOperation::lock_mutex()
{ {
BLI_mutex_lock(&this->m_mutex); BLI_mutex_lock(&mutex_);
} }
void NodeOperation::unlockMutex() void NodeOperation::unlock_mutex()
{ {
BLI_mutex_unlock(&this->m_mutex); BLI_mutex_unlock(&mutex_);
} }
void NodeOperation::deinitMutex() void NodeOperation::deinit_mutex()
{ {
BLI_mutex_end(&this->m_mutex); BLI_mutex_end(&mutex_);
} }
void NodeOperation::deinitExecution() void NodeOperation::deinit_execution()
{ {
/* pass */ /* pass */
} }
@@ -222,52 +219,52 @@ const rcti &NodeOperation::get_canvas() const
*/ */
void NodeOperation::unset_canvas() void NodeOperation::unset_canvas()
{ {
BLI_assert(m_inputs.size() == 0); BLI_assert(inputs_.size() == 0);
flags.is_canvas_set = false; 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); NodeOperationInput *input = get_input_socket(index);
if (input && input->isConnected()) { if (input && input->is_connected()) {
return &input->getLink()->getOperation(); return &input->get_link()->get_operation();
} }
return nullptr; return nullptr;
} }
bool NodeOperation::determineDependingAreaOfInterest(rcti *input, bool NodeOperation::determine_depending_area_of_interest(rcti *input,
ReadBufferOperation *readOperation, ReadBufferOperation *read_operation,
rcti *output) rcti *output)
{ {
if (m_inputs.size() == 0) { if (inputs_.size() == 0) {
BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax); BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax);
return false; return false;
} }
rcti tempOutput; rcti temp_output;
bool first = true; bool first = true;
for (int i = 0; i < getNumberOfInputSockets(); i++) { for (int i = 0; i < get_number_of_input_sockets(); i++) {
NodeOperation *inputOperation = this->getInputOperation(i); NodeOperation *input_operation = this->get_input_operation(i);
if (inputOperation && if (input_operation && input_operation->determine_depending_area_of_interest(
inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) { input, read_operation, &temp_output)) {
if (first) { if (first) {
output->xmin = tempOutput.xmin; output->xmin = temp_output.xmin;
output->ymin = tempOutput.ymin; output->ymin = temp_output.ymin;
output->xmax = tempOutput.xmax; output->xmax = temp_output.xmax;
output->ymax = tempOutput.ymax; output->ymax = temp_output.ymax;
first = false; first = false;
} }
else { else {
output->xmin = MIN2(output->xmin, tempOutput.xmin); output->xmin = MIN2(output->xmin, temp_output.xmin);
output->ymin = MIN2(output->ymin, tempOutput.ymin); output->ymin = MIN2(output->ymin, temp_output.ymin);
output->xmax = MAX2(output->xmax, tempOutput.xmax); output->xmax = MAX2(output->xmax, temp_output.xmax);
output->ymax = MAX2(output->ymax, tempOutput.ymax); output->ymax = MAX2(output->ymax, temp_output.ymax);
} }
} }
} }
@@ -300,7 +297,7 @@ void NodeOperation::get_area_of_interest(const int input_idx,
else { else {
/* Non full-frame operations never implement this method. To ensure correctness assume /* Non full-frame operations never implement this method. To ensure correctness assume
* whole area is used. */ * 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(); r_input_area = input_op->get_canvas();
} }
} }
@@ -309,8 +306,8 @@ void NodeOperation::get_area_of_interest(NodeOperation *input_op,
const rcti &output_area, const rcti &output_area,
rcti &r_input_area) rcti &r_input_area)
{ {
for (int i = 0; i < getNumberOfInputSockets(); i++) { for (int i = 0; i < get_number_of_input_sockets(); i++) {
if (input_op == getInputOperation(i)) { if (input_op == get_input_operation(i)) {
get_area_of_interest(i, output_area, r_input_area); get_area_of_interest(i, output_area, r_input_area);
return; return;
} }
@@ -343,11 +340,11 @@ void NodeOperation::render_full_frame(MemoryBuffer *output_buf,
Span<rcti> areas, Span<rcti> areas,
Span<MemoryBuffer *> inputs_bufs) Span<MemoryBuffer *> inputs_bufs)
{ {
initExecution(); init_execution();
for (const rcti &area : areas) { for (const rcti &area : areas) {
update_memory_buffer(output_buf, area, inputs_bufs); update_memory_buffer(output_buf, area, inputs_bufs);
} }
deinitExecution(); deinit_execution();
} }
/** /**
@@ -359,18 +356,18 @@ void NodeOperation::render_full_frame_fallback(MemoryBuffer *output_buf,
{ {
Vector<NodeOperationOutput *> orig_input_links = replace_inputs_with_buffers(inputs_bufs); Vector<NodeOperationOutput *> orig_input_links = replace_inputs_with_buffers(inputs_bufs);
initExecution(); init_execution();
const bool is_output_operation = getNumberOfOutputSockets() == 0; const bool is_output_operation = get_number_of_output_sockets() == 0;
if (!is_output_operation && output_buf->is_a_single_elem()) { if (!is_output_operation && output_buf->is_a_single_elem()) {
float *output_elem = output_buf->get_elem(0, 0); 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 { else {
for (const rcti &rect : areas) { for (const rcti &rect : areas) {
exec_system_->execute_work(rect, [=](const rcti &split_rect) { exec_system_->execute_work(rect, [=](const rcti &split_rect) {
rcti tile_rect = split_rect; rcti tile_rect = split_rect;
if (is_output_operation) { if (is_output_operation) {
executeRegion(&tile_rect, 0); execute_region(&tile_rect, 0);
} }
else { else {
render_tile(output_buf, &tile_rect); render_tile(output_buf, &tile_rect);
@@ -378,7 +375,7 @@ void NodeOperation::render_full_frame_fallback(MemoryBuffer *output_buf,
}); });
} }
} }
deinitExecution(); deinit_execution();
remove_buffers_and_restore_original_inputs(orig_input_links); remove_buffers_and_restore_original_inputs(orig_input_links);
} }
@@ -386,7 +383,7 @@ void NodeOperation::render_full_frame_fallback(MemoryBuffer *output_buf,
void NodeOperation::render_tile(MemoryBuffer *output_buf, rcti *tile_rect) void NodeOperation::render_tile(MemoryBuffer *output_buf, rcti *tile_rect)
{ {
const bool is_complex = get_flags().complex; 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; const int elem_stride = output_buf->elem_stride;
for (int y = tile_rect->ymin; y < tile_rect->ymax; y++) { for (int y = tile_rect->ymin; y < tile_rect->ymax; y++) {
float *output_elem = output_buf->get_elem(tile_rect->xmin, y); float *output_elem = output_buf->get_elem(tile_rect->xmin, y);
@@ -398,13 +395,13 @@ void NodeOperation::render_tile(MemoryBuffer *output_buf, rcti *tile_rect)
} }
else { else {
for (int x = tile_rect->xmin; x < tile_rect->xmax; x++) { 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; output_elem += elem_stride;
} }
} }
} }
if (tile_data) { if (tile_data) {
deinitializeTileData(tile_rect, tile_data); deinitialize_tile_data(tile_rect, tile_data);
} }
} }
@@ -414,14 +411,15 @@ void NodeOperation::render_tile(MemoryBuffer *output_buf, rcti *tile_rect)
Vector<NodeOperationOutput *> NodeOperation::replace_inputs_with_buffers( Vector<NodeOperationOutput *> NodeOperation::replace_inputs_with_buffers(
Span<MemoryBuffer *> inputs_bufs) 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()); Vector<NodeOperationOutput *> orig_links(inputs_bufs.size());
for (int i = 0; i < inputs_bufs.size(); i++) { for (int i = 0; i < inputs_bufs.size(); i++) {
NodeOperationInput *input_socket = getInputSocket(i); NodeOperationInput *input_socket = get_input_socket(i);
BufferOperation *buffer_op = new BufferOperation(inputs_bufs[i], input_socket->getDataType()); BufferOperation *buffer_op = new BufferOperation(inputs_bufs[i],
orig_links[i] = input_socket->getLink(); input_socket->get_data_type());
input_socket->setLink(buffer_op->getOutputSocket()); orig_links[i] = input_socket->get_link();
buffer_op->initExecution(); input_socket->set_link(buffer_op->get_output_socket());
buffer_op->init_execution();
} }
return orig_links; return orig_links;
} }
@@ -429,14 +427,14 @@ Vector<NodeOperationOutput *> NodeOperation::replace_inputs_with_buffers(
void NodeOperation::remove_buffers_and_restore_original_inputs( void NodeOperation::remove_buffers_and_restore_original_inputs(
Span<NodeOperationOutput *> original_inputs_links) 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++) { for (int i = 0; i < original_inputs_links.size(); i++) {
NodeOperation *buffer_op = get_input_operation(i); NodeOperation *buffer_op = get_input_operation(i);
BLI_assert(buffer_op != nullptr); BLI_assert(buffer_op != nullptr);
BLI_assert(typeid(*buffer_op) == typeid(BufferOperation)); BLI_assert(typeid(*buffer_op) == typeid(BufferOperation));
buffer_op->deinitExecution(); buffer_op->deinit_execution();
NodeOperationInput *input_socket = getInputSocket(i); NodeOperationInput *input_socket = get_input_socket(i);
input_socket->setLink(original_inputs_links[i]); input_socket->set_link(original_inputs_links[i]);
delete buffer_op; delete buffer_op;
} }
} }
@@ -447,15 +445,17 @@ void NodeOperation::remove_buffers_and_restore_original_inputs(
**** OpInput **** **** OpInput ****
*****************/ *****************/
NodeOperationInput::NodeOperationInput(NodeOperation *op, DataType datatype, ResizeMode resizeMode) NodeOperationInput::NodeOperationInput(NodeOperation *op,
: m_operation(op), m_datatype(datatype), m_resizeMode(resizeMode), m_link(nullptr) DataType datatype,
ResizeMode resize_mode)
: operation_(op), datatype_(datatype), resize_mode_(resize_mode), link_(nullptr)
{ {
} }
SocketReader *NodeOperationInput::getReader() SocketReader *NodeOperationInput::get_reader()
{ {
if (isConnected()) { if (is_connected()) {
return &m_link->getOperation(); return &link_->get_operation();
} }
return nullptr; return nullptr;
@@ -466,8 +466,8 @@ SocketReader *NodeOperationInput::getReader()
*/ */
bool NodeOperationInput::determine_canvas(const rcti &preferred_area, rcti &r_area) bool NodeOperationInput::determine_canvas(const rcti &preferred_area, rcti &r_area)
{ {
if (m_link) { if (link_) {
m_link->determine_canvas(preferred_area, r_area); link_->determine_canvas(preferred_area, r_area);
return !BLI_rcti_is_empty(&r_area); return !BLI_rcti_is_empty(&r_area);
} }
return false; return false;
@@ -478,13 +478,13 @@ bool NodeOperationInput::determine_canvas(const rcti &preferred_area, rcti &r_ar
******************/ ******************/
NodeOperationOutput::NodeOperationOutput(NodeOperation *op, DataType datatype) NodeOperationOutput::NodeOperationOutput(NodeOperation *op, DataType datatype)
: m_operation(op), m_datatype(datatype) : operation_(op), datatype_(datatype)
{ {
} }
void NodeOperationOutput::determine_canvas(const rcti &preferred_area, rcti &r_area) 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) { if (operation.get_flags().is_canvas_set) {
r_area = operation.get_canvas(); r_area = operation.get_canvas();
} }
@@ -561,9 +561,9 @@ std::ostream &operator<<(std::ostream &os, const NodeOperation &node_operation)
os << ",flags={" << flags << "}"; os << ",flags={" << flags << "}";
if (flags.is_read_buffer_operation) { if (flags.is_read_buffer_operation) {
const ReadBufferOperation *read_operation = (const ReadBufferOperation *)&node_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) { if (proxy) {
const WriteBufferOperation *write_operation = proxy->getWriteBufferOperation(); const WriteBufferOperation *write_operation = proxy->get_write_buffer_operation();
if (write_operation) { if (write_operation) {
os << ",write=" << (NodeOperation &)*write_operation; os << ",write=" << (NodeOperation &)*write_operation;
} }

View File

@@ -18,32 +18,32 @@
#pragma once #pragma once
#include <functional>
#include <list> #include <list>
#include <sstream>
#include <string>
#include "BLI_ghash.h" #include "BLI_ghash.h"
#include "BLI_hash.hh" #include "BLI_hash.hh"
#include "BLI_math_color.h" #include "BLI_rect.h"
#include "BLI_math_vector.h" #include "BLI_span.hh"
#include "BLI_threads.h" #include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "COM_Enums.h" #include "COM_Enums.h"
#include "COM_MemoryBuffer.h" #include "COM_MemoryBuffer.h"
#include "COM_MemoryProxy.h"
#include "COM_MetaData.h" #include "COM_MetaData.h"
#include "COM_Node.h"
#include "clew.h" #include "clew.h"
#include "DNA_node_types.h"
namespace blender::compositor { namespace blender::compositor {
class OpenCLDevice; class OpenCLDevice;
class ReadBufferOperation; class ReadBufferOperation;
class WriteBufferOperation;
class ExecutionSystem; class ExecutionSystem;
class NodeOperation; class NodeOperation;
class NodeOperationOutput;
typedef NodeOperation SocketReader; typedef NodeOperation SocketReader;
/** /**
@@ -83,56 +83,56 @@ enum class ResizeMode {
class NodeOperationInput { class NodeOperationInput {
private: private:
NodeOperation *m_operation; NodeOperation *operation_;
/** Datatype of this socket. Is used for automatically data transformation. /** Datatype of this socket. Is used for automatically data transformation.
* \section data-conversion * \section data-conversion
*/ */
DataType m_datatype; DataType datatype_;
/** Resize mode of this socket */ /** Resize mode of this socket */
ResizeMode m_resizeMode; ResizeMode resize_mode_;
/** Connected output */ /** Connected output */
NodeOperationOutput *m_link; NodeOperationOutput *link_;
public: public:
NodeOperationInput(NodeOperation *op, NodeOperationInput(NodeOperation *op,
DataType datatype, DataType datatype,
ResizeMode resizeMode = ResizeMode::Center); ResizeMode resize_mode = ResizeMode::Center);
NodeOperation &getOperation() const NodeOperation &get_operation() const
{ {
return *m_operation; return *operation_;
} }
DataType getDataType() const DataType get_data_type() const
{ {
return m_datatype; return datatype_;
} }
void setLink(NodeOperationOutput *link) void set_link(NodeOperationOutput *link)
{ {
m_link = link; link_ = link;
} }
NodeOperationOutput *getLink() const NodeOperationOutput *get_link() const
{ {
return m_link; return link_;
} }
bool isConnected() const bool is_connected() const
{ {
return m_link; return link_;
} }
void setResizeMode(ResizeMode resizeMode) void set_resize_mode(ResizeMode resize_mode)
{ {
this->m_resizeMode = resizeMode; resize_mode_ = resize_mode;
} }
ResizeMode getResizeMode() const ResizeMode get_resize_mode() const
{ {
return this->m_resizeMode; return resize_mode_;
} }
SocketReader *getReader(); SocketReader *get_reader();
bool determine_canvas(const rcti &preferred_area, rcti &r_area); bool determine_canvas(const rcti &preferred_area, rcti &r_area);
@@ -143,23 +143,23 @@ class NodeOperationInput {
class NodeOperationOutput { class NodeOperationOutput {
private: private:
NodeOperation *m_operation; NodeOperation *operation_;
/** Datatype of this socket. Is used for automatically data transformation. /** Datatype of this socket. Is used for automatically data transformation.
* \section data-conversion * \section data-conversion
*/ */
DataType m_datatype; DataType datatype_;
public: public:
NodeOperationOutput(NodeOperation *op, DataType datatype); NodeOperationOutput(NodeOperation *op, DataType datatype);
NodeOperation &getOperation() const NodeOperation &get_operation() const
{ {
return *m_operation; return *operation_;
} }
DataType getDataType() const DataType get_data_type() const
{ {
return m_datatype; return datatype_;
} }
void determine_canvas(const rcti &preferred_area, rcti &r_area); void determine_canvas(const rcti &preferred_area, rcti &r_area);
@@ -314,10 +314,10 @@ struct NodeOperationHash {
*/ */
class NodeOperation { class NodeOperation {
private: private:
int m_id; int id_;
std::string m_name; std::string name_;
Vector<NodeOperationInput> m_inputs; Vector<NodeOperationInput> inputs_;
Vector<NodeOperationOutput> m_outputs; Vector<NodeOperationOutput> outputs_;
size_t params_hash_; size_t params_hash_;
bool is_hash_output_params_implemented_; bool is_hash_output_params_implemented_;
@@ -334,16 +334,16 @@ class NodeOperation {
* \note only use when you really know what you are doing. * \note only use when you really know what you are doing.
* this mutex is used to share data among chunks in the same operation * this mutex is used to share data among chunks in the same operation
* \see TonemapOperation for an example of usage * \see TonemapOperation for an example of usage
* \see NodeOperation.initMutex initializes this mutex * \see NodeOperation.init_mutex initializes this mutex
* \see NodeOperation.deinitMutex deinitializes this mutex * \see NodeOperation.deinit_mutex deinitializes this mutex
* \see NodeOperation.getMutex retrieve a pointer to this mutex. * \see NodeOperation.get_mutex retrieve a pointer to this mutex.
*/ */
ThreadMutex m_mutex; ThreadMutex mutex_;
/** /**
* \brief reference to the editing bNodeTree, used for break and update callback * \brief reference to the editing bNodeTree, used for break and update callback
*/ */
const bNodeTree *m_btree; const bNodeTree *btree_;
protected: protected:
/** /**
@@ -367,22 +367,22 @@ class NodeOperation {
void set_name(const std::string name) void set_name(const std::string name)
{ {
m_name = name; name_ = name;
} }
const std::string get_name() const const std::string get_name() const
{ {
return m_name; return name_;
} }
void set_id(const int id) void set_id(const int id)
{ {
m_id = id; id_ = id;
} }
const int get_id() const const int get_id() const
{ {
return m_id; return id_;
} }
float get_constant_value_default(float default_value); float get_constant_value_default(float default_value);
@@ -395,28 +395,23 @@ class NodeOperation {
std::optional<NodeOperationHash> generate_hash(); std::optional<NodeOperationHash> generate_hash();
unsigned int getNumberOfInputSockets() const unsigned int get_number_of_input_sockets() const
{ {
return m_inputs.size(); return inputs_.size();
} }
unsigned int getNumberOfOutputSockets() const unsigned int get_number_of_output_sockets() const
{ {
return m_outputs.size(); return outputs_.size();
} }
NodeOperationOutput *getOutputSocket(unsigned int index = 0); NodeOperationOutput *get_output_socket(unsigned int index = 0);
NodeOperationInput *getInputSocket(unsigned int index); NodeOperationInput *get_input_socket(unsigned int index);
NodeOperation *get_input_operation(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);
}
virtual void determine_canvas(const rcti &preferred_area, rcti &r_area); 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. * ExecutionSystem during rendering or editing.
* *
* Default behavior if not overridden, this operation will not be evaluated as being an output * 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 * \return bool the result of this method
*/ */
virtual bool isOutputOperation(bool /*rendering*/) const virtual bool is_output_operation(bool /*rendering*/) const
{ {
return false; return false;
} }
@@ -440,9 +435,9 @@ class NodeOperation {
execution_model_ = model; execution_model_ = model;
} }
void setbNodeTree(const bNodeTree *tree) void set_bnodetree(const bNodeTree *tree)
{ {
this->m_btree = tree; btree_ = tree;
} }
void set_execution_system(ExecutionSystem *system) void set_execution_system(ExecutionSystem *system)
@@ -452,20 +447,20 @@ class NodeOperation {
/** /**
* Initializes operation data needed after operations are linked and resolutions determined. For * 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 init_data();
virtual void initExecution(); virtual void init_execution();
/** /**
* \brief when a chunk is executed by a CPUDevice, this method is called * \brief when a chunk is executed by a CPUDevice, this method is called
* \ingroup execution * \ingroup execution
* \param rect: the rectangle of the chunk (location and size) * \param rect: the rectangle of the chunk (location and size)
* \param chunkNumber: the chunkNumber to be calculated * \param chunk_number: the chunk_number to be calculated
* \param memoryBuffers: all input MemoryBuffer's needed * \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 program: the OpenCL program containing all compositor kernels
* \param queue: the OpenCL command queue of the device the chunk is executed on * \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 rect: the rectangle of the chunk (location and size)
* \param chunkNumber: the chunkNumber to be calculated * \param chunk_number: the chunk_number to be calculated
* \param memoryBuffers: all input MemoryBuffer's needed * \param memory_buffers: all input MemoryBuffer's needed
* \param outputBuffer: the outputbuffer to write to * \param output_buffer: the outputbuffer to write to
*/ */
virtual void executeOpenCLRegion(OpenCLDevice * /*device*/, virtual void execute_opencl_region(OpenCLDevice * /*device*/,
rcti * /*rect*/, rcti * /*rect*/,
unsigned int /*chunkNumber*/, unsigned int /*chunk_number*/,
MemoryBuffer ** /*memoryBuffers*/, MemoryBuffer ** /*memory_buffers*/,
MemoryBuffer * /*outputBuffer*/) MemoryBuffer * /*output_buffer*/)
{ {
} }
@@ -496,23 +491,23 @@ class NodeOperation {
* \param context: the OpenCL context * \param context: the OpenCL context
* \param program: the OpenCL program containing all compositor kernels * \param program: the OpenCL program containing all compositor kernels
* \param queue: the OpenCL command queue of the device the chunk is executed on * \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 output_memory_buffer: the allocated memory buffer in main CPU memory
* \param clOutputBuffer: the allocated memory buffer in OpenCLDevice memory * \param cl_output_buffer: the allocated memory buffer in OpenCLDevice memory
* \param inputMemoryBuffers: all input MemoryBuffer's needed * \param input_memory_buffers: all input MemoryBuffer's needed
* \param clMemToCleanUp: all created cl_mem references must be added to this list. * \param cl_mem_to_clean_up: all created cl_mem references must be added to this list.
* Framework will clean this after execution * 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 * Framework will clean this after execution
*/ */
virtual void executeOpenCL(OpenCLDevice * /*device*/, virtual void execute_opencl(OpenCLDevice * /*device*/,
MemoryBuffer * /*outputMemoryBuffer*/, MemoryBuffer * /*output_memory_buffer*/,
cl_mem /*clOutputBuffer*/, cl_mem /*cl_output_buffer*/,
MemoryBuffer ** /*inputMemoryBuffers*/, MemoryBuffer ** /*input_memory_buffers*/,
std::list<cl_mem> * /*clMemToCleanUp*/, std::list<cl_mem> * /*cl_mem_to_clean_up*/,
std::list<cl_kernel> * /*clKernelsToCleanUp*/) std::list<cl_kernel> * /*cl_kernels_to_clean_up*/)
{ {
} }
virtual void deinitExecution(); virtual void deinit_execution();
void set_canvas(const rcti &canvas_area); void set_canvas(const rcti &canvas_area);
const rcti &get_canvas() const; const rcti &get_canvas() const;
@@ -525,13 +520,13 @@ class NodeOperation {
* \return [true:false] * \return [true:false]
* \see BaseViewerOperation * \see BaseViewerOperation
*/ */
virtual bool isActiveViewerOutput() const virtual bool is_active_viewer_output() const
{ {
return false; return false;
} }
virtual bool determineDependingAreaOfInterest(rcti *input, virtual bool determine_depending_area_of_interest(rcti *input,
ReadBufferOperation *readOperation, ReadBufferOperation *read_operation,
rcti *output); rcti *output);
/** /**
@@ -554,58 +549,58 @@ class NodeOperation {
* \note only applicable for output operations like ViewerOperation * \note only applicable for output operations like ViewerOperation
* \return eCompositorPriority * \return eCompositorPriority
*/ */
virtual eCompositorPriority getRenderPriority() const virtual eCompositorPriority get_render_priority() const
{ {
return eCompositorPriority::Low; return eCompositorPriority::Low;
} }
inline bool isBraked() const inline bool is_braked() const
{ {
return this->m_btree->test_break(this->m_btree->tbh); return btree_->test_break(btree_->tbh);
} }
inline void updateDraw() inline void update_draw()
{ {
if (this->m_btree->update_draw) { if (btree_->update_draw) {
this->m_btree->update_draw(this->m_btree->udh); btree_->update_draw(btree_->udh);
} }
} }
unsigned int getWidth() const unsigned int get_width() const
{ {
return BLI_rcti_size_x(&get_canvas()); return BLI_rcti_size_x(&get_canvas());
} }
unsigned int getHeight() const unsigned int get_height() const
{ {
return BLI_rcti_size_y(&get_canvas()); 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; 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; return 0;
} }
@@ -614,7 +609,7 @@ class NodeOperation {
* Return the meta data associated with this branch. * Return the meta data associated with this branch.
* *
* The return parameter holds an instance or is an nullptr. */ * 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>(); return std::unique_ptr<MetaData>();
} }
@@ -672,28 +667,27 @@ class NodeOperation {
combine_hashes(params_hash_, get_default_hash_3(param1, param2, param3)); combine_hashes(params_hash_, get_default_hash_3(param1, param2, param3));
} }
void addInputSocket(DataType datatype, ResizeMode resize_mode = ResizeMode::Center); void add_input_socket(DataType datatype, ResizeMode resize_mode = ResizeMode::Center);
void addOutputSocket(DataType datatype); void add_output_socket(DataType datatype);
/* TODO(manzanilla): to be removed with tiled implementation. */ /* TODO(manzanilla): to be removed with tiled implementation. */
void setWidth(unsigned int width) void set_width(unsigned int width)
{ {
canvas_.xmax = canvas_.xmin + width; canvas_.xmax = canvas_.xmin + width;
this->flags.is_canvas_set = true; this->flags.is_canvas_set = true;
} }
void setHeight(unsigned int height) void set_height(unsigned int height)
{ {
canvas_.ymax = canvas_.ymin + height; canvas_.ymax = canvas_.ymin + height;
this->flags.is_canvas_set = true; this->flags.is_canvas_set = true;
} }
SocketReader *getInputSocketReader(unsigned int inputSocketindex); SocketReader *get_input_socket_reader(unsigned int index);
NodeOperation *getInputOperation(unsigned int inputSocketindex);
void deinitMutex(); void deinit_mutex();
void initMutex(); void init_mutex();
void lockMutex(); void lock_mutex();
void unlockMutex(); void unlock_mutex();
/** /**
* \brief set whether this operation is complex * \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. * 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. * 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; this->flags.complex = complex;
} }
@@ -712,9 +706,9 @@ class NodeOperation {
* \param result: is a float[4] array to store the result * \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 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 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], virtual void execute_pixel_sampled(float /*output*/[4],
float /*x*/, float /*x*/,
float /*y*/, float /*y*/,
PixelSampler /*sampler*/) PixelSampler /*sampler*/)
@@ -727,12 +721,12 @@ class NodeOperation {
* \param result: is a float[4] array to store the result * \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 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 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.
* \param chunkData: chunk specific data a during execution time. * \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 y: the y-coordinate of the pixel to calculate in image space
* \param dx: * \param dx:
* \param dy: * \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]) float /*output*/[4], float /*x*/, float /*y*/, float /*dx*/[2], float /*dy*/[2])
{ {
} }

View File

@@ -16,24 +16,19 @@
* Copyright 2013, Blender Foundation. * Copyright 2013, Blender Foundation.
*/ */
#include <set>
#include "BLI_multi_value_map.hh" #include "BLI_multi_value_map.hh"
#include "BLI_utildefines.h"
#include "COM_Converter.h" #include "COM_Converter.h"
#include "COM_Debug.h" #include "COM_Debug.h"
#include "COM_ExecutionSystem.h"
#include "COM_Node.h"
#include "COM_NodeConverter.h"
#include "COM_SocketProxyNode.h"
#include "COM_NodeOperation.h" #include "COM_ExecutionGroup.h"
#include "COM_PreviewOperation.h" #include "COM_PreviewOperation.h"
#include "COM_ReadBufferOperation.h" #include "COM_ReadBufferOperation.h"
#include "COM_SetColorOperation.h" #include "COM_SetColorOperation.h"
#include "COM_SetValueOperation.h" #include "COM_SetValueOperation.h"
#include "COM_SetVectorOperation.h" #include "COM_SetVectorOperation.h"
#include "COM_SocketProxyOperation.h"
#include "COM_TranslateOperation.h"
#include "COM_ViewerOperation.h" #include "COM_ViewerOperation.h"
#include "COM_WriteBufferOperation.h" #include "COM_WriteBufferOperation.h"
@@ -45,39 +40,39 @@ namespace blender::compositor {
NodeOperationBuilder::NodeOperationBuilder(const CompositorContext *context, NodeOperationBuilder::NodeOperationBuilder(const CompositorContext *context,
bNodeTree *b_nodetree, bNodeTree *b_nodetree,
ExecutionSystem *system) ExecutionSystem *system)
: m_context(context), exec_system_(system), m_current_node(nullptr), m_active_viewer(nullptr) : context_(context), exec_system_(system), current_node_(nullptr), active_viewer_(nullptr)
{ {
m_graph.from_bNodeTree(*context, b_nodetree); graph_.from_bNodeTree(*context, b_nodetree);
} }
void NodeOperationBuilder::convertToOperations(ExecutionSystem *system) void NodeOperationBuilder::convert_to_operations(ExecutionSystem *system)
{ {
/* interface handle for nodes */ /* interface handle for nodes */
NodeConverter converter(this); NodeConverter converter(this);
for (Node *node : m_graph.nodes()) { for (Node *node : graph_.nodes()) {
m_current_node = node; current_node_ = node;
DebugInfo::node_to_operations(node); DebugInfo::node_to_operations(node);
node->convertToOperations(converter, *m_context); node->convert_to_operations(converter, *context_);
} }
m_current_node = nullptr; current_node_ = nullptr;
/* The input map constructed by nodes maps operation inputs to node inputs. /* The input map constructed by nodes maps operation inputs to node inputs.
* Inverting yields a map of node inputs to all connected operation inputs, * Inverting yields a map of node inputs to all connected operation inputs,
* so multiple operations can use the same node input. * so multiple operations can use the same node input.
*/ */
blender::MultiValueMap<NodeInput *, NodeOperationInput *> inverse_input_map; blender::MultiValueMap<NodeInput *, NodeOperationInput *> inverse_input_map;
for (Map<NodeOperationInput *, NodeInput *>::MutableItem item : m_input_map.items()) { for (Map<NodeOperationInput *, NodeInput *>::MutableItem item : input_map_.items()) {
inverse_input_map.add(item.value, item.key); inverse_input_map.add(item.value, item.key);
} }
for (const NodeGraph::Link &link : m_graph.links()) { for (const NodeGraph::Link &link : graph_.links()) {
NodeOutput *from = link.from; NodeOutput *from = link.from;
NodeInput *to = link.to; NodeInput *to = link.to;
NodeOperationOutput *op_from = m_output_map.lookup_default(from, nullptr); NodeOperationOutput *op_from = output_map_.lookup_default(from, nullptr);
const blender::Span<NodeOperationInput *> op_to_list = inverse_input_map.lookup(to); const blender::Span<NodeOperationInput *> op_to_list = inverse_input_map.lookup(to);
if (!op_from || op_to_list.is_empty()) { if (!op_from || op_to_list.is_empty()) {
@@ -91,7 +86,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
} }
for (NodeOperationInput *op_to : op_to_list) { for (NodeOperationInput *op_to : op_to_list) {
addLink(op_from, op_to); add_link(op_from, op_to);
} }
} }
@@ -101,7 +96,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
add_datatype_conversions(); add_datatype_conversions();
if (m_context->get_execution_model() == eExecutionModel::FullFrame) { if (context_->get_execution_model() == eExecutionModel::FullFrame) {
save_graphviz("compositor_prior_folding"); save_graphviz("compositor_prior_folding");
ConstantFolder folder(*this); ConstantFolder folder(*this);
folder.fold_operations(); folder.fold_operations();
@@ -112,111 +107,111 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
save_graphviz("compositor_prior_merging"); save_graphviz("compositor_prior_merging");
merge_equal_operations(); merge_equal_operations();
if (m_context->get_execution_model() == eExecutionModel::Tiled) { if (context_->get_execution_model() == eExecutionModel::Tiled) {
/* surround complex ops with read/write buffer */ /* surround complex ops with read/write buffer */
add_complex_operation_buffers(); add_complex_operation_buffers();
} }
/* links not available from here on */ /* links not available from here on */
/* XXX make m_links a local variable to avoid confusion! */ /* XXX make links_ a local variable to avoid confusion! */
m_links.clear(); links_.clear();
prune_operations(); prune_operations();
/* ensure topological (link-based) order of nodes */ /* ensure topological (link-based) order of nodes */
/*sort_operations();*/ /* not needed yet */ /*sort_operations();*/ /* not needed yet */
if (m_context->get_execution_model() == eExecutionModel::Tiled) { if (context_->get_execution_model() == eExecutionModel::Tiled) {
/* create execution groups */ /* create execution groups */
group_operations(); group_operations();
} }
/* transfer resulting operations to the system */ /* transfer resulting operations to the system */
system->set_operations(m_operations, m_groups); system->set_operations(operations_, groups_);
} }
void NodeOperationBuilder::addOperation(NodeOperation *operation) void NodeOperationBuilder::add_operation(NodeOperation *operation)
{ {
operation->set_id(m_operations.size()); operation->set_id(operations_.size());
m_operations.append(operation); operations_.append(operation);
if (m_current_node) { if (current_node_) {
operation->set_name(m_current_node->getbNode()->name); operation->set_name(current_node_->get_bnode()->name);
} }
operation->set_execution_model(m_context->get_execution_model()); operation->set_execution_model(context_->get_execution_model());
operation->set_execution_system(exec_system_); operation->set_execution_system(exec_system_);
} }
void NodeOperationBuilder::replace_operation_with_constant(NodeOperation *operation, void NodeOperationBuilder::replace_operation_with_constant(NodeOperation *operation,
ConstantOperation *constant_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); 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, void NodeOperationBuilder::unlink_inputs_and_relink_outputs(NodeOperation *unlinked_op,
NodeOperation *linked_op) NodeOperation *linked_op)
{ {
int i = 0; int i = 0;
while (i < m_links.size()) { while (i < links_.size()) {
Link &link = m_links[i]; Link &link = links_[i];
if (&link.to()->getOperation() == unlinked_op) { if (&link.to()->get_operation() == unlinked_op) {
link.to()->setLink(nullptr); link.to()->set_link(nullptr);
m_links.remove(i); links_.remove(i);
continue; continue;
} }
if (&link.from()->getOperation() == unlinked_op) { if (&link.from()->get_operation() == unlinked_op) {
link.to()->setLink(linked_op->getOutputSocket()); link.to()->set_link(linked_op->get_output_socket());
m_links[i] = Link(linked_op->getOutputSocket(), link.to()); links_[i] = Link(linked_op->get_output_socket(), link.to());
} }
i++; i++;
} }
} }
void NodeOperationBuilder::mapInputSocket(NodeInput *node_socket, void NodeOperationBuilder::map_input_socket(NodeInput *node_socket,
NodeOperationInput *operation_socket) NodeOperationInput *operation_socket)
{ {
BLI_assert(m_current_node); BLI_assert(current_node_);
BLI_assert(node_socket->getNode() == m_current_node); BLI_assert(node_socket->get_node() == current_node_);
/* NOTE: this maps operation sockets to node sockets. /* 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. * to get a list of links for each node input socket.
*/ */
m_input_map.add_new(operation_socket, node_socket); input_map_.add_new(operation_socket, node_socket);
} }
void NodeOperationBuilder::mapOutputSocket(NodeOutput *node_socket, void NodeOperationBuilder::map_output_socket(NodeOutput *node_socket,
NodeOperationOutput *operation_socket) NodeOperationOutput *operation_socket)
{ {
BLI_assert(m_current_node); BLI_assert(current_node_);
BLI_assert(node_socket->getNode() == m_current_node); BLI_assert(node_socket->get_node() == current_node_);
m_output_map.add_new(node_socket, operation_socket); 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; return;
} }
m_links.append(Link(from, to)); links_.append(Link(from, to));
/* register with the input */ /* 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; int index = 0;
for (Link &link : m_links) { for (Link &link : links_) {
if (link.to() == to) { if (link.to() == to) {
/* unregister with the input */ /* unregister with the input */
to->setLink(nullptr); to->set_link(nullptr);
m_links.remove(index); links_.remove(index);
return; return;
} }
index++; index++;
@@ -225,69 +220,69 @@ void NodeOperationBuilder::removeInputLink(NodeOperationInput *to)
PreviewOperation *NodeOperationBuilder::make_preview_operation() const PreviewOperation *NodeOperationBuilder::make_preview_operation() const
{ {
BLI_assert(m_current_node); BLI_assert(current_node_);
if (!(m_current_node->getbNode()->flag & NODE_PREVIEW)) { if (!(current_node_->get_bnode()->flag & NODE_PREVIEW)) {
return nullptr; return nullptr;
} }
/* previews only in the active group */ /* previews only in the active group */
if (!m_current_node->isInActiveGroup()) { if (!current_node_->is_in_active_group()) {
return nullptr; return nullptr;
} }
/* do not calculate previews of hidden nodes */ /* do not calculate previews of hidden nodes */
if (m_current_node->getbNode()->flag & NODE_HIDDEN) { if (current_node_->get_bnode()->flag & NODE_HIDDEN) {
return nullptr; return nullptr;
} }
bNodeInstanceHash *previews = m_context->getPreviewHash(); bNodeInstanceHash *previews = context_->get_preview_hash();
if (previews) { if (previews) {
PreviewOperation *operation = new PreviewOperation(m_context->getViewSettings(), PreviewOperation *operation = new PreviewOperation(context_->get_view_settings(),
m_context->getDisplaySettings(), context_->get_display_settings(),
m_current_node->getbNode()->preview_xsize, current_node_->get_bnode()->preview_xsize,
m_current_node->getbNode()->preview_ysize); current_node_->get_bnode()->preview_ysize);
operation->setbNodeTree(m_context->getbNodeTree()); operation->set_bnodetree(context_->get_bnodetree());
operation->verifyPreview(previews, m_current_node->getInstanceKey()); operation->verify_preview(previews, current_node_->get_instance_key());
return operation; return operation;
} }
return nullptr; return nullptr;
} }
void NodeOperationBuilder::addPreview(NodeOperationOutput *output) void NodeOperationBuilder::add_preview(NodeOperationOutput *output)
{ {
PreviewOperation *operation = make_preview_operation(); PreviewOperation *operation = make_preview_operation();
if (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(); PreviewOperation *operation = make_preview_operation();
if (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 (m_active_viewer) { if (active_viewer_) {
if (m_current_node->isInActiveGroup()) { if (current_node_->is_in_active_group()) {
/* deactivate previous viewer */ /* deactivate previous viewer */
m_active_viewer->setActive(false); active_viewer_->set_active(false);
m_active_viewer = viewer; active_viewer_ = viewer;
viewer->setActive(true); viewer->set_active(true);
} }
} }
else { else {
if (m_current_node->getbNodeTree() == m_context->getbNodeTree()) { if (current_node_->get_bnodetree() == context_->get_bnodetree()) {
m_active_viewer = viewer; active_viewer_ = viewer;
viewer->setActive(true); viewer->set_active(true);
} }
} }
} }
@@ -299,27 +294,27 @@ void NodeOperationBuilder::registerViewer(ViewerOperation *viewer)
void NodeOperationBuilder::add_datatype_conversions() void NodeOperationBuilder::add_datatype_conversions()
{ {
Vector<Link> convert_links; Vector<Link> convert_links;
for (const Link &link : m_links) { for (const Link &link : links_) {
/* proxy operations can skip data type conversion */ /* proxy operations can skip data type conversion */
NodeOperation *from_op = &link.from()->getOperation(); NodeOperation *from_op = &link.from()->get_operation();
NodeOperation *to_op = &link.to()->getOperation(); NodeOperation *to_op = &link.to()->get_operation();
if (!(from_op->get_flags().use_datatype_conversion || if (!(from_op->get_flags().use_datatype_conversion ||
to_op->get_flags().use_datatype_conversion)) { to_op->get_flags().use_datatype_conversion)) {
continue; continue;
} }
if (link.from()->getDataType() != link.to()->getDataType()) { if (link.from()->get_data_type() != link.to()->get_data_type()) {
convert_links.append(link); convert_links.append(link);
} }
} }
for (const Link &link : convert_links) { for (const Link &link : convert_links) {
NodeOperation *converter = COM_convert_data_type(*link.from(), *link.to()); NodeOperation *converter = COM_convert_data_type(*link.from(), *link.to());
if (converter) { if (converter) {
addOperation(converter); add_operation(converter);
removeInputLink(link.to()); remove_input_link(link.to());
addLink(link.from(), converter->getInputSocket(0)); add_link(link.from(), converter->get_input_socket(0));
addLink(converter->getOutputSocket(0), link.to()); add_link(converter->get_output_socket(0), link.to());
} }
} }
} }
@@ -327,69 +322,69 @@ void NodeOperationBuilder::add_datatype_conversions()
void NodeOperationBuilder::add_operation_input_constants() void NodeOperationBuilder::add_operation_input_constants()
{ {
/* NOTE: unconnected inputs cached first to avoid modifying /* NOTE: unconnected inputs cached first to avoid modifying
* m_operations while iterating over it * operations_ while iterating over it
*/ */
Vector<NodeOperationInput *> pending_inputs; Vector<NodeOperationInput *> pending_inputs;
for (NodeOperation *op : m_operations) { for (NodeOperation *op : operations_) {
for (int k = 0; k < op->getNumberOfInputSockets(); ++k) { for (int k = 0; k < op->get_number_of_input_sockets(); ++k) {
NodeOperationInput *input = op->getInputSocket(k); NodeOperationInput *input = op->get_input_socket(k);
if (!input->isConnected()) { if (!input->is_connected()) {
pending_inputs.append(input); pending_inputs.append(input);
} }
} }
} }
for (NodeOperationInput *input : pending_inputs) { for (NodeOperationInput *input : pending_inputs) {
add_input_constant_value(input, m_input_map.lookup_default(input, nullptr)); add_input_constant_value(input, input_map_.lookup_default(input, nullptr));
} }
} }
void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input, void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
const NodeInput *node_input) const NodeInput *node_input)
{ {
switch (input->getDataType()) { switch (input->get_data_type()) {
case DataType::Value: { case DataType::Value: {
float value; float value;
if (node_input && node_input->getbNodeSocket()) { if (node_input && node_input->get_bnode_socket()) {
value = node_input->getEditorValueFloat(); value = node_input->get_editor_value_float();
} }
else { else {
value = 0.0f; value = 0.0f;
} }
SetValueOperation *op = new SetValueOperation(); SetValueOperation *op = new SetValueOperation();
op->setValue(value); op->set_value(value);
addOperation(op); add_operation(op);
addLink(op->getOutputSocket(), input); add_link(op->get_output_socket(), input);
break; break;
} }
case DataType::Color: { case DataType::Color: {
float value[4]; float value[4];
if (node_input && node_input->getbNodeSocket()) { if (node_input && node_input->get_bnode_socket()) {
node_input->getEditorValueColor(value); node_input->get_editor_value_color(value);
} }
else { else {
zero_v4(value); zero_v4(value);
} }
SetColorOperation *op = new SetColorOperation(); SetColorOperation *op = new SetColorOperation();
op->setChannels(value); op->set_channels(value);
addOperation(op); add_operation(op);
addLink(op->getOutputSocket(), input); add_link(op->get_output_socket(), input);
break; break;
} }
case DataType::Vector: { case DataType::Vector: {
float value[3]; float value[3];
if (node_input && node_input->getbNodeSocket()) { if (node_input && node_input->get_bnode_socket()) {
node_input->getEditorValueVector(value); node_input->get_editor_value_vector(value);
} }
else { else {
zero_v3(value); zero_v3(value);
} }
SetVectorOperation *op = new SetVectorOperation(); SetVectorOperation *op = new SetVectorOperation();
op->setVector(value); op->set_vector(value);
addOperation(op); add_operation(op);
addLink(op->getOutputSocket(), input); add_link(op->get_output_socket(), input);
break; break;
} }
} }
@@ -398,10 +393,10 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
void NodeOperationBuilder::resolve_proxies() void NodeOperationBuilder::resolve_proxies()
{ {
Vector<Link> proxy_links; Vector<Link> proxy_links;
for (const Link &link : m_links) { for (const Link &link : links_) {
/* don't replace links from proxy to proxy, since we may need them for replacing others! */ /* 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 && if (link.from()->get_operation().get_flags().is_proxy_operation &&
!link.to()->getOperation().get_flags().is_proxy_operation) { !link.to()->get_operation().get_flags().is_proxy_operation) {
proxy_links.append(link); proxy_links.append(link);
} }
} }
@@ -411,15 +406,15 @@ void NodeOperationBuilder::resolve_proxies()
NodeOperationOutput *from = link.from(); NodeOperationOutput *from = link.from();
do { do {
/* walk upstream bypassing the proxy operation */ /* walk upstream bypassing the proxy operation */
from = from->getOperation().getInputSocket(0)->getLink(); from = from->get_operation().get_input_socket(0)->get_link();
} while (from && from->getOperation().get_flags().is_proxy_operation); } 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, /* we may not have a final proxy input link,
* in that case it just gets dropped * in that case it just gets dropped
*/ */
if (from) { if (from) {
addLink(from, to); add_link(from, to);
} }
} }
} }
@@ -428,16 +423,18 @@ void NodeOperationBuilder::determine_canvases()
{ {
/* Determine all canvas areas of the operations. */ /* Determine all canvas areas of the operations. */
const rcti &preferred_area = COM_AREA_NONE; const rcti &preferred_area = COM_AREA_NONE;
for (NodeOperation *op : m_operations) { for (NodeOperation *op : operations_) {
if (op->isOutputOperation(m_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; rcti canvas = COM_AREA_NONE;
op->determine_canvas(preferred_area, canvas); op->determine_canvas(preferred_area, canvas);
op->set_canvas(canvas); op->set_canvas(canvas);
} }
} }
for (NodeOperation *op : m_operations) { for (NodeOperation *op : operations_) {
if (op->isOutputOperation(m_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; rcti canvas = COM_AREA_NONE;
op->determine_canvas(preferred_area, canvas); op->determine_canvas(preferred_area, canvas);
op->set_canvas(canvas); op->set_canvas(canvas);
@@ -447,13 +444,13 @@ void NodeOperationBuilder::determine_canvases()
/* Convert operation canvases when needed. */ /* Convert operation canvases when needed. */
{ {
Vector<Link> convert_links; Vector<Link> convert_links;
for (const Link &link : m_links) { for (const Link &link : links_) {
if (link.to()->getResizeMode() != ResizeMode::None) { if (link.to()->get_resize_mode() != ResizeMode::None) {
const rcti &from_canvas = link.from()->getOperation().get_canvas(); const rcti &from_canvas = link.from()->get_operation().get_canvas();
const rcti &to_canvas = link.to()->getOperation().get_canvas(); const rcti &to_canvas = link.to()->get_operation().get_canvas();
bool needs_conversion; 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 || needs_conversion = from_canvas.xmin != to_canvas.xmin ||
from_canvas.ymin != to_canvas.ymin; from_canvas.ymin != to_canvas.ymin;
} }
@@ -490,7 +487,7 @@ void NodeOperationBuilder::merge_equal_operations()
bool check_for_next_merge = true; bool check_for_next_merge = true;
while (check_for_next_merge) { while (check_for_next_merge) {
/* Re-generate hashes with any change. */ /* Re-generate hashes with any change. */
Vector<NodeOperationHash> hashes = generate_hashes(m_operations); Vector<NodeOperationHash> hashes = generate_hashes(operations_);
/* Make hashes be consecutive when they are equal. */ /* Make hashes be consecutive when they are equal. */
std::sort(hashes.begin(), hashes.end()); std::sort(hashes.begin(), hashes.end());
@@ -512,7 +509,7 @@ void NodeOperationBuilder::merge_equal_operations()
void NodeOperationBuilder::merge_equal_operations(NodeOperation *from, NodeOperation *into) void NodeOperationBuilder::merge_equal_operations(NodeOperation *from, NodeOperation *into)
{ {
unlink_inputs_and_relink_outputs(from, into); unlink_inputs_and_relink_outputs(from, into);
m_operations.remove_first_occurrence_and_reorder(from); operations_.remove_first_occurrence_and_reorder(from);
delete from; delete from;
} }
@@ -520,7 +517,7 @@ Vector<NodeOperationInput *> NodeOperationBuilder::cache_output_links(
NodeOperationOutput *output) const NodeOperationOutput *output) const
{ {
Vector<NodeOperationInput *> inputs; Vector<NodeOperationInput *> inputs;
for (const Link &link : m_links) { for (const Link &link : links_) {
if (link.from() == output) { if (link.from() == output) {
inputs.append(link.to()); inputs.append(link.to());
} }
@@ -531,9 +528,9 @@ Vector<NodeOperationInput *> NodeOperationBuilder::cache_output_links(
WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation( WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation(
NodeOperationOutput *output) const NodeOperationOutput *output) const
{ {
for (const Link &link : m_links) { for (const Link &link : links_) {
if (link.from() == output) { if (link.from() == output) {
NodeOperation &op = link.to()->getOperation(); NodeOperation &op = link.to()->get_operation();
if (op.get_flags().is_write_buffer_operation) { if (op.get_flags().is_write_buffer_operation) {
return (WriteBufferOperation *)(&op); return (WriteBufferOperation *)(&op);
} }
@@ -545,39 +542,39 @@ WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation
void NodeOperationBuilder::add_input_buffers(NodeOperation * /*operation*/, void NodeOperationBuilder::add_input_buffers(NodeOperation * /*operation*/,
NodeOperationInput *input) NodeOperationInput *input)
{ {
if (!input->isConnected()) { if (!input->is_connected()) {
return; return;
} }
NodeOperationOutput *output = input->getLink(); NodeOperationOutput *output = input->get_link();
if (output->getOperation().get_flags().is_read_buffer_operation) { if (output->get_operation().get_flags().is_read_buffer_operation) {
/* input is already buffered, no need to add another */ /* input is already buffered, no need to add another */
return; return;
} }
/* this link will be replaced below */ /* 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 */ /* check of other end already has write operation, otherwise add a new one */
WriteBufferOperation *writeoperation = find_attached_write_buffer_operation(output); WriteBufferOperation *writeoperation = find_attached_write_buffer_operation(output);
if (!writeoperation) { if (!writeoperation) {
writeoperation = new WriteBufferOperation(output->getDataType()); writeoperation = new WriteBufferOperation(output->get_data_type());
writeoperation->setbNodeTree(m_context->getbNodeTree()); writeoperation->set_bnodetree(context_->get_bnodetree());
addOperation(writeoperation); 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 */ /* add readbuffer op for the input */
ReadBufferOperation *readoperation = new ReadBufferOperation(output->getDataType()); ReadBufferOperation *readoperation = new ReadBufferOperation(output->get_data_type());
readoperation->setMemoryProxy(writeoperation->getMemoryProxy()); readoperation->set_memory_proxy(writeoperation->get_memory_proxy());
this->addOperation(readoperation); 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, void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
@@ -589,54 +586,54 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
return; return;
} }
WriteBufferOperation *writeOperation = nullptr; WriteBufferOperation *write_operation = nullptr;
for (NodeOperationInput *target : targets) { for (NodeOperationInput *target : targets) {
/* try to find existing write buffer operation */ /* try to find existing write buffer operation */
if (target->getOperation().get_flags().is_write_buffer_operation) { if (target->get_operation().get_flags().is_write_buffer_operation) {
BLI_assert(writeOperation == nullptr); /* there should only be one write op connected */ BLI_assert(write_operation == nullptr); /* there should only be one write op connected */
writeOperation = (WriteBufferOperation *)(&target->getOperation()); write_operation = (WriteBufferOperation *)(&target->get_operation());
} }
else { else {
/* remove all links to other nodes */ /* remove all links to other nodes */
removeInputLink(target); remove_input_link(target);
} }
} }
/* if no write buffer operation exists yet, create a new one */ /* if no write buffer operation exists yet, create a new one */
if (!writeOperation) { if (!write_operation) {
writeOperation = new WriteBufferOperation(operation->getOutputSocket()->getDataType()); write_operation = new WriteBufferOperation(operation->get_output_socket()->get_data_type());
writeOperation->setbNodeTree(m_context->getbNodeTree()); write_operation->set_bnodetree(context_->get_bnodetree());
addOperation(writeOperation); 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 */ /* add readbuffer op for every former connected input */
for (NodeOperationInput *target : targets) { for (NodeOperationInput *target : targets) {
if (&target->getOperation() == writeOperation) { if (&target->get_operation() == write_operation) {
continue; /* skip existing write op links */ continue; /* skip existing write op links */
} }
ReadBufferOperation *readoperation = new ReadBufferOperation( ReadBufferOperation *readoperation = new ReadBufferOperation(
operation->getOutputSocket()->getDataType()); operation->get_output_socket()->get_data_type());
readoperation->setMemoryProxy(writeOperation->getMemoryProxy()); readoperation->set_memory_proxy(write_operation->get_memory_proxy());
addOperation(readoperation); add_operation(readoperation);
addLink(readoperation->getOutputSocket(), target); add_link(readoperation->get_output_socket(), target);
readoperation->readResolutionFromWriteBuffer(); readoperation->read_resolution_from_write_buffer();
} }
} }
void NodeOperationBuilder::add_complex_operation_buffers() void NodeOperationBuilder::add_complex_operation_buffers()
{ {
/* NOTE: complex ops and get cached here first, since adding operations /* NOTE: complex ops and get cached here first, since adding operations
* will invalidate iterators over the main m_operations * will invalidate iterators over the main operations_
*/ */
Vector<NodeOperation *> complex_ops; Vector<NodeOperation *> complex_ops;
for (NodeOperation *operation : m_operations) { for (NodeOperation *operation : operations_) {
if (operation->get_flags().complex) { if (operation->get_flags().complex) {
complex_ops.append(operation); complex_ops.append(operation);
} }
@@ -645,12 +642,12 @@ void NodeOperationBuilder::add_complex_operation_buffers()
for (NodeOperation *op : complex_ops) { for (NodeOperation *op : complex_ops) {
DebugInfo::operation_read_write_buffer(op); DebugInfo::operation_read_write_buffer(op);
for (int index = 0; index < op->getNumberOfInputSockets(); index++) { for (int index = 0; index < op->get_number_of_input_sockets(); index++) {
add_input_buffers(op, op->getInputSocket(index)); add_input_buffers(op, op->get_input_socket(index));
} }
for (int index = 0; index < op->getNumberOfOutputSockets(); index++) { for (int index = 0; index < op->get_number_of_output_sockets(); index++) {
add_output_buffers(op, op->getOutputSocket(index)); add_output_buffers(op, op->get_output_socket(index));
} }
} }
} }
@@ -664,34 +661,34 @@ static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *
} }
reachable.insert(op); reachable.insert(op);
for (int i = 0; i < op->getNumberOfInputSockets(); i++) { for (int i = 0; i < op->get_number_of_input_sockets(); i++) {
NodeOperationInput *input = op->getInputSocket(i); NodeOperationInput *input = op->get_input_socket(i);
if (input->isConnected()) { if (input->is_connected()) {
find_reachable_operations_recursive(reachable, &input->getLink()->getOperation()); find_reachable_operations_recursive(reachable, &input->get_link()->get_operation());
} }
} }
/* associated write-buffer operations are executed as well */ /* associated write-buffer operations are executed as well */
if (op->get_flags().is_read_buffer_operation) { if (op->get_flags().is_read_buffer_operation) {
ReadBufferOperation *read_op = (ReadBufferOperation *)op; ReadBufferOperation *read_op = (ReadBufferOperation *)op;
MemoryProxy *memproxy = read_op->getMemoryProxy(); MemoryProxy *memproxy = read_op->get_memory_proxy();
find_reachable_operations_recursive(reachable, memproxy->getWriteBufferOperation()); find_reachable_operations_recursive(reachable, memproxy->get_write_buffer_operation());
} }
} }
void NodeOperationBuilder::prune_operations() void NodeOperationBuilder::prune_operations()
{ {
Tags reachable; Tags reachable;
for (NodeOperation *op : m_operations) { for (NodeOperation *op : operations_) {
/* output operations are primary executed operations */ /* output operations are primary executed operations */
if (op->isOutputOperation(m_context->isRendering())) { if (op->is_output_operation(context_->is_rendering())) {
find_reachable_operations_recursive(reachable, op); find_reachable_operations_recursive(reachable, op);
} }
} }
/* delete unreachable operations */ /* delete unreachable operations */
Vector<NodeOperation *> reachable_ops; Vector<NodeOperation *> reachable_ops;
for (NodeOperation *op : m_operations) { for (NodeOperation *op : operations_) {
if (reachable.find(op) != reachable.end()) { if (reachable.find(op) != reachable.end()) {
reachable_ops.append(op); reachable_ops.append(op);
} }
@@ -700,7 +697,7 @@ void NodeOperationBuilder::prune_operations()
} }
} }
/* finally replace the operations list with the pruned list */ /* finally replace the operations list with the pruned list */
m_operations = reachable_ops; operations_ = reachable_ops;
} }
/* topological (depth-first) sorting of operations */ /* topological (depth-first) sorting of operations */
@@ -713,10 +710,10 @@ static void sort_operations_recursive(Vector<NodeOperation *> &sorted,
} }
visited.insert(op); visited.insert(op);
for (int i = 0; i < op->getNumberOfInputSockets(); i++) { for (int i = 0; i < op->get_number_of_input_sockets(); i++) {
NodeOperationInput *input = op->getInputSocket(i); NodeOperationInput *input = op->get_input_socket(i);
if (input->isConnected()) { if (input->is_connected()) {
sort_operations_recursive(sorted, visited, &input->getLink()->getOperation()); sort_operations_recursive(sorted, visited, &input->get_link()->get_operation());
} }
} }
@@ -726,14 +723,14 @@ static void sort_operations_recursive(Vector<NodeOperation *> &sorted,
void NodeOperationBuilder::sort_operations() void NodeOperationBuilder::sort_operations()
{ {
Vector<NodeOperation *> sorted; Vector<NodeOperation *> sorted;
sorted.reserve(m_operations.size()); sorted.reserve(operations_.size());
Tags visited; Tags visited;
for (NodeOperation *operation : m_operations) { for (NodeOperation *operation : operations_) {
sort_operations_recursive(sorted, visited, operation); sort_operations_recursive(sorted, visited, operation);
} }
m_operations = sorted; operations_ = sorted;
} }
static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group) static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group)
@@ -743,23 +740,23 @@ static void add_group_operations_recursive(Tags &visited, NodeOperation *op, Exe
} }
visited.insert(op); visited.insert(op);
if (!group->addOperation(op)) { if (!group->add_operation(op)) {
return; return;
} }
/* add all eligible input ops to the group */ /* add all eligible input ops to the group */
for (int i = 0; i < op->getNumberOfInputSockets(); i++) { for (int i = 0; i < op->get_number_of_input_sockets(); i++) {
NodeOperationInput *input = op->getInputSocket(i); NodeOperationInput *input = op->get_input_socket(i);
if (input->isConnected()) { if (input->is_connected()) {
add_group_operations_recursive(visited, &input->getLink()->getOperation(), group); add_group_operations_recursive(visited, &input->get_link()->get_operation(), group);
} }
} }
} }
ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op) ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op)
{ {
ExecutionGroup *group = new ExecutionGroup(this->m_groups.size()); ExecutionGroup *group = new ExecutionGroup(groups_.size());
m_groups.append(group); groups_.append(group);
Tags visited; Tags visited;
add_group_operations_recursive(visited, op, group); add_group_operations_recursive(visited, op, group);
@@ -769,20 +766,20 @@ ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op)
void NodeOperationBuilder::group_operations() void NodeOperationBuilder::group_operations()
{ {
for (NodeOperation *op : m_operations) { for (NodeOperation *op : operations_) {
if (op->isOutputOperation(m_context->isRendering())) { if (op->is_output_operation(context_->is_rendering())) {
ExecutionGroup *group = make_group(op); ExecutionGroup *group = make_group(op);
group->setOutputExecutionGroup(true); group->set_output_execution_group(true);
} }
/* add new groups for associated memory proxies where needed */ /* add new groups for associated memory proxies where needed */
if (op->get_flags().is_read_buffer_operation) { if (op->get_flags().is_read_buffer_operation) {
ReadBufferOperation *read_op = (ReadBufferOperation *)op; ReadBufferOperation *read_op = (ReadBufferOperation *)op;
MemoryProxy *memproxy = read_op->getMemoryProxy(); MemoryProxy *memproxy = read_op->get_memory_proxy();
if (memproxy->getExecutor() == nullptr) { if (memproxy->get_executor() == nullptr) {
ExecutionGroup *group = make_group(memproxy->getWriteBufferOperation()); ExecutionGroup *group = make_group(memproxy->get_write_buffer_operation());
memproxy->setExecutor(group); memproxy->set_executor(group);
} }
} }
} }
@@ -791,7 +788,7 @@ void NodeOperationBuilder::group_operations()
void NodeOperationBuilder::save_graphviz(StringRefNull name) void NodeOperationBuilder::save_graphviz(StringRefNull name)
{ {
if (COM_EXPORT_GRAPHVIZ) { if (COM_EXPORT_GRAPHVIZ) {
exec_system_->set_operations(m_operations, m_groups); exec_system_->set_operations(operations_, groups_);
DebugInfo::graphviz(exec_system_, name); DebugInfo::graphviz(exec_system_, name);
} }
} }
@@ -809,15 +806,15 @@ std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder &builder)
os << "\n"; os << "\n";
for (const NodeOperationBuilder::Link &link : builder.get_links()) { for (const NodeOperationBuilder::Link &link : builder.get_links()) {
os << " op" << link.from()->getOperation().get_id() << " -> op" os << " op" << link.from()->get_operation().get_id() << " -> op"
<< link.to()->getOperation().get_id() << ";\n"; << link.to()->get_operation().get_id() << ";\n";
} }
for (const NodeOperation *operation : builder.get_operations()) { for (const NodeOperation *operation : builder.get_operations()) {
if (operation->get_flags().is_read_buffer_operation) { if (operation->get_flags().is_read_buffer_operation) {
const ReadBufferOperation &read_operation = static_cast<const ReadBufferOperation &>( const ReadBufferOperation &read_operation = static_cast<const ReadBufferOperation &>(
*operation); *operation);
const WriteBufferOperation &write_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"; os << " op" << write_operation.get_id() << " -> op" << read_operation.get_id() << ";\n";
} }
} }
@@ -829,7 +826,7 @@ std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder &builder)
std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder::Link &link) 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; return os;
} }

View File

@@ -18,9 +18,8 @@
#pragma once #pragma once
#include <map> #include "BLI_map.hh"
#include <set> #include "BLI_vector.hh"
#include <vector>
#include "COM_NodeGraph.h" #include "COM_NodeGraph.h"
@@ -47,45 +46,45 @@ class NodeOperationBuilder {
public: public:
class Link { class Link {
private: private:
NodeOperationOutput *m_from; NodeOperationOutput *from_;
NodeOperationInput *m_to; NodeOperationInput *to_;
public: public:
Link(NodeOperationOutput *from, NodeOperationInput *to) : m_from(from), m_to(to) Link(NodeOperationOutput *from, NodeOperationInput *to) : from_(from), to_(to)
{ {
} }
NodeOperationOutput *from() const NodeOperationOutput *from() const
{ {
return m_from; return from_;
} }
NodeOperationInput *to() const NodeOperationInput *to() const
{ {
return m_to; return to_;
} }
}; };
private: private:
const CompositorContext *m_context; const CompositorContext *context_;
NodeGraph m_graph; NodeGraph graph_;
ExecutionSystem *exec_system_; ExecutionSystem *exec_system_;
Vector<NodeOperation *> m_operations; Vector<NodeOperation *> operations_;
Vector<Link> m_links; Vector<Link> links_;
Vector<ExecutionGroup *> m_groups; Vector<ExecutionGroup *> groups_;
/** Maps operation inputs to node inputs */ /** Maps operation inputs to node inputs */
Map<NodeOperationInput *, NodeInput *> m_input_map; Map<NodeOperationInput *, NodeInput *> input_map_;
/** Maps node outputs to operation outputs */ /** Maps node outputs to operation outputs */
Map<NodeOutput *, NodeOperationOutput *> m_output_map; Map<NodeOutput *, NodeOperationOutput *> output_map_;
Node *m_current_node; Node *current_node_;
/** Operation that will be writing to the viewer image /** Operation that will be writing to the viewer image
* Only one operation can occupy this place at a time, * Only one operation can occupy this place at a time,
* to avoid race conditions * to avoid race conditions
*/ */
ViewerOperation *m_active_viewer; ViewerOperation *active_viewer_;
public: public:
NodeOperationBuilder(const CompositorContext *context, NodeOperationBuilder(const CompositorContext *context,
@@ -94,44 +93,44 @@ class NodeOperationBuilder {
const CompositorContext &context() const const CompositorContext &context() const
{ {
return *m_context; 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, void replace_operation_with_constant(NodeOperation *operation,
ConstantOperation *constant_operation); ConstantOperation *constant_operation);
/** Map input socket of the current node to an operation socket */ /** 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 */ /** 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 add_link(NodeOperationOutput *from, NodeOperationInput *to);
void removeInputLink(NodeOperationInput *to); void remove_input_link(NodeOperationInput *to);
/** Add a preview operation for a operation output */ /** 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 */ /** 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 */ /** 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 */ /** The currently active viewer output operation */
ViewerOperation *active_viewer() const ViewerOperation *active_viewer() const
{ {
return m_active_viewer; return active_viewer_;
} }
const Vector<NodeOperation *> &get_operations() const const Vector<NodeOperation *> &get_operations() const
{ {
return m_operations; return operations_;
} }
const Vector<Link> &get_links() const const Vector<Link> &get_links() const
{ {
return m_links; return links_;
} }
protected: protected:

View File

@@ -17,7 +17,9 @@
*/ */
#include "COM_OpenCLDevice.h" #include "COM_OpenCLDevice.h"
#include "COM_WorkScheduler.h"
#include "COM_ExecutionGroup.h"
#include "COM_ReadBufferOperation.h"
namespace blender::compositor { namespace blender::compositor {
@@ -38,68 +40,69 @@ const cl_image_format IMAGE_FORMAT_VALUE = {
OpenCLDevice::OpenCLDevice(cl_context context, OpenCLDevice::OpenCLDevice(cl_context context,
cl_device_id device, cl_device_id device,
cl_program program, cl_program program,
cl_int vendorId) cl_int vendor_id)
{ {
this->m_device = device; device_ = device;
this->m_context = context; context_ = context;
this->m_program = program; program_ = program;
this->m_queue = nullptr; queue_ = nullptr;
this->m_vendorID = vendorId; vendor_id_ = vendor_id;
cl_int error; cl_int error;
this->m_queue = clCreateCommandQueue(this->m_context, this->m_device, 0, &error); queue_ = clCreateCommandQueue(context_, device_, 0, &error);
} }
OpenCLDevice::OpenCLDevice(OpenCLDevice &&other) noexcept OpenCLDevice::OpenCLDevice(OpenCLDevice &&other) noexcept
: m_context(other.m_context), : context_(other.context_),
m_device(other.m_device), device_(other.device_),
m_program(other.m_program), program_(other.program_),
m_queue(other.m_queue), queue_(other.queue_),
m_vendorID(other.m_vendorID) vendor_id_(other.vendor_id_)
{ {
other.m_queue = nullptr; other.queue_ = nullptr;
} }
OpenCLDevice::~OpenCLDevice() OpenCLDevice::~OpenCLDevice()
{ {
if (this->m_queue) { if (queue_) {
clReleaseCommandQueue(this->m_queue); clReleaseCommandQueue(queue_);
} }
} }
void OpenCLDevice::execute(WorkPackage *work_package) void OpenCLDevice::execute(WorkPackage *work_package)
{ {
const unsigned int chunkNumber = work_package->chunk_number; const unsigned int chunk_number = work_package->chunk_number;
ExecutionGroup *executionGroup = work_package->execution_group; ExecutionGroup *execution_group = work_package->execution_group;
MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber); MemoryBuffer **input_buffers = execution_group->get_input_buffers_opencl(chunk_number);
MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(work_package->rect); MemoryBuffer *output_buffer = execution_group->allocate_output_buffer(work_package->rect);
executionGroup->getOutputOperation()->executeOpenCLRegion( execution_group->get_output_operation()->execute_opencl_region(
this, &work_package->rect, chunkNumber, inputBuffers, outputBuffer); 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, cl_mem OpenCLDevice::COM_cl_attach_memory_buffer_to_kernel_parameter(
int parameterIndex, cl_kernel kernel,
int offsetIndex, int parameter_index,
int offset_index,
std::list<cl_mem> *cleanup, std::list<cl_mem> *cleanup,
MemoryBuffer **inputMemoryBuffers, MemoryBuffer **input_memory_buffers,
SocketReader *reader) SocketReader *reader)
{ {
return COM_clAttachMemoryBufferToKernelParameter(kernel, return COM_cl_attach_memory_buffer_to_kernel_parameter(kernel,
parameterIndex, parameter_index,
offsetIndex, offset_index,
cleanup, cleanup,
inputMemoryBuffers, input_memory_buffers,
(ReadBufferOperation *)reader); (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: case 1:
return &IMAGE_FORMAT_VALUE; return &IMAGE_FORMAT_VALUE;
break; break;
@@ -116,166 +119,164 @@ const cl_image_format *OpenCLDevice::determineImageFormat(MemoryBuffer *memoryBu
return &IMAGE_FORMAT_COLOR; return &IMAGE_FORMAT_COLOR;
} }
cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, cl_mem OpenCLDevice::COM_cl_attach_memory_buffer_to_kernel_parameter(
int parameterIndex, cl_kernel kernel,
int offsetIndex, int parameter_index,
int offset_index,
std::list<cl_mem> *cleanup, std::list<cl_mem> *cleanup,
MemoryBuffer **inputMemoryBuffers, MemoryBuffer **input_memory_buffers,
ReadBufferOperation *reader) ReadBufferOperation *reader)
{ {
cl_int error; 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(this->m_context, cl_mem cl_buffer = clCreateImage2D(context_,
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
imageFormat, image_format,
result->getWidth(), result->get_width(),
result->getHeight(), result->get_height(),
0, 0,
result->getBuffer(), result->get_buffer(),
&error); &error);
if (error != CL_SUCCESS) { if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
} }
if (error == CL_SUCCESS) { 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) { if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
} }
COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result); COM_cl_attach_memory_buffer_offset_to_kernel_parameter(kernel, offset_index, result);
return clBuffer; return cl_buffer;
} }
void OpenCLDevice::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, void OpenCLDevice::COM_cl_attach_memory_buffer_offset_to_kernel_parameter(
int offsetIndex, cl_kernel kernel, int offset_index, MemoryBuffer *memory_buffer)
MemoryBuffer *memoryBuffer)
{ {
if (offsetIndex != -1) { if (offset_index != -1) {
cl_int error; cl_int error;
const rcti &rect = memoryBuffer->get_rect(); const rcti &rect = memory_buffer->get_rect();
cl_int2 offset = {{rect.xmin, rect.ymin}}; 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) { if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
} }
} }
} }
void OpenCLDevice::COM_clAttachSizeToKernelParameter(cl_kernel kernel, void OpenCLDevice::COM_cl_attach_size_to_kernel_parameter(cl_kernel kernel,
int offsetIndex, int offset_index,
NodeOperation *operation) NodeOperation *operation)
{ {
if (offsetIndex != -1) { if (offset_index != -1) {
cl_int error; 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) { if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
} }
} }
} }
void OpenCLDevice::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, void OpenCLDevice::COM_cl_attach_output_memory_buffer_to_kernel_parameter(
int parameterIndex, cl_kernel kernel, int parameter_index, cl_mem cl_output_memory_buffer)
cl_mem clOutputMemoryBuffer)
{ {
cl_int error; 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) { if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); 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; cl_int error;
const size_t size[] = { const size_t size[] = {
(size_t)outputMemoryBuffer->getWidth(), (size_t)output_memory_buffer->get_width(),
(size_t)outputMemoryBuffer->getHeight(), (size_t)output_memory_buffer->get_height(),
}; };
error = clEnqueueNDRangeKernel( error = clEnqueueNDRangeKernel(queue_, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
this->m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
if (error != CL_SUCCESS) { if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
} }
} }
void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, void OpenCLDevice::COM_cl_enqueue_range(cl_kernel kernel,
MemoryBuffer *outputMemoryBuffer, MemoryBuffer *output_memory_buffer,
int offsetIndex, int offset_index,
NodeOperation *operation) NodeOperation *operation)
{ {
cl_int error; cl_int error;
const int width = outputMemoryBuffer->getWidth(); const int width = output_memory_buffer->get_width();
const int height = outputMemoryBuffer->getHeight(); const int height = output_memory_buffer->get_height();
int offsetx; int offsetx;
int offsety; int offsety;
int localSize = 1024; int local_size = 1024;
size_t size[2]; size_t size[2];
cl_int2 offset; cl_int2 offset;
if (this->m_vendorID == NVIDIA) { if (vendor_id_ == NVIDIA) {
localSize = 32; local_size = 32;
} }
bool breaked = false; bool breaked = false;
for (offsety = 0; offsety < height && (!breaked); offsety += localSize) { for (offsety = 0; offsety < height && (!breaked); offsety += local_size) {
offset.s[1] = offsety; offset.s[1] = offsety;
if (offsety + localSize < height) { if (offsety + local_size < height) {
size[1] = localSize; size[1] = local_size;
} }
else { else {
size[1] = height - offsety; size[1] = height - offsety;
} }
for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) { for (offsetx = 0; offsetx < width && (!breaked); offsetx += local_size) {
if (offsetx + localSize < width) { if (offsetx + local_size < width) {
size[0] = localSize; size[0] = local_size;
} }
else { else {
size[0] = width - offsetx; size[0] = width - offsetx;
} }
offset.s[0] = 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) { if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
} }
error = clEnqueueNDRangeKernel( error = clEnqueueNDRangeKernel(
this->m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr); queue_, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
if (error != CL_SUCCESS) { if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
} }
clFlush(this->m_queue); clFlush(queue_);
if (operation->isBraked()) { if (operation->is_braked()) {
breaked = false; breaked = false;
} }
} }
} }
} }
cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname, cl_kernel OpenCLDevice::COM_cl_create_kernel(const char *kernelname,
std::list<cl_kernel> *clKernelsToCleanUp) std::list<cl_kernel> *cl_kernels_to_clean_up)
{ {
cl_int error; cl_int error;
cl_kernel kernel = clCreateKernel(this->m_program, kernelname, &error); cl_kernel kernel = clCreateKernel(program_, kernelname, &error);
if (error != CL_SUCCESS) { if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
} }
else { else {
if (clKernelsToCleanUp) { if (cl_kernels_to_clean_up) {
clKernelsToCleanUp->push_back(kernel); cl_kernels_to_clean_up->push_back(kernel);
} }
} }
return kernel; return kernel;

View File

@@ -20,13 +20,20 @@ class OpenCLDevice;
#pragma once #pragma once
#include <list>
#include "COM_Device.h" #include "COM_Device.h"
#include "COM_ReadBufferOperation.h"
#include "COM_WorkScheduler.h"
#include "clew.h" #include "clew.h"
namespace blender::compositor { namespace blender::compositor {
class NodeOperation;
class MemoryBuffer;
class ReadBufferOperation;
typedef NodeOperation SocketReader;
/** /**
* \brief device representing an GPU OpenCL device. * \brief device representing an GPU OpenCL device.
* an instance of this class represents a single cl_device * an instance of this class represents a single cl_device
@@ -36,27 +43,27 @@ class OpenCLDevice : public Device {
/** /**
* \brief opencl context * \brief opencl context
*/ */
cl_context m_context; cl_context context_;
/** /**
* \brief opencl device * \brief opencl device
*/ */
cl_device_id m_device; cl_device_id device_;
/** /**
* \brief opencl program * \brief opencl program
*/ */
cl_program m_program; cl_program program_;
/** /**
* \brief opencl command queue * \brief opencl command queue
*/ */
cl_command_queue m_queue; cl_command_queue queue_;
/** /**
* \brief opencl vendor ID * \brief opencl vendor ID
*/ */
cl_int m_vendorID; cl_int vendor_id_;
public: public:
/** /**
@@ -66,7 +73,7 @@ class OpenCLDevice : public Device {
* \param program: * \param program:
* \param vendorID: * \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; OpenCLDevice(OpenCLDevice &&other) noexcept;
@@ -82,45 +89,46 @@ class OpenCLDevice : public Device {
* \brief determine an image format * \brief determine an image format
* \param memorybuffer: * \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 this->m_context; return context_;
} }
cl_command_queue getQueue() cl_command_queue get_queue()
{ {
return this->m_queue; return queue_;
} }
cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, cl_mem COM_cl_attach_memory_buffer_to_kernel_parameter(cl_kernel kernel,
int parameterIndex, int parameter_index,
int offsetIndex, int offset_index,
std::list<cl_mem> *cleanup, std::list<cl_mem> *cleanup,
MemoryBuffer **inputMemoryBuffers, MemoryBuffer **input_memory_buffers,
SocketReader *reader); SocketReader *reader);
cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, cl_mem COM_cl_attach_memory_buffer_to_kernel_parameter(cl_kernel kernel,
int parameterIndex, int parameter_index,
int offsetIndex, int offset_index,
std::list<cl_mem> *cleanup, std::list<cl_mem> *cleanup,
MemoryBuffer **inputMemoryBuffers, MemoryBuffer **input_memory_buffers,
ReadBufferOperation *reader); ReadBufferOperation *reader);
void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, void COM_cl_attach_memory_buffer_offset_to_kernel_parameter(cl_kernel kernel,
int offsetIndex, int offset_index,
MemoryBuffer *memoryBuffers); MemoryBuffer *memory_buffers);
void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, void COM_cl_attach_output_memory_buffer_to_kernel_parameter(cl_kernel kernel,
int parameterIndex, int parameter_index,
cl_mem clOutputMemoryBuffer); cl_mem cl_output_memory_buffer);
void COM_clAttachSizeToKernelParameter(cl_kernel kernel, void COM_cl_attach_size_to_kernel_parameter(cl_kernel kernel,
int offsetIndex, int offset_index,
NodeOperation *operation); NodeOperation *operation);
void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer); void COM_cl_enqueue_range(cl_kernel kernel, MemoryBuffer *output_memory_buffer);
void COM_clEnqueueRange(cl_kernel kernel, void COM_cl_enqueue_range(cl_kernel kernel,
MemoryBuffer *outputMemoryBuffer, MemoryBuffer *output_memory_buffer,
int offsetIndex, int offset_index,
NodeOperation *operation); NodeOperation *operation);
cl_kernel COM_clCreateKernel(const char *kernelname, std::list<cl_kernel> *clKernelsToCleanUp); cl_kernel COM_cl_create_kernel(const char *kernelname,
std::list<cl_kernel> *cl_kernels_to_clean_up);
}; };
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -17,7 +17,6 @@
*/ */
#include "COM_SharedOperationBuffers.h" #include "COM_SharedOperationBuffers.h"
#include "BLI_rect.h"
#include "COM_NodeOperation.h" #include "COM_NodeOperation.h"
namespace blender::compositor { namespace blender::compositor {

View File

@@ -19,16 +19,19 @@
#pragma once #pragma once
#include "BLI_map.hh" #include "BLI_map.hh"
#include "BLI_span.hh"
#include "BLI_vector.hh" #include "BLI_vector.hh"
#include "COM_MemoryBuffer.h"
#include "DNA_vec_types.h"
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
# include "MEM_guardedalloc.h" # include "MEM_guardedalloc.h"
#endif #endif
#include <memory>
namespace blender::compositor { namespace blender::compositor {
class MemoryBuffer;
class NodeOperation;
/** /**
* Stores and shares operations rendered buffers including render data. Buffers are * Stores and shares operations rendered buffers including render data. Buffers are
* disposed once all dependent operations have finished reading them. * disposed once all dependent operations have finished reading them.

View File

@@ -22,42 +22,42 @@ namespace blender::compositor {
SingleThreadedOperation::SingleThreadedOperation() SingleThreadedOperation::SingleThreadedOperation()
{ {
this->m_cachedInstance = nullptr; cached_instance_ = nullptr;
flags.complex = true; flags.complex = true;
flags.single_threaded = 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*/)
{ {
this->m_cachedInstance->readNoCheck(output, x, y); cached_instance_->read_no_check(output, x, y);
} }
void SingleThreadedOperation::deinitExecution() void SingleThreadedOperation::deinit_execution()
{ {
deinitMutex(); deinit_mutex();
if (this->m_cachedInstance) { if (cached_instance_) {
delete this->m_cachedInstance; delete cached_instance_;
this->m_cachedInstance = nullptr; cached_instance_ = nullptr;
} }
} }
void *SingleThreadedOperation::initializeTileData(rcti *rect) void *SingleThreadedOperation::initialize_tile_data(rcti *rect)
{ {
if (this->m_cachedInstance) { if (cached_instance_) {
return this->m_cachedInstance; return cached_instance_;
} }
lockMutex(); lock_mutex();
if (this->m_cachedInstance == nullptr) { if (cached_instance_ == nullptr) {
// //
this->m_cachedInstance = createMemoryBuffer(rect); cached_instance_ = create_memory_buffer(rect);
} }
unlockMutex(); unlock_mutex();
return this->m_cachedInstance; return cached_instance_;
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -24,12 +24,12 @@ namespace blender::compositor {
class SingleThreadedOperation : public NodeOperation { class SingleThreadedOperation : public NodeOperation {
private: private:
MemoryBuffer *m_cachedInstance; MemoryBuffer *cached_instance_;
protected: protected:
inline bool isCached() inline bool is_cached()
{ {
return this->m_cachedInstance != nullptr; return cached_instance_ != nullptr;
} }
public: public:
@@ -38,21 +38,21 @@ class SingleThreadedOperation : public NodeOperation {
/** /**
* The inner loop of this operation. * 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 * Initialize the execution
*/ */
void initExecution() override; void init_execution() override;
/** /**
* Deinitialize the execution * 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 } // namespace blender::compositor

View File

@@ -35,24 +35,24 @@ TiledExecutionModel::TiledExecutionModel(CompositorContext &context,
Span<ExecutionGroup *> groups) Span<ExecutionGroup *> groups)
: ExecutionModel(context, operations), groups_(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")); node_tree->stats_draw(node_tree->sdh, TIP_("Compositing | Determining resolution"));
unsigned int resolution[2]; unsigned int resolution[2];
for (ExecutionGroup *group : groups_) { for (ExecutionGroup *group : groups_) {
resolution[0] = 0; resolution[0] = 0;
resolution[1] = 0; resolution[1] = 0;
group->determineResolution(resolution); group->determine_resolution(resolution);
if (border_.use_render_border) { if (border_.use_render_border) {
const rctf *render_border = border_.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); render_border->xmin, render_border->xmax, render_border->ymin, render_border->ymax);
} }
if (border_.use_viewer_border) { if (border_.use_viewer_border) {
const rctf *viewer_border = border_.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); 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; unsigned int order = 0;
for (NodeOperation *operation : operations) { for (NodeOperation *operation : operations) {
if (operation->get_flags().is_read_buffer_operation) { if (operation->get_flags().is_read_buffer_operation) {
ReadBufferOperation *readOperation = (ReadBufferOperation *)operation; ReadBufferOperation *read_operation = (ReadBufferOperation *)operation;
readOperation->setOffset(order); read_operation->set_offset(order);
order++; order++;
} }
} }
@@ -75,8 +75,8 @@ static void init_write_operations_for_execution(Span<NodeOperation *> operations
{ {
for (NodeOperation *operation : operations) { for (NodeOperation *operation : operations) {
if (operation->get_flags().is_write_buffer_operation) { if (operation->get_flags().is_write_buffer_operation) {
operation->setbNodeTree(bTree); operation->set_bnodetree(bTree);
operation->initExecution(); operation->init_execution();
} }
} }
} }
@@ -85,8 +85,8 @@ static void link_write_buffers(Span<NodeOperation *> operations)
{ {
for (NodeOperation *operation : operations) { for (NodeOperation *operation : operations) {
if (operation->get_flags().is_read_buffer_operation) { if (operation->get_flags().is_read_buffer_operation) {
ReadBufferOperation *readOperation = static_cast<ReadBufferOperation *>(operation); ReadBufferOperation *read_operation = static_cast<ReadBufferOperation *>(operation);
readOperation->updateMemoryBuffer(); read_operation->update_memory_buffer();
} }
} }
} }
@@ -96,8 +96,8 @@ static void init_non_write_operations_for_execution(Span<NodeOperation *> operat
{ {
for (NodeOperation *operation : operations) { for (NodeOperation *operation : operations) {
if (!operation->get_flags().is_write_buffer_operation) { if (!operation->get_flags().is_write_buffer_operation) {
operation->setbNodeTree(bTree); operation->set_bnodetree(bTree);
operation->initExecution(); operation->init_execution();
} }
} }
} }
@@ -106,27 +106,27 @@ static void init_execution_groups_for_execution(Span<ExecutionGroup *> groups,
const int chunk_size) const int chunk_size)
{ {
for (ExecutionGroup *execution_group : groups) { for (ExecutionGroup *execution_group : groups) {
execution_group->setChunksize(chunk_size); execution_group->set_chunksize(chunk_size);
execution_group->initExecution(); execution_group->init_execution();
} }
} }
void TiledExecutionModel::execute(ExecutionSystem &exec_system) 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")); editingtree->stats_draw(editingtree->sdh, TIP_("Compositing | Initializing execution"));
update_read_buffer_offset(operations_); 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_); link_write_buffers(operations_);
init_non_write_operations_for_execution(operations_, context_.getbNodeTree()); init_non_write_operations_for_execution(operations_, context_.get_bnodetree());
init_execution_groups_for_execution(groups_, context_.getChunksize()); init_execution_groups_for_execution(groups_, context_.get_chunksize());
WorkScheduler::start(context_); WorkScheduler::start(context_);
execute_groups(eCompositorPriority::High, exec_system); execute_groups(eCompositorPriority::High, exec_system);
if (!context_.isFastCalculation()) { if (!context_.is_fast_calculation()) {
execute_groups(eCompositorPriority::Medium, exec_system); execute_groups(eCompositorPriority::Medium, exec_system);
execute_groups(eCompositorPriority::Low, 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")); editingtree->stats_draw(editingtree->sdh, TIP_("Compositing | De-initializing execution"));
for (NodeOperation *operation : operations_) { for (NodeOperation *operation : operations_) {
operation->deinitExecution(); operation->deinit_execution();
} }
for (ExecutionGroup *execution_group : groups_) { 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_) { for (ExecutionGroup *execution_group : groups_) {
if (execution_group->get_flags().is_output && if (execution_group->get_flags().is_output &&
execution_group->getRenderPriority() == priority) { execution_group->get_render_priority() == priority) {
execution_group->execute(&exec_system); execution_group->execute(&exec_system);
} }
} }

View File

@@ -18,6 +18,7 @@
#pragma once #pragma once
#include "COM_Enums.h"
#include "COM_ExecutionModel.h" #include "COM_ExecutionModel.h"
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC

View File

@@ -18,7 +18,6 @@
#include "COM_WorkPackage.h" #include "COM_WorkPackage.h"
#include "COM_Enums.h"
#include "COM_ExecutionGroup.h" #include "COM_ExecutionGroup.h"
namespace blender::compositor { namespace blender::compositor {

View File

@@ -24,7 +24,7 @@
#include "COM_Enums.h" #include "COM_Enums.h"
#include "BLI_rect.h" #include "DNA_vec_types.h"
#include <functional> #include <functional>
#include <ostream> #include <ostream>
@@ -43,7 +43,7 @@ struct WorkPackage {
eWorkPackageState state = eWorkPackageState::NotScheduled; 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; ExecutionGroup *execution_group;

View File

@@ -16,15 +16,14 @@
* Copyright 2011, Blender Foundation. * Copyright 2011, Blender Foundation.
*/ */
#include <cstdio> #include "COM_WorkScheduler.h"
#include <list>
#include "COM_CPUDevice.h" #include "COM_CPUDevice.h"
#include "COM_CompositorContext.h"
#include "COM_ExecutionGroup.h"
#include "COM_OpenCLDevice.h" #include "COM_OpenCLDevice.h"
#include "COM_OpenCLKernels.cl.h" #include "COM_OpenCLKernels.cl.h"
#include "COM_WorkScheduler.h"
#include "COM_WriteBufferOperation.h" #include "COM_WriteBufferOperation.h"
#include "COM_compositor.h"
#include "clew.h" #include "clew.h"
@@ -33,7 +32,6 @@
#include "BLI_task.h" #include "BLI_task.h"
#include "BLI_threads.h" #include "BLI_threads.h"
#include "BLI_vector.hh" #include "BLI_vector.hh"
#include "PIL_time.h"
#include "BKE_global.h" #include "BKE_global.h"
@@ -106,7 +104,7 @@ static struct {
/** \name OpenCL Scheduling /** \name OpenCL Scheduling
* \{ */ * \{ */
static void CL_CALLBACK clContextError(const char *errinfo, static void CL_CALLBACK cl_context_error(const char *errinfo,
const void * /*private_info*/, const void * /*private_info*/,
size_t /*cb*/, size_t /*cb*/,
void * /*user_data*/) void * /*user_data*/)
@@ -128,7 +126,7 @@ static void *thread_execute_gpu(void *data)
static void opencl_start(const CompositorContext &context) 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(); g_work_scheduler.opencl.queue = BLI_thread_queue_init();
BLI_threadpool_init(&g_work_scheduler.opencl.threads, BLI_threadpool_init(&g_work_scheduler.opencl.threads,
thread_execute_gpu, thread_execute_gpu,
@@ -188,35 +186,35 @@ static void opencl_initialize(const bool use_opencl)
} }
if (clCreateContextFromType) { if (clCreateContextFromType) {
cl_uint numberOfPlatforms = 0; cl_uint number_of_platforms = 0;
cl_int error; cl_int error;
error = clGetPlatformIDs(0, nullptr, &numberOfPlatforms); error = clGetPlatformIDs(0, nullptr, &number_of_platforms);
if (error == -1001) { if (error == -1001) {
} /* GPU not supported */ } /* GPU not supported */
else if (error != CL_SUCCESS) { else if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
} }
if (G.f & G_DEBUG) { 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( cl_platform_id *platforms = (cl_platform_id *)MEM_mallocN(
sizeof(cl_platform_id) * numberOfPlatforms, __func__); sizeof(cl_platform_id) * number_of_platforms, __func__);
error = clGetPlatformIDs(numberOfPlatforms, platforms, nullptr); error = clGetPlatformIDs(number_of_platforms, platforms, nullptr);
unsigned int indexPlatform; unsigned int index_platform;
for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) { for (index_platform = 0; index_platform < number_of_platforms; index_platform++) {
cl_platform_id platform = platforms[indexPlatform]; cl_platform_id platform = platforms[index_platform];
cl_uint numberOfDevices = 0; cl_uint number_of_devices = 0;
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, nullptr, &numberOfDevices); clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, nullptr, &number_of_devices);
if (numberOfDevices <= 0) { if (number_of_devices <= 0) {
continue; continue;
} }
cl_device_id *cldevices = (cl_device_id *)MEM_mallocN( cl_device_id *cldevices = (cl_device_id *)MEM_mallocN(
sizeof(cl_device_id) * numberOfDevices, __func__); sizeof(cl_device_id) * number_of_devices, __func__);
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, nullptr); clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, number_of_devices, cldevices, nullptr);
g_work_scheduler.opencl.context = clCreateContext( 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) { if (error != CL_SUCCESS) {
printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
} }
@@ -224,7 +222,7 @@ static void opencl_initialize(const bool use_opencl)
g_work_scheduler.opencl.program = clCreateProgramWithSource( g_work_scheduler.opencl.program = clCreateProgramWithSource(
g_work_scheduler.opencl.context, 1, cl_str, nullptr, &error); g_work_scheduler.opencl.context, 1, cl_str, nullptr, &error);
error = clBuildProgram(g_work_scheduler.opencl.program, error = clBuildProgram(g_work_scheduler.opencl.program,
numberOfDevices, number_of_devices,
cldevices, cldevices,
nullptr, nullptr,
nullptr, nullptr,
@@ -257,9 +255,9 @@ static void opencl_initialize(const bool use_opencl)
MEM_freeN(build_log); MEM_freeN(build_log);
} }
else { else {
unsigned int indexDevices; unsigned int index_devices;
for (indexDevices = 0; indexDevices < numberOfDevices; indexDevices++) { for (index_devices = 0; index_devices < number_of_devices; index_devices++) {
cl_device_id device = cldevices[indexDevices]; cl_device_id device = cldevices[index_devices];
cl_int vendorID = 0; cl_int vendorID = 0;
cl_int error2 = clGetDeviceInfo( cl_int error2 = clGetDeviceInfo(
device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, nullptr); device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, nullptr);

View File

@@ -18,14 +18,12 @@
#pragma once #pragma once
#include "COM_ExecutionGroup.h"
#include "COM_Device.h"
#include "COM_WorkPackage.h"
#include "COM_defines.h"
namespace blender::compositor { namespace blender::compositor {
struct WorkPackage;
class CompositorContext;
/** \brief the workscheduler /** \brief the workscheduler
* \ingroup execution * \ingroup execution
*/ */
@@ -83,7 +81,7 @@ struct WorkScheduler {
* \brief Are there OpenCL capable GPU devices initialized? * \brief Are there OpenCL capable GPU devices initialized?
* the result of this method is stored in the CompositorContext * the result of this method is stored in the CompositorContext
* A node can generate a different operation tree when OpenCLDevices exists. * 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(); static bool has_gpu_devices();

View File

@@ -24,10 +24,8 @@
#include "BKE_scene.h" #include "BKE_scene.h"
#include "COM_ExecutionSystem.h" #include "COM_ExecutionSystem.h"
#include "COM_MovieDistortionOperation.h"
#include "COM_WorkScheduler.h" #include "COM_WorkScheduler.h"
#include "COM_compositor.h" #include "COM_compositor.h"
#include "clew.h"
static struct { static struct {
bool is_initialized = false; bool is_initialized = false;
@@ -66,9 +64,9 @@ void COM_execute(RenderData *render_data,
Scene *scene, Scene *scene,
bNodeTree *node_tree, bNodeTree *node_tree,
int rendering, int rendering,
const ColorManagedViewSettings *viewSettings, const ColorManagedViewSettings *view_settings,
const ColorManagedDisplaySettings *displaySettings, const ColorManagedDisplaySettings *display_settings,
const char *viewName) const char *view_name)
{ {
/* Initialize mutex, TODO: this mutex init is actually not thread safe and /* Initialize mutex, TODO: this mutex init is actually not thread safe and
* should be done somewhere as part of blender startup, all the other * should be done somewhere as part of blender startup, all the other
@@ -97,8 +95,14 @@ void COM_execute(RenderData *render_data,
/* Execute. */ /* Execute. */
const bool twopass = (node_tree->flag & NTREE_TWO_PASS) && !rendering; const bool twopass = (node_tree->flag & NTREE_TWO_PASS) && !rendering;
if (twopass) { if (twopass) {
blender::compositor::ExecutionSystem fast_pass( blender::compositor::ExecutionSystem fast_pass(render_data,
render_data, scene, node_tree, rendering, true, viewSettings, displaySettings, viewName); scene,
node_tree,
rendering,
true,
view_settings,
display_settings,
view_name);
fast_pass.execute(); fast_pass.execute();
if (node_tree->test_break(node_tree->tbh)) { if (node_tree->test_break(node_tree->tbh)) {
@@ -108,7 +112,7 @@ void COM_execute(RenderData *render_data,
} }
blender::compositor::ExecutionSystem system( 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(); system.execute();
BLI_mutex_unlock(&g_compositor.mutex); BLI_mutex_unlock(&g_compositor.mutex);

View File

@@ -21,50 +21,46 @@
#include "COM_AlphaOverKeyOperation.h" #include "COM_AlphaOverKeyOperation.h"
#include "COM_AlphaOverMixedOperation.h" #include "COM_AlphaOverMixedOperation.h"
#include "COM_AlphaOverPremultiplyOperation.h" #include "COM_AlphaOverPremultiplyOperation.h"
#include "COM_MixOperation.h"
#include "COM_SetValueOperation.h"
#include "DNA_material_types.h" /* the ramp types */
namespace blender::compositor { namespace blender::compositor {
void AlphaOverNode::convertToOperations(NodeConverter &converter, void AlphaOverNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
NodeInput *color1Socket = this->getInputSocket(1); NodeInput *color1Socket = this->get_input_socket(1);
NodeInput *color2Socket = this->getInputSocket(2); NodeInput *color2Socket = this->get_input_socket(2);
bNode *editorNode = this->getbNode(); bNode *editor_node = this->get_bnode();
MixBaseOperation *convertProg; MixBaseOperation *convert_prog;
NodeTwoFloats *ntf = (NodeTwoFloats *)editorNode->storage; NodeTwoFloats *ntf = (NodeTwoFloats *)editor_node->storage;
if (ntf->x != 0.0f) { if (ntf->x != 0.0f) {
AlphaOverMixedOperation *mixOperation = new AlphaOverMixedOperation(); AlphaOverMixedOperation *mix_operation = new AlphaOverMixedOperation();
mixOperation->setX(ntf->x); mix_operation->setX(ntf->x);
convertProg = mixOperation; convert_prog = mix_operation;
} }
else if (editorNode->custom1) { else if (editor_node->custom1) {
convertProg = new AlphaOverKeyOperation(); convert_prog = new AlphaOverKeyOperation();
} }
else { else {
convertProg = new AlphaOverPremultiplyOperation(); convert_prog = new AlphaOverPremultiplyOperation();
} }
convertProg->setUseValueAlphaMultiply(false); convert_prog->set_use_value_alpha_multiply(false);
if (color1Socket->isLinked()) { if (color1Socket->is_linked()) {
convertProg->set_canvas_input_index(1); convert_prog->set_canvas_input_index(1);
} }
else if (color2Socket->isLinked()) { else if (color2Socket->is_linked()) {
convertProg->set_canvas_input_index(2); convert_prog->set_canvas_input_index(2);
} }
else { else {
convertProg->set_canvas_input_index(0); convert_prog->set_canvas_input_index(0);
} }
converter.addOperation(convertProg); converter.add_operation(convert_prog);
converter.mapInputSocket(getInputSocket(0), convertProg->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), convert_prog->get_input_socket(0));
converter.mapInputSocket(getInputSocket(1), convertProg->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), convert_prog->get_input_socket(1));
converter.mapInputSocket(getInputSocket(2), convertProg->getInputSocket(2)); converter.map_input_socket(get_input_socket(2), convert_prog->get_input_socket(2));
converter.mapOutputSocket(getOutputSocket(0), convertProg->getOutputSocket(0)); converter.map_output_socket(get_output_socket(0), convert_prog->get_output_socket(0));
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,10 +28,10 @@ namespace blender::compositor {
*/ */
class AlphaOverNode : public Node { class AlphaOverNode : public Node {
public: public:
AlphaOverNode(bNode *editorNode) : Node(editorNode) AlphaOverNode(bNode *editor_node) : Node(editor_node)
{ {
} }
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -20,41 +20,40 @@
#include "COM_AntiAliasingNode.h" #include "COM_AntiAliasingNode.h"
#include "COM_SMAAOperation.h" #include "COM_SMAAOperation.h"
#include "DNA_node_types.h"
namespace blender::compositor { namespace blender::compositor {
void AntiAliasingNode::convertToOperations(NodeConverter &converter, void AntiAliasingNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
bNode *node = this->getbNode(); bNode *node = this->get_bnode();
NodeAntiAliasingData *data = (NodeAntiAliasingData *)node->storage; NodeAntiAliasingData *data = (NodeAntiAliasingData *)node->storage;
/* Edge Detection (First Pass) */ /* Edge Detection (First Pass) */
SMAAEdgeDetectionOperation *operation1 = nullptr; SMAAEdgeDetectionOperation *operation1 = nullptr;
operation1 = new SMAAEdgeDetectionOperation(); operation1 = new SMAAEdgeDetectionOperation();
operation1->setThreshold(data->threshold); operation1->set_threshold(data->threshold);
operation1->setLocalContrastAdaptationFactor(data->contrast_limit); operation1->set_local_contrast_adaptation_factor(data->contrast_limit);
converter.addOperation(operation1); converter.add_operation(operation1);
converter.mapInputSocket(getInputSocket(0), operation1->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation1->get_input_socket(0));
/* Blending Weight Calculation Pixel Shader (Second Pass) */ /* Blending Weight Calculation Pixel Shader (Second Pass) */
SMAABlendingWeightCalculationOperation *operation2 = SMAABlendingWeightCalculationOperation *operation2 =
new SMAABlendingWeightCalculationOperation(); new SMAABlendingWeightCalculationOperation();
operation2->setCornerRounding(data->corner_rounding); operation2->set_corner_rounding(data->corner_rounding);
converter.addOperation(operation2); converter.add_operation(operation2);
converter.addLink(operation1->getOutputSocket(), operation2->getInputSocket(0)); converter.add_link(operation1->get_output_socket(), operation2->get_input_socket(0));
/* Neighborhood Blending Pixel Shader (Third Pass) */ /* Neighborhood Blending Pixel Shader (Third Pass) */
SMAANeighborhoodBlendingOperation *operation3 = new SMAANeighborhoodBlendingOperation(); SMAANeighborhoodBlendingOperation *operation3 = new SMAANeighborhoodBlendingOperation();
converter.addOperation(operation3); converter.add_operation(operation3);
converter.mapInputSocket(getInputSocket(0), operation3->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation3->get_input_socket(0));
converter.addLink(operation2->getOutputSocket(), operation3->getInputSocket(1)); converter.add_link(operation2->get_output_socket(), operation3->get_input_socket(1));
converter.mapOutputSocket(getOutputSocket(0), operation3->getOutputSocket()); converter.map_output_socket(get_output_socket(0), operation3->get_output_socket());
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -30,10 +30,10 @@ namespace blender::compositor {
*/ */
class AntiAliasingNode : public Node { class AntiAliasingNode : public Node {
public: public:
AntiAliasingNode(bNode *editorNode) : Node(editorNode) AntiAliasingNode(bNode *editor_node) : Node(editor_node)
{ {
} }
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -18,28 +18,26 @@
#include "COM_BilateralBlurNode.h" #include "COM_BilateralBlurNode.h"
#include "COM_BilateralBlurOperation.h" #include "COM_BilateralBlurOperation.h"
#include "COM_ExecutionSystem.h"
#include "DNA_node_types.h"
namespace blender::compositor { namespace blender::compositor {
BilateralBlurNode::BilateralBlurNode(bNode *editorNode) : Node(editorNode) BilateralBlurNode::BilateralBlurNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void BilateralBlurNode::convertToOperations(NodeConverter &converter, void BilateralBlurNode::convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const const CompositorContext &context) const
{ {
NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->getbNode()->storage; NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->get_bnode()->storage;
BilateralBlurOperation *operation = new BilateralBlurOperation(); BilateralBlurOperation *operation = new BilateralBlurOperation();
operation->setQuality(context.getQuality()); operation->set_quality(context.get_quality());
operation->setData(data); operation->set_data(data);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class BilateralBlurNode : public Node { class BilateralBlurNode : public Node {
public: public:
BilateralBlurNode(bNode *editorNode); BilateralBlurNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -17,7 +17,6 @@
*/ */
#include "COM_BlurNode.h" #include "COM_BlurNode.h"
#include "COM_ExecutionSystem.h"
#include "COM_FastGaussianBlurOperation.h" #include "COM_FastGaussianBlurOperation.h"
#include "COM_GammaCorrectOperation.h" #include "COM_GammaCorrectOperation.h"
#include "COM_GaussianAlphaXBlurOperation.h" #include "COM_GaussianAlphaXBlurOperation.h"
@@ -27,107 +26,106 @@
#include "COM_GaussianYBlurOperation.h" #include "COM_GaussianYBlurOperation.h"
#include "COM_MathBaseOperation.h" #include "COM_MathBaseOperation.h"
#include "COM_SetValueOperation.h" #include "COM_SetValueOperation.h"
#include "DNA_node_types.h"
namespace blender::compositor { namespace blender::compositor {
BlurNode::BlurNode(bNode *editorNode) : Node(editorNode) BlurNode::BlurNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void BlurNode::convertToOperations(NodeConverter &converter, void BlurNode::convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const const CompositorContext &context) const
{ {
bNode *editorNode = this->getbNode(); bNode *editor_node = this->get_bnode();
NodeBlurData *data = (NodeBlurData *)editorNode->storage; NodeBlurData *data = (NodeBlurData *)editor_node->storage;
NodeInput *inputSizeSocket = this->getInputSocket(1); NodeInput *input_size_socket = this->get_input_socket(1);
bool connectedSizeSocket = inputSizeSocket->isLinked(); bool connected_size_socket = input_size_socket->is_linked();
const float size = this->getInputSocket(1)->getEditorValueFloat(); const float size = this->get_input_socket(1)->get_editor_value_float();
const bool extend_bounds = (editorNode->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0; const bool extend_bounds = (editor_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;
eCompositorQuality quality = context.getQuality(); eCompositorQuality quality = context.get_quality();
NodeOperation *input_operation = nullptr, *output_operation = nullptr; NodeOperation *input_operation = nullptr, *output_operation = nullptr;
if (data->filtertype == R_FILTER_FAST_GAUSS) { if (data->filtertype == R_FILTER_FAST_GAUSS) {
FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation(); FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
operationfgb->setData(data); operationfgb->set_data(data);
operationfgb->setExtendBounds(extend_bounds); operationfgb->set_extend_bounds(extend_bounds);
converter.addOperation(operationfgb); converter.add_operation(operationfgb);
converter.mapInputSocket(getInputSocket(1), operationfgb->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operationfgb->get_input_socket(1));
input_operation = operationfgb; input_operation = operationfgb;
output_operation = operationfgb; output_operation = operationfgb;
} }
else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) { else if (editor_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) {
MathAddOperation *clamp = new MathAddOperation(); MathAddOperation *clamp = new MathAddOperation();
SetValueOperation *zero = new SetValueOperation(); SetValueOperation *zero = new SetValueOperation();
zero->setValue(0.0f); zero->set_value(0.0f);
clamp->setUseClamp(true); clamp->set_use_clamp(true);
converter.addOperation(clamp); converter.add_operation(clamp);
converter.addOperation(zero); converter.add_operation(zero);
converter.mapInputSocket(getInputSocket(1), clamp->getInputSocket(0)); converter.map_input_socket(get_input_socket(1), clamp->get_input_socket(0));
converter.addLink(zero->getOutputSocket(), clamp->getInputSocket(1)); converter.add_link(zero->get_output_socket(), clamp->get_input_socket(1));
GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
operationx->setData(data); operationx->set_data(data);
operationx->setQuality(quality); operationx->set_quality(quality);
operationx->setSize(1.0f); operationx->set_size(1.0f);
operationx->setFalloff(PROP_SMOOTH); operationx->set_falloff(PROP_SMOOTH);
operationx->setSubtract(false); operationx->set_subtract(false);
operationx->setExtendBounds(extend_bounds); operationx->set_extend_bounds(extend_bounds);
converter.addOperation(operationx); converter.add_operation(operationx);
converter.addLink(clamp->getOutputSocket(), operationx->getInputSocket(0)); converter.add_link(clamp->get_output_socket(), operationx->get_input_socket(0));
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
operationy->setData(data); operationy->set_data(data);
operationy->setQuality(quality); operationy->set_quality(quality);
operationy->setSize(1.0f); operationy->set_size(1.0f);
operationy->setFalloff(PROP_SMOOTH); operationy->set_falloff(PROP_SMOOTH);
operationy->setSubtract(false); operationy->set_subtract(false);
operationy->setExtendBounds(extend_bounds); operationy->set_extend_bounds(extend_bounds);
converter.addOperation(operationy); converter.add_operation(operationy);
converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0)); converter.add_link(operationx->get_output_socket(), operationy->get_input_socket(0));
GaussianBlurReferenceOperation *operation = new GaussianBlurReferenceOperation(); GaussianBlurReferenceOperation *operation = new GaussianBlurReferenceOperation();
operation->setData(data); operation->set_data(data);
operation->setQuality(quality); operation->set_quality(quality);
operation->setExtendBounds(extend_bounds); operation->set_extend_bounds(extend_bounds);
converter.addOperation(operation); converter.add_operation(operation);
converter.addLink(operationy->getOutputSocket(), operation->getInputSocket(1)); converter.add_link(operationy->get_output_socket(), operation->get_input_socket(1));
output_operation = operation; output_operation = operation;
input_operation = operation; input_operation = operation;
} }
else if (!data->bokeh) { else if (!data->bokeh) {
GaussianXBlurOperation *operationx = new GaussianXBlurOperation(); GaussianXBlurOperation *operationx = new GaussianXBlurOperation();
operationx->setData(data); operationx->set_data(data);
operationx->setQuality(quality); operationx->set_quality(quality);
operationx->checkOpenCL(); operationx->check_opencl();
operationx->setExtendBounds(extend_bounds); operationx->set_extend_bounds(extend_bounds);
converter.addOperation(operationx); converter.add_operation(operationx);
converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operationx->get_input_socket(1));
GaussianYBlurOperation *operationy = new GaussianYBlurOperation(); GaussianYBlurOperation *operationy = new GaussianYBlurOperation();
operationy->setData(data); operationy->set_data(data);
operationy->setQuality(quality); operationy->set_quality(quality);
operationy->checkOpenCL(); operationy->check_opencl();
operationy->setExtendBounds(extend_bounds); operationy->set_extend_bounds(extend_bounds);
converter.addOperation(operationy); converter.add_operation(operationy);
converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operationy->get_input_socket(1));
converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0)); converter.add_link(operationx->get_output_socket(), operationy->get_input_socket(0));
if (!connectedSizeSocket) { if (!connected_size_socket) {
operationx->setSize(size); operationx->set_size(size);
operationy->setSize(size); operationy->set_size(size);
} }
input_operation = operationx; input_operation = operationx;
@@ -135,15 +133,15 @@ void BlurNode::convertToOperations(NodeConverter &converter,
} }
else { else {
GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation(); GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation();
operation->setData(data); operation->set_data(data);
operation->setQuality(quality); operation->set_quality(quality);
operation->setExtendBounds(extend_bounds); operation->set_extend_bounds(extend_bounds);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
if (!connectedSizeSocket) { if (!connected_size_socket) {
operation->setSize(size); operation->set_size(size);
} }
input_operation = operation; input_operation = operation;
@@ -153,21 +151,21 @@ void BlurNode::convertToOperations(NodeConverter &converter,
if (data->gamma) { if (data->gamma) {
GammaCorrectOperation *correct = new GammaCorrectOperation(); GammaCorrectOperation *correct = new GammaCorrectOperation();
GammaUncorrectOperation *inverse = new GammaUncorrectOperation(); GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
converter.addOperation(correct); converter.add_operation(correct);
converter.addOperation(inverse); converter.add_operation(inverse);
converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), correct->get_input_socket(0));
converter.addLink(correct->getOutputSocket(), input_operation->getInputSocket(0)); converter.add_link(correct->get_output_socket(), input_operation->get_input_socket(0));
converter.addLink(output_operation->getOutputSocket(), inverse->getInputSocket(0)); converter.add_link(output_operation->get_output_socket(), inverse->get_input_socket(0));
converter.mapOutputSocket(getOutputSocket(), inverse->getOutputSocket()); converter.map_output_socket(get_output_socket(), inverse->get_output_socket());
converter.addPreview(inverse->getOutputSocket()); converter.add_preview(inverse->get_output_socket());
} }
else { else {
converter.mapInputSocket(getInputSocket(0), input_operation->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), input_operation->get_input_socket(0));
converter.mapOutputSocket(getOutputSocket(), output_operation->getOutputSocket()); converter.map_output_socket(get_output_socket(), output_operation->get_output_socket());
converter.addPreview(output_operation->getOutputSocket()); converter.add_preview(output_operation->get_output_socket());
} }
} }

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class BlurNode : public Node { class BlurNode : public Node {
public: public:
BlurNode(bNode *editorNode); BlurNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -18,61 +18,56 @@
#include "COM_BokehBlurNode.h" #include "COM_BokehBlurNode.h"
#include "COM_BokehBlurOperation.h" #include "COM_BokehBlurOperation.h"
#include "COM_ConvertDepthToRadiusOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_VariableSizeBokehBlurOperation.h" #include "COM_VariableSizeBokehBlurOperation.h"
#include "DNA_camera_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
namespace blender::compositor { namespace blender::compositor {
BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode) BokehBlurNode::BokehBlurNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void BokehBlurNode::convertToOperations(NodeConverter &converter, void BokehBlurNode::convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const const CompositorContext &context) const
{ {
bNode *b_node = this->getbNode(); bNode *b_node = this->get_bnode();
NodeInput *inputSizeSocket = this->getInputSocket(2); NodeInput *input_size_socket = this->get_input_socket(2);
bool connectedSizeSocket = inputSizeSocket->isLinked(); bool connected_size_socket = input_size_socket->is_linked();
const bool extend_bounds = (b_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0; const bool extend_bounds = (b_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;
if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connectedSizeSocket) { if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connected_size_socket) {
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
operation->setQuality(context.getQuality()); operation->set_quality(context.get_quality());
operation->setThreshold(0.0f); operation->set_threshold(0.0f);
operation->setMaxBlur(b_node->custom4); operation->set_max_blur(b_node->custom4);
operation->setDoScaleSize(true); operation->set_do_scale_size(true);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
} }
else { else {
BokehBlurOperation *operation = new BokehBlurOperation(); BokehBlurOperation *operation = new BokehBlurOperation();
operation->setQuality(context.getQuality()); operation->set_quality(context.get_quality());
operation->setExtendBounds(extend_bounds); operation->set_extend_bounds(extend_bounds);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
/* NOTE: on the bokeh blur operation the sockets are switched. /* NOTE: on the bokeh blur operation the sockets are switched.
* for this reason the next two lines are correct. Fix for T43771. */ * for this reason the next two lines are correct. Fix for T43771. */
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(3)); converter.map_input_socket(get_input_socket(2), operation->get_input_socket(3));
converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(2)); converter.map_input_socket(get_input_socket(3), operation->get_input_socket(2));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
if (!connectedSizeSocket) { if (!connected_size_socket) {
operation->setSize(this->getInputSocket(2)->getEditorValueFloat()); operation->set_size(this->get_input_socket(2)->get_editor_value_float());
} }
} }
} }

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class BokehBlurNode : public Node { class BokehBlurNode : public Node {
public: public:
BokehBlurNode(bNode *editorNode); BokehBlurNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -18,25 +18,24 @@
#include "COM_BokehImageNode.h" #include "COM_BokehImageNode.h"
#include "COM_BokehImageOperation.h" #include "COM_BokehImageOperation.h"
#include "COM_ExecutionSystem.h"
namespace blender::compositor { namespace blender::compositor {
BokehImageNode::BokehImageNode(bNode *editorNode) : Node(editorNode) BokehImageNode::BokehImageNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void BokehImageNode::convertToOperations(NodeConverter &converter, void BokehImageNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
BokehImageOperation *operation = new BokehImageOperation(); BokehImageOperation *operation = new BokehImageOperation();
operation->setData((NodeBokehImage *)this->getbNode()->storage); operation->set_data((NodeBokehImage *)this->get_bnode()->storage);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
converter.addPreview(operation->getOutputSocket(0)); converter.add_preview(operation->get_output_socket(0));
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class BokehImageNode : public Node { class BokehImageNode : public Node {
public: public:
BokehImageNode(bNode *editorNode); BokehImageNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -18,59 +18,59 @@
#include "COM_BoxMaskNode.h" #include "COM_BoxMaskNode.h"
#include "COM_BoxMaskOperation.h" #include "COM_BoxMaskOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_ScaleOperation.h" #include "COM_ScaleOperation.h"
#include "COM_SetValueOperation.h" #include "COM_SetValueOperation.h"
namespace blender::compositor { namespace blender::compositor {
BoxMaskNode::BoxMaskNode(bNode *editorNode) : Node(editorNode) BoxMaskNode::BoxMaskNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void BoxMaskNode::convertToOperations(NodeConverter &converter, void BoxMaskNode::convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const const CompositorContext &context) const
{ {
NodeInput *inputSocket = this->getInputSocket(0); NodeInput *input_socket = this->get_input_socket(0);
NodeOutput *outputSocket = this->getOutputSocket(0); NodeOutput *output_socket = this->get_output_socket(0);
BoxMaskOperation *operation; BoxMaskOperation *operation;
operation = new BoxMaskOperation(); operation = new BoxMaskOperation();
operation->setData((NodeBoxMask *)this->getbNode()->storage); operation->set_data((NodeBoxMask *)this->get_bnode()->storage);
operation->setMaskType(this->getbNode()->custom1); operation->set_mask_type(this->get_bnode()->custom1);
converter.addOperation(operation); converter.add_operation(operation);
if (inputSocket->isLinked()) { if (input_socket->is_linked()) {
converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); converter.map_input_socket(input_socket, operation->get_input_socket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); converter.map_output_socket(output_socket, operation->get_output_socket());
} }
else { else {
/* Value operation to produce original transparent image */ /* Value operation to produce original transparent image */
SetValueOperation *valueOperation = new SetValueOperation(); SetValueOperation *value_operation = new SetValueOperation();
valueOperation->setValue(0.0f); value_operation->set_value(0.0f);
converter.addOperation(valueOperation); converter.add_operation(value_operation);
/* Scale that image up to render resolution */ /* Scale that image up to render resolution */
const RenderData *rd = context.getRenderData(); const RenderData *rd = context.get_render_data();
const float render_size_factor = context.getRenderPercentageAsFactor(); const float render_size_factor = context.get_render_percentage_as_factor();
ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation(); ScaleFixedSizeOperation *scale_operation = new ScaleFixedSizeOperation();
scaleOperation->setIsAspect(false); scale_operation->set_is_aspect(false);
scaleOperation->setIsCrop(false); scale_operation->set_is_crop(false);
scaleOperation->setOffset(0.0f, 0.0f); scale_operation->set_offset(0.0f, 0.0f);
scaleOperation->setNewWidth(rd->xsch * render_size_factor); scale_operation->set_new_width(rd->xsch * render_size_factor);
scaleOperation->setNewHeight(rd->ysch * render_size_factor); scale_operation->set_new_height(rd->ysch * render_size_factor);
scaleOperation->getInputSocket(0)->setResizeMode(ResizeMode::Align); scale_operation->get_input_socket(0)->set_resize_mode(ResizeMode::Align);
converter.addOperation(scaleOperation); converter.add_operation(scale_operation);
converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0)); converter.add_link(value_operation->get_output_socket(0),
converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0)); scale_operation->get_input_socket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); converter.add_link(scale_operation->get_output_socket(0), operation->get_input_socket(0));
converter.map_output_socket(output_socket, operation->get_output_socket(0));
} }
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class BoxMaskNode : public Node { class BoxMaskNode : public Node {
public: public:
BoxMaskNode(bNode *editorNode); BoxMaskNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -18,27 +18,26 @@
#include "COM_BrightnessNode.h" #include "COM_BrightnessNode.h"
#include "COM_BrightnessOperation.h" #include "COM_BrightnessOperation.h"
#include "COM_ExecutionSystem.h"
namespace blender::compositor { namespace blender::compositor {
BrightnessNode::BrightnessNode(bNode *editorNode) : Node(editorNode) BrightnessNode::BrightnessNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void BrightnessNode::convertToOperations(NodeConverter &converter, void BrightnessNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
bNode *bnode = this->getbNode(); bNode *bnode = this->get_bnode();
BrightnessOperation *operation = new BrightnessOperation(); BrightnessOperation *operation = new BrightnessOperation();
operation->setUsePremultiply((bnode->custom1 & 1) != 0); operation->set_use_premultiply((bnode->custom1 & 1) != 0);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class BrightnessNode : public Node { class BrightnessNode : public Node {
public: public:
BrightnessNode(bNode *editorNode); BrightnessNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -17,26 +17,25 @@
*/ */
#include "COM_ChannelMatteNode.h" #include "COM_ChannelMatteNode.h"
#include "BKE_node.h"
#include "COM_ChannelMatteOperation.h" #include "COM_ChannelMatteOperation.h"
#include "COM_ConvertOperation.h" #include "COM_ConvertOperation.h"
#include "COM_SetAlphaMultiplyOperation.h" #include "COM_SetAlphaMultiplyOperation.h"
namespace blender::compositor { namespace blender::compositor {
ChannelMatteNode::ChannelMatteNode(bNode *editorNode) : Node(editorNode) ChannelMatteNode::ChannelMatteNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ChannelMatteNode::convertToOperations(NodeConverter &converter, void ChannelMatteNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
bNode *node = this->getbNode(); bNode *node = this->get_bnode();
NodeInput *inputSocketImage = this->getInputSocket(0); NodeInput *input_socket_image = this->get_input_socket(0);
NodeOutput *outputSocketImage = this->getOutputSocket(0); NodeOutput *output_socket_image = this->get_output_socket(0);
NodeOutput *outputSocketMatte = this->getOutputSocket(1); NodeOutput *output_socket_matte = this->get_output_socket(1);
NodeOperation *convert = nullptr, *inv_convert = nullptr; NodeOperation *convert = nullptr, *inv_convert = nullptr;
/* colorspace */ /* colorspace */
@@ -53,9 +52,9 @@ void ChannelMatteNode::convertToOperations(NodeConverter &converter,
break; break;
case CMP_NODE_CHANNEL_MATTE_CS_YCC: /* YCC */ case CMP_NODE_CHANNEL_MATTE_CS_YCC: /* YCC */
convert = new ConvertRGBToYCCOperation(); convert = new ConvertRGBToYCCOperation();
((ConvertRGBToYCCOperation *)convert)->setMode(BLI_YCC_ITU_BT709); ((ConvertRGBToYCCOperation *)convert)->set_mode(BLI_YCC_ITU_BT709);
inv_convert = new ConvertYCCToRGBOperation(); inv_convert = new ConvertYCCToRGBOperation();
((ConvertYCCToRGBOperation *)inv_convert)->setMode(BLI_YCC_ITU_BT709); ((ConvertYCCToRGBOperation *)inv_convert)->set_mode(BLI_YCC_ITU_BT709);
break; break;
default: default:
break; break;
@@ -63,36 +62,36 @@ void ChannelMatteNode::convertToOperations(NodeConverter &converter,
ChannelMatteOperation *operation = new ChannelMatteOperation(); ChannelMatteOperation *operation = new ChannelMatteOperation();
/* pass the ui properties to the operation */ /* pass the ui properties to the operation */
operation->setSettings((NodeChroma *)node->storage, node->custom2); operation->set_settings((NodeChroma *)node->storage, node->custom2);
converter.addOperation(operation); converter.add_operation(operation);
SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); SetAlphaMultiplyOperation *operation_alpha = new SetAlphaMultiplyOperation();
converter.addOperation(operationAlpha); converter.add_operation(operation_alpha);
if (convert != nullptr) { if (convert != nullptr) {
converter.addOperation(convert); converter.add_operation(convert);
converter.mapInputSocket(inputSocketImage, convert->getInputSocket(0)); converter.map_input_socket(input_socket_image, convert->get_input_socket(0));
converter.addLink(convert->getOutputSocket(), operation->getInputSocket(0)); converter.add_link(convert->get_output_socket(), operation->get_input_socket(0));
converter.addLink(convert->getOutputSocket(), operationAlpha->getInputSocket(0)); converter.add_link(convert->get_output_socket(), operation_alpha->get_input_socket(0));
} }
else { else {
converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0)); converter.map_input_socket(input_socket_image, operation->get_input_socket(0));
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
} }
converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0)); converter.map_output_socket(output_socket_matte, operation->get_output_socket(0));
converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); converter.add_link(operation->get_output_socket(), operation_alpha->get_input_socket(1));
if (inv_convert != nullptr) { if (inv_convert != nullptr) {
converter.addOperation(inv_convert); converter.add_operation(inv_convert);
converter.addLink(operationAlpha->getOutputSocket(0), inv_convert->getInputSocket(0)); converter.add_link(operation_alpha->get_output_socket(0), inv_convert->get_input_socket(0));
converter.mapOutputSocket(outputSocketImage, inv_convert->getOutputSocket()); converter.map_output_socket(output_socket_image, inv_convert->get_output_socket());
converter.addPreview(inv_convert->getOutputSocket()); converter.add_preview(inv_convert->get_output_socket());
} }
else { else {
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); converter.map_output_socket(output_socket_image, operation_alpha->get_output_socket());
converter.addPreview(operationAlpha->getOutputSocket()); converter.add_preview(operation_alpha->get_output_socket());
} }
} }

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class ChannelMatteNode : public Node { class ChannelMatteNode : public Node {
public: public:
ChannelMatteNode(bNode *editorNode); ChannelMatteNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -17,53 +17,52 @@
*/ */
#include "COM_ChromaMatteNode.h" #include "COM_ChromaMatteNode.h"
#include "BKE_node.h"
#include "COM_ChromaMatteOperation.h" #include "COM_ChromaMatteOperation.h"
#include "COM_ConvertOperation.h" #include "COM_ConvertOperation.h"
#include "COM_SetAlphaMultiplyOperation.h" #include "COM_SetAlphaMultiplyOperation.h"
namespace blender::compositor { namespace blender::compositor {
ChromaMatteNode::ChromaMatteNode(bNode *editorNode) : Node(editorNode) ChromaMatteNode::ChromaMatteNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ChromaMatteNode::convertToOperations(NodeConverter &converter, void ChromaMatteNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
bNode *editorsnode = getbNode(); bNode *editorsnode = get_bnode();
NodeInput *inputSocketImage = this->getInputSocket(0); NodeInput *input_socket_image = this->get_input_socket(0);
NodeInput *inputSocketKey = this->getInputSocket(1); NodeInput *input_socket_key = this->get_input_socket(1);
NodeOutput *outputSocketImage = this->getOutputSocket(0); NodeOutput *output_socket_image = this->get_output_socket(0);
NodeOutput *outputSocketMatte = this->getOutputSocket(1); NodeOutput *output_socket_matte = this->get_output_socket(1);
ConvertRGBToYCCOperation *operationRGBToYCC_Image = new ConvertRGBToYCCOperation(); ConvertRGBToYCCOperation *operationRGBToYCC_Image = new ConvertRGBToYCCOperation();
ConvertRGBToYCCOperation *operationRGBToYCC_Key = new ConvertRGBToYCCOperation(); ConvertRGBToYCCOperation *operationRGBToYCC_Key = new ConvertRGBToYCCOperation();
operationRGBToYCC_Image->setMode(BLI_YCC_ITU_BT709); operationRGBToYCC_Image->set_mode(BLI_YCC_ITU_BT709);
operationRGBToYCC_Key->setMode(BLI_YCC_ITU_BT709); operationRGBToYCC_Key->set_mode(BLI_YCC_ITU_BT709);
converter.addOperation(operationRGBToYCC_Image); converter.add_operation(operationRGBToYCC_Image);
converter.addOperation(operationRGBToYCC_Key); converter.add_operation(operationRGBToYCC_Key);
ChromaMatteOperation *operation = new ChromaMatteOperation(); ChromaMatteOperation *operation = new ChromaMatteOperation();
operation->setSettings((NodeChroma *)editorsnode->storage); operation->set_settings((NodeChroma *)editorsnode->storage);
converter.addOperation(operation); converter.add_operation(operation);
SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); SetAlphaMultiplyOperation *operation_alpha = new SetAlphaMultiplyOperation();
converter.addOperation(operationAlpha); converter.add_operation(operation_alpha);
converter.mapInputSocket(inputSocketImage, operationRGBToYCC_Image->getInputSocket(0)); converter.map_input_socket(input_socket_image, operationRGBToYCC_Image->get_input_socket(0));
converter.mapInputSocket(inputSocketKey, operationRGBToYCC_Key->getInputSocket(0)); converter.map_input_socket(input_socket_key, operationRGBToYCC_Key->get_input_socket(0));
converter.addLink(operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0)); converter.add_link(operationRGBToYCC_Image->get_output_socket(), operation->get_input_socket(0));
converter.addLink(operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1)); converter.add_link(operationRGBToYCC_Key->get_output_socket(), operation->get_input_socket(1));
converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket()); converter.map_output_socket(output_socket_matte, operation->get_output_socket());
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); converter.add_link(operation->get_output_socket(), operation_alpha->get_input_socket(1));
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); converter.map_output_socket(output_socket_image, operation_alpha->get_output_socket());
converter.addPreview(operationAlpha->getOutputSocket()); converter.add_preview(operation_alpha->get_output_socket());
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class ChromaMatteNode : public Node { class ChromaMatteNode : public Node {
public: public:
ChromaMatteNode(bNode *editorNode); ChromaMatteNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -17,28 +17,25 @@
*/ */
#include "COM_ColorBalanceNode.h" #include "COM_ColorBalanceNode.h"
#include "BKE_node.h"
#include "COM_ColorBalanceASCCDLOperation.h" #include "COM_ColorBalanceASCCDLOperation.h"
#include "COM_ColorBalanceLGGOperation.h" #include "COM_ColorBalanceLGGOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_MixOperation.h"
namespace blender::compositor { namespace blender::compositor {
ColorBalanceNode::ColorBalanceNode(bNode *editorNode) : Node(editorNode) ColorBalanceNode::ColorBalanceNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ColorBalanceNode::convertToOperations(NodeConverter &converter, void ColorBalanceNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
bNode *node = this->getbNode(); bNode *node = this->get_bnode();
NodeColorBalance *n = (NodeColorBalance *)node->storage; NodeColorBalance *n = (NodeColorBalance *)node->storage;
NodeInput *inputSocket = this->getInputSocket(0); NodeInput *input_socket = this->get_input_socket(0);
NodeInput *inputImageSocket = this->getInputSocket(1); NodeInput *input_image_socket = this->get_input_socket(1);
NodeOutput *outputSocket = this->getOutputSocket(0); NodeOutput *output_socket = this->get_output_socket(0);
NodeOperation *operation; NodeOperation *operation;
if (node->custom1 == 0) { if (node->custom1 == 0) {
@@ -50,9 +47,9 @@ void ColorBalanceNode::convertToOperations(NodeConverter &converter,
gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f; gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f;
} }
operationLGG->setGain(n->gain); operationLGG->set_gain(n->gain);
operationLGG->setLift(lift_lgg); operationLGG->set_lift(lift_lgg);
operationLGG->setGammaInv(gamma_inv); operationLGG->set_gamma_inv(gamma_inv);
operation = operationLGG; operation = operationLGG;
} }
else { else {
@@ -62,16 +59,16 @@ void ColorBalanceNode::convertToOperations(NodeConverter &converter,
copy_v3_fl(offset, n->offset_basis); copy_v3_fl(offset, n->offset_basis);
add_v3_v3(offset, n->offset); add_v3_v3(offset, n->offset);
operationCDL->setOffset(offset); operationCDL->set_offset(offset);
operationCDL->setPower(n->power); operationCDL->set_power(n->power);
operationCDL->setSlope(n->slope); operationCDL->set_slope(n->slope);
operation = operationCDL; operation = operationCDL;
} }
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); converter.map_input_socket(input_socket, operation->get_input_socket(0));
converter.mapInputSocket(inputImageSocket, operation->getInputSocket(1)); converter.map_input_socket(input_image_socket, operation->get_input_socket(1));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); converter.map_output_socket(output_socket, operation->get_output_socket(0));
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class ColorBalanceNode : public Node { class ColorBalanceNode : public Node {
public: public:
ColorBalanceNode(bNode *editorNode); ColorBalanceNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -18,30 +18,29 @@
#include "COM_ColorCorrectionNode.h" #include "COM_ColorCorrectionNode.h"
#include "COM_ColorCorrectionOperation.h" #include "COM_ColorCorrectionOperation.h"
#include "COM_ExecutionSystem.h"
namespace blender::compositor { namespace blender::compositor {
ColorCorrectionNode::ColorCorrectionNode(bNode *editorNode) : Node(editorNode) ColorCorrectionNode::ColorCorrectionNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ColorCorrectionNode::convertToOperations(NodeConverter &converter, void ColorCorrectionNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
bNode *editorNode = getbNode(); bNode *editor_node = get_bnode();
ColorCorrectionOperation *operation = new ColorCorrectionOperation(); ColorCorrectionOperation *operation = new ColorCorrectionOperation();
operation->setData((NodeColorCorrection *)editorNode->storage); operation->set_data((NodeColorCorrection *)editor_node->storage);
operation->setRedChannelEnabled((editorNode->custom1 & 1) != 0); operation->set_red_channel_enabled((editor_node->custom1 & 1) != 0);
operation->setGreenChannelEnabled((editorNode->custom1 & 2) != 0); operation->set_green_channel_enabled((editor_node->custom1 & 2) != 0);
operation->setBlueChannelEnabled((editorNode->custom1 & 4) != 0); operation->set_blue_channel_enabled((editor_node->custom1 & 4) != 0);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class ColorCorrectionNode : public Node { class ColorCorrectionNode : public Node {
public: public:
ColorCorrectionNode(bNode *editorNode); ColorCorrectionNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -18,43 +18,42 @@
#include "COM_ColorCurveNode.h" #include "COM_ColorCurveNode.h"
#include "COM_ColorCurveOperation.h" #include "COM_ColorCurveOperation.h"
#include "COM_ExecutionSystem.h"
namespace blender::compositor { namespace blender::compositor {
ColorCurveNode::ColorCurveNode(bNode *editorNode) : Node(editorNode) ColorCurveNode::ColorCurveNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ColorCurveNode::convertToOperations(NodeConverter &converter, void ColorCurveNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
if (this->getInputSocket(2)->isLinked() || this->getInputSocket(3)->isLinked()) { if (this->get_input_socket(2)->is_linked() || this->get_input_socket(3)->is_linked()) {
ColorCurveOperation *operation = new ColorCurveOperation(); ColorCurveOperation *operation = new ColorCurveOperation();
operation->setCurveMapping((CurveMapping *)this->getbNode()->storage); operation->set_curve_mapping((CurveMapping *)this->get_bnode()->storage);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3)); converter.map_input_socket(get_input_socket(3), operation->get_input_socket(3));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
} }
else { else {
ConstantLevelColorCurveOperation *operation = new ConstantLevelColorCurveOperation(); ConstantLevelColorCurveOperation *operation = new ConstantLevelColorCurveOperation();
float col[4]; float col[4];
this->getInputSocket(2)->getEditorValueColor(col); this->get_input_socket(2)->get_editor_value_color(col);
operation->setBlackLevel(col); operation->set_black_level(col);
this->getInputSocket(3)->getEditorValueColor(col); this->get_input_socket(3)->get_editor_value_color(col);
operation->setWhiteLevel(col); operation->set_white_level(col);
operation->setCurveMapping((CurveMapping *)this->getbNode()->storage); operation->set_curve_mapping((CurveMapping *)this->get_bnode()->storage);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
} }
} }

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class ColorCurveNode : public Node { class ColorCurveNode : public Node {
public: public:
ColorCurveNode(bNode *editorNode); ColorCurveNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -18,24 +18,23 @@
#include "COM_ColorExposureNode.h" #include "COM_ColorExposureNode.h"
#include "COM_ColorExposureOperation.h" #include "COM_ColorExposureOperation.h"
#include "COM_ExecutionSystem.h"
namespace blender::compositor { namespace blender::compositor {
ExposureNode::ExposureNode(bNode *editorNode) : Node(editorNode) ExposureNode::ExposureNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ExposureNode::convertToOperations(NodeConverter &converter, void ExposureNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
ExposureOperation *operation = new ExposureOperation(); ExposureOperation *operation = new ExposureOperation();
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class ExposureNode : public Node { class ExposureNode : public Node {
public: public:
ExposureNode(bNode *editorNode); ExposureNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -17,51 +17,50 @@
*/ */
#include "COM_ColorMatteNode.h" #include "COM_ColorMatteNode.h"
#include "BKE_node.h"
#include "COM_ColorMatteOperation.h" #include "COM_ColorMatteOperation.h"
#include "COM_ConvertOperation.h" #include "COM_ConvertOperation.h"
#include "COM_SetAlphaMultiplyOperation.h" #include "COM_SetAlphaMultiplyOperation.h"
namespace blender::compositor { namespace blender::compositor {
ColorMatteNode::ColorMatteNode(bNode *editorNode) : Node(editorNode) ColorMatteNode::ColorMatteNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ColorMatteNode::convertToOperations(NodeConverter &converter, void ColorMatteNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
bNode *editorsnode = getbNode(); bNode *editorsnode = get_bnode();
NodeInput *inputSocketImage = this->getInputSocket(0); NodeInput *input_socket_image = this->get_input_socket(0);
NodeInput *inputSocketKey = this->getInputSocket(1); NodeInput *input_socket_key = this->get_input_socket(1);
NodeOutput *outputSocketImage = this->getOutputSocket(0); NodeOutput *output_socket_image = this->get_output_socket(0);
NodeOutput *outputSocketMatte = this->getOutputSocket(1); NodeOutput *output_socket_matte = this->get_output_socket(1);
ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation(); ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation();
ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation(); ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation();
converter.addOperation(operationRGBToHSV_Image); converter.add_operation(operationRGBToHSV_Image);
converter.addOperation(operationRGBToHSV_Key); converter.add_operation(operationRGBToHSV_Key);
ColorMatteOperation *operation = new ColorMatteOperation(); ColorMatteOperation *operation = new ColorMatteOperation();
operation->setSettings((NodeChroma *)editorsnode->storage); operation->set_settings((NodeChroma *)editorsnode->storage);
converter.addOperation(operation); converter.add_operation(operation);
SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); SetAlphaMultiplyOperation *operation_alpha = new SetAlphaMultiplyOperation();
converter.addOperation(operationAlpha); converter.add_operation(operation_alpha);
converter.mapInputSocket(inputSocketImage, operationRGBToHSV_Image->getInputSocket(0)); converter.map_input_socket(input_socket_image, operationRGBToHSV_Image->get_input_socket(0));
converter.mapInputSocket(inputSocketKey, operationRGBToHSV_Key->getInputSocket(0)); converter.map_input_socket(input_socket_key, operationRGBToHSV_Key->get_input_socket(0));
converter.addLink(operationRGBToHSV_Image->getOutputSocket(), operation->getInputSocket(0)); converter.add_link(operationRGBToHSV_Image->get_output_socket(), operation->get_input_socket(0));
converter.addLink(operationRGBToHSV_Key->getOutputSocket(), operation->getInputSocket(1)); converter.add_link(operationRGBToHSV_Key->get_output_socket(), operation->get_input_socket(1));
converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0)); converter.map_output_socket(output_socket_matte, operation->get_output_socket(0));
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); converter.add_link(operation->get_output_socket(), operation_alpha->get_input_socket(1));
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); converter.map_output_socket(output_socket_image, operation_alpha->get_output_socket());
converter.addPreview(operationAlpha->getOutputSocket()); converter.add_preview(operation_alpha->get_output_socket());
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class ColorMatteNode : public Node { class ColorMatteNode : public Node {
public: public:
ColorMatteNode(bNode *editorNode); ColorMatteNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -17,27 +17,26 @@
*/ */
#include "COM_ColorNode.h" #include "COM_ColorNode.h"
#include "COM_ExecutionSystem.h"
#include "COM_SetColorOperation.h" #include "COM_SetColorOperation.h"
namespace blender::compositor { namespace blender::compositor {
ColorNode::ColorNode(bNode *editorNode) : Node(editorNode) ColorNode::ColorNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ColorNode::convertToOperations(NodeConverter &converter, void ColorNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
SetColorOperation *operation = new SetColorOperation(); SetColorOperation *operation = new SetColorOperation();
NodeOutput *output = this->getOutputSocket(0); NodeOutput *output = this->get_output_socket(0);
float col[4]; float col[4];
output->getEditorValueColor(col); output->get_editor_value_color(col);
operation->setChannels(col); operation->set_channels(col);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapOutputSocket(output, operation->getOutputSocket()); converter.map_output_socket(output, operation->get_output_socket());
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class ColorNode : public Node { class ColorNode : public Node {
public: public:
ColorNode(bNode *editorNode); ColorNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -17,40 +17,37 @@
*/ */
#include "COM_ColorRampNode.h" #include "COM_ColorRampNode.h"
#include "BKE_node.h"
#include "COM_ColorRampOperation.h" #include "COM_ColorRampOperation.h"
#include "COM_ConvertOperation.h" #include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
#include "DNA_texture_types.h"
namespace blender::compositor { namespace blender::compositor {
ColorRampNode::ColorRampNode(bNode *editorNode) : Node(editorNode) ColorRampNode::ColorRampNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ColorRampNode::convertToOperations(NodeConverter &converter, void ColorRampNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
NodeInput *inputSocket = this->getInputSocket(0); NodeInput *input_socket = this->get_input_socket(0);
NodeOutput *outputSocket = this->getOutputSocket(0); NodeOutput *output_socket = this->get_output_socket(0);
NodeOutput *outputSocketAlpha = this->getOutputSocket(1); NodeOutput *output_socket_alpha = this->get_output_socket(1);
bNode *editorNode = this->getbNode(); bNode *editor_node = this->get_bnode();
ColorRampOperation *operation = new ColorRampOperation(); ColorRampOperation *operation = new ColorRampOperation();
operation->setColorBand((ColorBand *)editorNode->storage); operation->set_color_band((ColorBand *)editor_node->storage);
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); converter.map_input_socket(input_socket, operation->get_input_socket(0));
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); converter.map_output_socket(output_socket, operation->get_output_socket(0));
SeparateChannelOperation *operation2 = new SeparateChannelOperation(); SeparateChannelOperation *operation2 = new SeparateChannelOperation();
operation2->setChannel(3); operation2->set_channel(3);
converter.addOperation(operation2); converter.add_operation(operation2);
converter.addLink(operation->getOutputSocket(), operation2->getInputSocket(0)); converter.add_link(operation->get_output_socket(), operation2->get_input_socket(0));
converter.mapOutputSocket(outputSocketAlpha, operation2->getOutputSocket()); converter.map_output_socket(output_socket_alpha, operation2->get_output_socket());
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class ColorRampNode : public Node { class ColorRampNode : public Node {
public: public:
ColorRampNode(bNode *editorNode); ColorRampNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -17,35 +17,34 @@
*/ */
#include "COM_ColorSpillNode.h" #include "COM_ColorSpillNode.h"
#include "BKE_node.h"
#include "COM_ColorSpillOperation.h" #include "COM_ColorSpillOperation.h"
namespace blender::compositor { namespace blender::compositor {
ColorSpillNode::ColorSpillNode(bNode *editorNode) : Node(editorNode) ColorSpillNode::ColorSpillNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ColorSpillNode::convertToOperations(NodeConverter &converter, void ColorSpillNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
bNode *editorsnode = getbNode(); bNode *editorsnode = get_bnode();
NodeInput *inputSocketImage = this->getInputSocket(0); NodeInput *input_socket_image = this->get_input_socket(0);
NodeInput *inputSocketFac = this->getInputSocket(1); NodeInput *input_socket_fac = this->get_input_socket(1);
NodeOutput *outputSocketImage = this->getOutputSocket(0); NodeOutput *output_socket_image = this->get_output_socket(0);
ColorSpillOperation *operation; ColorSpillOperation *operation;
operation = new ColorSpillOperation(); operation = new ColorSpillOperation();
operation->setSettings((NodeColorspill *)editorsnode->storage); operation->set_settings((NodeColorspill *)editorsnode->storage);
operation->setSpillChannel(editorsnode->custom1 - 1); /* Channel for spilling */ operation->set_spill_channel(editorsnode->custom1 - 1); /* Channel for spilling */
operation->setSpillMethod(editorsnode->custom2); /* Channel method */ operation->set_spill_method(editorsnode->custom2); /* Channel method */
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0)); converter.map_input_socket(input_socket_image, operation->get_input_socket(0));
converter.mapInputSocket(inputSocketFac, operation->getInputSocket(1)); converter.map_input_socket(input_socket_fac, operation->get_input_socket(1));
converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket()); converter.map_output_socket(output_socket_image, operation->get_output_socket());
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,8 +28,8 @@ namespace blender::compositor {
*/ */
class ColorSpillNode : public Node { class ColorSpillNode : public Node {
public: public:
ColorSpillNode(bNode *editorNode); ColorSpillNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -19,26 +19,25 @@
#include "COM_ColorToBWNode.h" #include "COM_ColorToBWNode.h"
#include "COM_ConvertOperation.h" #include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
namespace blender::compositor { namespace blender::compositor {
ColorToBWNode::ColorToBWNode(bNode *editorNode) : Node(editorNode) ColorToBWNode::ColorToBWNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void ColorToBWNode::convertToOperations(NodeConverter &converter, void ColorToBWNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
NodeInput *colorSocket = this->getInputSocket(0); NodeInput *color_socket = this->get_input_socket(0);
NodeOutput *valueSocket = this->getOutputSocket(0); NodeOutput *value_socket = this->get_output_socket(0);
ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation(); ConvertColorToBWOperation *convert_prog = new ConvertColorToBWOperation();
converter.addOperation(convertProg); converter.add_operation(convert_prog);
converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0)); converter.map_input_socket(color_socket, convert_prog->get_input_socket(0));
converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0)); converter.map_output_socket(value_socket, convert_prog->get_output_socket(0));
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -29,8 +29,8 @@ namespace blender::compositor {
*/ */
class ColorToBWNode : public Node { class ColorToBWNode : public Node {
public: public:
ColorToBWNode(bNode *editorNode); ColorToBWNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -22,70 +22,70 @@
namespace blender::compositor { namespace blender::compositor {
CombineColorNode::CombineColorNode(bNode *editorNode) : Node(editorNode) CombineColorNode::CombineColorNode(bNode *editor_node) : Node(editor_node)
{ {
} }
void CombineColorNode::convertToOperations(NodeConverter &converter, void CombineColorNode::convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const const CompositorContext &context) const
{ {
NodeInput *inputRSocket = this->getInputSocket(0); NodeInput *input_rsocket = this->get_input_socket(0);
NodeInput *inputGSocket = this->getInputSocket(1); NodeInput *input_gsocket = this->get_input_socket(1);
NodeInput *inputBSocket = this->getInputSocket(2); NodeInput *input_bsocket = this->get_input_socket(2);
NodeInput *inputASocket = this->getInputSocket(3); NodeInput *input_asocket = this->get_input_socket(3);
NodeOutput *outputSocket = this->getOutputSocket(0); NodeOutput *output_socket = this->get_output_socket(0);
CombineChannelsOperation *operation = new CombineChannelsOperation(); CombineChannelsOperation *operation = new CombineChannelsOperation();
if (inputRSocket->isLinked()) { if (input_rsocket->is_linked()) {
operation->set_canvas_input_index(0); operation->set_canvas_input_index(0);
} }
else if (inputGSocket->isLinked()) { else if (input_gsocket->is_linked()) {
operation->set_canvas_input_index(1); operation->set_canvas_input_index(1);
} }
else if (inputBSocket->isLinked()) { else if (input_bsocket->is_linked()) {
operation->set_canvas_input_index(2); operation->set_canvas_input_index(2);
} }
else { else {
operation->set_canvas_input_index(3); operation->set_canvas_input_index(3);
} }
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(inputRSocket, operation->getInputSocket(0)); converter.map_input_socket(input_rsocket, operation->get_input_socket(0));
converter.mapInputSocket(inputGSocket, operation->getInputSocket(1)); converter.map_input_socket(input_gsocket, operation->get_input_socket(1));
converter.mapInputSocket(inputBSocket, operation->getInputSocket(2)); converter.map_input_socket(input_bsocket, operation->get_input_socket(2));
converter.mapInputSocket(inputASocket, operation->getInputSocket(3)); converter.map_input_socket(input_asocket, operation->get_input_socket(3));
NodeOperation *color_conv = getColorConverter(context); NodeOperation *color_conv = get_color_converter(context);
if (color_conv) { if (color_conv) {
converter.addOperation(color_conv); converter.add_operation(color_conv);
converter.addLink(operation->getOutputSocket(), color_conv->getInputSocket(0)); converter.add_link(operation->get_output_socket(), color_conv->get_input_socket(0));
converter.mapOutputSocket(outputSocket, color_conv->getOutputSocket()); converter.map_output_socket(output_socket, color_conv->get_output_socket());
} }
else { else {
converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); converter.map_output_socket(output_socket, operation->get_output_socket());
} }
} }
NodeOperation *CombineRGBANode::getColorConverter(const CompositorContext & /*context*/) const NodeOperation *CombineRGBANode::get_color_converter(const CompositorContext & /*context*/) const
{ {
return nullptr; /* no conversion needed */ return nullptr; /* no conversion needed */
} }
NodeOperation *CombineHSVANode::getColorConverter(const CompositorContext & /*context*/) const NodeOperation *CombineHSVANode::get_color_converter(const CompositorContext & /*context*/) const
{ {
return new ConvertHSVToRGBOperation(); return new ConvertHSVToRGBOperation();
} }
NodeOperation *CombineYCCANode::getColorConverter(const CompositorContext & /*context*/) const NodeOperation *CombineYCCANode::get_color_converter(const CompositorContext & /*context*/) const
{ {
ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation(); ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation();
bNode *editorNode = this->getbNode(); bNode *editor_node = this->get_bnode();
operation->setMode(editorNode->custom1); operation->set_mode(editor_node->custom1);
return operation; return operation;
} }
NodeOperation *CombineYUVANode::getColorConverter(const CompositorContext & /*context*/) const NodeOperation *CombineYUVANode::get_color_converter(const CompositorContext & /*context*/) const
{ {
return new ConvertYUVToRGBOperation(); return new ConvertYUVToRGBOperation();
} }

View File

@@ -24,48 +24,48 @@ namespace blender::compositor {
class CombineColorNode : public Node { class CombineColorNode : public Node {
public: public:
CombineColorNode(bNode *editorNode); CombineColorNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
protected: protected:
virtual NodeOperation *getColorConverter(const CompositorContext &context) const = 0; virtual NodeOperation *get_color_converter(const CompositorContext &context) const = 0;
}; };
class CombineRGBANode : public CombineColorNode { class CombineRGBANode : public CombineColorNode {
public: public:
CombineRGBANode(bNode *editorNode) : CombineColorNode(editorNode) CombineRGBANode(bNode *editor_node) : CombineColorNode(editor_node)
{ {
} }
NodeOperation *getColorConverter(const CompositorContext &context) const override; NodeOperation *get_color_converter(const CompositorContext &context) const override;
}; };
class CombineHSVANode : public CombineColorNode { class CombineHSVANode : public CombineColorNode {
public: public:
CombineHSVANode(bNode *editorNode) : CombineColorNode(editorNode) CombineHSVANode(bNode *editor_node) : CombineColorNode(editor_node)
{ {
} }
NodeOperation *getColorConverter(const CompositorContext &context) const override; NodeOperation *get_color_converter(const CompositorContext &context) const override;
}; };
class CombineYCCANode : public CombineColorNode { class CombineYCCANode : public CombineColorNode {
public: public:
CombineYCCANode(bNode *editorNode) : CombineColorNode(editorNode) CombineYCCANode(bNode *editor_node) : CombineColorNode(editor_node)
{ {
} }
NodeOperation *getColorConverter(const CompositorContext &context) const override; NodeOperation *get_color_converter(const CompositorContext &context) const override;
}; };
class CombineYUVANode : public CombineColorNode { class CombineYUVANode : public CombineColorNode {
public: public:
CombineYUVANode(bNode *editorNode) : CombineColorNode(editorNode) CombineYUVANode(bNode *editor_node) : CombineColorNode(editor_node)
{ {
} }
NodeOperation *getColorConverter(const CompositorContext &context) const override; NodeOperation *get_color_converter(const CompositorContext &context) const override;
}; };
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -18,48 +18,47 @@
#include "COM_CompositorNode.h" #include "COM_CompositorNode.h"
#include "COM_CompositorOperation.h" #include "COM_CompositorOperation.h"
#include "COM_ExecutionSystem.h"
namespace blender::compositor { namespace blender::compositor {
CompositorNode::CompositorNode(bNode *editorNode) : Node(editorNode) CompositorNode::CompositorNode(bNode *editor_node) : Node(editor_node)
{ {
/* pass */ /* pass */
} }
void CompositorNode::convertToOperations(NodeConverter &converter, void CompositorNode::convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const const CompositorContext &context) const
{ {
bNode *editorNode = this->getbNode(); bNode *editor_node = this->get_bnode();
bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC) || context.isRendering(); bool is_active = (editor_node->flag & NODE_DO_OUTPUT_RECALC) || context.is_rendering();
bool ignore_alpha = (editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0; bool ignore_alpha = (editor_node->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0;
NodeInput *imageSocket = this->getInputSocket(0); NodeInput *image_socket = this->get_input_socket(0);
NodeInput *alphaSocket = this->getInputSocket(1); NodeInput *alpha_socket = this->get_input_socket(1);
NodeInput *depthSocket = this->getInputSocket(2); NodeInput *depth_socket = this->get_input_socket(2);
CompositorOperation *compositorOperation = new CompositorOperation(); CompositorOperation *compositor_operation = new CompositorOperation();
compositorOperation->setScene(context.getScene()); compositor_operation->set_scene(context.get_scene());
compositorOperation->setSceneName(context.getScene()->id.name); compositor_operation->set_scene_name(context.get_scene()->id.name);
compositorOperation->setRenderData(context.getRenderData()); compositor_operation->set_render_data(context.get_render_data());
compositorOperation->setViewName(context.getViewName()); compositor_operation->set_view_name(context.get_view_name());
compositorOperation->setbNodeTree(context.getbNodeTree()); compositor_operation->set_bnodetree(context.get_bnodetree());
/* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */ /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
compositorOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked()); compositor_operation->set_use_alpha_input(ignore_alpha || alpha_socket->is_linked());
compositorOperation->setActive(is_active); compositor_operation->set_active(is_active);
converter.addOperation(compositorOperation); converter.add_operation(compositor_operation);
converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0)); converter.map_input_socket(image_socket, compositor_operation->get_input_socket(0));
/* only use alpha link if "use alpha" is enabled */ /* only use alpha link if "use alpha" is enabled */
if (ignore_alpha) { if (ignore_alpha) {
converter.addInputValue(compositorOperation->getInputSocket(1), 1.0f); converter.add_input_value(compositor_operation->get_input_socket(1), 1.0f);
} }
else { else {
converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1)); converter.map_input_socket(alpha_socket, compositor_operation->get_input_socket(1));
} }
converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2)); converter.map_input_socket(depth_socket, compositor_operation->get_input_socket(2));
converter.addNodeInputPreview(imageSocket); converter.add_node_input_preview(image_socket);
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -29,8 +29,8 @@ namespace blender::compositor {
*/ */
class CompositorNode : public Node { class CompositorNode : public Node {
public: public:
CompositorNode(bNode *editorNode); CompositorNode(bNode *editor_node);
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

View File

@@ -18,15 +18,14 @@
#include "COM_ConvertAlphaNode.h" #include "COM_ConvertAlphaNode.h"
#include "COM_ConvertOperation.h" #include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
namespace blender::compositor { namespace blender::compositor {
void ConvertAlphaNode::convertToOperations(NodeConverter &converter, void ConvertAlphaNode::convert_to_operations(NodeConverter &converter,
const CompositorContext & /*context*/) const const CompositorContext & /*context*/) const
{ {
NodeOperation *operation = nullptr; NodeOperation *operation = nullptr;
bNode *node = this->getbNode(); bNode *node = this->get_bnode();
/* value hardcoded in rna_nodetree.c */ /* value hardcoded in rna_nodetree.c */
if (node->custom1 == 1) { if (node->custom1 == 1) {
@@ -36,10 +35,10 @@ void ConvertAlphaNode::convertToOperations(NodeConverter &converter,
operation = new ConvertStraightToPremulOperation(); operation = new ConvertStraightToPremulOperation();
} }
converter.addOperation(operation); converter.add_operation(operation);
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
} }
} // namespace blender::compositor } // namespace blender::compositor

View File

@@ -28,10 +28,10 @@ namespace blender::compositor {
*/ */
class ConvertAlphaNode : public Node { class ConvertAlphaNode : public Node {
public: public:
ConvertAlphaNode(bNode *editorNode) : Node(editorNode) ConvertAlphaNode(bNode *editor_node) : Node(editor_node)
{ {
} }
void convertToOperations(NodeConverter &converter, void convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const override; const CompositorContext &context) const override;
}; };

Some files were not shown because too many files have changed in this diff Show More